@explorer02/cfm-survey-sdk 0.1.8 → 0.2.0
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/index.d.mts +24 -26
- package/dist/index.d.ts +24 -26
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/postinstall.js +21 -30
- package/templates/AGENT.md +24 -10
- package/templates/docs/00-integration/constraints.md +54 -0
- package/templates/docs/00-integration/setup.md +80 -0
- package/templates/docs/00-integration/useSurveySDK.md +107 -0
- package/templates/docs/{03-client-components → 01-components}/01-survey-page.md +2 -0
- package/templates/docs/{03-client-components → 01-components}/02-question.md +2 -0
- package/templates/docs/{03-client-components → 01-components}/03-rating-scale.md +2 -0
- package/templates/docs/{03-client-components → 01-components}/04-csat-scale.md +3 -1
- package/templates/docs/{03-client-components → 01-components}/05-csat-matrix-scale.md +2 -0
- package/templates/docs/{03-client-components → 01-components}/06-likert-matrix-scale.md +2 -0
- package/templates/docs/{03-client-components → 01-components}/07-slider-matrix-scale.md +2 -0
- package/templates/docs/{03-client-components → 01-components}/08-file-upload-scale.md +2 -0
- package/templates/docs/{03-client-components → 01-components}/09-custom-slider-track.md +2 -0
- package/templates/docs/{03-client-components → 01-components}/10-header-footer.md +3 -1
- package/templates/docs/{03-client-components → 01-components}/11-progress-bar.md +2 -0
- package/templates/docs/{03-client-components → 01-components}/12-language-selector.md +2 -0
- package/templates/docs/{03-client-components → 01-components}/13-matrix-dropdown.md +2 -0
- package/templates/docs/{03-client-components → 01-components}/README.md +3 -3
- package/templates/docs/02-question-types/01-rating.md +0 -8
- package/templates/docs/02-reference/config-field-index.md +158 -0
- package/templates/docs/02-reference/question-types/01-rating.md +52 -0
- package/templates/docs/02-reference/question-types/README.md +71 -0
- package/templates/docs/02-reference/routing-table.md +37 -0
- package/templates/docs/03-ui-specs/00-question-shell.md +89 -0
- package/templates/docs/03-ui-specs/01-rating.md +80 -0
- package/templates/docs/03-ui-specs/02-radio.md +57 -0
- package/templates/docs/03-ui-specs/03-text.md +51 -0
- package/templates/docs/03-ui-specs/04-csat.md +57 -0
- package/templates/docs/03-ui-specs/05-rating-scale.md +49 -0
- package/templates/docs/03-ui-specs/06-slider.md +42 -0
- package/templates/docs/03-ui-specs/07-matrix-cfm.md +66 -0
- package/templates/docs/03-ui-specs/08-matrix-csat-rating.md +65 -0
- package/templates/docs/03-ui-specs/09-slider-matrix.md +61 -0
- package/templates/docs/03-ui-specs/10-file-upload.md +54 -0
- package/templates/docs/03-ui-specs/11-text-and-media.md +49 -0
- package/templates/docs/03-ui-specs/12-survey-chrome.md +60 -0
- package/templates/docs/03-ui-specs/README.md +79 -0
- package/templates/docs/03-ui-specs/shared/custom-slider-track.md +52 -0
- package/templates/docs/03-ui-specs/shared/matrix-dropdown.md +38 -0
- package/templates/docs/MANIFEST.json +150 -0
- package/templates/docs/index.md +111 -142
- package/templates/docs/templates/implementation_plan.md +91 -0
- package/templates/docs/01-sdk-core/01-fetch-survey.md +0 -68
- package/templates/docs/01-sdk-core/02-survey-mapper.md +0 -85
- package/templates/docs/01-sdk-core/03-question-mappers.md +0 -114
- package/templates/docs/01-sdk-core/04-pagination.md +0 -72
- package/templates/docs/01-sdk-core/05-validation.md +0 -66
- package/templates/docs/01-sdk-core/06-submit-survey.md +0 -90
- package/templates/docs/01-sdk-core/07-language-handling.md +0 -111
- package/templates/docs/01-sdk-core/08-icons-and-emojis.md +0 -56
- package/templates/docs/01-sdk-core/README.md +0 -53
- package/templates/docs/02-question-types/02-radio.md +0 -26
- package/templates/docs/02-question-types/03-text.md +0 -26
- package/templates/docs/02-question-types/12-text-and-media.md +0 -35
- package/templates/docs/02-question-types/README.md +0 -74
- package/templates/docs/04-critical-rules/01-import-rules.md +0 -51
- package/templates/docs/04-critical-rules/02-action-dispatching.md +0 -56
- package/templates/docs/04-critical-rules/03-scroll-navigation.md +0 -37
- package/templates/docs/04-critical-rules/04-logo-branding.md +0 -42
- package/templates/docs/04-critical-rules/05-troubleshooting.md +0 -46
- package/templates/docs/04-critical-rules/README.md +0 -29
- /package/templates/docs/{02-question-types → 02-reference/question-types}/04-csat.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/05-rating-scale.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/06-slider.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/07-matrix-cfm.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/08-matrix-csat.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/09-matrix-rating.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/10-slider-matrix.md +0 -0
- /package/templates/docs/{02-question-types → 02-reference/question-types}/11-file-upload.md +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# UI Specifications — Reference Implementation Guide
|
|
2
|
+
|
|
3
|
+
> **Authoritative source:** [`apps/client/src/components/`](../../../../../../apps/client/src/components/) in the monorepo.
|
|
4
|
+
> Agents must reproduce this UI when building survey apps. Read the spec for each question type present in the fetched survey.
|
|
5
|
+
|
|
6
|
+
## How to Read a UI Spec
|
|
7
|
+
|
|
8
|
+
Each file in this folder follows the same structure:
|
|
9
|
+
|
|
10
|
+
1. **Config inventory** — every SDK field, whether the reference client implements it
|
|
11
|
+
2. **Layout anatomy** — structured ASCII diagram
|
|
12
|
+
3. **Config decision tree** — matches `if/else` branches in reference code
|
|
13
|
+
4. **Interactive states** — default, hover, selected, disabled, focus
|
|
14
|
+
5. **Tooltips & labels** — positioning formulas
|
|
15
|
+
6. **Color tokens** — exact hex values from reference client
|
|
16
|
+
7. **Answer mutation** — `onSelect` / `onAction CHANGE` shape
|
|
17
|
+
8. **Agent checklist**
|
|
18
|
+
|
|
19
|
+
## Design Tokens (Reference Client)
|
|
20
|
+
|
|
21
|
+
| Token | Value | Usage |
|
|
22
|
+
|-------|-------|-------|
|
|
23
|
+
| Primary | `#e20074` | Borders, rings, dots, slider fill, selected text |
|
|
24
|
+
| Selected bg | `#fdf2f8` | Card options, CSAT buttons, matrix cells |
|
|
25
|
+
| NPS track highlight | `#fbe8f3` | Selected radio cell in NPS track row |
|
|
26
|
+
| NPS track bar | `#f2f2f2` | Gray bar behind NPS radios |
|
|
27
|
+
| Validation border | `#333333` | Error banner |
|
|
28
|
+
| Validation bg | `#d9d9d9` | Error banner |
|
|
29
|
+
| Row band | `#f3f4f6` | Slider matrix row background |
|
|
30
|
+
| Zebra row | `rgba(249,250,251,0.8)` | Matrix alternating rows |
|
|
31
|
+
| Tooltip bg | `#1f2937` | Hover tooltips on emoji/slider |
|
|
32
|
+
| Likert carousel dot (active) | `#2563eb` | LikertMatrix carousel only |
|
|
33
|
+
| CSAT carousel dot (active) | `#e20074` | CsatMatrix carousel |
|
|
34
|
+
|
|
35
|
+
## Reference Component Index
|
|
36
|
+
|
|
37
|
+
| Spec file | Reference component | `question.type` |
|
|
38
|
+
|-----------|---------------------|-----------------|
|
|
39
|
+
| [00-question-shell.md](00-question-shell.md) | `Question.tsx` | All (wrapper) |
|
|
40
|
+
| [01-rating.md](01-rating.md) | `RatingScale.tsx` | `rating` |
|
|
41
|
+
| [02-radio.md](02-radio.md) | `Question.tsx` inline | `radio` |
|
|
42
|
+
| [03-text.md](03-text.md) | `Question.tsx` inline | `text` |
|
|
43
|
+
| [04-csat.md](04-csat.md) | `CsatScale.tsx` | `csat` |
|
|
44
|
+
| [05-rating-scale.md](05-rating-scale.md) | *(gap — reuse CsatScale patterns)* | `rating_scale` |
|
|
45
|
+
| [06-slider.md](06-slider.md) | *(gap — reuse CustomSliderTrack)* | `slider` |
|
|
46
|
+
| [07-matrix-cfm.md](07-matrix-cfm.md) | `LikertMatrixScale.tsx` | `matrix` + CFM |
|
|
47
|
+
| [08-matrix-csat-rating.md](08-matrix-csat-rating.md) | `CsatMatrixScale.tsx` | CSAT/RATING matrix |
|
|
48
|
+
| [09-slider-matrix.md](09-slider-matrix.md) | `SliderMatrixScale.tsx` | `slider_matrix` |
|
|
49
|
+
| [10-file-upload.md](10-file-upload.md) | `FileUploadScale.tsx` | `file_upload` |
|
|
50
|
+
| [11-text-and-media.md](11-text-and-media.md) | `Question.tsx` inline | `text_and_media` |
|
|
51
|
+
| [12-survey-chrome.md](12-survey-chrome.md) | `SurveyPage.tsx` + chrome | Shell |
|
|
52
|
+
| [shared/custom-slider-track.md](shared/custom-slider-track.md) | `CustomSliderTrack.tsx` | Primitive |
|
|
53
|
+
| [shared/matrix-dropdown.md](shared/matrix-dropdown.md) | `MatrixDropdown.tsx` | Primitive |
|
|
54
|
+
|
|
55
|
+
## NPS Traffic-Light Colors
|
|
56
|
+
|
|
57
|
+
Use `option.color` from SDK — never invent colors:
|
|
58
|
+
|
|
59
|
+
| Value | Hex |
|
|
60
|
+
|-------|-----|
|
|
61
|
+
| 0 | `#e2001a` |
|
|
62
|
+
| 1 | `#e4251b` |
|
|
63
|
+
| 2 | `#ec610a` |
|
|
64
|
+
| 3 | `#f18b00` |
|
|
65
|
+
| 4 | `#f7b200` |
|
|
66
|
+
| 5 | `#fcd900` |
|
|
67
|
+
| 6 | `#fcd900` |
|
|
68
|
+
| 7 | `#9fca00` |
|
|
69
|
+
| 8 | `#6bb300` |
|
|
70
|
+
| 9 | `#339a00` |
|
|
71
|
+
| 10 | `#008000` |
|
|
72
|
+
|
|
73
|
+
## When to Read
|
|
74
|
+
|
|
75
|
+
After Phase 3 in [`index.md`](../index.md), for each question in `state.currentQuestions`:
|
|
76
|
+
|
|
77
|
+
1. Read [`02-reference/question-types/`](../02-reference/question-types/) for data shape
|
|
78
|
+
2. Read matching spec from this folder (see [`MANIFEST.json`](../MANIFEST.json) `uiSpecs`)
|
|
79
|
+
3. Cross-check [`config-field-index.md`](../02-reference/config-field-index.md)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# UI Spec: Custom Slider Track (shared primitive)
|
|
2
|
+
|
|
3
|
+
> **Reference:** `apps/client/src/components/CustomSliderTrack.tsx`
|
|
4
|
+
> **Used by:** `SliderMatrixScale.tsx`, `CsatMatrixScale` (graphics), standalone `slider` (gap)
|
|
5
|
+
|
|
6
|
+
## Layer Architecture
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
1. Gray inactive track (#e5e7eb, 4px height)
|
|
10
|
+
2. Magenta fill bar (width = percentage%, #e20074 or #9ca3af if disabled)
|
|
11
|
+
3. Tick marks (1px × 8px at ticks positions)
|
|
12
|
+
4. Invisible <input type="range"> overlay (opacity 0, full hit area)
|
|
13
|
+
5. Visual thumb: circle OR emoji (sliderType === 'graphics')
|
|
14
|
+
6. Tooltip bubble on hover/drag (#1f2937 bg, rounded value)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Props
|
|
18
|
+
|
|
19
|
+
| Prop | Role |
|
|
20
|
+
|------|------|
|
|
21
|
+
| `min`, `max`, `htmlStep` | Range input bounds |
|
|
22
|
+
| `value` | Current position |
|
|
23
|
+
| `disabled` | Gray theme, opacity 0.5, no interaction |
|
|
24
|
+
| `displayValues` | Reserved — tooltip always shows on hover/drag in client |
|
|
25
|
+
| `hasSelectedValue` | Reserved |
|
|
26
|
+
| `sliderType: 'graphics'` | Emoji thumb via `getEmojiForIndex` |
|
|
27
|
+
| `ticks` | Discrete tick count + emoji index scale |
|
|
28
|
+
| `reverseScaleOrder` | Flip emoji index calculation |
|
|
29
|
+
|
|
30
|
+
## Interactive States
|
|
31
|
+
|
|
32
|
+
| State | Thumb | Tooltip |
|
|
33
|
+
|-------|-------|---------|
|
|
34
|
+
| Default | White circle, 2.5px magenta border | Hidden |
|
|
35
|
+
| Hover/drag | Pink glow ring `rgba(226,0,116,0.2)` | Dark bubble with `Math.round(value)` |
|
|
36
|
+
| Disabled | Gray border, opacity 0.5 | Hidden |
|
|
37
|
+
| Graphics | Emoji at percentage position | Same tooltip |
|
|
38
|
+
|
|
39
|
+
## Emoji Index Formula
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
const idx = Math.round(((value - min) / (max - min)) * ((ticks || 10) - 1));
|
|
43
|
+
const displayIdx = reverseScaleOrder ? (ticks || 10) - 1 - idx : idx;
|
|
44
|
+
getEmojiForIndex(displayIdx, ticks || 10)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Agent Checklist
|
|
48
|
+
|
|
49
|
+
- [ ] 4-layer overlay with invisible range input
|
|
50
|
+
- [ ] Tooltip on hover AND drag
|
|
51
|
+
- [ ] Graphics mode emoji thumb
|
|
52
|
+
- [ ] Transition disabled while dragging
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# UI Spec: Matrix Dropdown (shared primitive)
|
|
2
|
+
|
|
3
|
+
> **Reference:** `apps/client/src/components/MatrixDropdown.tsx`
|
|
4
|
+
> **Used by:** `LikertMatrixScale`, `CsatMatrixScale` vertical list
|
|
5
|
+
|
|
6
|
+
## Modes
|
|
7
|
+
|
|
8
|
+
| `multiple` | Trigger | Selection |
|
|
9
|
+
|------------|---------|-----------|
|
|
10
|
+
| `false` | Single line + chevron | One value; checkmark on selected option |
|
|
11
|
+
| `true` | Tag chips with × | Toggle array; N/A mutex |
|
|
12
|
+
|
|
13
|
+
## Interactive States
|
|
14
|
+
|
|
15
|
+
| State | Trigger border | Shadow |
|
|
16
|
+
|-------|----------------|--------|
|
|
17
|
+
| Closed | `#d1d5db` | subtle |
|
|
18
|
+
| Open | `#e20074` | `0 0 0 3px rgba(226,0,116,0.1)` |
|
|
19
|
+
| Option hover | bg `#fdf2f8` | — |
|
|
20
|
+
| Option selected | bg `#fdf2f8`, text `#e20074` | — |
|
|
21
|
+
| N/A mutex (multi) | Other options opacity 0.5, disabled | — |
|
|
22
|
+
|
|
23
|
+
## N/A Mutex (multi-select)
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
if (val === null) {
|
|
27
|
+
if (multiValues.includes(null)) onChange([]);
|
|
28
|
+
else onChange([null]);
|
|
29
|
+
}
|
|
30
|
+
// When null selected, non-null options disabled
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Agent Checklist
|
|
34
|
+
|
|
35
|
+
- [ ] Click-outside closes panel
|
|
36
|
+
- [ ] HTML labels via dangerouslySetInnerHTML
|
|
37
|
+
- [ ] Single: close on select
|
|
38
|
+
- [ ] Multi: tag chips removable with ×
|
|
@@ -0,0 +1,150 @@
|
|
|
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
|
+
"uiSpecs": {
|
|
130
|
+
"questionShell": "03-ui-specs/00-question-shell.md",
|
|
131
|
+
"rating": "03-ui-specs/01-rating.md",
|
|
132
|
+
"radio": "03-ui-specs/02-radio.md",
|
|
133
|
+
"text": "03-ui-specs/03-text.md",
|
|
134
|
+
"csat": "03-ui-specs/04-csat.md",
|
|
135
|
+
"rating_scale": "03-ui-specs/05-rating-scale.md",
|
|
136
|
+
"slider": "03-ui-specs/06-slider.md",
|
|
137
|
+
"matrix_CFM_MATRIX": "03-ui-specs/07-matrix-cfm.md",
|
|
138
|
+
"matrix_CSAT_MATRIX": "03-ui-specs/08-matrix-csat-rating.md",
|
|
139
|
+
"matrix_RATING_MATRIX": "03-ui-specs/08-matrix-csat-rating.md",
|
|
140
|
+
"slider_matrix": "03-ui-specs/09-slider-matrix.md",
|
|
141
|
+
"file_upload": "03-ui-specs/10-file-upload.md",
|
|
142
|
+
"text_and_media": "03-ui-specs/11-text-and-media.md",
|
|
143
|
+
"surveyChrome": "03-ui-specs/12-survey-chrome.md"
|
|
144
|
+
},
|
|
145
|
+
"sharedUiSpecs": {
|
|
146
|
+
"customSliderTrack": "03-ui-specs/shared/custom-slider-track.md",
|
|
147
|
+
"matrixDropdown": "03-ui-specs/shared/matrix-dropdown.md"
|
|
148
|
+
},
|
|
149
|
+
"configFieldIndex": "02-reference/config-field-index.md"
|
|
150
|
+
}
|
package/templates/docs/index.md
CHANGED
|
@@ -1,151 +1,120 @@
|
|
|
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
|
-
|
|
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
|
-
##
|
|
9
|
-
|
|
10
|
-
The `docs/` folder mirrors the SDK's internal architecture:
|
|
7
|
+
## Documentation Layout
|
|
11
8
|
|
|
12
9
|
```
|
|
13
10
|
docs/
|
|
14
|
-
├── index.md
|
|
15
|
-
├──
|
|
16
|
-
├──
|
|
17
|
-
├──
|
|
18
|
-
|
|
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/ ← Wiring blueprints (read ALL before coding)
|
|
15
|
+
├── 02-reference/ ← Routing table + config-field-index (on demand)
|
|
16
|
+
├── 03-ui-specs/ ← Authoritative UI specs (reference-client driven)
|
|
17
|
+
└── templates/
|
|
18
|
+
└── implementation_plan.md
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
6
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
12.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
|
114
|
-
|
|
115
|
-
|
|
|
116
|
-
|
|
|
117
|
-
|
|
|
118
|
-
|
|
|
119
|
-
|
|
|
120
|
-
|
|
|
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.
|
|
21
|
+
**Import rule:** Use whatever package name appears in the project's `package.json` (`@explorer02/cfm-survey-sdk` or `@repo/sdk`).
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Client Inputs (3 only)
|
|
26
|
+
|
|
27
|
+
1. **Initial prompt** — mockup, brand colors, layout preferences
|
|
28
|
+
2. **Instance ID** — JWT token (agent asks in chat)
|
|
29
|
+
3. **Deploy confirmation** — yes/no for production deploy
|
|
30
|
+
|
|
31
|
+
**Branding comes from INPUT 1 only.** No setup wizard. No `survey-config.json`.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Execution Pipeline
|
|
36
|
+
|
|
37
|
+
### PHASE 0: ORIENT
|
|
38
|
+
|
|
39
|
+
- Read this file and `AGENT.md`
|
|
40
|
+
- Detect framework: read `package.json` — Next.js / Vite / CRA (see `00-integration/setup.md`)
|
|
41
|
+
- Extract branding and layout from client prompt
|
|
42
|
+
- For existing apps: read project structure; do not blindly scaffold
|
|
43
|
+
|
|
44
|
+
### PHASE 1: SCAFFOLD
|
|
45
|
+
|
|
46
|
+
Read: `00-integration/setup.md` (matching framework section)
|
|
47
|
+
|
|
48
|
+
Install SDK + `@tanstack/react-query` + `react-icons`. Apply framework-specific config.
|
|
49
|
+
|
|
50
|
+
### PHASE 2: INSTANCE ID (INPUT 2)
|
|
51
|
+
|
|
52
|
+
Read: `00-integration/useSurveySDK.md`
|
|
53
|
+
|
|
54
|
+
Ask: *"Please provide your survey instance ID (JWT token)."*
|
|
55
|
+
|
|
56
|
+
### PHASE 3: SDK CONTRACT
|
|
57
|
+
|
|
58
|
+
Read: `00-integration/useSurveySDK.md`
|
|
59
|
+
|
|
60
|
+
Understand `useSurveySDK`, `onAction`, states. Do **not** read internal mapper/source paths.
|
|
61
|
+
|
|
62
|
+
Optional: read `02-reference/routing-table.md` for type overview.
|
|
63
|
+
|
|
64
|
+
### PHASE 4: PLAN + INGEST (CRITICAL)
|
|
65
|
+
|
|
66
|
+
1. Read **every** file in `01-components/` (all 14 blueprints)
|
|
67
|
+
2. Copy `docs/templates/implementation_plan.md` → `./implementation_plan.md`
|
|
68
|
+
3. Fill every section — do **not** invent a different structure
|
|
69
|
+
4. **Auto-proceed to Phase 5** — do not wait for approval
|
|
70
|
+
|
|
71
|
+
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`).
|
|
72
|
+
|
|
73
|
+
### PHASE 5: BUILD
|
|
74
|
+
|
|
75
|
+
Read: `00-integration/constraints.md`
|
|
76
|
+
|
|
77
|
+
For each question in `state.currentQuestions`:
|
|
78
|
+
|
|
79
|
+
1. Read `02-reference/question-types/{type}.md` for data shape
|
|
80
|
+
2. Read `03-ui-specs/{NN}-{type}.md` (use `MANIFEST.json` `uiSpecs`; split matrix by `subType`)
|
|
81
|
+
3. If `matrixFormat`, `buttonType`, or `sliderType` is present → read `03-ui-specs/shared/` specs
|
|
82
|
+
4. Cross-check `02-reference/config-field-index.md` for every non-default field
|
|
83
|
+
5. Match reference client behavior in `apps/client/src/components/` when available
|
|
84
|
+
|
|
85
|
+
Implement components per blueprints + UI specs. Use exported types:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { useSurveySDK, ACTIONS, type SurveyAction } from '@explorer02/cfm-survey-sdk';
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### PHASE 6: VERIFY
|
|
92
|
+
|
|
93
|
+
Read: `00-integration/constraints.md` (troubleshooting)
|
|
94
|
+
|
|
95
|
+
Checklist:
|
|
96
|
+
|
|
97
|
+
- [ ] `Question.tsx` switch covers all 12 `question.type` values
|
|
98
|
+
- [ ] Every question wrapper has `id={question.id}`
|
|
99
|
+
- [ ] No imports from `@explorer02/cfm-survey-sdk/src/...`
|
|
100
|
+
- [ ] `SurveyPage` handles loading / error / empty / submitted / active
|
|
101
|
+
- [ ] `npm run build` exits 0
|
|
102
|
+
|
|
103
|
+
### PHASE 7: DEPLOY (INPUT 3)
|
|
104
|
+
|
|
105
|
+
Ask: *"Your survey is built and verified. Ready to deploy?"*
|
|
106
|
+
|
|
107
|
+
If yes: `npx cfm-sdk deploy` (preferred) or `npx vercel --prod --yes`
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Progressive Reading Guide
|
|
112
|
+
|
|
113
|
+
| When | Read |
|
|
114
|
+
|------|------|
|
|
115
|
+
| Always first | `index.md`, `00-integration/setup.md`, `00-integration/useSurveySDK.md`, `00-integration/constraints.md` |
|
|
116
|
+
| Before any React code | All `01-components/*.md` |
|
|
117
|
+
| On demand | `02-reference/question-types/<type>.md` for types in survey |
|
|
118
|
+
| Before building each question | `03-ui-specs/` per `MANIFEST.uiSpecs` |
|
|
119
|
+
| Config audit | `02-reference/config-field-index.md` |
|
|
120
|
+
| Tooling | `MANIFEST.json`, `templates/implementation_plan.md` |
|