@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,11 +1,24 @@
1
1
  You are an AI coding agent tasked with building a survey UI using the CFM Survey SDK.
2
2
 
3
- ## Start Here
3
+ ## Start Here (read in order — do not skip)
4
4
 
5
- **Monorepo:** read `packages/sdk/templates/docs/index.md`
6
- **Installed package:** read `node_modules/@explorer02/cfm-survey-sdk/templates/docs/index.md`
5
+ 1. **`docs/00-integration/agent-operating-contract.md`** — anti-hallucination rules, read-before-write gates, forbidden inventions
6
+ 2. **`docs/00-integration/agent-execution-flow.md`** — pipeline, client questions, phase order
7
+ 3. **`docs/index.md`** — phase summary and artifact list
8
+ 4. **`docs/MANIFEST.json`** — machine-readable phase + question-type routing
7
9
 
8
- Also read `MANIFEST.json` in the same `templates/docs/` folder for machine-readable phase and question-type routing.
10
+ **Monorepo:** `packages/sdk/templates/docs/`
11
+ **Installed package:** `node_modules/@explorer02/cfm-survey-sdk/templates/docs/`
12
+
13
+ ## Anti-hallucination (summary)
14
+
15
+ - **If it's not in the docs or `docs/templates/`, do not implement it from memory.**
16
+ - **Read before write** — complete the phase gate reads in `agent-operating-contract.md` §2 before any code.
17
+ - **Copy templates first** — `Question.tsx`, scales, `selectionStyles.ts`, `labelStyles.ts`, `survey-theme.css`.
18
+ - **Forbidden:** `apps/client`, SDK `/src/` imports, `subType`, stub branches, guessing answer shapes.
19
+ - **Verify before handoff** — `bash templates/verify-agent-build.sh` must pass.
20
+
21
+ Full blocklist and doc routing table: `agent-operating-contract.md`.
9
22
 
10
23
  ## Package Name
11
24
 
@@ -13,27 +26,59 @@ Import from whatever appears in `package.json`:
13
26
  - `@explorer02/cfm-survey-sdk` (npm)
14
27
  - `@repo/sdk` (monorepo)
15
28
 
29
+ ## Four client inputs
30
+
31
+ | # | When | Ask |
32
+ |---|------|-----|
33
+ | 1 | Start | *(Client prompt — usually given)* |
34
+ | 2 | Phase 2 | *"Please provide your survey instance ID (JWT token)."* |
35
+ | 3 | Phase 6 | *"Your survey is running locally. Would you like to customize the UI through the web wizard?"* |
36
+ | 4 | Phase 7 | *"Your survey is built and verified. Ready to deploy to production?"* |
37
+
16
38
  ## Phase Summary
17
39
 
18
40
  | Phase | Action |
19
41
  |-------|--------|
20
- | 0 | Detect framework; extract branding from client prompt |
21
- | 1 | Scaffold React app — `00-integration/setup.md` |
22
- | 2 | Ask client for instanceId JWT |
23
- | 3 | Read `client-integration-guide.md` + `question-type-sdk-matrix.md` + hook/logic/lifecycle docs — full SDK contract |
24
- | 4 | Fetch survey; inventory types; read MANIFEST-driven docs per type + matrix row; copy `templates/Question.tsx` + `implementation_plan.md` |
25
- | 5 | Build UI — read matrix before any scale component; create files from `component-checklist.md`; dispatch on **11** flat `QUESTION_TYPE` literals; apply AWS static export if prompt requires |
26
- | 6 | Run `templates/verify-agent-build.sh` |
27
- | 7 | On confirmation: **AWS prompt** → `00-integration/aws-deploy.md` + EC2 3-channel deploy; **Vercel prompt** → `npx cfm-sdk deploy` |
42
+ | 0 | Orient — read operating contract + execution flow; detect framework; extract branding |
43
+ | 1 | Scaffold — `00-integration/setup.md` |
44
+ | 2 | Ask JWT `useSurveySDK.md` |
45
+ | 3 | SDK contract — `client-integration-guide.md` + logic/lifecycle docs |
46
+ | 4 | Plan — fetch survey, inventory types, copy `Question.tsx` + `implementation_plan.md` |
47
+ | 5 | **Build wizard-ready UI** — read per-type `03-ui-specs/*` for every inventory type |
48
+ | 6 | Verify `verify-agent-build.sh`; start dev server; **ask wizard (INPUT 3)** |
49
+ | 6b | Optional `npx cfm-sdk customize-ui` upload previews **send deployed wizard link to client** → block until submit; read `survey-ui-config.diff.md` |
50
+ | 6c | Apply every path from `survey-ui-config.final.json` → `confirm-ui-config` → re-verify |
51
+ | 7 | Deploy — on confirmation per prompt or `deploy.target` |
52
+
53
+ **Wizard run is optional. Wizard-ready build is mandatory in Phase 5.**
54
+
55
+ **Do NOT** run the wizard before the survey UI is built. **Do NOT** read legacy `survey-config.json`. **Do NOT** use `apps/client` as implementation source.
56
+
57
+ ## Phase 5 required artifacts
58
+
59
+ | Source (`docs/templates/`) | Destination |
60
+ |----------------------------|-------------|
61
+ | `survey-theme.css` | `src/styles/survey-theme.css` |
62
+ | `selectionStyles.ts` | `src/lib/surveyUi/selectionStyles.ts` |
63
+ | `labelStyles.ts` | `src/lib/surveyUi/labelStyles.ts` |
64
+ | `previewBridge.ts` | `src/lib/previewBridge.ts` |
65
+ | Scale components per inventory | `src/components/` |
66
+ | Draft config | `./survey-ui-config.json` |
67
+
68
+ Read: `wizard-preview-build-guide.md`, `wizard-question-type-styling.md`, per-type `03-ui-specs/*` (one per fetched type).
69
+
70
+ **Selection pattern:** focus ring = outer border + inner dot; cell selected = annulus fill between ring and dot.
71
+
72
+ **Do NOT** render `"not yet implemented"` or default fallback stubs in `Question.tsx`. Dispatch all **11** flat `QUESTION_TYPE` literals — no `subType`.
28
73
 
29
- **Do NOT** run `cfm-sdk init`, read `survey-config.json`, or use any setup wizard.
74
+ **Copy scale templates:** `SliderMatrixScale`, `LikertMatrixScale`, `CsatMatrixScale`, `RatingScale`, `FileUploadScale`, `HeatmapScale`, `RankOrderScale`, `MatrixDropdown`, `CustomSliderTrack`, `surveyUiIcons`, `surveyUiScaleUtils`, `heatmapCoords`, `customFieldValues` (when needed).
30
75
 
31
- **Do NOT** render `"not yet implemented"` or default fallback stubs in `Question.tsx`. Copy `templates/docs/templates/Question.tsx` and create all required scale components.
76
+ **Custom field logic:** when survey references `entityType: 'CUSTOM_FIELD'`, copy `customFieldValues.ts` and wire in hook options **and** `<Question customFieldValues={...} />`.
32
77
 
33
- **Do NOT** route matrix questions by `subType` — use flat types: `CFM_MATRIX`, `CSAT_MATRIX`, `RATING_MATRIX`, `SLIDER_MATRIX`.
78
+ **Matrix types:** copy `LikertMatrixScale` / `CsatMatrixScale` — never bare radio grids without statement + label rows.
34
79
 
35
- **Read `question-type-sdk-matrix.md` before building any scale component** it defines answer shapes, visibility helpers, and performance expectations for all 11 types.
80
+ **FILE_UPLOAD:** presigned upload per `file-upload-aws.md` — raw `File[]` does not submit.
36
81
 
37
82
  **Monorepo:** run `npm run build` in `packages/sdk` before starting the client dev server.
38
83
 
39
- Follow the master index strictly. Do not guess SDK internals. Do not import from `/src/` paths.
84
+ Follow `agent-operating-contract.md` and `agent-execution-flow.md` strictly. Do not guess SDK internals. Do not import from `/src/` paths.
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env bash
2
+ # Deploy survey-wizard SPA to S3 sites/_wizard/ on the hosting bucket.
3
+ # Usage (from repo root):
4
+ # export HOSTING_BUCKET=... CLOUDFRONT_BASE_URL=... CLOUDFRONT_DISTRIBUTION_ID=...
5
+ # export VITE_WIZARD_API_BASE=http://43.204.26.213:3000
6
+ # bash packages/sdk/templates/deploy-wizard-to-s3.sh
7
+
8
+ set -euo pipefail
9
+
10
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
12
+
13
+ : "${HOSTING_BUCKET:?HOSTING_BUCKET required}"
14
+ : "${CLOUDFRONT_BASE_URL:?CLOUDFRONT_BASE_URL required}"
15
+ : "${AWS_REGION:=ap-south-1}"
16
+ : "${VITE_WIZARD_API_BASE:?VITE_WIZARD_API_BASE required for production wizard build}"
17
+
18
+ WIZARD_PREFIX="${WIZARD_S3_PREFIX:-sites/_wizard}"
19
+ CF_BASE="${CLOUDFRONT_BASE_URL%/}"
20
+
21
+ echo "Building survey-wizard (VITE_WIZARD_API_BASE=$VITE_WIZARD_API_BASE)..."
22
+ cd "$REPO_ROOT"
23
+ VITE_WIZARD_API_BASE="$VITE_WIZARD_API_BASE" yarn workspace @repo/survey-wizard build
24
+
25
+ DIST="$REPO_ROOT/packages/sdk/templates/wizard-dist"
26
+
27
+ if [ ! -d "$DIST" ]; then
28
+ echo "wizard-dist not found at $DIST"
29
+ exit 1
30
+ fi
31
+
32
+ echo "Uploading to s3://${HOSTING_BUCKET}/${WIZARD_PREFIX}/"
33
+ aws s3 sync "$DIST/" "s3://${HOSTING_BUCKET}/${WIZARD_PREFIX}/" \
34
+ --region "$AWS_REGION" \
35
+ --delete \
36
+ --cache-control "public,max-age=300"
37
+
38
+ if [ -n "${CLOUDFRONT_DISTRIBUTION_ID:-}" ]; then
39
+ echo "Invalidating CloudFront /${WIZARD_PREFIX}/* ..."
40
+ aws cloudfront create-invalidation \
41
+ --distribution-id "$CLOUDFRONT_DISTRIBUTION_ID" \
42
+ --paths "/${WIZARD_PREFIX}/*" \
43
+ --query 'Invalidation.Id' \
44
+ --output text
45
+ else
46
+ echo "CLOUDFRONT_DISTRIBUTION_ID not set — skip invalidation"
47
+ fi
48
+
49
+ echo ""
50
+ echo "Done. Wizard URLs:"
51
+ echo " CloudFront (static UI): ${CF_BASE}/${WIZARD_PREFIX}/index.html"
52
+ echo " EC2 session (customize-ui opens this): http://43.204.26.213:3000/wizard-app/index.html"
@@ -0,0 +1,281 @@
1
+ # Agent Execution Flow
2
+
3
+ > **Read first:** [`agent-operating-contract.md`](agent-operating-contract.md) (anti-hallucination), then this file with [`index.md`](../index.md).
4
+ > This doc defines the **only** approved agent workflow: what to read, what to ask the client, and what to execute — in order.
5
+
6
+ Machine-readable routing: [`MANIFEST.json`](../MANIFEST.json) `phases[]`.
7
+
8
+ ---
9
+
10
+ ## Golden rules
11
+
12
+ 0. **Operating contract** — follow [`agent-operating-contract.md`](agent-operating-contract.md): read-before-write gates, doc routing table, hallucination blocklist.
13
+ 1. **Docs-first** — never guess SDK behavior; read MANIFEST-routed docs before writing code.
14
+ 2. **Four client inputs only** — prompt (given), instanceId (ask), wizard yes/no (ask), deploy yes/no (ask).
15
+ 3. **Build before wizard** — survey UI must run on localhost before Phase 6b.
16
+ 4. **UI-only wizard** — wizard changes tokens and chrome text, never dispatch logic or answer shapes.
17
+ 5. **No stubs** — zero `"not yet implemented"` branches; dispatch all **11** `question.type` literals.
18
+ 6. **Flat types** — no `subType`; route `CFM_MATRIX`, `CSAT_MATRIX`, `RATING_MATRIX`, `SLIDER_MATRIX` separately.
19
+ 7. **Copy templates** — scale components from `docs/templates/`; extend, do not rewrite from scratch.
20
+ 8. **Wizard-ready in Phase 5** — always wire `survey-theme.css`, `selectionStyles.ts`, `labelStyles.ts`, and `data-cfm-*` hooks even if client skips the wizard later.
21
+
22
+ ---
23
+
24
+ ## Client inputs — exact questions
25
+
26
+ | # | When | Agent asks (verbatim intent) | On answer |
27
+ |---|------|------------------------------|-----------|
28
+ | **1** | Start (usually given) | *(Client prompt — mockup, brand, deploy target hints)* | Extract branding; note AWS/Vercel keywords |
29
+ | **2** | Phase 2 | *"Please provide your survey instance ID (JWT token)."* | Store as `CFM_INSTANCE_ID` / `SURVEY_INSTANCE_ID`; fetch survey |
30
+ | **3** | Phase 6 (after verify + dev server) | *"Your survey is running locally. Would you like to customize the UI through the web wizard?"* | **Yes** → Phase 6b. **No** → Phase 7 ask |
31
+ | **4** | Phase 7 | *"Your survey is built and verified. Ready to deploy to production?"* | **Yes** → deploy per prompt/config. **No** → stop |
32
+
33
+ **Do not ask** about wizard before Phase 6. **Do not run** `customize-ui` before build + verify.
34
+
35
+ ---
36
+
37
+ ## Phase-by-phase execution
38
+
39
+ ### Phase 0 — Orient
40
+
41
+ **Read:** `agent-operating-contract.md`, `index.md`, `AGENT.md`, `agent-execution-flow.md`, `MANIFEST.json` (skim `phases`, `typeLiterals`, `questionTypes`)
42
+
43
+ **Do:**
44
+ - Detect framework from `package.json` → `setup.md`
45
+ - Extract colors, logo style, layout from client prompt into notes for `implementation_plan.md`
46
+
47
+ ---
48
+
49
+ ### Phase 1 — Scaffold
50
+
51
+ **Read:** `00-integration/setup.md` (framework section)
52
+
53
+ **Do:**
54
+ - Install `@explorer02/cfm-survey-sdk` (or `@repo/sdk`), `@tanstack/react-query`, `react-icons`
55
+ - Apply AWS static export config **now** if prompt mentions AWS/CloudFront/S3/EC2/Sprinklr
56
+
57
+ ---
58
+
59
+ ### Phase 2 — Instance ID (INPUT 2)
60
+
61
+ **Read:** `00-integration/useSurveySDK.md`
62
+
63
+ **Ask:** JWT token (see table above)
64
+
65
+ **Do:**
66
+ - Wire `instanceId` in `SurveyPage` / hook options
67
+ - Do **not** build question UI yet
68
+
69
+ ---
70
+
71
+ ### Phase 3 — SDK contract
72
+
73
+ **Read (in order):**
74
+ 1. `00-integration/client-integration-guide.md`
75
+ 2. `00-integration/question-type-sdk-matrix.md`
76
+ 3. `00-integration/useSurveySDK.md`
77
+ 4. `00-integration/client-lib-folder.md`
78
+ 5. `00-integration/custom-field-logic-and-navigation.md`
79
+ 6. `00-integration/skip-logic-and-navigation.md`
80
+ 7. `00-integration/display-logic-and-navigation.md`
81
+ 8. `00-integration/placeholders-and-tokens.md`
82
+ 9. `00-integration/survey-lifecycle-analytics.md`
83
+ 10. `02-reference/exports.md`, `02-reference/value-derivation.md`
84
+
85
+ **Do:**
86
+ - Understand `onAction`, `state.answers`, visibility helpers, lifecycle actions
87
+ - **Forbidden:** imports from `.../src/...` inside the SDK package
88
+
89
+ ---
90
+
91
+ ### Phase 4 — Plan + ingest
92
+
93
+ **Read (always):**
94
+ - `component-checklist.md`, `canonical-survey-fixtures.md`, `logic-fields-catalog.md`
95
+ - `03-ui-specs/00-question-shell.md`, `03-ui-specs/12-survey-chrome.md`
96
+ - `01-components/01-survey-page.md`, `01-components/02-question.md`
97
+ - `01-components/14-intro-page.md`, `01-components/15-end-page.md`, `01-components/16-paused-page.md`
98
+
99
+ **Read (per fetched survey type):** MANIFEST `questionTypes.{type}` → `blueprint` + `reference` + `uiSpec`
100
+
101
+ **Read (when flags match):** MANIFEST `sharedUiSpecTriggers` → `03-ui-specs/shared/*`
102
+
103
+ **Do:**
104
+ 1. Fetch survey with instanceId
105
+ 2. List unique `question.type` values in `implementation_plan.md` §3b
106
+ 3. Copy `templates/implementation_plan.md` → project root; fill all sections
107
+ 4. Copy `templates/Question.tsx` as dispatcher starting point
108
+ 5. **Auto-proceed to Phase 5** — no approval wait
109
+
110
+ ---
111
+
112
+ ### Phase 5 — Build (wizard-ready)
113
+
114
+ **Read:**
115
+ - `00-integration/constraints.md`
116
+ - `00-integration/component-checklist.md`
117
+ - `00-integration/wizard-preview-build-guide.md` **(required)**
118
+ - `00-integration/wizard-question-type-styling.md` **(required)**
119
+ - `00-integration/question-type-sdk-matrix.md`
120
+ - Per-type `03-ui-specs/*` from inventory
121
+
122
+ **Copy to project (required artifacts):**
123
+
124
+ | Source (`docs/templates/`) | Destination |
125
+ |----------------------------|-------------|
126
+ | `survey-theme.css` | `src/styles/survey-theme.css` |
127
+ | `selectionStyles.ts` | `src/lib/surveyUi/selectionStyles.ts` |
128
+ | `labelStyles.ts` | `src/lib/surveyUi/labelStyles.ts` |
129
+ | `previewBridge.ts` | `src/lib/previewBridge.ts` (local `customize` dev) |
130
+ | Scale components per inventory | `src/components/` |
131
+ | `surveyUiScaleUtils.ts`, `surveyUiIcons.tsx` | `src/lib/` |
132
+ | `customFieldValues.ts` | `src/lib/` (when `_c_…` in survey logic) |
133
+
134
+ **Wire in `globals.css`:**
135
+ ```css
136
+ @import "./styles/survey-theme.css";
137
+ ```
138
+
139
+ **Wire in root `layout.tsx`:** `<PreviewBridgeInit />` (see `wizard-preview-build-guide.md`)
140
+
141
+ **Chrome contract (`data-cfm-*`):**
142
+ - Header: `data-cfm-logo` and/or `data-cfm-logo-text`, `data-cfm-company`
143
+ - SurveyPage: `data-cfm-btn-next`, `data-cfm-btn-back`
144
+ - Intro/End: `data-cfm-survey-title`, `data-cfm-thank-you`
145
+ - Footer: `data-cfm-copyright`, `data-cfm-footer-links`
146
+
147
+ **Selection styling (all scale radios):** use `selectionStyles.ts` — see `wizard-question-type-styling.md`
148
+
149
+ **Label items (matrices/sliders):** use `labelStyles.ts` — column headers are label items, not hint labels (CFM matrix)
150
+
151
+ **Draft config:** write `./survey-ui-config.json` + keep CSS in sync (seeds wizard in 6b)
152
+
153
+ **Forbidden in Phase 5:**
154
+ - Changing `Question.tsx` dispatch / `onAction` payloads
155
+ - `subType` routing
156
+ - Stub placeholder branches
157
+ - Hardcoded brand hex for wizard-controlled tokens
158
+
159
+ **Auto-proceed to Phase 6** after build compiles.
160
+
161
+ ---
162
+
163
+ ### Phase 6 — Verify
164
+
165
+ **Read:** `constraints.md` (troubleshooting)
166
+
167
+ **Run:** `bash templates/verify-agent-build.sh`
168
+
169
+ **Checklist:** see `index.md` Phase 6 + `component-checklist.md` Step 3–4
170
+
171
+ **Do:**
172
+ - `npm run build` → exit 0
173
+ - Start dev server; confirm survey loads
174
+ - **Ask INPUT 3** (wizard question)
175
+
176
+ ---
177
+
178
+ ### Phase 6b — Wizard session (optional, INPUT 3 = Yes)
179
+
180
+ **Read:** `wizard-config-handoff.md`, `ui-customization-wizard.md`, `wizard-api.md`, `wizard-preview-build-guide.md`
181
+
182
+ **Prerequisites:** Phase 6 passed; draft `survey-ui-config.json` exists
183
+
184
+ **Run (agent blocks until client submits):**
185
+ ```bash
186
+ export CFM_INSTANCE_ID="<JWT>"
187
+ export CFM_DEPLOY_API_BASE="http://43.204.26.213:3000"
188
+ npx cfm-sdk customize-ui
189
+ ```
190
+
191
+ **Sequence:**
192
+ 1. CLI exports component previews and uploads to S3
193
+ 2. CLI prints **deployed wizard link** — agent **copies and sends to client**
194
+ 3. Client opens EC2 link, customizes, clicks **Review & Build**
195
+ 4. Agent keeps CLI open until `✅ Configuration ready`
196
+
197
+ **Agent must:**
198
+ 1. Share the deployed wizard URL with the client (from CLI output, after S3 upload)
199
+ 2. Tell client to complete wizard and click **Review & Build**
200
+ 2. **Keep CLI running** — poll until `✅ Configuration ready` (do not Ctrl+C)
201
+ 3. Read `survey-ui-config.diff.md` when CLI exits 0
202
+ 4. **Do not apply** to codebase yet — proceed to Phase 6c
203
+
204
+ **Artifacts (AWS review mode):**
205
+ - `survey-ui-config.final.json` — apply source
206
+ - `survey-ui-config.diff.md` — audit every changed path
207
+ - `survey-ui-config.json` — still **seed** until Phase 6c confirm step
208
+
209
+ **Local alternative:** `npx cfm-sdk customize` — blocks until `UI configuration saved` → writes `survey-ui-config.json` directly.
210
+
211
+ **If client said No:** skip to Phase 7 ask.
212
+
213
+ ---
214
+
215
+ ### Phase 6c — Apply wizard changes (mandatory when wizard used)
216
+
217
+ **Read:** `wizard-config-handoff.md`, `apply-ui-config.md`, `wizard-question-type-styling.md`
218
+
219
+ **Input file:**
220
+ - AWS: `survey-ui-config.final.json`
221
+ - Local: `survey-ui-config.json`
222
+
223
+ **Do (in order):**
224
+ 1. Validate JSON against `templates/survey-ui-config.schema.json`
225
+ 2. Read **entire** `survey-ui-config.diff.md` (AWS) — every path must be applied
226
+ 3. Regenerate `src/styles/survey-theme.css` from **full** final config (not partial)
227
+ 4. Update all `data-cfm-*` content hooks (title, buttons, footer, logo)
228
+ 5. Apply layout toggles in `SurveyPage` / chrome
229
+ 6. Wire `placeholders`, `customFields`, `debug` from final config
230
+ 7. Apply per-type `questionTypes.*` for every type in `surveyTypes[]`
231
+ 8. AWS: `npx cfm-sdk confirm-ui-config` (promotes final → active + downloads logo)
232
+ 9. Re-run `verify-agent-build.sh` + `npm run build`
233
+ 10. **Do not** change dispatch logic in `Question.tsx`
234
+
235
+ **Blocking:** Do not proceed to Phase 7 until diff paths are applied and verify passes.
236
+
237
+ ---
238
+
239
+ ### Phase 7 — Deploy (INPUT 4)
240
+
241
+ **Ask:** deploy confirmation (see table)
242
+
243
+ **Route:**
244
+ - AWS keywords in prompt → `aws-deploy.md` + `deploy-to-aws.sh`
245
+ - Else / Vercel → `npx cfm-sdk deploy`
246
+ - Override with `survey-ui-config.json` → `deploy.target` when present
247
+
248
+ ---
249
+
250
+ ## Wizard styling quick reference
251
+
252
+ | Wizard control | CSS variable | Component pattern |
253
+ |----------------|--------------|-------------------|
254
+ | Question card → Cell selected | `--cfm-matrix-selected` | Annulus fill between ring and dot; numbered/star cell bg |
255
+ | Question card → Focus ring | `--cfm-input-focus-ring` | Outer radio border + inner dot |
256
+ | Matrix label items | `--cfm-matrix-column-label-*` | `matrixColumnLabelStyle()` |
257
+ | CSAT label items | `--cfm-csat-column-label-*` | `csatColumnLabelStyle()` |
258
+ | Hint labels (NPS min/max) | `--cfm-hint-label-*` | `hintLabelStyle()` |
259
+ | Number labels (traffic/mono/individual) | `--cfm-number-*` | `resolveNumberLabelColor()` in scale utils |
260
+ | File upload border | `--cfm-upload-border-color` | Dropzone border |
261
+ | MCQ selection | focus ring + cell selected | Radio ring/dot pattern |
262
+
263
+ Full mapping: [`wizard-question-type-styling.md`](wizard-question-type-styling.md)
264
+
265
+ ---
266
+
267
+ ## Doc index by task
268
+
269
+ | Task | Read |
270
+ |------|------|
271
+ | Anti-hallucination / doc routing | `agent-operating-contract.md` |
272
+ | Full pipeline | `agent-operating-contract.md` + this file + `index.md` |
273
+ | Hook / answers | `client-integration-guide.md`, `useSurveySDK.md` |
274
+ | Copy files list | `component-checklist.md`, `client-lib-folder.md` |
275
+ | Matrix labels | `canonical-survey-fixtures.md` |
276
+ | Wizard chrome | `wizard-preview-build-guide.md` |
277
+ | Wizard per-type | `wizard-question-type-styling.md` |
278
+ | Wait + capture + apply order | `wizard-config-handoff.md` |
279
+ | Apply every config path | `apply-ui-config.md` |
280
+ | Logo rules | `constraints.md` §4, `10-header-footer.md` |
281
+ | UI spec details | `03-ui-specs/{type}.md` per inventory |