@kabmo-labs/kabmo 0.56.0 → 0.57.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.
Files changed (122) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +2 -2
  3. package/dist/client/static/js/{Body-jfy4bhk2.js → Body-k96gtstv.js} +1 -1
  4. package/dist/client/static/js/{CsvGrid-4c5t668z.js → CsvGrid-t84xmbk9.js} +1 -1
  5. package/dist/client/static/js/{DocxView-3x7whtvq.js → DocxView-4jda3szm.js} +1 -1
  6. package/dist/client/static/js/{DrawioView-tbkc5dfz.js → DrawioView-9qvvtnvt.js} +1 -1
  7. package/dist/client/static/js/{HtmlPreview-egxkayya.js → HtmlPreview-4pba1ys5.js} +1 -1
  8. package/dist/client/static/js/{ImageView-swhzvw2p.js → ImageView-0gf5xdsv.js} +1 -1
  9. package/dist/client/static/js/{LayoutWrapper-sangsrt5.js → LayoutWrapper-pwbq5syv.js} +1 -1
  10. package/dist/client/static/js/MergeDiffView-m4jkr786.js +1 -0
  11. package/dist/client/static/js/{Modal-1fj8kvme.js → Modal-yjszc3vy.js} +12 -12
  12. package/dist/client/static/js/{PdfView-0k2egsbz.js → PdfView-sny55sne.js} +1 -1
  13. package/dist/client/static/js/{SessionsView-t547rqeb.js → SessionsView-q3800n83.js} +1 -1
  14. package/dist/client/static/js/{SheetView-anb3gavm.js → SheetView-ezqak2b4.js} +1 -1
  15. package/dist/client/static/js/{SvgPreview-e2wrj2hj.js → SvgPreview-q1cvdf4s.js} +1 -1
  16. package/dist/client/static/js/{abnfDiagram-O67JEVCF-0rs86b68.js → abnfDiagram-O67JEVCF-ftm2qwa3.js} +1 -1
  17. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-0k3zzxz1.js → architectureDiagram-NJMV4G6O-j8kqfzmf.js} +1 -1
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-t1n1fx96.js → blockDiagram-BEXU5L5S-m3zpsp9h.js} +3 -3
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-93b7eds9.js → c4Diagram-YGBWAQC7-myshvbrx.js} +2 -2
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-bnf85z0f.js → classDiagram-v2-NBCMYWYE-s0cwmsj4.js} +1 -1
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-e290161f.js → cose-bilkent-JH36ORCC-t5t02sfr.js} +1 -1
  22. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-s13ra9ag.js → cynefinDiagram-VND7K2PF-6yxd72sh.js} +1 -1
  23. package/dist/client/static/js/{dagre-6A5THRUB-83wshh5e.js → dagre-6A5THRUB-vft5103m.js} +1 -1
  24. package/dist/client/static/js/{diagram-22UHCM2B-ywh4wqna.js → diagram-22UHCM2B-yy2jfvxt.js} +1 -1
  25. package/dist/client/static/js/{diagram-3UASUU5V-cb53z698.js → diagram-3UASUU5V-1xqhzq20.js} +1 -1
  26. package/dist/client/static/js/{diagram-ATOU4E4O-btf55c44.js → diagram-ATOU4E4O-f11cxgvm.js} +1 -1
  27. package/dist/client/static/js/{diagram-CDSNMT55-p6tbbm1n.js → diagram-CDSNMT55-gqmkfcp7.js} +3 -3
  28. package/dist/client/static/js/{diagram-MLGK6HIB-6kzssf4y.js → diagram-MLGK6HIB-1fg7304a.js} +1 -1
  29. package/dist/client/static/js/{diagram-MPIPVDR6-4v0yncvv.js → diagram-MPIPVDR6-mem80369.js} +1 -1
  30. package/dist/client/static/js/{dockerfile-r422htmd.js → dockerfile-jarjwxp9.js} +1 -1
  31. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-mw1gh30z.js → ebnfDiagram-ZINNZB2B-4rcbvfrj.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-1pe786ap.js → elk-276RUBZZ-ykd0stxz.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-x7rk70q6.js → erDiagram-OPXOYQCR-b2th9bk4.js} +1 -1
  34. package/dist/client/static/js/flowDiagram-KWPJA3E3-f3bdtc1z.js +1 -0
  35. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-j3m5km4p.js → ganttDiagram-FUAMR5RP-64p5r7cx.js} +2 -2
  36. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-fd1kebdy.js → gitGraphDiagram-X574FWY7-z3yc333r.js} +1 -1
  37. package/dist/client/static/js/{index-004x0a3p.js → index-1mm7kyjd.js} +1 -1
  38. package/dist/client/static/js/{index-4dzvjfkd.js → index-2gf593e3.js} +1 -1
  39. package/dist/client/static/js/{index-4jg10xtp.js → index-3w18s59k.js} +1 -1
  40. package/dist/client/static/js/{index-tcp5cp53.js → index-3x3nhs8n.js} +1 -1
  41. package/dist/client/static/js/{index-j1prebvy.js → index-5m0se6fk.js} +1 -1
  42. package/dist/client/static/js/{index-kbk0vmex.js → index-6m5n8b6w.js} +1 -1
  43. package/dist/client/static/js/{index-bnamrpm6.js → index-77wznmg5.js} +1 -1
  44. package/dist/client/static/js/{index-cbbwq25c.js → index-bwwgtesb.js} +1 -1
  45. package/dist/client/static/js/{index-zkef5q39.js → index-c2vc6znd.js} +1 -1
  46. package/dist/client/static/js/{index-4acka5fn.js → index-dxx49b9m.js} +1 -1
  47. package/dist/client/static/js/{index-bxhszdcz.js → index-ebnd5hnr.js} +1 -1
  48. package/dist/client/static/js/{index-g84dwmvr.js → index-ep353yxd.js} +1 -1
  49. package/dist/client/static/js/{index-s6nv35dv.js → index-ewtv8gg7.js} +1 -1
  50. package/dist/client/static/js/{index-jtyzeynv.js → index-g71wn1pr.js} +1 -1
  51. package/dist/client/static/js/{index-473wm10a.js → index-gr07t5c4.js} +1 -1
  52. package/dist/client/static/js/{index-drsy400d.js → index-h4qmywn5.js} +1 -1
  53. package/dist/client/static/js/{index-s4v3vcsn.js → index-hmjb96kb.js} +1 -1
  54. package/dist/client/static/js/{index-q4t5j3x7.js → index-jd2h5tvh.js} +1 -1
  55. package/dist/client/static/js/{index-0mhxw0a1.js → index-k57bandz.js} +1 -1
  56. package/dist/client/static/js/{index-dfha2z56.js → index-k6wms0kx.js} +1 -1
  57. package/dist/client/static/js/{index-7tsdw8wt.js → index-k9v6477a.js} +1 -1
  58. package/dist/client/static/js/{index-4fpyzg5e.js → index-kbaffwp1.js} +20 -20
  59. package/dist/client/static/js/{index-3k45gspr.js → index-mdmtxh1c.js} +1 -1
  60. package/dist/client/static/js/{index-hgsjynb0.js → index-mv83hpva.js} +1 -1
  61. package/dist/client/static/js/{index-qdabc51h.js → index-n71ffk62.js} +2 -2
  62. package/dist/client/static/js/{index-qrwjxqdh.js → index-nr5gwny1.js} +176 -176
  63. package/dist/client/static/js/{index-rm5b3kn8.js → index-q9gbwqbe.js} +3 -3
  64. package/dist/client/static/js/{index-4nyajpeg.js → index-rqpbva78.js} +1 -1
  65. package/dist/client/static/js/{index-q178zgxp.js → index-sw370sk7.js} +1 -1
  66. package/dist/client/static/js/{index-8e66p2a7.js → index-t415df0c.js} +1 -1
  67. package/dist/client/static/js/index-taz2nfym.css +1 -0
  68. package/dist/client/static/js/{index-22frp78d.js → index-w659dhe5.js} +1 -1
  69. package/dist/client/static/js/{index-29b1ysz6.js → index-wgcgshdh.js} +1 -1
  70. package/dist/client/static/js/{index-72v57e07.js → index-x6945djv.js} +1 -1
  71. package/dist/client/static/js/{index-satnfvaz.js → index-y5mf2w81.js} +1 -1
  72. package/dist/client/static/js/{index-jbaceghb.js → index-y69cbdvd.js} +1 -1
  73. package/dist/client/static/js/{index-3hrvhyym.js → index-y6qtx68e.js} +1 -1
  74. package/dist/client/static/js/{index-5fxm2tpg.js → index-yktwxghr.js} +1 -1
  75. package/dist/client/static/js/{index-8n4qwd64.js → index-zj65csnm.js} +2 -2
  76. package/dist/client/static/js/{infoDiagram-VRGFBTTK-1m0br602.js → infoDiagram-VRGFBTTK-59xq3n1b.js} +2 -2
  77. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-zryzhpq6.js → ishikawaDiagram-OU5B5YK6-v18q4qt7.js} +2 -2
  78. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-6apqr7h4.js → journeyDiagram-ZHPQQLJL-etazj0p8.js} +2 -2
  79. package/dist/client/static/js/{kanban-definition-PNTS6WVX-am385c1e.js → kanban-definition-PNTS6WVX-ph15e5p2.js} +1 -1
  80. package/dist/client/static/js/{mermaid.core-k937exrm.js → mermaid.core-7ygd161b.js} +2 -2
  81. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-hx8qq866.js → mindmap-definition-NLK3R4M7-j5xsftrf.js} +1 -1
  82. package/dist/client/static/js/one-dark-pro-4s2rr12v.js +1 -0
  83. package/dist/client/static/js/one-light-3bkk59ww.js +1 -0
  84. package/dist/client/static/js/{pegDiagram-GJSIUBJH-1hasj2h7.js → pegDiagram-GJSIUBJH-09nvb70v.js} +1 -1
  85. package/dist/client/static/js/{pieDiagram-5QR66LMP-x5nwff8r.js → pieDiagram-5QR66LMP-6ymh1960.js} +2 -2
  86. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-gmrcr5jb.js → quadrantDiagram-O4NWA36T-hk61avw2.js} +2 -2
  87. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-rdznfhfb.js → railroadDiagram-XR7U4H2S-3jvqrfnb.js} +1 -1
  88. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-v9wb3ppf.js → requirementDiagram-PLB6GJNP-zthfj48k.js} +1 -1
  89. package/dist/client/static/js/{rust-9cgnbbcs.js → rust-q7n7q6dy.js} +1 -1
  90. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-3p4ddd2h.js → sankeyDiagram-IPEJSGJF-nh5d6xte.js} +1 -1
  91. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-wfcqxjfq.js → sequenceDiagram-PO4LG4MO-crej9b40.js} +4 -4
  92. package/dist/client/static/js/{sizeCapture-INFHLROL-g02k0k8x.js → sizeCapture-INFHLROL-nvvxw58j.js} +1 -1
  93. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-7k449yvg.js → stateDiagram-v2-GCMORJYK-e6tztjnj.js} +1 -1
  94. package/dist/client/static/js/{swimlanes-2SLR337P-zkf2bgm8.js → swimlanes-2SLR337P-xhdqjqmf.js} +1 -1
  95. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-yex8g4fx.js → swimlanesDiagram-TC7HE7FX-hbwg3m3k.js} +1 -1
  96. package/dist/client/static/js/{timeline-definition-EJHVYXUP-qsfpjr1c.js → timeline-definition-EJHVYXUP-9cve31zc.js} +1 -1
  97. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-b2vprhsr.js → usecaseDiagram-POWQR4AR-asycstwe.js} +1 -1
  98. package/dist/client/static/js/{vennDiagram-UO4OBE2U-x0ffeg2t.js → vennDiagram-UO4OBE2U-gbzk6era.js} +4 -4
  99. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-hsnhaf4f.js → wardleyDiagram-VNRHLVJA-1swwfszr.js} +2 -2
  100. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-90f9aadp.js → xychartDiagram-PMCCYNJV-v7qkwv0b.js} +3 -3
  101. package/package.json +3 -3
  102. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.tsx +25 -62
  103. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormDialog.test.tsx +40 -0
  104. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormDialog.tsx +41 -2
  105. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionList.tsx +117 -0
  106. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/SwipeDeck.tsx +220 -0
  107. package/src/client/data/settings/omp-schema.json +59 -7
  108. package/src/client/hooks/chat/timeline/ask-frames-form.test.ts +29 -0
  109. package/src/shared/lib/chat/ask-form/data.ts +25 -6
  110. package/src/shared/lib/chat/ask-form/deck.ts +80 -0
  111. package/src/shared/lib/chat/ask-form/fields.ts +26 -1
  112. package/src/shared/lib/chat/ask-form/index.ts +18 -310
  113. package/src/shared/lib/chat/ask-form/types.ts +14 -2
  114. package/src/shared/lib/chat/ask-form/walker.ts +350 -0
  115. package/src/shared/lib/chat/ask-form.test.ts +41 -0
  116. package/src/shared/lib/omp/config/schema-releases-19-4.test.ts +47 -0
  117. package/src/shared/lib/omp/config/schema-releases.test.ts +4 -2
  118. package/dist/client/static/js/MergeDiffView-bv00y63x.js +0 -1
  119. package/dist/client/static/js/flowDiagram-KWPJA3E3-kfwaac44.js +0 -1
  120. package/dist/client/static/js/index-gedsa0z7.css +0 -1
  121. package/dist/client/static/js/one-dark-pro-phxqe9mx.js +0 -1
  122. package/dist/client/static/js/one-light-vhwh499y.js +0 -1
@@ -30,7 +30,7 @@ export interface DraftOption {
30
30
 
31
31
  export interface DraftField {
32
32
  name: string;
33
- kind: 'choice' | 'text';
33
+ kind: 'choice' | 'text' | 'card';
34
34
  multi: boolean;
35
35
  select: boolean;
36
36
  label: string;
@@ -44,6 +44,10 @@ export interface DraftField {
44
44
  /** The control carries `required`. Since omp 19.2.0 it is a hint: the form
45
45
  * handler flags the empty control but still submits, so it never blocks. */
46
46
  required: boolean;
47
+ /** Card only: the side labels, each already resolved per-card over the
48
+ * deck's — what swiping right and left mean. */
49
+ yes?: string;
50
+ no?: string;
47
51
  }
48
52
 
49
53
  /** Named fields, in document order, as the questions the card renders. */
@@ -51,6 +55,27 @@ export function toQuestions(fields: DraftField[]): AskQuestion[] {
51
55
  const questions: AskQuestion[] = [];
52
56
  for (const field of fields) {
53
57
  if (!field.name) continue;
58
+ if (field.kind === 'card') {
59
+ // omp's card deck: the question is the card's first text block (here its
60
+ // caption — the walker hands text blocks to `caption` — else its name),
61
+ // and the three verdict rows ride as options, yes/no/skip in order, so
62
+ // the existing `OptionRow` picks and the same Submit carry them. The
63
+ // verdict values are the fixed words omp submits as booleans for, never
64
+ // the labels, which the user may have relabelled.
65
+ const question = oneLine(field.label) || field.caption || field.section || field.name;
66
+ questions.push({
67
+ id: field.name,
68
+ question,
69
+ options: [
70
+ { label: field.yes ?? 'Yes', value: 'yes' },
71
+ { label: field.no ?? 'No', value: 'no' },
72
+ { label: 'Skip', value: 'skip' },
73
+ ],
74
+ multi: false,
75
+ kind: 'card',
76
+ });
77
+ continue;
78
+ }
54
79
  const lone = field.kind === 'choice' && field.options.length === 1 ? oneLine(field.options[0].label) : '';
55
80
  const question = oneLine(field.label) || field.caption || field.section || lone || field.name;
56
81
  const options: AskOption[] = field.options.map((option) => ({
@@ -17,324 +17,32 @@
17
17
  *
18
18
  * The parser is deliberately small: agent-written forms use labels, fieldsets,
19
19
  * paragraphs, selects and plain inputs. Anything it cannot read degrades to the
20
- * control's `name`, never to a blank card.
20
+ * control's `name`, never to a blank card. The walk itself lives in
21
+ * `walker.ts`; this module only owns the entry and the turn from drafts to
22
+ * questions (`fields.ts`).
21
23
  */
22
24
 
25
+ import { toQuestions, type DraftField } from '@/shared/lib/chat/ask-form/fields';
26
+ import { readLabelTargets } from '@/shared/lib/chat/ask-form/labels';
27
+ import { flush, walk, type WalkContext } from '@/shared/lib/chat/ask-form/walker';
28
+ import { tokenize } from '@/shared/lib/chat/ask-form/tokens';
23
29
  import type { AskQuestion } from '@/shared/lib/chat/ask-form/types';
24
- import { toQuestions, type DraftField, type DraftOption } from '@/shared/lib/chat/ask-form/fields';
25
- import { IGNORED_INPUTS, readLabelTargets } from '@/shared/lib/chat/ask-form/labels';
26
- import {
27
- BLOCK,
28
- findChild,
29
- hasControl,
30
- HEADING,
31
- matchingClose,
32
- nameLabel,
33
- oneLine,
34
- SKIPPED,
35
- textOf,
36
- tokenize,
37
- type Token,
38
- } from '@/shared/lib/chat/ask-form/tokens';
39
30
 
40
31
  /** Fields of one form, in document order, with the question text omp derives. */
41
32
  export function parseAskForm(html: string): AskQuestion[] {
42
33
  if (!html.trim()) return [];
43
34
  const form = /<form\b[^>]*>([\s\S]*)<\/form>/i.exec(html);
44
35
  const tokens = tokenize(form ? form[1] : html);
45
- const labelFor = readLabelTargets(tokens);
46
-
47
- const fields: DraftField[] = [];
48
- const groups = new Map<string, DraftField>();
49
- let section = '';
50
- let caption = '';
51
- let inline = '';
52
-
53
- const flush = () => {
54
- const text = oneLine(inline);
55
- inline = '';
56
- if (text) caption = text;
57
- };
58
-
59
- const addField = (field: DraftField) => {
60
- // The text block immediately before a control is its caption (omp's
61
- // `fieldQuestions`), so the pending inline run must be flushed BEFORE the
62
- // field is built — flushing after left `<span>Which?</span><select>` with
63
- // the control's own name as its question.
64
- flush();
65
- field.caption = caption;
66
- fields.push(field);
67
- caption = '';
68
- };
69
-
70
- const controlLabel = (attrs: Record<string, string>, wrapping: string | undefined): string => {
71
- const own = wrapping !== undefined ? oneLine(wrapping) : '';
72
- if (own) return own;
73
- const detached = attrs.id ? labelFor.get(attrs.id) : undefined;
74
- return detached ? oneLine(detached) : '';
75
- };
76
-
77
- const addInput = (attrs: Record<string, string>, wrapping: string | undefined) => {
78
- const type = (attrs.type ?? 'text').toLowerCase();
79
- if (IGNORED_INPUTS[type]) return;
80
- const name = attrs.name ?? '';
81
- if (type === 'radio' || type === 'checkbox') {
82
- const value = attrs.value ?? 'on';
83
- const option: DraftOption = {
84
- value,
85
- // omp's fallback is the RAW `value` attribute, else the name — not the
86
- // `on` default a valueless checkbox submits. Using `on` made a lone
87
- // checkbox's question "on" while omp's dialog title was its name.
88
- label: controlLabel(attrs, wrapping) || attrs.value || name,
89
- checked: 'checked' in attrs,
90
- disabled: 'disabled' in attrs,
91
- };
92
- const key = `${type}\u0000${name}`;
93
- const group = groups.get(key);
94
- if (group) {
95
- group.options.push(option);
96
- // omp does the same (`group.field.required ||= required`): one member of
97
- // the group marking it required makes the whole group required. Since
98
- // 19.2.0 that only labels the group — a submission without a pick is
99
- // accepted, and the model gets the rest of the form.
100
- group.required ||= 'required' in attrs;
101
- return;
102
- }
103
- const field: DraftField = {
104
- name,
105
- kind: 'choice',
106
- multi: type === 'checkbox',
107
- select: false,
108
- label: '',
109
- options: [option],
110
- value: '',
111
- multiline: false,
112
- caption,
113
- section,
114
- required: 'required' in attrs,
115
- };
116
- groups.set(key, field);
117
- addField(field);
118
- return;
119
- }
120
- addField({
121
- name,
122
- kind: 'text',
123
- multi: false,
124
- select: false,
125
- label: controlLabel(attrs, wrapping) || nameLabel(name),
126
- options: [],
127
- value: attrs.value ?? '',
128
- multiline: false,
129
- caption,
130
- section,
131
- required: 'required' in attrs,
132
- });
133
- };
134
-
135
- const addSelect = (attrs: Record<string, string>, inner: Token[], wrapping: string | undefined) => {
136
- const options: DraftOption[] = [];
137
- for (let index = 0; index < inner.length; index += 1) {
138
- const token = inner[index];
139
- if (token.kind !== 'open' || token.tag !== 'option') continue;
140
- const end = token.selfClosing ? index + 1 : matchingClose(inner, index, 'option');
141
- const text = textOf(inner, index + 1, end);
142
- options.push({
143
- value: token.attrs.value ?? text,
144
- label: text,
145
- checked: 'selected' in token.attrs,
146
- disabled: 'disabled' in token.attrs,
147
- });
148
- index = end;
149
- }
150
- const multi = 'multiple' in attrs;
151
- if (!multi && options.length > 0 && !options.some((option) => option.checked)) {
152
- const first = options.find((option) => !option.disabled);
153
- if (first) first.checked = true;
154
- }
155
- addField({
156
- name: attrs.name ?? '',
157
- kind: 'choice',
158
- multi,
159
- select: true,
160
- label: controlLabel(attrs, wrapping),
161
- options,
162
- value: '',
163
- multiline: false,
164
- caption,
165
- section,
166
- required: 'required' in attrs,
167
- });
36
+ const ctx: WalkContext = {
37
+ tokens,
38
+ labelFor: readLabelTargets(tokens),
39
+ fields: [],
40
+ groups: new Map<string, DraftField>(),
41
+ section: '',
42
+ caption: '',
43
+ inline: '',
168
44
  };
169
-
170
- /**
171
- * Walk a token range. `quiet` is a `<label>` that wraps controls: its text is
172
- * the control's LABEL (already passed as `wrapping`), never a block of the
173
- * form, so it must not caption the field it names.
174
- */
175
- const walk = (
176
- start: number,
177
- end: number,
178
- wrapping: string | undefined,
179
- depth: number,
180
- quiet = false,
181
- ): void => {
182
- const settle = () => {
183
- if (!quiet) flush();
184
- };
185
- for (let index = start; index < end; index += 1) {
186
- const token = tokens[index];
187
- if (token.kind === 'text') {
188
- if (!quiet) inline += token.text;
189
- continue;
190
- }
191
- const tag = token.tag;
192
- if (tag.startsWith('/')) {
193
- if (BLOCK[tag.slice(1)] || HEADING[tag.slice(1)] || tag === '/legend' || tag === '/pre' || tag === '/table') {
194
- settle();
195
- }
196
- continue;
197
- }
198
- if (token.selfClosing) {
199
- if (tag === 'br' && !quiet) inline += '\n';
200
- else if (tag === 'hr') settle();
201
- else if (tag === 'input') addInput(token.attrs, wrapping);
202
- continue;
203
- }
204
- // An unclosed tag (`<span class="truncate">` written literally inside a
205
- // code span) has no `</span>`; `matchingClose` then answers the end of the
206
- // document, and walking to it re-walked every field after the enclosing
207
- // block — the same question appeared twice and the frame could not be
208
- // placed. Clamp to the range this walk owns.
209
- const close = Math.min(matchingClose(tokens, index, tag), end);
210
- if (SKIPPED[tag]) {
211
- index = close;
212
- continue;
213
- }
214
- if (tag === 'label') {
215
- const target = token.attrs.for;
216
- if (target && labelFor.has(target)) {
217
- index = close;
218
- continue;
219
- }
220
- walk(index + 1, close, textOf(tokens, index + 1, close), depth, true);
221
- index = close;
222
- continue;
223
- }
224
- if (tag === 'fieldset') {
225
- settle();
226
- const legendAt = findChild(tokens, index + 1, close, 'legend');
227
- if (depth === 0 && !quiet) {
228
- // omp starts a NEW section at a top-level fieldset: the blocks before
229
- // it (a `<p>` caption included) do not reach the fields inside, which
230
- // borrow the legend instead. Keeping the caption made a form's
231
- // explanatory paragraph caption the first field — and since that
232
- // paragraph is not the title omp shows, the live dialog could not be
233
- // matched back to the question.
234
- caption = '';
235
- section = legendAt === -1 ? '' : textOf(tokens, legendAt + 1, matchingClose(tokens, legendAt, 'legend'));
236
- if (legendAt === -1) {
237
- walk(index + 1, close, wrapping, depth + 1);
238
- } else {
239
- walk(index + 1, legendAt, wrapping, depth + 1);
240
- walk(matchingClose(tokens, legendAt, 'legend') + 1, close, wrapping, depth + 1);
241
- }
242
- section = '';
243
- } else {
244
- walk(index + 1, close, wrapping, depth + 1, quiet);
245
- }
246
- settle();
247
- index = close;
248
- continue;
249
- }
250
- if (tag === 'legend' || HEADING[tag]) {
251
- settle();
252
- walk(index + 1, close, wrapping, depth, quiet);
253
- settle();
254
- index = close;
255
- continue;
256
- }
257
- if (BLOCK[tag]) {
258
- settle();
259
- walk(index + 1, close, wrapping, depth, quiet);
260
- settle();
261
- index = close;
262
- continue;
263
- }
264
- // A `<table>` of controls (a decision matrix) is LAYOUT: omp walks it, so
265
- // the row's text captions the control and the field survives. Treating
266
- // every table as prose dropped the fields entirely, and a tool call whose
267
- // questions never parsed cannot claim its dialogs — the whole ask fell to
268
- // the modal.
269
- if (tag === 'table') {
270
- settle();
271
- if (hasControl(tokens, index + 1, close)) walk(index + 1, close, wrapping, depth, quiet);
272
- else if (!quiet) caption = '';
273
- settle();
274
- index = close;
275
- continue;
276
- }
277
- if (tag === 'ul' || tag === 'ol' || tag === 'pre') {
278
- settle();
279
- // A list of controls is layout; any other list is a block, which clears
280
- // the caption the next field would otherwise borrow.
281
- if ((tag === 'ul' || tag === 'ol') && hasControl(tokens, index + 1, close)) {
282
- walk(index + 1, close, wrapping, depth, quiet);
283
- } else if (!quiet) {
284
- caption = '';
285
- }
286
- settle();
287
- index = close;
288
- continue;
289
- }
290
- // Cell boundaries separate one cell's text from the next; without them
291
- // every cell in a row ran together into one caption.
292
- if (tag === 'td' || tag === 'th' || tag === 'tr') {
293
- settle();
294
- walk(index + 1, close, wrapping, depth, quiet);
295
- settle();
296
- index = close;
297
- continue;
298
- }
299
- if (tag === 'input') {
300
- addInput(token.attrs, wrapping);
301
- continue;
302
- }
303
- if (tag === 'select') {
304
- addSelect(token.attrs, tokens.slice(index + 1, close), wrapping);
305
- index = close;
306
- continue;
307
- }
308
- if (tag === 'textarea') {
309
- addField({
310
- name: token.attrs.name ?? '',
311
- kind: 'text',
312
- multi: false,
313
- select: false,
314
- label: controlLabel(token.attrs, wrapping) || nameLabel(token.attrs.name ?? ''),
315
- options: [],
316
- value: textOf(tokens, index + 1, close),
317
- multiline: true,
318
- caption,
319
- section,
320
- required: 'required' in token.attrs,
321
- });
322
- index = close;
323
- continue;
324
- }
325
- if (tag === 'img') {
326
- settle();
327
- if (!quiet) caption = '';
328
- continue;
329
- }
330
- // Inline markup (`code`, `strong`, `em`, `a`, `span`, …): keep its text.
331
- walk(index + 1, close, wrapping, depth, quiet);
332
- index = close;
333
- }
334
- };
335
-
336
- walk(0, tokens.length, undefined, 0);
337
- flush();
338
-
339
- return toQuestions(fields);
45
+ walk(ctx, 0, tokens.length, undefined, 0);
46
+ flush(ctx);
47
+ return toQuestions(ctx.fields);
340
48
  }
@@ -44,7 +44,15 @@ export interface AskQuestion {
44
44
  * things depending on it (`ask-form/index.ts`). Absent on the pre-18.18.3 shape,
45
45
  * where every question was a choice.
46
46
  */
47
- kind?: 'choice' | 'text';
47
+ /**
48
+ * Which control the question came from. The HTML form distinguishes a choice
49
+ * list from a text field, and an answer's rendered text means different
50
+ * things depending on it (`ask-form/index.ts`). Absent on the pre-18.18.3 shape,
51
+ * where every question was a choice. `card` is a `<booldeck>` swipe card
52
+ * (omp 19.4.0): the answer is a verdict, and `options` carries its three
53
+ * rows — yes, no, skip — in that order.
54
+ */
55
+ kind?: 'choice' | 'text' | 'card';
48
56
  /**
49
57
  * The control carries the `required` attribute. Since omp 19.2.0 a form
50
58
  * submission that leaves it empty is still accepted (the dialog flags it and
@@ -52,8 +60,12 @@ export interface AskQuestion {
52
60
  * per-field walk, which does enforce it.
53
61
  */
54
62
  required?: boolean;
63
+ /**
64
+ * Card only: the verdict the user already swiped, read back from a recorded
65
+ * answer so a reloaded card shows it settled. Absent while undecided.
66
+ */
67
+ verdict?: 'yes' | 'no' | 'skip';
55
68
  }
56
-
57
69
  export interface AskAnswer {
58
70
  selectedOptions: string[];
59
71
  customInput?: string;