@explorer02/cfm-survey-sdk 0.1.4 → 0.1.6

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 (46) hide show
  1. package/package.json +1 -1
  2. package/postinstall.js +30 -18
  3. package/templates/AGENT.md +10 -2341
  4. package/templates/docs/01-sdk-core/01-fetch-survey.md +68 -0
  5. package/templates/docs/01-sdk-core/02-survey-mapper.md +85 -0
  6. package/templates/docs/01-sdk-core/03-question-mappers.md +114 -0
  7. package/templates/docs/01-sdk-core/04-pagination.md +72 -0
  8. package/templates/docs/01-sdk-core/05-validation.md +66 -0
  9. package/templates/docs/01-sdk-core/06-submit-survey.md +90 -0
  10. package/templates/docs/01-sdk-core/07-language-handling.md +111 -0
  11. package/templates/docs/01-sdk-core/08-icons-and-emojis.md +56 -0
  12. package/templates/docs/01-sdk-core/README.md +53 -0
  13. package/templates/docs/02-question-types/01-rating.md +52 -0
  14. package/templates/docs/02-question-types/02-radio.md +26 -0
  15. package/templates/docs/02-question-types/03-text.md +26 -0
  16. package/templates/docs/02-question-types/04-csat.md +54 -0
  17. package/templates/docs/02-question-types/05-rating-scale.md +26 -0
  18. package/templates/docs/02-question-types/06-slider.md +30 -0
  19. package/templates/docs/02-question-types/07-matrix-cfm.md +43 -0
  20. package/templates/docs/02-question-types/08-matrix-csat.md +29 -0
  21. package/templates/docs/02-question-types/09-matrix-rating.md +28 -0
  22. package/templates/docs/02-question-types/10-slider-matrix.md +40 -0
  23. package/templates/docs/02-question-types/11-file-upload.md +34 -0
  24. package/templates/docs/02-question-types/12-text-and-media.md +35 -0
  25. package/templates/docs/02-question-types/README.md +74 -0
  26. package/templates/docs/03-client-components/01-survey-page.md +113 -0
  27. package/templates/docs/03-client-components/02-question.md +74 -0
  28. package/templates/docs/03-client-components/03-rating-scale.md +91 -0
  29. package/templates/docs/03-client-components/04-csat-scale.md +79 -0
  30. package/templates/docs/03-client-components/05-csat-matrix-scale.md +77 -0
  31. package/templates/docs/03-client-components/06-likert-matrix-scale.md +43 -0
  32. package/templates/docs/03-client-components/07-slider-matrix-scale.md +93 -0
  33. package/templates/docs/03-client-components/08-file-upload-scale.md +87 -0
  34. package/templates/docs/03-client-components/09-custom-slider-track.md +72 -0
  35. package/templates/docs/03-client-components/10-header-footer.md +46 -0
  36. package/templates/docs/03-client-components/11-progress-bar.md +31 -0
  37. package/templates/docs/03-client-components/12-language-selector.md +41 -0
  38. package/templates/docs/03-client-components/13-matrix-dropdown.md +42 -0
  39. package/templates/docs/03-client-components/README.md +63 -0
  40. package/templates/docs/04-critical-rules/01-import-rules.md +51 -0
  41. package/templates/docs/04-critical-rules/02-action-dispatching.md +56 -0
  42. package/templates/docs/04-critical-rules/03-scroll-navigation.md +37 -0
  43. package/templates/docs/04-critical-rules/04-logo-branding.md +42 -0
  44. package/templates/docs/04-critical-rules/05-troubleshooting.md +46 -0
  45. package/templates/docs/04-critical-rules/README.md +29 -0
  46. package/templates/docs/index.md +129 -0
@@ -0,0 +1,31 @@
1
+ # Progress Bar
2
+
3
+ > **Component**: `ProgressBar`
4
+ > **Role**: Displays completion status at the top of the survey.
5
+
6
+ ## Props Interface
7
+ ```typescript
8
+ type ProgressBarProps = {
9
+ progressPercentage: number; // 0 to 100
10
+ };
11
+ ```
12
+
13
+ ## Implementation
14
+
15
+ ```tsx
16
+ export default function ProgressBar({ progressPercentage }: ProgressBarProps) {
17
+ // Ensure it's bounded between 0 and 100
18
+ const width = Math.min(100, Math.max(0, progressPercentage));
19
+
20
+ return (
21
+ <div className="mb-8 h-2 w-full overflow-hidden rounded-full bg-gray-100">
22
+ <div
23
+ className="h-full bg-[#e20074] transition-all duration-500 ease-out"
24
+ style={{ width: `${width}%` }}
25
+ />
26
+ </div>
27
+ );
28
+ }
29
+ ```
30
+
31
+ The `progressPercentage` value is provided directly by `state.progressPercentage` from the `useSurveySDK` hook.
@@ -0,0 +1,41 @@
1
+ # Language Selector
2
+
3
+ > **Component**: `LanguageSelector`
4
+ > **Role**: Allows the user to switch the survey language.
5
+
6
+ ## Props Interface
7
+ ```typescript
8
+ type LanguageSelectorProps = {
9
+ languages: SurveyLanguage[];
10
+ selectedLanguage: string;
11
+ onChange: (code: string) => void;
12
+ };
13
+ ```
14
+
15
+ ## Implementation
16
+
17
+ Only render the selector if there is more than 1 language available.
18
+
19
+ ```tsx
20
+ export default function LanguageSelector({ languages, selectedLanguage, onChange }: LanguageSelectorProps) {
21
+ if (!languages || languages.length <= 1) return null;
22
+
23
+ return (
24
+ <div className="mb-6 flex justify-end">
25
+ <select
26
+ value={selectedLanguage}
27
+ onChange={e => onChange(e.target.value)}
28
+ className="rounded-md border border-gray-300 py-1.5 pl-3 pr-8 text-sm focus:border-[#e20074] focus:ring-1 focus:ring-[#e20074]"
29
+ >
30
+ {languages.map(lang => (
31
+ <option key={lang.code} value={lang.code}>
32
+ {lang.name}
33
+ </option>
34
+ ))}
35
+ </select>
36
+ </div>
37
+ );
38
+ }
39
+ ```
40
+
41
+ When `onChange` fires, it updates state in `SurveyPage.tsx`, which triggers the SDK to re-map the translations.
@@ -0,0 +1,42 @@
1
+ # Matrix Dropdown
2
+
3
+ > **Component**: `MatrixDropdown`
4
+ > **Used by**: `CsatMatrixScale`, `LikertMatrixScale`
5
+
6
+ ## Role
7
+ Renders a dropdown selector for a single row in a matrix question. Used when `matrixFormat === 'dropdown'` or `buttonType === 'dropdown'`.
8
+
9
+ ## Props Interface
10
+ ```typescript
11
+ type MatrixDropdownProps = {
12
+ columns: MatrixColumn[];
13
+ selectedValue: string | number | null | undefined;
14
+ onChange: (value: string | number | null) => void;
15
+ placeholder?: string;
16
+ };
17
+ ```
18
+
19
+ ## Structure
20
+ Renders a native HTML `<select>` element.
21
+
22
+ ```tsx
23
+ <select
24
+ value={selectedValue === null ? '' : String(selectedValue ?? '')}
25
+ onChange={e => {
26
+ const val = e.target.value;
27
+ if (val === '') onChange(null); // Map empty string back to null for N/A
28
+ else {
29
+ // Find original option to keep type (number vs string) intact
30
+ const opt = columns.find(c => String(c.value) === val);
31
+ onChange(opt ? opt.value : val);
32
+ }
33
+ }}
34
+ >
35
+ <option value="" disabled>Select an option...</option>
36
+ {columns.map(col => (
37
+ <option key={String(col.value)} value={String(col.value)}>
38
+ {col.label}
39
+ </option>
40
+ ))}
41
+ </select>
42
+ ```
@@ -0,0 +1,63 @@
1
+ # Client Components Overview
2
+
3
+ > This folder documents the React client components that render the survey UI.
4
+ > It explains the architecture, the dispatcher (`Question.tsx`), and all 11 individual question scale components.
5
+
6
+ ## Component Architecture
7
+
8
+ The UI is driven by a single top-level `SurveyPage` component which iterates over the `currentQuestions` array and passes each `SurveyQuestion` object to the `Question` dispatcher component.
9
+
10
+ ```
11
+ SurveyPage (Top-level orchestrator)
12
+
13
+ ├── Header (Branding/Logo)
14
+ ├── ProgressBar
15
+ ├── LanguageSelector
16
+ ├── Footer
17
+
18
+ └── Question (Dispatcher, mapped over `currentQuestions`)
19
+
20
+ ├── RatingScale (handles 'rating' and 'rating_scale')
21
+ ├── CsatScale (handles 'csat')
22
+ ├── LikertMatrixScale (handles 'matrix' CFM_MATRIX)
23
+ ├── CsatMatrixScale (handles 'matrix' CSAT_MATRIX / 'rating_matrix')
24
+ ├── SliderMatrixScale (handles 'slider_matrix')
25
+ ├── FileUploadScale (handles 'file_upload')
26
+
27
+ ├── (Inline UI for 'radio', 'text', 'text_and_media')
28
+
29
+ └── Shared Sub-Components:
30
+ ├── CustomSliderTrack (used by csat/matrix sliders)
31
+ └── MatrixDropdown (used by matrix dropdowns)
32
+ ```
33
+
34
+ ## Styling Approach
35
+
36
+ - Built entirely with **Tailwind CSS**.
37
+ - **No external UI libraries** (no Material UI, Chakra, etc.).
38
+ - The default brand colour is Telekom Magenta: `#e20074`.
39
+ - The UI follows a strict, clean, modern corporate aesthetic (card-based layout, subtle borders, pink accents on selection).
40
+
41
+ ## The `Question` Dispatcher
42
+
43
+ The `Question` component (`apps/client/src/components/Question.tsx`) is the heart of the rendering engine. It receives a `SurveyQuestion` union type and switches on `question.type` (and `question.subType` for matrices) to render the correct specialized scale component.
44
+
45
+ See `02-question.md` for details on the dispatcher logic.
46
+
47
+ ## Files in This Folder
48
+
49
+ | File | Component |
50
+ |------|-----------|
51
+ | `01-survey-page.md` | `SurveyPage` orchestrator |
52
+ | `02-question.md` | `Question` dispatcher & inline types |
53
+ | `03-rating-scale.md` | `RatingScale` (NPS/Stars) |
54
+ | `04-csat-scale.md` | `CsatScale` (Emoji/Star CSAT) |
55
+ | `05-csat-matrix-scale.md` | `CsatMatrixScale` (Satisfaction Grid) |
56
+ | `06-likert-matrix-scale.md` | `LikertMatrixScale` (Text Grid) |
57
+ | `07-slider-matrix-scale.md` | `SliderMatrixScale` (Sliders Grid) |
58
+ | `08-file-upload-scale.md` | `FileUploadScale` |
59
+ | `09-custom-slider-track.md` | `CustomSliderTrack` (Emoji thumbs) |
60
+ | `10-header-footer.md` | `Header` & `Footer` |
61
+ | `11-progress-bar.md` | `ProgressBar` |
62
+ | `12-language-selector.md` | `LanguageSelector` |
63
+ | `13-matrix-dropdown.md` | `MatrixDropdown` |
@@ -0,0 +1,51 @@
1
+ # Import Rules & Setup
2
+
3
+ > Non-negotiable constraints for setting up Next.js with `@explorer02/cfm-survey-sdk`.
4
+
5
+ ## 1. Top-Level Imports ONLY
6
+
7
+ You must import from the root package name.
8
+
9
+ ```tsx
10
+ // ✅ REQUIRED
11
+ import { useSurveySDK, getEmojiForIndex } from '@explorer02/cfm-survey-sdk';
12
+
13
+ // ❌ FORBIDDEN (Will fail Next.js build)
14
+ import { useSurveySDK } from '@explorer02/cfm-survey-sdk/src/fetchSurvey/useFetchSurvey';
15
+ ```
16
+
17
+ ## 2. Peer Dependencies
18
+
19
+ The SDK requires `@tanstack/react-query` to be installed in the client project:
20
+
21
+ ```bash
22
+ npm install @explorer02/cfm-survey-sdk @tanstack/react-query
23
+ ```
24
+
25
+ ## 3. Client Components Only
26
+
27
+ Because the SDK uses React state, `useQuery`, and DOM interactions, the `SurveyPage` must be a client component.
28
+
29
+ ```tsx
30
+ 'use client';
31
+
32
+ import { useSurveySDK } from '@explorer02/cfm-survey-sdk';
33
+ ```
34
+
35
+ ## 4. Next.js Configuration
36
+
37
+ **CRITICAL**: You must configure `next.config.js` to transpile the SDK, because the SDK exports modern ES modules and uses CSS that Next.js needs to process.
38
+
39
+ ```javascript
40
+ /** @type {import('next').NextConfig} */
41
+ const nextConfig = {
42
+ transpilePackages: ['@explorer02/cfm-survey-sdk'],
43
+ };
44
+
45
+ module.exports = nextConfig;
46
+ ```
47
+ If you forget this, you will get `"SyntaxError: Cannot use import statement outside a module"`.
48
+
49
+ ## 5. React 18 / StrictMode
50
+
51
+ Next.js `reactStrictMode: true` causes effects to fire twice in development. The SDK is built to handle this safely (e.g., query caching), but be aware of double-logging if `debug: true` is enabled.
@@ -0,0 +1,56 @@
1
+ # Action Dispatching Rule
2
+
3
+ > The single flow of data mutation in the SDK.
4
+
5
+ ## The Rule
6
+
7
+ You must NEVER try to update the `state` object directly. The `state` returned by `useSurveySDK` is deeply immutable.
8
+
9
+ All state mutations (answering a question, navigating pages, submitting) must be done through the `onAction` dispatcher function provided by the hook.
10
+
11
+ ## The `onAction` Function
12
+
13
+ ```typescript
14
+ const { onAction } = useSurveySDK({ ... });
15
+ ```
16
+
17
+ ### Action Types
18
+
19
+ #### 1. Answering a Question
20
+ ```tsx
21
+ // Standard (number/string)
22
+ onAction({
23
+ type: 'CHANGE',
24
+ payload: { questionId: 'q123', value: 4 }
25
+ });
26
+
27
+ // Matrix (MatrixAnswerMap)
28
+ onAction({
29
+ type: 'CHANGE',
30
+ payload: { questionId: 'q456', value: { row1: 5, row2: 2 } }
31
+ });
32
+ ```
33
+
34
+ #### 2. Next Page
35
+ ```tsx
36
+ // Automatically triggers validation. If on the last page, auto-converts to SUBMIT.
37
+ onAction({ type: 'NEXT' });
38
+ ```
39
+
40
+ #### 3. Previous Page
41
+ ```tsx
42
+ onAction({ type: 'PREVIOUS' });
43
+ ```
44
+
45
+ #### 4. Force Submit
46
+ ```tsx
47
+ // Validates ALL pages, then triggers API request.
48
+ onAction({ type: 'SUBMIT' });
49
+ ```
50
+
51
+ ## Why This Matters
52
+ The `onAction` dispatcher internally handles:
53
+ - Clearing validation errors the moment a user answers
54
+ - Tracking analytics (timestamps, backtrack counts)
55
+ - Preserving scroll position
56
+ - Triggering cross-question logic
@@ -0,0 +1,37 @@
1
+ # Scroll Navigation Rule
2
+
3
+ > The DOM requirement for validation error scrolling to function.
4
+
5
+ ## The Rule
6
+
7
+ When rendering the wrapper for ANY question, the outermost DOM element (usually a `<section>` or `<div>`) **MUST** have its `id` attribute set to `question.id`.
8
+
9
+ ```tsx
10
+ // ✅ REQUIRED
11
+ export default function Question({ question, ... }) {
12
+ return (
13
+ <section id={question.id} className="p-6 bg-white rounded-xl">
14
+ <h2>{question.text}</h2>
15
+ {/* ... */}
16
+ </section>
17
+ );
18
+ }
19
+
20
+ // ❌ FORBIDDEN
21
+ export default function Question({ question, ... }) {
22
+ return (
23
+ <section className="p-6 bg-white rounded-xl">
24
+ <h2 id={question.id}>{question.text}</h2> {/* Wrong element */}
25
+ {/* ... */}
26
+ </section>
27
+ );
28
+ }
29
+ ```
30
+
31
+ ## Why This Matters
32
+
33
+ When the user clicks "Next" or "Submit", the SDK validates the fields. If it finds a required field is empty, it does two things:
34
+ 1. Sets `validationErrors[questionId]`
35
+ 2. Calls `document.getElementById(questionId).scrollIntoView()`
36
+
37
+ If the ID is missing from the DOM, the error message will appear, but the page will not scroll to the error, resulting in a broken User Experience (especially on long pages).
@@ -0,0 +1,42 @@
1
+ # Logo and Branding Rule
2
+
3
+ > How to handle logos and branding without breaking the build or deployment.
4
+
5
+ ## The Rule
6
+
7
+ You must **NEVER** use `<img>` tags pointing to external URLs (e.g., Telekom or Sprinklr servers) for the main brand logo.
8
+
9
+ You must **NEVER** attempt to download image files, save them to the `public/` folder, and reference them.
10
+
11
+ You MUST construct the logo purely using **Tailwind CSS**.
12
+
13
+ ## Example: Telekom "T" Logo (Abstracted)
14
+
15
+ Instead of finding the exact Telekom logo, build a clean, recognizable abstract representation using geometric divs:
16
+
17
+ ```tsx
18
+ {/* Abstract Magenta "T" equivalent */}
19
+ <div className="flex items-center gap-2">
20
+ <div className="flex h-8 w-8 items-center justify-center rounded-sm bg-[#e20074]">
21
+ <div className="flex flex-col items-center">
22
+ <div className="h-1 w-4 bg-white" />
23
+ <div className="h-3 w-1 bg-white" />
24
+ </div>
25
+ </div>
26
+ <span className="font-bold text-gray-900 tracking-tight">Telekom</span>
27
+ </div>
28
+ ```
29
+
30
+ ## Example: Generic Circular Logo
31
+
32
+ ```tsx
33
+ <div className="flex items-center gap-3">
34
+ <div className="h-8 w-8 rounded-full bg-gradient-to-tr from-blue-600 to-indigo-500" />
35
+ <span className="text-xl font-bold tracking-tight text-gray-900">BrandName</span>
36
+ </div>
37
+ ```
38
+
39
+ ## Why This Matters
40
+ 1. **Broken Links**: External image URLs often change, expire, or return 403 Forbidden when accessed from a Vercel deployment domain.
41
+ 2. **File System Issues**: Downloading assets to `public/` during an automated AI build process often fails due to permissions, path resolution, or missing dependencies.
42
+ 3. **Performance**: CSS-only logos render instantly and scale perfectly without network requests.
@@ -0,0 +1,46 @@
1
+ # Troubleshooting & Common Errors
2
+
3
+ > Solutions for common issues encountered while building with the SDK.
4
+
5
+ ## 1. "Cannot use import statement outside a module"
6
+ **Symptom**: Next.js build fails immediately on start.
7
+ **Cause**: Next.js is not transpiling the SDK package.
8
+ **Fix**: Add the package to `transpilePackages` in `next.config.js`:
9
+ ```javascript
10
+ const nextConfig = {
11
+ transpilePackages: ['@explorer02/cfm-survey-sdk'],
12
+ };
13
+ ```
14
+
15
+ ## 2. Infinite Re-renders / Re-fetching
16
+ **Symptom**: The browser freezes or the network tab shows hundreds of API requests to the survey endpoint.
17
+ **Cause**: Passing a new object reference to `options.placeholders` on every render.
18
+ **Fix**: Extract the placeholders object outside the component:
19
+ ```tsx
20
+ // OUTSIDE the component
21
+ const SURVEY_PLACEHOLDERS = { FIRST_NAME: 'John' };
22
+
23
+ export default function SurveyPage() {
24
+ const { ... } = useSurveySDK({ options: { placeholders: SURVEY_PLACEHOLDERS } });
25
+ }
26
+ ```
27
+
28
+ ## 3. "window is not defined" or "document is not defined"
29
+ **Symptom**: Next.js SSR crashes with DOM errors.
30
+ **Cause**: A component using the SDK is missing the `'use client'` directive. The SDK relies on browser APIs.
31
+ **Fix**: Add `'use client';` to the very top of `SurveyPage.tsx` and any file importing the SDK.
32
+
33
+ ## 4. Clicking "Next" shows errors but doesn't scroll
34
+ **Symptom**: Required field validation fails, text appears, but the viewport doesn't move.
35
+ **Cause**: The DOM wrapper for the question is missing the `id` attribute.
36
+ **Fix**: Ensure `<section id={question.id}>` is present on the outermost element of every question card.
37
+
38
+ ## 5. Survey renders completely empty
39
+ **Symptom**: `surveyQueryResults.data` is `null`, but there's no error.
40
+ **Cause**: The provided `instanceId` is empty, malformed, or has expired/been deleted on the server.
41
+ **Fix**: Verify the `instanceId` JWT token. Ask the client to provide a fresh one.
42
+
43
+ ## 6. Icons/Emojis are missing or look broken
44
+ **Symptom**: CSAT scales show empty boxes instead of faces.
45
+ **Cause**: Missing peer dependencies.
46
+ **Fix**: Ensure `react-icons` is installed in the client project: `npm install react-icons`.
@@ -0,0 +1,29 @@
1
+ # Critical Operating Rules
2
+
3
+ > This folder contains the absolute, non-negotiable constraints you MUST follow when building a survey using `@explorer02/cfm-survey-sdk`.
4
+
5
+ ## Files in This Folder
6
+
7
+ | File | Topic | Importance |
8
+ |------|-------|------------|
9
+ | `01-import-rules.md` | Imports and Next.js setup | **CRITICAL** (Build breaks without it) |
10
+ | `02-action-dispatching.md` | `onAction` pattern | **CRITICAL** (State breaks without it) |
11
+ | `03-scroll-navigation.md` | `id={question.id}` rule | **CRITICAL** (Validation UX breaks) |
12
+ | `04-logo-branding.md` | CSS-only logo mandate | **CRITICAL** (Deployment breaks) |
13
+ | `05-troubleshooting.md` | Common errors & fixes | Useful reference |
14
+
15
+ ## The Golden Rule
16
+
17
+ **You are building a client application using a pre-compiled npm package.**
18
+
19
+ You are STRICTLY PROHIBITED from trying to modify, monkey-patch, or import internal files from inside `node_modules/@explorer02/cfm-survey-sdk`.
20
+
21
+ Everything you need is exported from the top-level barrel file.
22
+
23
+ ```typescript
24
+ // ✅ CORRECT
25
+ import { useSurveySDK, type SurveyQuestion } from '@explorer02/cfm-survey-sdk';
26
+
27
+ // ❌ WRONG — Build will fail immediately
28
+ import { mapQuestion } from '@explorer02/cfm-survey-sdk/src/fetchSurvey/utils';
29
+ ```
@@ -0,0 +1,129 @@
1
+ # CFM SURVEY SDK — AGENT DOCUMENTATION INDEX
2
+
3
+ **@explorer02/cfm-survey-sdk**
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.
7
+
8
+ ## ── HOW THIS DOCUMENTATION SYSTEM WORKS ──────────────────────────────────────
9
+
10
+ The `docs/` folder mirrors the SDK's internal architecture:
11
+
12
+ ```
13
+ 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
19
+ ```
20
+
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: BUILD THE SURVEY UI
80
+ Read these component docs IN ORDER:
81
+
82
+ 1. `03-client-components/README.md` — File structure overview
83
+ 2. `03-client-components/01-survey-page.md` — MAIN orchestrator (REQUIRED)
84
+ 3. `03-client-components/02-question.md` — Question dispatcher (REQUIRED)
85
+ 4. `03-client-components/10-header-footer.md` — CSS-built logo/branding
86
+ 5. `03-client-components/11-progress-bar.md` — Progress indicator
87
+ 6. `03-client-components/12-language-selector.md` — Language dropdown
88
+
89
+ Then for EACH question type present in the fetched survey, read the matching question-type doc AND component doc:
90
+
91
+ | `question.type` | Question Doc | Component Doc |
92
+ |---|---|---|
93
+ | `'rating'` | `02-question-types/01-rating` | `03-components/03-rating` |
94
+ | `'radio'` | `02-question-types/02-radio` | (inline in Question) |
95
+ | `'text'` | `02-question-types/03-text` | (inline in Question) |
96
+ | `'csat'` | `02-question-types/04-csat` | `03-components/04-csat` |
97
+ | `'rating_scale'` | `02-question-types/05-rating-s` | `03-components/03-rating` |
98
+ | `'slider'` | `02-question-types/06-slider` | `03-components/09-slider` |
99
+ | `'matrix'` CFM | `02-question-types/07-matrix-c` | `03-components/06-likert` |
100
+ | `'matrix'` CSAT | `02-question-types/08-matrix-c` | `03-components/05-csat-m` |
101
+ | `'matrix'` RATING| `02-question-types/09-matrix-r` | `03-components/05-csat-m` |
102
+ | `'slider_matrix'`| `02-question-types/10-slider-m` | `03-components/07-slider` |
103
+ | `'file_upload'` | `02-question-types/11-file-up` | `03-components/08-file` |
104
+ | `'text_and_media'`| `02-question-types/12-text-med` | (inline in Question) |
105
+
106
+ Also read these shared component docs:
107
+ - `03-client-components/09-custom-slider-track.md` (used by CSAT matrix, slider matrix when sliderType='graphics')
108
+ - `03-client-components/13-matrix-dropdown.md` (used by matrix dropdown fmt)
109
+
110
+ ### PHASE 5: APPLY CRITICAL RULES
111
+ Read ALL files in `04-critical-rules/`:
112
+ 1. `01-import-rules.md` — Package imports, 'use client', Suspense
113
+ 2. `02-action-dispatching.md` — onAction pattern, placeholder constants
114
+ 3. `03-scroll-navigation.md` — id={question.id} requirement
115
+ 4. `04-logo-branding.md` — CSS-only logo, no external image needed
116
+ 5. `05-troubleshooting.md` — Common build errors and fixes
117
+
118
+ Verify your implementation against every rule before proceeding.
119
+
120
+ ### PHASE 6: BUILD VERIFICATION
121
+ 1. Run: `npm run build`
122
+ 2. If errors → fix automatically → re-run until clean
123
+ 3. Run: `npm run dev`
124
+ 4. Verify: survey loads, navigation works, validation fires, submit works
125
+
126
+ ### PHASE 7: DEPLOYMENT (INPUT 3)
127
+ Ask the client: "Your survey is built and verified. Ready to deploy to Vercel?"
128
+ If yes → run: `npx vercel --prod --yes`
129
+ Report the final deployment URL to the client.