@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.
- package/dist/cli/index.js +141 -33
- package/dist/cli/index.mjs +141 -33
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -1
- package/postinstall.js +9 -5
- package/templates/AGENT.md +60 -19
- package/templates/deploy-wizard-to-s3.sh +52 -0
- package/templates/docs/00-integration/agent-execution-flow.md +293 -0
- package/templates/docs/00-integration/agent-operating-contract.md +268 -0
- package/templates/docs/00-integration/apply-ui-config.md +390 -0
- package/templates/docs/00-integration/aws-deploy.md +117 -3
- package/templates/docs/00-integration/canonical-survey-fixtures.md +94 -0
- package/templates/docs/00-integration/client-integration-guide.md +9 -7
- package/templates/docs/00-integration/client-lib-folder.md +115 -0
- package/templates/docs/00-integration/component-checklist.md +90 -62
- package/templates/docs/00-integration/constraints.md +14 -5
- package/templates/docs/00-integration/custom-field-logic-and-navigation.md +56 -0
- package/templates/docs/00-integration/mockup-ui-extraction.md +113 -0
- package/templates/docs/00-integration/placeholders-and-custom-fields-wiring.md +192 -0
- package/templates/docs/00-integration/placeholders-and-tokens.md +2 -1
- package/templates/docs/00-integration/progress.md +4 -2
- package/templates/docs/00-integration/setup.md +12 -0
- package/templates/docs/00-integration/ui-customization-wizard.md +123 -0
- package/templates/docs/00-integration/useSurveySDK.md +35 -1
- package/templates/docs/00-integration/wizard-api.md +126 -0
- package/templates/docs/00-integration/wizard-config-handoff.md +292 -0
- package/templates/docs/00-integration/wizard-preview-build-guide.md +405 -0
- package/templates/docs/00-integration/wizard-question-type-styling.md +197 -0
- package/templates/docs/00-integration/wizard-troubleshooting.md +80 -0
- package/templates/docs/01-components/01-survey-page.md +18 -8
- package/templates/docs/01-components/02-question.md +2 -2
- package/templates/docs/01-components/03-rating-scale.md +12 -18
- package/templates/docs/01-components/05-csat-matrix-scale.md +18 -26
- package/templates/docs/01-components/06-likert-matrix-scale.md +19 -39
- package/templates/docs/01-components/07-slider-matrix-scale.md +48 -33
- package/templates/docs/01-components/09-custom-slider-track.md +15 -25
- package/templates/docs/01-components/10-header-footer.md +23 -4
- package/templates/docs/01-components/11-progress-bar.md +14 -6
- package/templates/docs/01-components/19-survey-sticky-chrome.md +79 -0
- package/templates/docs/01-components/README.md +2 -2
- package/templates/docs/02-reference/question-types/10-slider-matrix.md +38 -26
- package/templates/docs/02-reference/routing-table.md +1 -0
- package/templates/docs/02-reference/value-derivation.md +1 -1
- package/templates/docs/03-ui-specs/00-question-shell.md +10 -0
- package/templates/docs/03-ui-specs/01-rating.md +18 -0
- package/templates/docs/03-ui-specs/02-radio.md +16 -1
- package/templates/docs/03-ui-specs/03-text.md +12 -1
- package/templates/docs/03-ui-specs/04-csat.md +84 -50
- package/templates/docs/03-ui-specs/06-slider.md +3 -1
- package/templates/docs/03-ui-specs/07-matrix-cfm.md +71 -48
- package/templates/docs/03-ui-specs/08-matrix-csat-rating.md +48 -18
- package/templates/docs/03-ui-specs/09-slider-matrix.md +59 -32
- package/templates/docs/03-ui-specs/10-file-upload.md +11 -0
- package/templates/docs/03-ui-specs/11-text-and-media.md +4 -0
- package/templates/docs/03-ui-specs/12-survey-chrome.md +54 -5
- package/templates/docs/03-ui-specs/13-heatmap.md +12 -1
- package/templates/docs/03-ui-specs/14-rank-order.md +11 -0
- package/templates/docs/03-ui-specs/README.md +4 -2
- package/templates/docs/03-ui-specs/shared/matrix-dropdown.md +1 -1
- package/templates/docs/MANIFEST.json +180 -7
- package/templates/docs/index.md +114 -117
- package/templates/docs/templates/CsatMatrixScale.tsx +637 -0
- package/templates/docs/templates/FileUploadScale.tsx +262 -0
- package/templates/docs/templates/HeatmapScale.tsx +114 -0
- package/templates/docs/templates/LikertMatrixScale.tsx +414 -0
- package/templates/docs/templates/Question.tsx +3 -0
- package/templates/docs/templates/RatingScale.tsx +129 -0
- package/templates/docs/templates/SliderMatrixScale.tsx +248 -0
- package/templates/docs/templates/SurveyStickyChrome.tsx +24 -0
- package/templates/docs/templates/customFieldValues.ts +36 -0
- package/templates/docs/templates/deploy-to-aws.sh +74 -0
- package/templates/docs/templates/implementation_plan.md +64 -10
- package/templates/docs/templates/labelStyles.ts +33 -0
- package/templates/docs/templates/selectionStyles.ts +100 -0
- package/templates/docs/templates/surveyUiIcons.tsx +11 -0
- package/templates/docs/templates/surveyUiScaleUtils.ts +51 -0
- package/templates/docs/templates/verify-agent-build.sh +119 -0
- package/templates/preview-harness/preview-bridge.inline.js +201 -0
- package/templates/preview-harness/previewPages.js +108 -0
- package/templates/preview-harness/previewPages.ts +298 -0
- package/templates/preview-harness/vite-app/src/PreviewConfigContext.tsx +67 -0
- package/templates/preview-harness/vite-app/src/QuestionPreview.tsx +122 -0
- package/templates/preview-harness/vite-app/src/SurveyPagePreview.tsx +75 -0
- package/templates/preview-harness/vite-app/src/fixtures/questions.ts +311 -0
- package/templates/preview-harness/vite-app/src/globals.css +16 -0
- package/templates/preview-harness/vite-app/src/mount.tsx +9 -0
- package/templates/preview-harness/vite-app/src/preview-live-overrides.css +101 -0
- package/templates/preview-harness/vite-app/stubs/next-dynamic.tsx +25 -0
- package/templates/preview-harness/vite-app/stubs/next-image.tsx +29 -0
- package/templates/previewBridge.ts +153 -0
- package/templates/survey-theme.css +295 -0
- package/templates/survey-ui-config.schema.json +213 -0
- package/templates/wizard-dist/assets/PreviewMock-AoZdAEPZ.js +1 -0
- package/templates/wizard-dist/assets/TypePanel-39FnbtvG.js +1 -0
- package/templates/wizard-dist/assets/index-BhWM50Yu.css +1 -0
- package/templates/wizard-dist/assets/index-CWKdsJOp.js +34 -0
- package/templates/wizard-dist/assets/vendor-BwkXDkd3.js +17 -0
- package/templates/wizard-dist/index.html +20 -0
- package/templates/wizard.html +13 -1129
package/templates/AGENT.md
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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,31 +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 |
|
|
21
|
-
| 1 | Scaffold
|
|
22
|
-
| 2 | Ask
|
|
23
|
-
| 3 |
|
|
24
|
-
| 4 |
|
|
25
|
-
| 5 | Build UI —
|
|
26
|
-
| 6 |
|
|
27
|
-
|
|
|
42
|
+
| 0 | Orient — read operating contract + execution flow; **UI-only** mockup notes (`mockup-ui-extraction.md`); detect framework |
|
|
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 **from API**, placeholders + custom fields, 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`** (default when client says yes); `customize-ui` only for remote client |
|
|
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).
|
|
28
69
|
|
|
29
|
-
**
|
|
70
|
+
**Selection pattern:** focus ring = outer border + inner dot; cell selected = annulus fill between ring and dot.
|
|
30
71
|
|
|
31
|
-
**Do NOT** render `"not yet implemented"` or default fallback stubs in `Question.tsx`.
|
|
72
|
+
**Do NOT** render `"not yet implemented"` or default fallback stubs in `Question.tsx`. Dispatch all **11** flat `QUESTION_TYPE` literals — no `subType`.
|
|
32
73
|
|
|
33
|
-
**Copy scale templates
|
|
74
|
+
**Copy scale templates:** `SliderMatrixScale`, `LikertMatrixScale`, `CsatMatrixScale`, `RatingScale`, `FileUploadScale`, `HeatmapScale`, `RankOrderScale`, `MatrixDropdown`, `CustomSliderTrack`, `surveyUiIcons`, `surveyUiScaleUtils`, `heatmapCoords`, `customFieldValues` (when needed).
|
|
34
75
|
|
|
35
|
-
**
|
|
76
|
+
**Custom field logic:** when survey references `entityType: 'CUSTOM_FIELD'`, copy `customFieldValues.ts` and wire in hook options **and** `<Question customFieldValues={...} />`.
|
|
36
77
|
|
|
37
|
-
**
|
|
78
|
+
**Matrix types:** copy `LikertMatrixScale` / `CsatMatrixScale` — never bare radio grids without statement + label rows.
|
|
38
79
|
|
|
39
|
-
**FILE_UPLOAD:**
|
|
80
|
+
**FILE_UPLOAD:** presigned upload per `file-upload-aws.md` — raw `File[]` does not submit.
|
|
40
81
|
|
|
41
82
|
**Monorepo:** run `npm run build` in `packages/sdk` before starting the client dev server.
|
|
42
83
|
|
|
43
|
-
Follow
|
|
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,293 @@
|
|
|
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)* | UI-only notes per `mockup-ui-extraction.md`; **not** survey structure |
|
|
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 **UI-only** from mockup/prompt per [`mockup-ui-extraction.md`](mockup-ui-extraction.md) — colors, chrome, header/footer format, display copy
|
|
46
|
+
- Do **not** infer question types, language, or logic from mockup
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### Phase 1 — Scaffold
|
|
51
|
+
|
|
52
|
+
**Read:** `00-integration/setup.md` (framework section)
|
|
53
|
+
|
|
54
|
+
**Do:**
|
|
55
|
+
- Install `@explorer02/cfm-survey-sdk` (or `@repo/sdk`), `@tanstack/react-query`, `react-icons`
|
|
56
|
+
- Apply AWS static export config **now** if prompt mentions AWS/CloudFront/S3/EC2/Sprinklr
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### Phase 2 — Instance ID (INPUT 2)
|
|
61
|
+
|
|
62
|
+
**Read:** `00-integration/useSurveySDK.md`
|
|
63
|
+
|
|
64
|
+
**Ask:** JWT token (see table above)
|
|
65
|
+
|
|
66
|
+
**Do:**
|
|
67
|
+
- Wire `instanceId` in `SurveyPage` / hook options
|
|
68
|
+
- Do **not** build question UI yet
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### Phase 3 — SDK contract
|
|
73
|
+
|
|
74
|
+
**Read (in order):**
|
|
75
|
+
1. `00-integration/client-integration-guide.md`
|
|
76
|
+
2. `00-integration/question-type-sdk-matrix.md`
|
|
77
|
+
3. `00-integration/useSurveySDK.md`
|
|
78
|
+
4. `00-integration/client-lib-folder.md`
|
|
79
|
+
5. `00-integration/custom-field-logic-and-navigation.md`
|
|
80
|
+
6. `00-integration/skip-logic-and-navigation.md`
|
|
81
|
+
7. `00-integration/display-logic-and-navigation.md`
|
|
82
|
+
8. `00-integration/placeholders-and-tokens.md`
|
|
83
|
+
9. `00-integration/survey-lifecycle-analytics.md`
|
|
84
|
+
10. `02-reference/exports.md`, `02-reference/value-derivation.md`
|
|
85
|
+
|
|
86
|
+
**Do:**
|
|
87
|
+
- Understand `onAction`, `state.answers`, visibility helpers, lifecycle actions
|
|
88
|
+
- **Forbidden:** imports from `.../src/...` inside the SDK package
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
### Phase 4 — Plan + ingest
|
|
93
|
+
|
|
94
|
+
**Read (always):**
|
|
95
|
+
- `component-checklist.md`, `canonical-survey-fixtures.md`, `logic-fields-catalog.md`
|
|
96
|
+
- `03-ui-specs/00-question-shell.md`, `03-ui-specs/12-survey-chrome.md`
|
|
97
|
+
- `01-components/01-survey-page.md`, `01-components/02-question.md`
|
|
98
|
+
- `01-components/14-intro-page.md`, `01-components/15-end-page.md`, `01-components/16-paused-page.md`
|
|
99
|
+
|
|
100
|
+
**Read (per fetched survey type):** MANIFEST `questionTypes.{type}` → `blueprint` + `reference` + `uiSpec`
|
|
101
|
+
|
|
102
|
+
**Read (when flags match):** MANIFEST `sharedUiSpecTriggers` → `03-ui-specs/shared/*`
|
|
103
|
+
|
|
104
|
+
**Do:**
|
|
105
|
+
1. Fetch survey with instanceId
|
|
106
|
+
2. List unique `question.type` values in `implementation_plan.md` §3b (**from fetch only**)
|
|
107
|
+
3. Scan placeholders + `_c_…` custom fields per [`placeholders-and-custom-fields-wiring.md`](placeholders-and-custom-fields-wiring.md)
|
|
108
|
+
4. Copy `templates/implementation_plan.md` → project root; fill all sections
|
|
109
|
+
4. Copy `templates/Question.tsx` as dispatcher starting point
|
|
110
|
+
5. **Auto-proceed to Phase 5** — no approval wait
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### Phase 5 — Build (wizard-ready)
|
|
115
|
+
|
|
116
|
+
**Read:**
|
|
117
|
+
- `00-integration/constraints.md`
|
|
118
|
+
- `00-integration/component-checklist.md`
|
|
119
|
+
- `00-integration/wizard-preview-build-guide.md` **(required)**
|
|
120
|
+
- `00-integration/wizard-question-type-styling.md` **(required)**
|
|
121
|
+
- `00-integration/question-type-sdk-matrix.md`
|
|
122
|
+
- Per-type `03-ui-specs/*` from inventory
|
|
123
|
+
|
|
124
|
+
**Copy to project (required artifacts):**
|
|
125
|
+
|
|
126
|
+
| Source (`docs/templates/`) | Destination |
|
|
127
|
+
|----------------------------|-------------|
|
|
128
|
+
| `survey-theme.css` | `src/styles/survey-theme.css` |
|
|
129
|
+
| `selectionStyles.ts` | `src/lib/surveyUi/selectionStyles.ts` |
|
|
130
|
+
| `labelStyles.ts` | `src/lib/surveyUi/labelStyles.ts` |
|
|
131
|
+
| `previewBridge.ts` | `src/lib/previewBridge.ts` (local `customize` dev) |
|
|
132
|
+
| Scale components per inventory | `src/components/` |
|
|
133
|
+
| `surveyUiScaleUtils.ts`, `surveyUiIcons.tsx` | `src/lib/` |
|
|
134
|
+
| `customFieldValues.ts` | `src/lib/` (when `_c_…` in survey logic) |
|
|
135
|
+
|
|
136
|
+
**Wire in `globals.css`:**
|
|
137
|
+
```css
|
|
138
|
+
@import "./styles/survey-theme.css";
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Wire in root `layout.tsx`:** `<PreviewBridgeInit />` (see `wizard-preview-build-guide.md`)
|
|
142
|
+
|
|
143
|
+
**Chrome contract (`data-cfm-*`):**
|
|
144
|
+
- Header: `data-cfm-logo` and/or `data-cfm-logo-text`, `data-cfm-company`
|
|
145
|
+
- SurveyPage: `data-cfm-btn-next`, `data-cfm-btn-back`
|
|
146
|
+
- Intro/End: `data-cfm-survey-title`, `data-cfm-thank-you`
|
|
147
|
+
- Footer: `data-cfm-copyright`, `data-cfm-footer-links`
|
|
148
|
+
|
|
149
|
+
**Selection styling (all scale radios):** use `selectionStyles.ts` — see `wizard-question-type-styling.md`
|
|
150
|
+
|
|
151
|
+
**Label items (matrices/sliders):** use `labelStyles.ts` — column headers are label items, not hint labels (CFM matrix)
|
|
152
|
+
|
|
153
|
+
**Draft config:** write `./survey-ui-config.json` + keep CSS in sync (seeds wizard in 6b)
|
|
154
|
+
|
|
155
|
+
**Forbidden in Phase 5:**
|
|
156
|
+
- Changing `Question.tsx` dispatch / `onAction` payloads
|
|
157
|
+
- `subType` routing
|
|
158
|
+
- Stub placeholder branches
|
|
159
|
+
- Hardcoded brand hex for wizard-controlled tokens
|
|
160
|
+
|
|
161
|
+
**Auto-proceed to Phase 6** after build compiles.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
### Phase 6 — Verify
|
|
166
|
+
|
|
167
|
+
**Read:** `constraints.md` (troubleshooting)
|
|
168
|
+
|
|
169
|
+
**Run:** `bash templates/verify-agent-build.sh`
|
|
170
|
+
|
|
171
|
+
**Checklist:** see `index.md` Phase 6 + `component-checklist.md` Step 3–4
|
|
172
|
+
|
|
173
|
+
**Do:**
|
|
174
|
+
- `npm run build` → exit 0
|
|
175
|
+
- Start dev server; confirm survey loads
|
|
176
|
+
- **Ask INPUT 3** (wizard question)
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### Phase 6b — Wizard session (optional, INPUT 3 = Yes)
|
|
181
|
+
|
|
182
|
+
**Default:** `npx cfm-sdk customize` — local wizard on `localhost:4200`. Best for preview smoothness, direct JSON save, and automatic cleanup.
|
|
183
|
+
|
|
184
|
+
**EC2 fallback:** `customize-ui` — only when client customizes from **another device**.
|
|
185
|
+
|
|
186
|
+
**Read:** `ui-customization-wizard.md`, `wizard-preview-build-guide.md`, `wizard-troubleshooting.md`, `apply-ui-config.md`
|
|
187
|
+
|
|
188
|
+
**Prerequisites:** Phase 6 passed; draft `survey-ui-config.json` exists
|
|
189
|
+
|
|
190
|
+
**Run (default — agent blocks until client saves):**
|
|
191
|
+
```bash
|
|
192
|
+
npx cfm-sdk customize
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Sequence:**
|
|
196
|
+
1. CLI auto-exports all 11 component previews to `out/previews/`
|
|
197
|
+
2. Opens wizard at `http://localhost:4200`
|
|
198
|
+
3. Client customizes (same machine as agent); live iframes from local previews
|
|
199
|
+
4. Client clicks **Review & Build** → `survey-ui-config.json` written
|
|
200
|
+
5. CLI exits 0 → agent applies per Phase 6c
|
|
201
|
+
|
|
202
|
+
**Tell the client:** *"Complete the wizard in the browser that just opened and click **Review & Build**."*
|
|
203
|
+
|
|
204
|
+
**Remote client only:**
|
|
205
|
+
```bash
|
|
206
|
+
export CFM_INSTANCE_ID="<JWT>"
|
|
207
|
+
export CFM_DEPLOY_API_BASE="http://43.204.26.213:3000"
|
|
208
|
+
npx cfm-sdk customize-ui
|
|
209
|
+
```
|
|
210
|
+
Share EC2 link; keep CLI open until `✅ Configuration ready`. See `wizard-config-handoff.md`.
|
|
211
|
+
|
|
212
|
+
**If client said No:** skip to Phase 7 ask.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
### Phase 6c — Apply wizard changes (mandatory when wizard used)
|
|
217
|
+
|
|
218
|
+
**Read:** `wizard-config-handoff.md`, `apply-ui-config.md`, `wizard-question-type-styling.md`
|
|
219
|
+
|
|
220
|
+
**Input file:**
|
|
221
|
+
- AWS: `survey-ui-config.final.json`
|
|
222
|
+
- Local: `survey-ui-config.json`
|
|
223
|
+
|
|
224
|
+
**Do (in order):**
|
|
225
|
+
1. Validate JSON against `templates/survey-ui-config.schema.json`
|
|
226
|
+
2. Read **entire** `survey-ui-config.diff.md` (AWS) — every path must be applied
|
|
227
|
+
3. Regenerate `src/styles/survey-theme.css` from **full** final config (not partial)
|
|
228
|
+
4. Update all `data-cfm-*` content hooks (title, buttons, footer, logo)
|
|
229
|
+
5. Apply layout toggles in `SurveyPage` / chrome
|
|
230
|
+
6. Wire `placeholders`, `customFields`, `debug` from final config
|
|
231
|
+
7. Apply per-type `questionTypes.*` for every type in `surveyTypes[]`
|
|
232
|
+
8. AWS: `npx cfm-sdk confirm-ui-config` (promotes final → active + downloads logo)
|
|
233
|
+
9. When `global.logo.fileName` is set: update `Header.tsx` `data-cfm-logo src="./{fileName}"`; verify `public/{fileName}` exists
|
|
234
|
+
10. Re-run `verify-agent-build.sh` + `npm run build`
|
|
235
|
+
11. Verify logo in static output: `test -f out/$(jq -r '.global.logo.fileName' survey-ui-config.json)` when fileName set
|
|
236
|
+
12. **Do not** change dispatch logic in `Question.tsx`
|
|
237
|
+
|
|
238
|
+
**Blocking:** Do not proceed to Phase 7 until diff paths are applied and verify passes.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
### Phase 7 — Deploy (INPUT 4)
|
|
243
|
+
|
|
244
|
+
**Ask:** deploy confirmation (see table)
|
|
245
|
+
|
|
246
|
+
**Before AWS deploy (when wizard set a logo):**
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
LOGO=$(python3 -c "import json; print(json.load(open('survey-ui-config.json')).get('global',{}).get('logo',{}).get('fileName') or '')")
|
|
250
|
+
test -z "$LOGO" || test -f "out/$LOGO" || { echo "Logo missing from out/ — fix Phase 6c Header + public/"; exit 1; }
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
See [`aws-deploy.md`](aws-deploy.md) § Logos & local assets.
|
|
254
|
+
|
|
255
|
+
**Route:**
|
|
256
|
+
- AWS keywords in prompt → `aws-deploy.md` + `deploy-to-aws.sh`
|
|
257
|
+
- Else / Vercel → `npx cfm-sdk deploy`
|
|
258
|
+
- Override with `survey-ui-config.json` → `deploy.target` when present
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Wizard styling quick reference
|
|
263
|
+
|
|
264
|
+
| Wizard control | CSS variable | Component pattern |
|
|
265
|
+
|----------------|--------------|-------------------|
|
|
266
|
+
| Question card → Cell selected | `--cfm-matrix-selected` | Annulus fill between ring and dot; numbered/star cell bg |
|
|
267
|
+
| Question card → Focus ring | `--cfm-input-focus-ring` | Outer radio border + inner dot |
|
|
268
|
+
| Matrix label items | `--cfm-matrix-column-label-*` | `matrixColumnLabelStyle()` |
|
|
269
|
+
| CSAT label items | `--cfm-csat-column-label-*` | `csatColumnLabelStyle()` |
|
|
270
|
+
| Hint labels (NPS min/max) | `--cfm-hint-label-*` | `hintLabelStyle()` |
|
|
271
|
+
| Number labels (traffic/mono/individual) | `--cfm-number-*` | `resolveNumberLabelColor()` in scale utils |
|
|
272
|
+
| File upload border | `--cfm-upload-border-color` | Dropzone border |
|
|
273
|
+
| MCQ selection | focus ring + cell selected | Radio ring/dot pattern |
|
|
274
|
+
|
|
275
|
+
Full mapping: [`wizard-question-type-styling.md`](wizard-question-type-styling.md)
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Doc index by task
|
|
280
|
+
|
|
281
|
+
| Task | Read |
|
|
282
|
+
|------|------|
|
|
283
|
+
| Anti-hallucination / doc routing | `agent-operating-contract.md` |
|
|
284
|
+
| Full pipeline | `agent-operating-contract.md` + this file + `index.md` |
|
|
285
|
+
| Hook / answers | `client-integration-guide.md`, `useSurveySDK.md` |
|
|
286
|
+
| Copy files list | `component-checklist.md`, `client-lib-folder.md` |
|
|
287
|
+
| Matrix labels | `canonical-survey-fixtures.md` |
|
|
288
|
+
| Wizard chrome | `wizard-preview-build-guide.md` |
|
|
289
|
+
| Wizard per-type | `wizard-question-type-styling.md` |
|
|
290
|
+
| Wait + capture + apply order | `wizard-config-handoff.md` |
|
|
291
|
+
| Apply every config path | `apply-ui-config.md` |
|
|
292
|
+
| Logo rules | `constraints.md` §4, `10-header-footer.md` |
|
|
293
|
+
| UI spec details | `03-ui-specs/{type}.md` per inventory |
|