@explorer02/cfm-survey-sdk 0.1.8 → 0.1.9

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 (58) hide show
  1. package/dist/index.d.mts +24 -26
  2. package/dist/index.d.ts +24 -26
  3. package/dist/index.js +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/package.json +2 -2
  6. package/postinstall.js +21 -30
  7. package/templates/AGENT.md +24 -10
  8. package/templates/docs/00-integration/constraints.md +54 -0
  9. package/templates/docs/00-integration/setup.md +80 -0
  10. package/templates/docs/00-integration/useSurveySDK.md +107 -0
  11. package/templates/docs/{03-client-components → 01-components}/README.md +1 -1
  12. package/templates/docs/02-question-types/01-rating.md +0 -8
  13. package/templates/docs/02-reference/question-types/01-rating.md +52 -0
  14. package/templates/docs/02-reference/question-types/README.md +71 -0
  15. package/templates/docs/02-reference/routing-table.md +37 -0
  16. package/templates/docs/MANIFEST.json +129 -0
  17. package/templates/docs/index.md +100 -142
  18. package/templates/docs/templates/implementation_plan.md +78 -0
  19. package/templates/docs/01-sdk-core/01-fetch-survey.md +0 -68
  20. package/templates/docs/01-sdk-core/02-survey-mapper.md +0 -85
  21. package/templates/docs/01-sdk-core/03-question-mappers.md +0 -114
  22. package/templates/docs/01-sdk-core/04-pagination.md +0 -72
  23. package/templates/docs/01-sdk-core/05-validation.md +0 -66
  24. package/templates/docs/01-sdk-core/06-submit-survey.md +0 -90
  25. package/templates/docs/01-sdk-core/07-language-handling.md +0 -111
  26. package/templates/docs/01-sdk-core/08-icons-and-emojis.md +0 -56
  27. package/templates/docs/01-sdk-core/README.md +0 -53
  28. package/templates/docs/02-question-types/02-radio.md +0 -26
  29. package/templates/docs/02-question-types/03-text.md +0 -26
  30. package/templates/docs/02-question-types/12-text-and-media.md +0 -35
  31. package/templates/docs/02-question-types/README.md +0 -74
  32. package/templates/docs/04-critical-rules/01-import-rules.md +0 -51
  33. package/templates/docs/04-critical-rules/02-action-dispatching.md +0 -56
  34. package/templates/docs/04-critical-rules/03-scroll-navigation.md +0 -37
  35. package/templates/docs/04-critical-rules/04-logo-branding.md +0 -42
  36. package/templates/docs/04-critical-rules/05-troubleshooting.md +0 -46
  37. package/templates/docs/04-critical-rules/README.md +0 -29
  38. /package/templates/docs/{03-client-components → 01-components}/01-survey-page.md +0 -0
  39. /package/templates/docs/{03-client-components → 01-components}/02-question.md +0 -0
  40. /package/templates/docs/{03-client-components → 01-components}/03-rating-scale.md +0 -0
  41. /package/templates/docs/{03-client-components → 01-components}/04-csat-scale.md +0 -0
  42. /package/templates/docs/{03-client-components → 01-components}/05-csat-matrix-scale.md +0 -0
  43. /package/templates/docs/{03-client-components → 01-components}/06-likert-matrix-scale.md +0 -0
  44. /package/templates/docs/{03-client-components → 01-components}/07-slider-matrix-scale.md +0 -0
  45. /package/templates/docs/{03-client-components → 01-components}/08-file-upload-scale.md +0 -0
  46. /package/templates/docs/{03-client-components → 01-components}/09-custom-slider-track.md +0 -0
  47. /package/templates/docs/{03-client-components → 01-components}/10-header-footer.md +0 -0
  48. /package/templates/docs/{03-client-components → 01-components}/11-progress-bar.md +0 -0
  49. /package/templates/docs/{03-client-components → 01-components}/12-language-selector.md +0 -0
  50. /package/templates/docs/{03-client-components → 01-components}/13-matrix-dropdown.md +0 -0
  51. /package/templates/docs/{02-question-types → 02-reference/question-types}/04-csat.md +0 -0
  52. /package/templates/docs/{02-question-types → 02-reference/question-types}/05-rating-scale.md +0 -0
  53. /package/templates/docs/{02-question-types → 02-reference/question-types}/06-slider.md +0 -0
  54. /package/templates/docs/{02-question-types → 02-reference/question-types}/07-matrix-cfm.md +0 -0
  55. /package/templates/docs/{02-question-types → 02-reference/question-types}/08-matrix-csat.md +0 -0
  56. /package/templates/docs/{02-question-types → 02-reference/question-types}/09-matrix-rating.md +0 -0
  57. /package/templates/docs/{02-question-types → 02-reference/question-types}/10-slider-matrix.md +0 -0
  58. /package/templates/docs/{02-question-types → 02-reference/question-types}/11-file-upload.md +0 -0
@@ -21,14 +21,6 @@ type RatingQuestion = QuestionBase & {
21
21
  ## Answer Shape: `number`
22
22
  Example: `7` (the selected badge value)
23
23
 
24
- ## Options Auto-Generation
25
- If the API provides no explicit options, the SDK generates 0-10:
26
- ```typescript
27
- Array.from({ length: 11 }, (_, i) => ({
28
- id: String(i), label: String(i), value: i, color: getColor(i)
29
- }));
30
- ```
31
-
32
24
  ## NPS Traffic-Light Colors
33
25
  ```
34
26
  0: #e2001a (red) 3: #f18b00 (orange) 6: #fcd900 (yellow)
@@ -0,0 +1,52 @@
1
+ # Rating Question (NPS 0-10)
2
+
3
+ > **Type**: `'rating'` | **API Source**: `SCALE` with `SCALE_TYPE=TEN_POINT` or `NPS_SCALE`
4
+ > **Mapper**: `ratingMapper.ts` | **Component**: `RatingScale`
5
+
6
+ ## TypeScript Type
7
+
8
+ ```typescript
9
+ type RatingQuestion = QuestionBase & {
10
+ type: 'rating';
11
+ options: SurveyOption[]; // 0-10 with NPS traffic-light colors
12
+ minLabel?: string; // Left label (e.g. "Not Likely")
13
+ midLabel?: string; // Middle label (e.g. "Neutral")
14
+ maxLabel?: string; // Right label (e.g. "Extremely Likely")
15
+ midLabelIndex?: number; // Fractional position for mid-label CSS
16
+ reverseScaleOrder?: boolean; // Render high→low
17
+ buttonVariant?: 'radio' | 'numbered' | 'emoji';
18
+ };
19
+ ```
20
+
21
+ ## Answer Shape: `number`
22
+ Example: `7` (the selected badge value)
23
+
24
+ ## Options Auto-Generation
25
+ If the API provides no explicit options, the SDK generates 0-10:
26
+ ```typescript
27
+ Array.from({ length: 11 }, (_, i) => ({
28
+ id: String(i), label: String(i), value: i, color: getColor(i)
29
+ }));
30
+ ```
31
+
32
+ ## NPS Traffic-Light Colors
33
+ ```
34
+ 0: #e2001a (red) 3: #f18b00 (orange) 6: #fcd900 (yellow)
35
+ 1: #e4251b 4: #f7b200 7: #9fca00 (lime)
36
+ 2: #ec610a 5: #fcd900 8: #6bb300 (green)
37
+ 9: #339a00
38
+ 10: #008000
39
+ ```
40
+
41
+ ## Mid-Label Positioning
42
+ ```typescript
43
+ // CSS left percentage for mid-label
44
+ const left = (midLabelIndex / (options.length - 1)) * 100;
45
+ // For 11-point scale: midLabelIndex defaults to 7.5
46
+ ```
47
+
48
+ ## Rendering Guidance
49
+ - Display as horizontal row of numbered badge buttons
50
+ - Each badge uses `option.color` as background
51
+ - Selected badge: emphasized border/scale, all others dimmed
52
+ - Labels positioned: minLabel (left), midLabel (calculated %), maxLabel (right)
@@ -0,0 +1,71 @@
1
+ # Question Types Reference
2
+
3
+ > Read **on demand** — only for types present in the fetched survey.
4
+ > UI implementation: `01-components/`. Routing table: `02-reference/routing-table.md`.
5
+
6
+ ## Discriminated Union
7
+
8
+ ```typescript
9
+ type SurveyQuestion =
10
+ | RatingQuestion // 'rating'
11
+ | RadioQuestion // 'radio'
12
+ | TextQuestion // 'text'
13
+ | CsatQuestion // 'csat'
14
+ | RatingScaleQuestion // 'rating_scale'
15
+ | SliderQuestion // 'slider'
16
+ | MatrixQuestion // 'matrix' (check subType)
17
+ | RatingMatrixQuestion // 'rating_matrix'
18
+ | SliderMatrixQuestion // 'slider_matrix'
19
+ | FileUploadQuestion // 'file_upload'
20
+ | TextAndMediaQuestion; // 'text_and_media'
21
+ ```
22
+
23
+ ## Shared `QuestionBase` Properties
24
+
25
+ | Property | Type | Notes |
26
+ |----------|------|-------|
27
+ | `id` | `string` | **MUST** be DOM `id` on wrapper |
28
+ | `text` | `string` | HTML — use `dangerouslySetInnerHTML` |
29
+ | `description` | `string?` | HTML |
30
+ | `required` | `boolean?` | |
31
+ | `requiredErrorMessage` | `string?` | Custom validation message |
32
+ | `questionNumber` | `number?` | 1-indexed |
33
+
34
+ ---
35
+
36
+ ## radio {#radio}
37
+
38
+ - **Type:** `RadioQuestion` — `type: 'radio'`
39
+ - **Answer:** `string | number` (option id or value)
40
+ - **UI:** Inline MCQ radio cards in `Question.tsx` — see `01-components/02-question.md`
41
+ - **No separate reference doc needed**
42
+
43
+ ## text {#text}
44
+
45
+ - **Type:** `TextQuestion` — `type: 'text'`
46
+ - **Answer:** `string`
47
+ - **UI:** Inline `<textarea>` or `<input>` in `Question.tsx`
48
+ - **No separate reference doc needed**
49
+
50
+ ## text_and_media {#text_and_media}
51
+
52
+ - **Type:** `TextAndMediaQuestion` — `type: 'text_and_media'`
53
+ - **Answer:** none — display-only, skipped in validation and submission
54
+ - **UI:** Inline `<video>` or `<img>` from `question.mediaUrl` — no scale component
55
+ - **No separate reference doc needed**
56
+
57
+ ---
58
+
59
+ ## Detailed Reference Docs
60
+
61
+ | File | Type | When to read |
62
+ |------|------|--------------|
63
+ | `01-rating.md` | `rating` | NPS / numeric scales |
64
+ | `04-csat.md` | `csat` | CSAT emoji/star (≤5 options) |
65
+ | `05-rating-scale.md` | `rating_scale` | Star/emoji rating |
66
+ | `06-slider.md` | `slider` | Single range slider |
67
+ | `07-matrix-cfm.md` | `matrix` + `CFM_MATRIX` | Likert text grid |
68
+ | `08-matrix-csat.md` | `matrix` + CSAT/RATING | Satisfaction grid |
69
+ | `09-matrix-rating.md` | `rating_matrix` | NPS-style grid |
70
+ | `10-slider-matrix.md` | `slider_matrix` | Slider grid |
71
+ | `11-file-upload.md` | `file_upload` | File attachments |
@@ -0,0 +1,37 @@
1
+ # Question Type → Component Routing
2
+
3
+ > Canonical mapping. For UI implementation details, read `01-components/`. For data shapes, read `02-reference/question-types/`.
4
+
5
+ | `question.type` | `question.subType` | Component | Answer Shape | Reference Doc |
6
+ |-----------------|-------------------|-----------|--------------|---------------|
7
+ | `'rating'` | — | `RatingScale` | `number` | `question-types/01-rating.md` |
8
+ | `'radio'` | — | Inline in `Question` | `string \| number` | `question-types/README.md#radio` |
9
+ | `'text'` | — | Inline in `Question` | `string` | `question-types/README.md#text` |
10
+ | `'csat'` | — | `CsatScale` | `number \| null` | `question-types/04-csat.md` |
11
+ | `'rating_scale'` | — | `RatingScale` | `number` | `question-types/05-rating-scale.md` |
12
+ | `'slider'` | — | `CustomSliderTrack` | `number` | `question-types/06-slider.md` |
13
+ | `'matrix'` | `'CFM_MATRIX'` | `LikertMatrixScale` | `MatrixAnswerMap` | `question-types/07-matrix-cfm.md` |
14
+ | `'matrix'` | `'CSAT_MATRIX'` | `CsatMatrixScale` | `MatrixAnswerMap` | `question-types/08-matrix-csat.md` |
15
+ | `'matrix'` | `'RATING_MATRIX'` | `CsatMatrixScale` | `MatrixAnswerMap` | `question-types/08-matrix-csat.md` |
16
+ | `'rating_matrix'` | — | `CsatMatrixScale` | `MatrixAnswerMap` | `question-types/09-matrix-rating.md` |
17
+ | `'slider_matrix'` | — | `SliderMatrixScale` | `MatrixAnswerMap` | `question-types/10-slider-matrix.md` |
18
+ | `'file_upload'` | — | `FileUploadScale` | `UploadedFile[]` | `question-types/11-file-upload.md` |
19
+ | `'text_and_media'` | — | Inline in `Question` | (no answer) | `question-types/README.md#text_and_media` |
20
+
21
+ ## Component Blueprint Docs
22
+
23
+ | Component | Blueprint |
24
+ |-----------|-----------|
25
+ | `SurveyPage` | `01-components/01-survey-page.md` |
26
+ | `Question` | `01-components/02-question.md` |
27
+ | `RatingScale` | `01-components/03-rating-scale.md` |
28
+ | `CsatScale` | `01-components/04-csat-scale.md` |
29
+ | `CsatMatrixScale` | `01-components/05-csat-matrix-scale.md` |
30
+ | `LikertMatrixScale` | `01-components/06-likert-matrix-scale.md` |
31
+ | `SliderMatrixScale` | `01-components/07-slider-matrix-scale.md` |
32
+ | `FileUploadScale` | `01-components/08-file-upload-scale.md` |
33
+ | `CustomSliderTrack` | `01-components/09-custom-slider-track.md` |
34
+ | `Header` / `Footer` | `01-components/10-header-footer.md` |
35
+ | `ProgressBar` | `01-components/11-progress-bar.md` |
36
+ | `LanguageSelector` | `01-components/12-language-selector.md` |
37
+ | `MatrixDropdown` | `01-components/13-matrix-dropdown.md` |
@@ -0,0 +1,129 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "packageNames": {
4
+ "npm": "@explorer02/cfm-survey-sdk",
5
+ "monorepo": "@repo/sdk"
6
+ },
7
+ "entryPoint": "index.md",
8
+ "clientInputs": ["initialPrompt", "instanceIdJwt", "deployConfirmation"],
9
+ "phases": [
10
+ {
11
+ "id": 0,
12
+ "name": "orient",
13
+ "read": ["index.md", "../AGENT.md"],
14
+ "actions": ["detectFramework", "extractBrandingFromClientPrompt"]
15
+ },
16
+ {
17
+ "id": 1,
18
+ "name": "scaffold",
19
+ "read": ["00-integration/setup.md"],
20
+ "frameworks": ["nextjs", "vite", "cra"]
21
+ },
22
+ {
23
+ "id": 2,
24
+ "name": "instanceId",
25
+ "read": ["00-integration/useSurveySDK.md"]
26
+ },
27
+ {
28
+ "id": 3,
29
+ "name": "sdkContract",
30
+ "read": ["00-integration/useSurveySDK.md"]
31
+ },
32
+ {
33
+ "id": 4,
34
+ "name": "planAndIngest",
35
+ "read": [
36
+ "01-components/README.md",
37
+ "01-components/01-survey-page.md",
38
+ "01-components/02-question.md",
39
+ "01-components/03-rating-scale.md",
40
+ "01-components/04-csat-scale.md",
41
+ "01-components/05-csat-matrix-scale.md",
42
+ "01-components/06-likert-matrix-scale.md",
43
+ "01-components/07-slider-matrix-scale.md",
44
+ "01-components/08-file-upload-scale.md",
45
+ "01-components/09-custom-slider-track.md",
46
+ "01-components/10-header-footer.md",
47
+ "01-components/11-progress-bar.md",
48
+ "01-components/12-language-selector.md",
49
+ "01-components/13-matrix-dropdown.md"
50
+ ],
51
+ "template": "templates/implementation_plan.md",
52
+ "output": "implementation_plan.md"
53
+ },
54
+ {
55
+ "id": 5,
56
+ "name": "build",
57
+ "read": ["00-integration/constraints.md", "02-reference/routing-table.md"],
58
+ "onDemand": "02-reference/question-types"
59
+ },
60
+ {
61
+ "id": 6,
62
+ "name": "verify",
63
+ "read": ["00-integration/constraints.md"],
64
+ "checklist": [
65
+ "questionDispatcherCoversAll12Types",
66
+ "everyQuestionWrapperHasId",
67
+ "noInternalSdkImports",
68
+ "surveyPageFiveStates",
69
+ "npmRunBuildPasses"
70
+ ]
71
+ },
72
+ {
73
+ "id": 7,
74
+ "name": "deploy",
75
+ "command": "npx cfm-sdk deploy"
76
+ }
77
+ ],
78
+ "questionTypes": {
79
+ "rating": {
80
+ "component": "01-components/03-rating-scale.md",
81
+ "reference": "02-reference/question-types/01-rating.md"
82
+ },
83
+ "radio": {
84
+ "component": "01-components/02-question.md",
85
+ "reference": "02-reference/question-types/README.md#radio"
86
+ },
87
+ "text": {
88
+ "component": "01-components/02-question.md",
89
+ "reference": "02-reference/question-types/README.md#text"
90
+ },
91
+ "csat": {
92
+ "component": "01-components/04-csat-scale.md",
93
+ "reference": "02-reference/question-types/04-csat.md"
94
+ },
95
+ "rating_scale": {
96
+ "component": "01-components/03-rating-scale.md",
97
+ "reference": "02-reference/question-types/05-rating-scale.md"
98
+ },
99
+ "slider": {
100
+ "component": "01-components/09-custom-slider-track.md",
101
+ "reference": "02-reference/question-types/06-slider.md"
102
+ },
103
+ "matrix": {
104
+ "component": "01-components/06-likert-matrix-scale.md",
105
+ "reference": "02-reference/question-types/07-matrix-cfm.md",
106
+ "subTypes": {
107
+ "CFM_MATRIX": "01-components/06-likert-matrix-scale.md",
108
+ "CSAT_MATRIX": "01-components/05-csat-matrix-scale.md",
109
+ "RATING_MATRIX": "01-components/05-csat-matrix-scale.md"
110
+ }
111
+ },
112
+ "rating_matrix": {
113
+ "component": "01-components/05-csat-matrix-scale.md",
114
+ "reference": "02-reference/question-types/09-matrix-rating.md"
115
+ },
116
+ "slider_matrix": {
117
+ "component": "01-components/07-slider-matrix-scale.md",
118
+ "reference": "02-reference/question-types/10-slider-matrix.md"
119
+ },
120
+ "file_upload": {
121
+ "component": "01-components/08-file-upload-scale.md",
122
+ "reference": "02-reference/question-types/11-file-upload.md"
123
+ },
124
+ "text_and_media": {
125
+ "component": "01-components/02-question.md",
126
+ "reference": "02-reference/question-types/README.md#text_and_media"
127
+ }
128
+ }
129
+ }
@@ -1,151 +1,109 @@
1
1
  # CFM SURVEY SDK — AGENT DOCUMENTATION INDEX
2
2
 
3
- **@explorer02/cfm-survey-sdk**
3
+ **@explorer02/cfm-survey-sdk** (npm) · **@repo/sdk** (monorepo)
4
4
 
5
- This file is the MASTER GUIDE for AI coding agents (Cursor, Copilot, etc.).
6
- It is a structured roadmap that tells the agent exactly which documentation files to read and in what order.
5
+ Master guide for AI coding agents. Machine-readable index: `MANIFEST.json`.
7
6
 
8
- ## ── HOW THIS DOCUMENTATION SYSTEM WORKS ──────────────────────────────────────
9
-
10
- The `docs/` folder mirrors the SDK's internal architecture:
7
+ ## Documentation Layout
11
8
 
12
9
  ```
13
10
  docs/
14
- ├── index.md ← YOU ARE HERE — read this first
15
- ├── 01-sdk-core/ SDK internals: fetch, map, paginate, validate, submit
16
- ├── 02-question-types/ ← One doc per question type (12 types)
17
- ├── 03-client-components/ One doc per UI component (13 components)
18
- └── 04-critical-rules/ Non-negotiable constraints, imports, troubleshooting
11
+ ├── index.md ← YOU ARE HERE
12
+ ├── MANIFEST.json Phase + question-type routing (for tooling)
13
+ ├── 00-integration/ ← Setup, hook contract, constraints
14
+ ├── 01-components/ UI blueprints (read ALL before coding)
15
+ ├── 02-reference/ Routing table + question-type data (on demand)
16
+ └── templates/
17
+ └── implementation_plan.md
19
18
  ```
20
19
 
21
- ## ── CLIENT INTERACTION FLOW (3 INPUTS ONLY) ──────────────────────────────────
22
-
23
- The entire build process requires EXACTLY 3 inputs from the client:
24
-
25
- **INPUT 1: Client's initial prompt**
26
- → "Build a survey like this image using @explorer02/cfm-survey-sdk"
27
- May include UI mockup screenshots, brand colors, or text description
28
- Agent begins project scaffolding and component architecture
29
-
30
- **INPUT 2: Instance ID (agent asks for it)**
31
- Agent asks: "Please provide your survey instance ID (JWT token)"
32
- → Client pastes the instanceId string
33
- → Agent wires it into SurveyPage.tsx and fetches the survey
34
-
35
- **INPUT 3: Deployment confirmation (agent asks at the end)**
36
- → Agent asks: "Your survey is built and tested. Ready to deploy to Vercel?"
37
- Client confirms → Agent runs `npx vercel --prod --yes`
38
-
39
- ## ── EXECUTION PIPELINE ───────────────────────────────────────────────────────
40
-
41
- Follow these phases IN ORDER. Each phase references specific doc files.
42
-
43
- ### PHASE 1: PROJECT SCAFFOLDING
44
- Read: `04-critical-rules/01-import-rules.md`
45
-
46
- Actions:
47
- 1. Create Next.js project:
48
- `npx -y create-next-app@latest ./ --ts --tailwind --eslint --app --src-dir --import-alias "@/*" --use-npm`
49
- 2. Install SDK:
50
- `npm install @explorer02/cfm-survey-sdk @tanstack/react-query`
51
- 3. Configure `next.config.js`:
52
- `transpilePackages: ["@explorer02/cfm-survey-sdk"]`
53
-
54
- ### PHASE 2: ASK FOR INSTANCE ID (INPUT 2)
55
- Read: `01-sdk-core/01-fetch-survey.md`
56
-
57
- Ask the client in chat:
58
- "Please provide your survey instance ID (the JWT token string) so I can connect your survey."
59
-
60
- Wait for the client to paste the instanceId. Store it you will wire it into SurveyPage.tsx in Phase 4.
61
-
62
- ### PHASE 3: UNDERSTAND THE SDK PIPELINE
63
- Read these docs IN ORDER to understand how the SDK works:
64
-
65
- 1. `01-sdk-core/01-fetch-survey.md` — How survey data is fetched
66
- 2. `01-sdk-core/02-survey-mapper.md` — How raw API → Survey object
67
- 3. `01-sdk-core/03-question-mappers.md` How questions are typed/mapped
68
- 4. `01-sdk-core/07-language-handling.md`Translations & placeholders
69
- 5. `01-sdk-core/04-pagination.md` Page navigation state
70
- 6. `01-sdk-core/05-validation.md` — Required field validation
71
- 7. `01-sdk-core/06-submit-survey.md` — Response submission format
72
- 8. `01-sdk-core/08-icons-and-emojis.md` — CSAT emoji/star icon system
73
-
74
- Then understand what question types exist:
75
- 9. `02-question-types/README.md` — Overview of all 12 types
76
-
77
- *You do NOT need to read every question type doc upfront. Read them ON DEMAND when you encounter each type during component building.*
78
-
79
- ### PHASE 4: UI ARCHITECTURE & WORKFLOW PLANNING (CRITICAL)
80
- Before writing ANY React code, you MUST enter Planning Mode and generate a deeply comprehensive \`implementation_plan.md\`.
81
-
82
- **DEEP CONTEXT INGESTION REQUIRED**:
83
- Before you even start writing the plan, you MUST read EVERY SINGLE markdown file inside \`03-client-components/\`. You cannot plan accurately without knowing the exact architectures required for CSAT bounds, file validations, and matrix transpositions.
84
-
85
- Read ALL the component architectural blueprints IN ORDER:
86
- 1. \`03-client-components/README.md\`
87
- 2. \`03-client-components/01-survey-page.md\`
88
- 3. \`03-client-components/02-question.md\`
89
- 4. \`03-client-components/03-rating-scale.md\`
90
- 5. \`03-client-components/04-csat-scale.md\`
91
- 6. \`03-client-components/05-csat-matrix-scale.md\`
92
- 7. \`03-client-components/06-likert-matrix-scale.md\`
93
- 8. \`03-client-components/07-slider-matrix-scale.md\`
94
- 9. \`03-client-components/08-file-upload-scale.md\`
95
- 10. \`03-client-components/09-custom-slider-track.md\`
96
- 11. \`03-client-components/10-header-footer.md\`
97
- 12. \`03-client-components/11-progress-bar.md\`
98
- 13. \`03-client-components/12-language-selector.md\`
99
- 14. \`03-client-components/13-matrix-dropdown.md\`
100
-
101
- Your \`implementation_plan.md\` MUST be structured professionally and precisely cover:
102
- 1. **Data Fetching & State**: Precisely how \`useSurveySDK(instanceId)\` will be integrated. How to handle \`isLoading\`, \`error\`, \`empty\`, and \`submitted\` states properly.
103
- 2. **Pagination, Actions, & Flow**: How you will iterate through pages, manage \`onAction({ type: 'NEXT' / 'PREVIOUS' })\`, and precisely wire up the \`ProgressBar\`.
104
- 3. **Question Dispatching**: How \`Question.tsx\` will comprehensively route all 12 \`question.type\` variants (including \`text_and_media\` for \`CONTENT\` questions). How it will safely handle rich HTML parsing and validation error display.
105
- 4. **Question Architectures & Component Checklist**: You must create a checklist inside your plan for EACH complex component. You must verify mappings, step sizes, ticks, hover effects, scale items positioning, and matrix transposition logic EXACTLY as detailed in the blueprints.
106
- 5. **Theme, Brand & Logos**: How you will engineer CSS-only logos based on the client's mockup prompt and map specific brand colors to hover states.
107
- 6. **Submit Survey**: How you will trigger the final \`submitSurvey\` dispatch and elegantly transition the UI to the Thank You screen.
108
-
109
- **ACTION**: Generate the \`implementation_plan.md\`. Once the plan is written, **DO NOT WAIT FOR APPROVAL**. Automatically proceed to trigger Phase 5 and start implementing the code!
110
-
111
- Then for EACH question type present in the fetched survey, read the matching question-type doc AND component doc:
112
-
113
- | `question.type` | Question Doc | Component Doc |
114
- |---|---|---|
115
- | `'rating'` | `02-question-types/01-rating` | `03-components/03-rating` |
116
- | `'radio'` | `02-question-types/02-radio` | (inline in Question) |
117
- | `'text'` | `02-question-types/03-text` | (inline in Question) |
118
- | `'csat'` | `02-question-types/04-csat` | `03-components/04-csat` |
119
- | `'rating_scale'` | `02-question-types/05-rating-s` | `03-components/03-rating` |
120
- | `'slider'` | `02-question-types/06-slider` | `03-components/09-slider` |
121
- | `'matrix'` CFM | `02-question-types/07-matrix-c` | `03-components/06-likert` |
122
- | `'matrix'` CSAT | `02-question-types/08-matrix-c` | `03-components/05-csat-m` |
123
- | `'matrix'` RATING| `02-question-types/09-matrix-r` | `03-components/05-csat-m` |
124
- | `'slider_matrix'`| `02-question-types/10-slider-m` | `03-components/07-slider` |
125
- | `'file_upload'` | `02-question-types/11-file-up` | `03-components/08-file` |
126
- | `'text_and_media'`| `02-question-types/12-text-med` | (inline in Question) |
127
-
128
- Also read these shared component docs:
129
- - `03-client-components/09-custom-slider-track.md` (used by CSAT matrix, slider matrix when sliderType='graphics')
130
- - `03-client-components/13-matrix-dropdown.md` (used by matrix dropdown fmt)
131
-
132
- ### PHASE 5: APPLY CRITICAL RULES
133
- Read ALL files in `04-critical-rules/`:
134
- 1. `01-import-rules.md` — Package imports, 'use client', Suspense
135
- 2. `02-action-dispatching.md` — onAction pattern, placeholder constants
136
- 3. `03-scroll-navigation.md` — id={question.id} requirement
137
- 4. `04-logo-branding.md` — CSS-only logo, no external image needed
138
- 5. `05-troubleshooting.md` — Common build errors and fixes
139
-
140
- Verify your implementation against every rule before proceeding.
141
-
142
- ### PHASE 6: BUILD VERIFICATION
143
- 1. Run: `npm run build`
144
- 2. If errors → fix automatically → re-run until clean
145
- 3. Run: `npm run dev`
146
- 4. Verify: survey loads, navigation works, validation fires, submit works
147
-
148
- ### PHASE 7: DEPLOYMENT (INPUT 3)
149
- Ask the client: "Your survey is built and verified. Ready to deploy to Vercel?"
150
- If yes → run: `npx vercel --prod --yes`
151
- Report the final deployment URL to the client.
20
+ **Import rule:** Use whatever package name appears in the project's `package.json` (`@explorer02/cfm-survey-sdk` or `@repo/sdk`).
21
+
22
+ ---
23
+
24
+ ## Client Inputs (3 only)
25
+
26
+ 1. **Initial prompt** mockup, brand colors, layout preferences
27
+ 2. **Instance ID** JWT token (agent asks in chat)
28
+ 3. **Deploy confirmation** — yes/no for production deploy
29
+
30
+ **Branding comes from INPUT 1 only.** No setup wizard. No `survey-config.json`.
31
+
32
+ ---
33
+
34
+ ## Execution Pipeline
35
+
36
+ ### PHASE 0: ORIENT
37
+
38
+ - Read this file and `AGENT.md`
39
+ - Detect framework: read `package.json` — Next.js / Vite / CRA (see `00-integration/setup.md`)
40
+ - Extract branding and layout from client prompt
41
+ - For existing apps: read project structure; do not blindly scaffold
42
+
43
+ ### PHASE 1: SCAFFOLD
44
+
45
+ Read: `00-integration/setup.md` (matching framework section)
46
+
47
+ Install SDK + `@tanstack/react-query` + `react-icons`. Apply framework-specific config.
48
+
49
+ ### PHASE 2: INSTANCE ID (INPUT 2)
50
+
51
+ Read: `00-integration/useSurveySDK.md`
52
+
53
+ Ask: *"Please provide your survey instance ID (JWT token)."*
54
+
55
+ ### PHASE 3: SDK CONTRACT
56
+
57
+ Read: `00-integration/useSurveySDK.md`
58
+
59
+ Understand `useSurveySDK`, `onAction`, states. Do **not** read internal mapper/source paths.
60
+
61
+ Optional: read `02-reference/routing-table.md` for type overview.
62
+
63
+ ### PHASE 4: PLAN + INGEST (CRITICAL)
64
+
65
+ 1. Read **every** file in `01-components/` (all 14 blueprints)
66
+ 2. Copy `docs/templates/implementation_plan.md` `./implementation_plan.md`
67
+ 3. Fill every section do **not** invent a different structure
68
+ 4. **Auto-proceed to Phase 5** do not wait for approval
69
+
70
+ For each question type in the fetched survey, also read matching docs from `02-reference/question-types/` (see `MANIFEST.json` or `02-reference/routing-table.md`).
71
+
72
+ ### PHASE 5: BUILD
73
+
74
+ Read: `00-integration/constraints.md`
75
+
76
+ Implement components per blueprints. Use exported types:
77
+
78
+ ```typescript
79
+ import { useSurveySDK, ACTIONS, type SurveyAction } from '@explorer02/cfm-survey-sdk';
80
+ ```
81
+
82
+ ### PHASE 6: VERIFY
83
+
84
+ Read: `00-integration/constraints.md` (troubleshooting)
85
+
86
+ Checklist:
87
+
88
+ - [ ] `Question.tsx` switch covers all 12 `question.type` values
89
+ - [ ] Every question wrapper has `id={question.id}`
90
+ - [ ] No imports from `@explorer02/cfm-survey-sdk/src/...`
91
+ - [ ] `SurveyPage` handles loading / error / empty / submitted / active
92
+ - [ ] `npm run build` exits 0
93
+
94
+ ### PHASE 7: DEPLOY (INPUT 3)
95
+
96
+ Ask: *"Your survey is built and verified. Ready to deploy?"*
97
+
98
+ If yes: `npx cfm-sdk deploy` (preferred) or `npx vercel --prod --yes`
99
+
100
+ ---
101
+
102
+ ## Progressive Reading Guide
103
+
104
+ | When | Read |
105
+ |------|------|
106
+ | Always first | `index.md`, `00-integration/setup.md`, `00-integration/useSurveySDK.md`, `00-integration/constraints.md` |
107
+ | Before any React code | All `01-components/*.md` |
108
+ | On demand | `02-reference/question-types/<type>.md` for types in survey |
109
+ | Tooling | `MANIFEST.json`, `templates/implementation_plan.md` |
@@ -0,0 +1,78 @@
1
+ # Survey UI Implementation Plan
2
+
3
+ > Copy this file to `./implementation_plan.md` in the project root. Fill every section before writing React code.
4
+
5
+ ## 0. Project Context
6
+
7
+ - **Framework:** [ ] Next.js App Router [ ] Vite [ ] CRA [ ] Existing app
8
+ - **Package import name:** (from `package.json` — `@explorer02/cfm-survey-sdk` or `@repo/sdk`)
9
+ - **instanceId:** (JWT — wired in SurveyPage)
10
+ - **Branding source:** (client prompt / mockup description — no wizard)
11
+
12
+ ## 1. Data Fetching & State
13
+
14
+ - [ ] `useSurveySDK` options: instanceId, language, placeholders, debug
15
+ - [ ] `SurveyPage` 5-state machine: loading / error / empty / submitted / active
16
+ - [ ] `surveyQueryResults.isLoading`, `.error`, `.data` handling
17
+ - [ ] `submitSurveyResults.isLoading`, `.error`, `.data` handling
18
+
19
+ ## 2. Pagination, Actions & Flow
20
+
21
+ - [ ] `onAction` NEXT / PREVIOUS / SUBMIT wiring
22
+ - [ ] `ProgressBar` bound to `state.progressPercentage`
23
+ - [ ] Back/Next button visibility per layout config
24
+ - [ ] Last-page NEXT → auto SUBMIT behavior
25
+
26
+ ## 3. Question Dispatching (`Question.tsx`)
27
+
28
+ Exhaustive switch — check each:
29
+
30
+ - [ ] `rating` → `RatingScale`
31
+ - [ ] `csat` → `CsatScale`
32
+ - [ ] `radio` → inline MCQ
33
+ - [ ] `text` → inline textarea/input
34
+ - [ ] `rating_scale` → `RatingScale` (star/emoji)
35
+ - [ ] `slider` → `CustomSliderTrack`
36
+ - [ ] `matrix` + `CFM_MATRIX` → `LikertMatrixScale`
37
+ - [ ] `matrix` + `CSAT_MATRIX` / `RATING_MATRIX` → `CsatMatrixScale`
38
+ - [ ] `rating_matrix` → `CsatMatrixScale`
39
+ - [ ] `slider_matrix` → `SliderMatrixScale`
40
+ - [ ] `file_upload` → `FileUploadScale`
41
+ - [ ] `text_and_media` → inline media (no scale)
42
+ - [ ] `dangerouslySetInnerHTML` for `question.text` / `description`
43
+ - [ ] `validationError` banner per question
44
+ - [ ] `id={question.id}` on every question wrapper
45
+
46
+ ## 4. Component Architecture Checklist
47
+
48
+ | Component | In survey? | Blueprint doc | Key constraints verified |
49
+ |-----------|------------|---------------|--------------------------|
50
+ | RatingScale | | `01-components/03-rating-scale.md` | |
51
+ | CsatScale | | `01-components/04-csat-scale.md` | |
52
+ | CsatMatrixScale | | `01-components/05-csat-matrix-scale.md` | |
53
+ | LikertMatrixScale | | `01-components/06-likert-matrix-scale.md` | |
54
+ | SliderMatrixScale | | `01-components/07-slider-matrix-scale.md` | |
55
+ | FileUploadScale | | `01-components/08-file-upload-scale.md` | |
56
+ | CustomSliderTrack | | `01-components/09-custom-slider-track.md` | |
57
+ | Header / Footer | | `01-components/10-header-footer.md` | |
58
+ | ProgressBar | | `01-components/11-progress-bar.md` | |
59
+ | LanguageSelector | | `01-components/12-language-selector.md` | |
60
+ | MatrixDropdown | | `01-components/13-matrix-dropdown.md` | |
61
+
62
+ ## 5. Theme, Brand & Logo
63
+
64
+ - [ ] CSS-only logo (no `<img>`, no `public/` uploads)
65
+ - [ ] Primary / hover colors from client prompt
66
+ - [ ] Header / Footer / ProgressBar / LanguageSelector per layout
67
+
68
+ ## 6. Submit & Thank You
69
+
70
+ - [ ] `onAction({ type: 'SUBMIT' })` on final page
71
+ - [ ] Thank-you screen when `submitSurveyResults.data` is set
72
+ - [ ] Custom thank-you message from client prompt if provided
73
+
74
+ ## 7. Pre-Build Verification
75
+
76
+ - [ ] No imports from `.../src/` internal paths
77
+ - [ ] All mutations via `onAction` — no direct state mutation
78
+ - [ ] `npm run build` passes