vc-extras 0.0.0-stage → 0.1.1

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 (243) hide show
  1. package/README.md +128 -3
  2. package/agent-install.mjs +159 -0
  3. package/agents/tester.md +23 -0
  4. package/install-extras.mjs +66 -0
  5. package/install-menu.mjs +42 -0
  6. package/install-skills.mjs +112 -0
  7. package/package.json +72 -6
  8. package/plugin-registry.mjs +73 -0
  9. package/plugins/config-ui/index.ts +160 -0
  10. package/plugins/config-ui/lib/arguments.mjs +24 -0
  11. package/plugins/config-ui/lib/documents.mjs +67 -0
  12. package/plugins/config-ui/lib/frontmatter.mjs +91 -0
  13. package/plugins/config-ui/lib/open.mjs +17 -0
  14. package/plugins/config-ui/lib/ownership.mjs +99 -0
  15. package/plugins/config-ui/lib/page.mjs +11 -0
  16. package/plugins/config-ui/lib/patch.mjs +36 -0
  17. package/plugins/config-ui/lib/paths.mjs +14 -0
  18. package/plugins/config-ui/lib/plugin-fields.mjs +86 -0
  19. package/plugins/config-ui/lib/plugin-validation.mjs +28 -0
  20. package/plugins/config-ui/lib/redaction.mjs +8 -0
  21. package/plugins/config-ui/lib/registry.mjs +282 -0
  22. package/plugins/config-ui/lib/secrets.mjs +45 -0
  23. package/plugins/config-ui/lib/server.mjs +251 -0
  24. package/plugins/config-ui/lib/sources.mjs +96 -0
  25. package/plugins/config-ui/lib/state.mjs +157 -0
  26. package/plugins/config-ui/lib/themes.mjs +113 -0
  27. package/plugins/config-ui/lib/writer.mjs +691 -0
  28. package/plugins/config-ui/package.json +12 -0
  29. package/plugins/config-ui/project-local-owner.ts +106 -0
  30. package/plugins/config-ui/vc-extras.plugin.json +13 -0
  31. package/plugins/config-ui/web/app.mjs +997 -0
  32. package/plugins/config-ui/web/index.html +342 -0
  33. package/plugins/pi-blackhole/vc-extras.plugin.json +12 -0
  34. package/plugins/pi-btw/vc-extras.plugin.json +12 -0
  35. package/plugins/pi-claude-code/vc-extras.plugin.json +12 -0
  36. package/plugins/pi-fff/vc-extras.plugin.json +12 -0
  37. package/plugins/pi-jev-auto-mode/vc-extras.plugin.json +12 -0
  38. package/plugins/pi-mcp-adapter/vc-extras.plugin.json +12 -0
  39. package/plugins/pi-web-access/vc-extras.plugin.json +12 -0
  40. package/plugins/vc-ask/claude-hook.mjs +37 -0
  41. package/plugins/vc-ask/codex-native.mjs +28 -0
  42. package/plugins/vc-ask/host-channel.mjs +75 -0
  43. package/plugins/vc-ask/index.ts +57 -0
  44. package/plugins/vc-ask/native-questions.mjs +33 -0
  45. package/plugins/vc-ask/package.json +10 -0
  46. package/plugins/vc-ask/payload.ts +170 -0
  47. package/plugins/vc-ask/questionnaire/LICENSE.ask-user-question +21 -0
  48. package/plugins/vc-ask/questionnaire/UPSTREAM.md +104 -0
  49. package/plugins/vc-ask/questionnaire/answer-channel.ts +135 -0
  50. package/plugins/vc-ask/questionnaire/config.ts +180 -0
  51. package/plugins/vc-ask/questionnaire/events.ts +154 -0
  52. package/plugins/vc-ask/questionnaire/execute.ts +688 -0
  53. package/plugins/vc-ask/questionnaire/i18n.ts +73 -0
  54. package/plugins/vc-ask/questionnaire/inline-entry.ts +312 -0
  55. package/plugins/vc-ask/questionnaire/locales/de.json +43 -0
  56. package/plugins/vc-ask/questionnaire/locales/en.json +42 -0
  57. package/plugins/vc-ask/questionnaire/locales/es.json +43 -0
  58. package/plugins/vc-ask/questionnaire/locales/fr.json +43 -0
  59. package/plugins/vc-ask/questionnaire/locales/pt-BR.json +43 -0
  60. package/plugins/vc-ask/questionnaire/locales/pt.json +43 -0
  61. package/plugins/vc-ask/questionnaire/locales/ru.json +43 -0
  62. package/plugins/vc-ask/questionnaire/locales/uk.json +43 -0
  63. package/plugins/vc-ask/questionnaire/locales/zh.json +46 -0
  64. package/plugins/vc-ask/questionnaire/presentation.ts +11 -0
  65. package/plugins/vc-ask/questionnaire/question-preview.ts +6 -0
  66. package/plugins/vc-ask/questionnaire/rpc.ts +221 -0
  67. package/plugins/vc-ask/questionnaire/session-timeout.ts +67 -0
  68. package/plugins/vc-ask/questionnaire/state/build-questionnaire.ts +144 -0
  69. package/plugins/vc-ask/questionnaire/state/external-editor.ts +62 -0
  70. package/plugins/vc-ask/questionnaire/state/geometry.ts +131 -0
  71. package/plugins/vc-ask/questionnaire/state/key-router.ts +382 -0
  72. package/plugins/vc-ask/questionnaire/state/panel-router.ts +32 -0
  73. package/plugins/vc-ask/questionnaire/state/questionnaire-session.ts +642 -0
  74. package/plugins/vc-ask/questionnaire/state/row-intent.ts +143 -0
  75. package/plugins/vc-ask/questionnaire/state/selectors/contract.ts +24 -0
  76. package/plugins/vc-ask/questionnaire/state/selectors/derivations.ts +40 -0
  77. package/plugins/vc-ask/questionnaire/state/selectors/focus.ts +17 -0
  78. package/plugins/vc-ask/questionnaire/state/selectors/projections.ts +99 -0
  79. package/plugins/vc-ask/questionnaire/state/state-reducer.ts +455 -0
  80. package/plugins/vc-ask/questionnaire/state/state.ts +90 -0
  81. package/plugins/vc-ask/questionnaire/state/vertical.ts +158 -0
  82. package/plugins/vc-ask/questionnaire/timeout.ts +59 -0
  83. package/plugins/vc-ask/questionnaire/tool/external-answer.ts +103 -0
  84. package/plugins/vc-ask/questionnaire/tool/format-answer.ts +24 -0
  85. package/plugins/vc-ask/questionnaire/tool/normalize-params.ts +37 -0
  86. package/plugins/vc-ask/questionnaire/tool/response-envelope.ts +75 -0
  87. package/plugins/vc-ask/questionnaire/tool/types.ts +74 -0
  88. package/plugins/vc-ask/questionnaire/tool/validate-questionnaire.ts +75 -0
  89. package/plugins/vc-ask/questionnaire/view/card-theme.ts +245 -0
  90. package/plugins/vc-ask/questionnaire/view/components/inline-input.ts +66 -0
  91. package/plugins/vc-ask/questionnaire/view/components/multi-select-view.ts +177 -0
  92. package/plugins/vc-ask/questionnaire/view/components/option-list-view.ts +65 -0
  93. package/plugins/vc-ask/questionnaire/view/components/preview/markdown-content-cache.ts +101 -0
  94. package/plugins/vc-ask/questionnaire/view/components/preview/preview-block-renderer.ts +130 -0
  95. package/plugins/vc-ask/questionnaire/view/components/preview/preview-box-renderer.ts +86 -0
  96. package/plugins/vc-ask/questionnaire/view/components/preview/preview-layout-decider.ts +204 -0
  97. package/plugins/vc-ask/questionnaire/view/components/preview/preview-pane.ts +257 -0
  98. package/plugins/vc-ask/questionnaire/view/components/submit-picker.ts +65 -0
  99. package/plugins/vc-ask/questionnaire/view/components/tab-bar.ts +57 -0
  100. package/plugins/vc-ask/questionnaire/view/components/wrapping-select.ts +269 -0
  101. package/plugins/vc-ask/questionnaire/view/dialog-builder.ts +319 -0
  102. package/plugins/vc-ask/questionnaire/view/document-theme.ts +53 -0
  103. package/plugins/vc-ask/questionnaire/view/document-view.ts +306 -0
  104. package/plugins/vc-ask/questionnaire/view/panel-chrome.ts +133 -0
  105. package/plugins/vc-ask/questionnaire/view/props-adapter.ts +77 -0
  106. package/plugins/vc-ask/questionnaire/view/stateful-view.ts +24 -0
  107. package/plugins/vc-ask/questionnaire/view/tab-components.ts +16 -0
  108. package/plugins/vc-ask/questionnaire/view/tab-content-strategy.ts +280 -0
  109. package/plugins/vc-ask/questionnaire/view/vertical-view.ts +218 -0
  110. package/plugins/vc-ask/user-input-events.ts +34 -0
  111. package/plugins/vc-ask/vc-extras.plugin.json +18 -0
  112. package/plugins/vc-footer/agents/claude-code/adapter.mjs +29 -0
  113. package/plugins/vc-footer/agents/claude-code/cli.mjs +23 -0
  114. package/plugins/vc-footer/agents/claude-code/renderer.mjs +1 -0
  115. package/plugins/vc-footer/agents/claude-code/types.d.ts +38 -0
  116. package/plugins/vc-footer/agents/codex/adapter.mjs +13 -0
  117. package/plugins/vc-footer/agents/codex/mcp.mjs +45 -0
  118. package/plugins/vc-footer/agents/codex/native.mjs +19 -0
  119. package/plugins/vc-footer/agents/codex/renderer.mjs +2 -0
  120. package/plugins/vc-footer/agents/pi/adapter.mjs +23 -0
  121. package/plugins/vc-footer/agents/pi/index.js +84 -0
  122. package/plugins/vc-footer/agents/pi/project-local-owner.mjs +97 -0
  123. package/plugins/vc-footer/agents/pi/renderer.mjs +5 -0
  124. package/plugins/vc-footer/core/data.mjs +218 -0
  125. package/plugins/vc-footer/core/render.mjs +291 -0
  126. package/plugins/vc-footer/core/types.d.ts +29 -0
  127. package/plugins/vc-footer/package.json +22 -0
  128. package/plugins/vc-footer/vc-extras.plugin.json +32 -0
  129. package/skills/animate/LICENSE +21 -0
  130. package/skills/animate/RECIPES.md +324 -0
  131. package/skills/animate/SKILL.md +208 -0
  132. package/skills/animate/UPSTREAM.md +19 -0
  133. package/skills/animation-performance/LICENSE +21 -0
  134. package/skills/animation-performance/SKILL.md +223 -0
  135. package/skills/animation-performance/UPSTREAM.md +19 -0
  136. package/skills/answer-me-with-html/SKILL.md +174 -0
  137. package/skills/answer-me-with-html/scripts/am.mjs +12896 -0
  138. package/skills/apple-design/LICENSE +21 -0
  139. package/skills/apple-design/SKILL.md +291 -0
  140. package/skills/apple-design/UPSTREAM.md +19 -0
  141. package/skills/bad-smell/SKILL.md +44 -0
  142. package/skills/commit/SKILL.md +90 -0
  143. package/skills/emil-design-eng/LICENSE +21 -0
  144. package/skills/emil-design-eng/SKILL.md +677 -0
  145. package/skills/emil-design-eng/UPSTREAM.md +19 -0
  146. package/skills/find-the-truth/SKILL.md +38 -0
  147. package/skills/find-the-truth/references/trace-method.md +48 -0
  148. package/skills/find-the-truth/references/truth-method.md +39 -0
  149. package/skills/gestures/LICENSE +21 -0
  150. package/skills/gestures/SKILL.md +107 -0
  151. package/skills/gestures/UPSTREAM.md +19 -0
  152. package/skills/humanizer-zh/LICENSE +21 -0
  153. package/skills/humanizer-zh/SKILL.md +409 -0
  154. package/skills/humanizer-zh/UPSTREAM.md +7 -0
  155. package/skills/impeccable/LICENSE +191 -0
  156. package/skills/impeccable/NOTICE.md +11 -0
  157. package/skills/impeccable/SKILL.md +90 -0
  158. package/skills/impeccable/licenses/modern-screenshot-MIT.txt +9 -0
  159. package/skills/impeccable/licenses/platform-design-skills-MIT.txt +21 -0
  160. package/skills/impeccable/reference/adapt.md +318 -0
  161. package/skills/impeccable/reference/adapt.native.md +58 -0
  162. package/skills/impeccable/reference/android.md +46 -0
  163. package/skills/impeccable/reference/animate.md +89 -0
  164. package/skills/impeccable/reference/audit.md +139 -0
  165. package/skills/impeccable/reference/audit.native.md +139 -0
  166. package/skills/impeccable/reference/bolder.md +33 -0
  167. package/skills/impeccable/reference/clarify.md +94 -0
  168. package/skills/impeccable/reference/colorize.md +86 -0
  169. package/skills/impeccable/reference/component-review.md +63 -0
  170. package/skills/impeccable/reference/craft-floor.md +44 -0
  171. package/skills/impeccable/reference/craft.md +5 -0
  172. package/skills/impeccable/reference/critique.md +819 -0
  173. package/skills/impeccable/reference/degraded/asset-producer.md +42 -0
  174. package/skills/impeccable/reference/degraded/documenter.md +24 -0
  175. package/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
  176. package/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
  177. package/skills/impeccable/reference/delight.md +70 -0
  178. package/skills/impeccable/reference/distill.md +111 -0
  179. package/skills/impeccable/reference/doctor.md +54 -0
  180. package/skills/impeccable/reference/document.md +416 -0
  181. package/skills/impeccable/reference/extract.md +69 -0
  182. package/skills/impeccable/reference/generate.md +101 -0
  183. package/skills/impeccable/reference/harden.md +362 -0
  184. package/skills/impeccable/reference/hooks.md +114 -0
  185. package/skills/impeccable/reference/init.md +131 -0
  186. package/skills/impeccable/reference/ios.md +51 -0
  187. package/skills/impeccable/reference/layout.md +84 -0
  188. package/skills/impeccable/reference/live-setup.md +104 -0
  189. package/skills/impeccable/reference/live.md +327 -0
  190. package/skills/impeccable/reference/mode-operate.md +21 -0
  191. package/skills/impeccable/reference/mode-persuade.md +19 -0
  192. package/skills/impeccable/reference/mode-read.md +21 -0
  193. package/skills/impeccable/reference/new-work.md +152 -0
  194. package/skills/impeccable/reference/onboard.md +234 -0
  195. package/skills/impeccable/reference/operate.md +61 -0
  196. package/skills/impeccable/reference/optimize.md +257 -0
  197. package/skills/impeccable/reference/overdrive.md +127 -0
  198. package/skills/impeccable/reference/polish.md +105 -0
  199. package/skills/impeccable/reference/quieter.md +99 -0
  200. package/skills/impeccable/reference/region-map.md +26 -0
  201. package/skills/impeccable/reference/routing.md +24 -0
  202. package/skills/impeccable/reference/shape.md +59 -0
  203. package/skills/impeccable/reference/typeset.md +90 -0
  204. package/skills/impeccable/reference/visualize.md +47 -0
  205. package/skills/impeccable/scripts/VERSION +1 -0
  206. package/skills/impeccable/scripts/command-metadata.json +98 -0
  207. package/skills/impeccable/scripts/data/font-index-failures.json +121 -0
  208. package/skills/impeccable/scripts/data/font-index.json +1 -0
  209. package/skills/impeccable/scripts/engine-checksums.txt +9 -0
  210. package/skills/impeccable/scripts/impeccable +249 -0
  211. package/skills/impeccable/scripts/impeccable.cmd +278 -0
  212. package/skills/impeccable/scripts/live-browser-dom.js +320 -0
  213. package/skills/impeccable/scripts/live-browser-ignores.js +246 -0
  214. package/skills/impeccable/scripts/live-browser-session.js +183 -0
  215. package/skills/impeccable/scripts/live-browser.js +13862 -0
  216. package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
  217. package/skills/improve-animations/AUDIT.md +115 -0
  218. package/skills/improve-animations/LICENSE +21 -0
  219. package/skills/improve-animations/PLAN-TEMPLATE.md +73 -0
  220. package/skills/improve-animations/SKILL.md +110 -0
  221. package/skills/improve-animations/UPSTREAM.md +19 -0
  222. package/skills/pick-ui-library/LICENSE +21 -0
  223. package/skills/pick-ui-library/SKILL.md +85 -0
  224. package/skills/pick-ui-library/UPSTREAM.md +19 -0
  225. package/skills/review-animations/LICENSE +21 -0
  226. package/skills/review-animations/SKILL.md +120 -0
  227. package/skills/review-animations/STANDARDS.md +187 -0
  228. package/skills/review-animations/UPSTREAM.md +19 -0
  229. package/skills/test/SKILL.md +29 -0
  230. package/skills/test/references/test-method.md +60 -0
  231. package/skills/write-doc/SKILL.md +115 -0
  232. package/skills/write-doc/examples/result-report.md +53 -0
  233. package/skills/write-doc/examples/task-summary.md +45 -0
  234. package/skills/write-doc/references/terminology.md +147 -0
  235. package/specs/ask-host-protocol-v1.md +58 -0
  236. package/specs/design-demo.md +1102 -0
  237. package/specs/frontend-immersive.md +28 -0
  238. package/specs/plugin-install-v2.md +123 -0
  239. package/specs/plugin-install.md +38 -0
  240. package/specs/web-modes/explore.md +31 -0
  241. package/specs/web-modes/risk.md +15 -0
  242. package/specs/web-modes/verify.md +16 -0
  243. package/vc-extras.mjs +62 -0
@@ -0,0 +1,143 @@
1
+ import type { QuestionData } from "../tool/types.js";
2
+ import type { WrappingSelectItem } from "../view/components/wrapping-select.js";
3
+
4
+ /**
5
+ * Row kind discriminator. Single source of truth — derived from the runtime
6
+ * `WrappingSelectItem` union (`wrapping-select.ts:18-22`) so adding a new
7
+ * variant there forces a `ROW_INTENT_META` entry here (compile-time
8
+ * exhaustiveness via `Record<RowKind, …>`).
9
+ */
10
+ export type RowKind = WrappingSelectItem["kind"];
11
+
12
+ /**
13
+ * Sentinel kinds — the subset of `RowKind` representing protocol-driven rows
14
+ * (vs author-defined `option` rows). The auto-append walker, the reserved-label
15
+ * derivation, and `LABELS_BY_KIND` consumers iterate this list.
16
+ */
17
+ export type SentinelKind = Exclude<RowKind, "option">;
18
+ export const SENTINEL_KINDS: readonly SentinelKind[] = ["other", "next"];
19
+
20
+ /**
21
+ * Per-kind static metadata. Pure data — no closures, no per-kind handler
22
+ * functions. Behavior-bearing branches (answer construction in
23
+ * `key-router.ts:69-99`, the Next-row render block in `multi-select-view.ts`,
24
+ * and the inline-Input render branch in `wrapping-select.ts`) keep their
25
+ * exhaustive switches and READ flags from this table.
26
+ *
27
+ * Adding a new sentinel:
28
+ * 1. Add the variant to `WrappingSelectItem` (`wrapping-select.ts:18-22`).
29
+ * 2. Add an entry here. Compile fails until both edits are present.
30
+ * 3. (If user-facing) author wherever the row is synthesized — typically
31
+ * `buildItemsForQuestion` for main-list residents.
32
+ *
33
+ * Field semantics:
34
+ * - `label` — user-facing string. For `option` it's an empty placeholder
35
+ * (per-instance labels come from `QuestionData.options[i].label`); every
36
+ * sentinel uses its META entry as the single source of truth.
37
+ * - `reserved` — author-facing labels matching this string trigger
38
+ * `reserved_label` at validation time. `RESERVED_LABEL_SET` is derived.
39
+ * - `livesInMainList` — true iff the row appears in `itemsByTab[i]`. Every
40
+ * current sentinel lives in the main list (the `next` row is synthesized by
41
+ * `sentinelsToAppend`).
42
+ * - `numbered` — true iff the row contributes to the main-list numbering.
43
+ * Multi-select Next is the only `numbered=false` row that lives in the list.
44
+ * - `activatesInputMode` — true iff focusing the row should toggle
45
+ * `state.inputMode = true`. Read by `state-reducer.ts` `nav` case.
46
+ * - `blocksMultiToggle` — in multiSelect mode, Space (and Enter-as-toggle)
47
+ * on this row is suppressed. The Next sentinel is the only true.
48
+ * - `autoSubmitsInMulti` — in multiSelect mode, Enter on this row commits
49
+ * the question (emits `multi_confirm`). The Next sentinel is the only true.
50
+ * - `autoAppendOnSingleSelect` — `buildItemsForQuestion` appends
51
+ * this row when the question is single-select, regardless of whether any
52
+ * option carries a `preview`. The "other" sentinel is the only true.
53
+ * - `autoAppendOnMultiSelect` — `buildItemsForQuestion` appends this row
54
+ * when the question is multi-select. The `other` and `next` sentinels are both true.
55
+ */
56
+ export interface RowIntentMeta {
57
+ label: string;
58
+ reserved: boolean;
59
+ livesInMainList: boolean;
60
+ numbered: boolean;
61
+ activatesInputMode: boolean;
62
+ blocksMultiToggle: boolean;
63
+ autoSubmitsInMulti: boolean;
64
+ autoAppendOnSingleSelect: boolean;
65
+ autoAppendOnMultiSelect: boolean;
66
+ }
67
+
68
+ export const ROW_INTENT_META: Record<RowKind, RowIntentMeta> = {
69
+ option: {
70
+ label: "",
71
+ reserved: false,
72
+ livesInMainList: true,
73
+ numbered: true,
74
+ activatesInputMode: false,
75
+ blocksMultiToggle: false,
76
+ autoSubmitsInMulti: false,
77
+ autoAppendOnSingleSelect: false,
78
+ autoAppendOnMultiSelect: false,
79
+ },
80
+ other: {
81
+ label: "Type something.",
82
+ reserved: true,
83
+ livesInMainList: true,
84
+ numbered: true,
85
+ activatesInputMode: true,
86
+ blocksMultiToggle: false,
87
+ autoSubmitsInMulti: false,
88
+ autoAppendOnSingleSelect: true,
89
+ autoAppendOnMultiSelect: true,
90
+ },
91
+ next: {
92
+ label: "Next",
93
+ reserved: true,
94
+ livesInMainList: true,
95
+ numbered: false,
96
+ activatesInputMode: false,
97
+ blocksMultiToggle: true,
98
+ autoSubmitsInMulti: true,
99
+ autoAppendOnSingleSelect: false,
100
+ autoAppendOnMultiSelect: true,
101
+ },
102
+ };
103
+
104
+ /**
105
+ * Kind-keyed label view. `option` is excluded — its label is per-instance,
106
+ * not per-kind. `types.ts#SENTINEL_LABELS` re-sources from here.
107
+ */
108
+ export const LABELS_BY_KIND: { readonly [K in SentinelKind]: string } = {
109
+ other: ROW_INTENT_META.other.label,
110
+ next: ROW_INTENT_META.next.label,
111
+ };
112
+
113
+ /**
114
+ * Reserved-label set for runtime validation. Includes "Other" (a model-conditioned
115
+ * label that has no runtime kind) plus every sentinel with `reserved: true`.
116
+ */
117
+ export const RESERVED_LABEL_SET: ReadonlySet<string> = new Set<string>([
118
+ "Other",
119
+ ...SENTINEL_KINDS.filter((k) => ROW_INTENT_META[k].reserved).map((k) => ROW_INTENT_META[k].label),
120
+ ]);
121
+
122
+ /**
123
+ * Walk the META table to synthesize sentinel rows for one question. The two
124
+ * append predicates are mutually exclusive in practice (`multiSelect` vs
125
+ * single-select) but the walker doesn't enforce that — adding a third bucket
126
+ * only requires a new META flag.
127
+ *
128
+ * Returns sentinel descriptors in declaration order of `SENTINEL_KINDS`. The
129
+ * caller wraps each with the `WrappingSelectItem` shape (kind + label).
130
+ */
131
+ export function sentinelsToAppend(question: QuestionData): SentinelKind[] {
132
+ const out: SentinelKind[] = [];
133
+ for (const k of SENTINEL_KINDS) {
134
+ const meta = ROW_INTENT_META[k];
135
+ if (!meta.livesInMainList) continue;
136
+ if (question.multiSelect === true) {
137
+ if (meta.autoAppendOnMultiSelect) out.push(k);
138
+ } else {
139
+ if (meta.autoAppendOnSingleSelect) out.push(k);
140
+ }
141
+ }
142
+ return out;
143
+ }
@@ -0,0 +1,24 @@
1
+ import type { QuestionData } from "../../tool/types.js";
2
+ import type { PreviewPaneProps } from "../../view/components/preview/preview-pane.js";
3
+ import type { WrappingSelectItem } from "../../view/components/wrapping-select.js";
4
+ import type { ActiveView, StatefulView } from "../../view/stateful-view.js";
5
+ import type { TabComponents } from "../../view/tab-components.js";
6
+ import type { QuestionnaireState } from "../state.js";
7
+
8
+ export interface BindingContext {
9
+ readonly questions: readonly QuestionData[];
10
+ readonly itemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;
11
+ readonly totalQuestions: number;
12
+ readonly activeView: ActiveView;
13
+ readonly inputBuffer: string;
14
+ readonly inputCursorOffset: number | undefined;
15
+ readonly activePreviewPane: StatefulView<PreviewPaneProps>;
16
+ }
17
+
18
+ export interface PerTabBindingContext extends BindingContext {
19
+ readonly tab: TabComponents;
20
+ readonly i: number;
21
+ }
22
+
23
+ export type GlobalSelector<P> = (state: QuestionnaireState, ctx: BindingContext) => P;
24
+ export type PerTabSelector<P> = (state: QuestionnaireState, ctx: PerTabBindingContext) => P;
@@ -0,0 +1,40 @@
1
+ import type { QuestionAnswer, QuestionData } from "../../tool/types.js";
2
+ import type { WrappingSelectItem } from "../../view/components/wrapping-select.js";
3
+
4
+ /**
5
+ * Which row in the active tab should be marked as "previously confirmed"? Drives the
6
+ * `WrappingSelect` confirmed-row indicator (label + ` ✔`) when the user navigates back
7
+ * to a question they already answered. Returns `undefined` when no marker should be drawn —
8
+ * multi-select handles its own `[✔]` boxes via `multiSelectChecked`, and a missing/non-matching
9
+ * answer (defensive) silently skips the marker.
10
+ */
11
+ export function selectConfirmedIndicator(
12
+ questions: readonly QuestionData[],
13
+ currentTab: number,
14
+ answers: ReadonlyMap<number, QuestionAnswer>,
15
+ items: readonly WrappingSelectItem[],
16
+ ): { index: number; labelOverride?: string } | undefined {
17
+ const q = questions[currentTab];
18
+ if (!q || q.multiSelect === true) return undefined;
19
+ const prior = answers.get(currentTab);
20
+ if (!prior) return undefined;
21
+ if (prior.kind === "custom") {
22
+ const otherIndex = items.findIndex((it) => it.kind === "other");
23
+ if (otherIndex < 0) return undefined;
24
+ return { index: otherIndex, labelOverride: prior.answer ?? "" };
25
+ }
26
+ if (prior.kind !== "option" || typeof prior.answer !== "string") return undefined;
27
+ const index = items.findIndex((it) => it.kind === "option" && it.label === prior.answer);
28
+ if (index < 0) return undefined;
29
+ return { index };
30
+ }
31
+
32
+ /**
33
+ * Index of the preview pane to display for the current tab. The Submit tab (currentTab ===
34
+ * questions.length) reuses the last question's pane purely for layout — the strategy
35
+ * machinery picks the right body component independently. Defensive against `totalQuestions === 0`.
36
+ */
37
+ export function selectActivePreviewPaneIndex(currentTab: number, totalQuestions: number): number {
38
+ if (totalQuestions <= 0) return 0;
39
+ return Math.min(currentTab, totalQuestions - 1);
40
+ }
@@ -0,0 +1,17 @@
1
+ import type { ActiveView } from "../../view/stateful-view.js";
2
+
3
+ /**
4
+ * Discriminated focus selector — single source of truth for "which view owns
5
+ * focus this tick?" Priority order matches the dispatcher cascade
6
+ * (`key-router.ts`) and the reducer's defensive clears (`state-reducer.ts`).
7
+ *
8
+ * Priority: notes > submit > options.
9
+ */
10
+ export function selectActiveView(
11
+ state: { notesVisible: boolean; currentTab: number },
12
+ totalQuestions: number,
13
+ ): ActiveView {
14
+ if (state.notesVisible) return "notes";
15
+ if (state.currentTab === totalQuestions) return "submit";
16
+ return "options";
17
+ }
@@ -0,0 +1,99 @@
1
+ import { MULTI_SUBMIT_LABEL, type MultiSelectViewProps } from "../../view/components/multi-select-view.js";
2
+ import type { OptionListViewProps } from "../../view/components/option-list-view.js";
3
+ import type { PreviewPaneProps } from "../../view/components/preview/preview-pane.js";
4
+ import type { SubmitPickerProps } from "../../view/components/submit-picker.js";
5
+ import type { TabBarProps } from "../../view/components/tab-bar.js";
6
+ import type { DialogProps } from "../../view/dialog-builder.js";
7
+ import { displayLabel } from "../../i18n.js";
8
+ import type { GlobalSelector, PerTabSelector } from "./contract.js";
9
+ import { selectConfirmedIndicator } from "./derivations.js";
10
+
11
+ export const selectMultiSelectProps: PerTabSelector<MultiSelectViewProps> = (state, ctx) => {
12
+ const question = ctx.questions[ctx.i];
13
+ if (!question) {
14
+ return {
15
+ rows: [],
16
+ other: {
17
+ active: false,
18
+ inputMode: false,
19
+ inputBuffer: ctx.inputBuffer,
20
+ inputCursorOffset: ctx.inputCursorOffset,
21
+ },
22
+ nextActive: false,
23
+ nextLabel: displayLabel("next"),
24
+ };
25
+ }
26
+ const focused = ctx.activeView === "options";
27
+ const rows: { checked: boolean; active: boolean }[] = [];
28
+ for (let i = 0; i < question.options.length; i++) {
29
+ rows.push({
30
+ checked: state.multiSelectChecked.has(i),
31
+ active: focused && i === state.optionIndex,
32
+ });
33
+ }
34
+ const otherActive = focused && state.optionIndex === question.options.length;
35
+ const nextActive = focused && state.optionIndex === question.options.length + 1;
36
+ const isLastQuestion = ctx.i === ctx.questions.length - 1;
37
+ const nextLabel = isLastQuestion ? MULTI_SUBMIT_LABEL : displayLabel("next");
38
+ return {
39
+ rows,
40
+ other: {
41
+ active: otherActive,
42
+ inputMode: state.inputMode,
43
+ inputBuffer: ctx.inputBuffer,
44
+ inputCursorOffset: ctx.inputCursorOffset,
45
+ },
46
+ nextActive,
47
+ nextLabel,
48
+ };
49
+ };
50
+
51
+ export const selectOptionListProps: PerTabSelector<OptionListViewProps> = (state, ctx) => {
52
+ const items = ctx.itemsByTab[ctx.i] ?? [];
53
+ const focused = ctx.activeView === "options";
54
+ const confirmed = selectConfirmedIndicator(ctx.questions, state.currentTab, state.answers, items);
55
+ return {
56
+ selectedIndex: state.optionIndex,
57
+ focused,
58
+ inputBuffer: ctx.inputBuffer,
59
+ inputCursorOffset: ctx.inputCursorOffset,
60
+ ...(confirmed ? { confirmed } : {}),
61
+ };
62
+ };
63
+
64
+ export const selectSubmitPickerProps: GlobalSelector<SubmitPickerProps> = (state, ctx) => {
65
+ const focused = ctx.activeView === "submit";
66
+ return {
67
+ rows: [
68
+ { active: focused && state.submitChoiceIndex === 0 },
69
+ { active: focused && state.submitChoiceIndex === 1 },
70
+ ],
71
+ };
72
+ };
73
+
74
+ export const selectPreviewPaneProps: PerTabSelector<PreviewPaneProps> = (state, ctx) => ({
75
+ notesVisible: state.notesVisible,
76
+ selectedIndex: state.optionIndex,
77
+ focused: ctx.activeView === "options",
78
+ inputMode: state.inputMode,
79
+ });
80
+
81
+ export const selectTabBarProps: GlobalSelector<TabBarProps> = (state, ctx) => {
82
+ const tabs = ctx.questions.map((q, i) => ({
83
+ label: q.header && q.header.length > 0 ? q.header : `Q${i + 1}`,
84
+ answered: state.answers.has(i),
85
+ active: i === state.currentTab,
86
+ }));
87
+ return {
88
+ tabs,
89
+ submit: {
90
+ active: state.currentTab === ctx.questions.length,
91
+ allAnswered: state.answers.size === ctx.questions.length && ctx.questions.length > 0,
92
+ },
93
+ };
94
+ };
95
+
96
+ export const selectDialogProps: GlobalSelector<DialogProps> = (state, ctx) => ({
97
+ state,
98
+ activePreviewPane: ctx.activePreviewPane,
99
+ });