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