@adecore/agents-react 0.38.0 → 0.39.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 (51) hide show
  1. package/dist/agents/AgentModelLabel.d.ts +10 -0
  2. package/dist/agents/AgentModelLabel.js +97 -0
  3. package/dist/chat/ui/Composer.js +385 -360
  4. package/dist/chat/ui/Pickers.d.ts +2 -1
  5. package/dist/chat/ui/Pickers.js +126 -123
  6. package/dist/chat/ui/PromptEditor.d.ts +19 -0
  7. package/dist/chat/ui/PromptEditor.js +115 -0
  8. package/dist/chat/ui/Timeline.d.ts +2 -1
  9. package/dist/chat/ui/Timeline.js +13 -1
  10. package/dist/chat/ui/composer/ComposerControls.d.ts +3 -0
  11. package/dist/chat/ui/composer/ComposerControls.js +235 -38
  12. package/dist/chat/ui/composer/key-handler.d.ts +1 -1
  13. package/dist/chat/ui/composer/key-handler.js +3 -11
  14. package/dist/chat/ui/composer/prompt-picks.d.ts +4 -0
  15. package/dist/chat/ui/composer/prompt-picks.js +14 -0
  16. package/dist/chat/ui/composer/use-composer-menus.d.ts +4 -49
  17. package/dist/chat/ui/composer/use-composer-menus.js +65 -519
  18. package/dist/chat/ui/composer/use-prompt-menus.d.ts +73 -0
  19. package/dist/chat/ui/composer/use-prompt-menus.js +536 -0
  20. package/dist/chat/ui/index.d.ts +3 -0
  21. package/dist/chat/ui/index.js +2 -0
  22. package/dist/host-hooks.d.ts +2 -1
  23. package/dist/host-hooks.js +6 -0
  24. package/dist/host.d.ts +17 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/locales/en/agent-chat.d.ts +1 -0
  27. package/dist/locales/en/agent-chat.js +1 -0
  28. package/dist/locales/nl/agent-chat.d.ts +1 -0
  29. package/dist/locales/nl/agent-chat.js +1 -0
  30. package/dist/providers/index.d.ts +1 -0
  31. package/dist/providers/index.js +1 -0
  32. package/dist/theme.css +3 -0
  33. package/package.json +8 -8
  34. package/src/agents/AgentModelLabel.tsx +40 -0
  35. package/src/chat/ui/Composer.tsx +12 -3
  36. package/src/chat/ui/Pickers.tsx +4 -1
  37. package/src/chat/ui/PromptEditor.tsx +130 -0
  38. package/src/chat/ui/Timeline.tsx +22 -1
  39. package/src/chat/ui/composer/ComposerControls.tsx +65 -15
  40. package/src/chat/ui/composer/key-handler.ts +3 -9
  41. package/src/chat/ui/composer/prompt-picks.ts +17 -0
  42. package/src/chat/ui/composer/use-composer-menus.ts +18 -275
  43. package/src/chat/ui/composer/use-prompt-menus.ts +341 -0
  44. package/src/chat/ui/index.ts +3 -0
  45. package/src/host-hooks.ts +9 -1
  46. package/src/host.ts +27 -1
  47. package/src/index.ts +2 -0
  48. package/src/locales/en/agent-chat.ts +1 -0
  49. package/src/locales/nl/agent-chat.ts +1 -0
  50. package/src/providers/index.ts +1 -0
  51. package/src/theme.css +3 -0
@@ -1,560 +1,106 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
- import { useEffect, useId, useMemo, useState } from 'react';
2
+ import { useEffect, useState } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { ensureSyntaxTree, syntaxTree } from '@codemirror/language';
5
- import { useChatHost } from '../../../host.js';
6
4
  import { useChatScope } from '../../../scope.js';
7
- import { referenceSuggestions, referenceTokens } from '../../chat-references.js';
8
- import { usableSlashCommands } from '../../guards.js';
9
- import { chipRanges, findMentionQuery, findReferenceQuery, findSkillQuery, insertMention, insertReference, insertSkill, mentionPick, NO_MENTION_SEARCH, queryOutsideChips } from '../../mentions.js';
10
- import { inCode } from './keys.js';
11
- import { clampMenuIndex, composerMenuAria } from './menu-aria.js';
5
+ import { usePromptMenus } from './use-prompt-menus.js';
12
6
  import { useHostReferables } from '../../../host-hooks.js';
13
- const SEARCH_DEBOUNCE_MS = 80;
14
- // What fits above the composer without turning the picker into a file tree.
15
- const MENTION_RESULTS = 8;
16
- const REFERENCE_RESULTS = 8;
17
7
  // Commands the composer handles itself; the CLI's own ones are sent through as text.
18
8
  export const LOCAL_COMMANDS = ['model', 'compact', 'clear'];
19
- function sameQuery(left, right) {
20
- return left?.start === right?.start && left?.query === right?.query;
21
- }
22
- /*
23
- * The pickers over the box: `/` for a command, `$` for a skill, `@` for a file and `#` for a view,
24
- * a node or another chat. One is open at a time, and the arrow keys and the editor's ARIA attributes
25
- * follow that one.
26
- */
9
+ /* The pickers over a chat's composer, fed by what the chat's CLI has: its skills, its commands and its folder. */
27
10
  export function useComposerMenus(t0) {
28
- const $ = _c(110);
11
+ const $ = _c(22);
29
12
  const {
30
13
  chatId,
31
14
  info,
32
15
  capabilities,
33
16
  providerName,
34
- draft: t1,
17
+ draft,
35
18
  inputRef
36
19
  } = t0;
37
- const {
38
- draft,
39
- setDraft,
40
- setText
41
- } = t1;
42
20
  const {
43
21
  t
44
22
  } = useTranslation("agent-chat");
45
23
  const scope = useChatScope();
46
- const host = useChatHost();
47
- const {
48
- searchFiles
49
- } = host;
50
24
  const referables = useHostReferables(scope.id, chatId);
51
- const [menuIndex, setMenuIndex] = useState(0);
52
- const [mention, setMention] = useState(null);
53
- const [referenceQuery, setReferenceQuery] = useState(null);
54
- const [skillQuery, setSkillQuery] = useState(null);
55
- let t2;
25
+ let t1;
56
26
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
57
- t2 = [];
58
- $[0] = t2;
27
+ t1 = [];
28
+ $[0] = t1;
59
29
  } else {
60
- t2 = $[0];
30
+ t1 = $[0];
61
31
  }
62
- const [skills, setSkills] = useState(t2);
63
- const [searched, setSearched] = useState(NO_MENTION_SEARCH);
64
- const text = draft.text;
65
- const goals = capabilities?.goals;
66
- let t3;
67
- if ($[1] !== info.cwd || $[2] !== mention || $[3] !== scope.id || $[4] !== searchFiles) {
68
- t3 = () => {
69
- if (mention === null) {
70
- return;
71
- }
32
+ const [skills, setSkills] = useState(t1);
33
+ let t2;
34
+ if ($[1] !== chatId || $[2] !== scope.chats) {
35
+ t2 = () => {
72
36
  let stale = false;
73
- const search = () => {
74
- if (searchFiles === null) {
75
- return;
76
- }
77
- searchFiles(scope.id, info.cwd, mention.query, MENTION_RESULTS).then(files => {
78
- if (!stale) {
79
- setSearched({
80
- query: mention.query,
81
- files
82
- });
83
- setMenuIndex(0);
84
- }
85
- }).catch(_temp);
86
- };
87
- if (mention.query === "") {
88
- search();
89
- return () => {
90
- stale = true;
91
- };
92
- }
93
- const timer = setTimeout(search, SEARCH_DEBOUNCE_MS);
94
- return () => {
95
- stale = true;
96
- clearTimeout(timer);
97
- };
98
- };
99
- $[1] = info.cwd;
100
- $[2] = mention;
101
- $[3] = scope.id;
102
- $[4] = searchFiles;
103
- $[5] = t3;
104
- } else {
105
- t3 = $[5];
106
- }
107
- let t4;
108
- if ($[6] !== info.cwd || $[7] !== mention || $[8] !== scope || $[9] !== searchFiles) {
109
- t4 = [scope, info.cwd, mention, searchFiles];
110
- $[6] = info.cwd;
111
- $[7] = mention;
112
- $[8] = scope;
113
- $[9] = searchFiles;
114
- $[10] = t4;
115
- } else {
116
- t4 = $[10];
117
- }
118
- useEffect(t3, t4);
119
- let t5;
120
- if ($[11] !== chatId || $[12] !== scope.chats) {
121
- t5 = () => {
122
- let stale_0 = false;
123
37
  scope.chats.listSkills(chatId).then(found => {
124
- if (!stale_0) {
38
+ if (!stale) {
125
39
  setSkills(found);
126
40
  }
127
- }).catch(_temp2);
41
+ }).catch(_temp);
128
42
  return () => {
129
- stale_0 = true;
43
+ stale = true;
130
44
  };
131
45
  };
132
- $[11] = chatId;
133
- $[12] = scope.chats;
134
- $[13] = t5;
135
- } else {
136
- t5 = $[13];
137
- }
138
- let t6;
139
- if ($[14] !== chatId || $[15] !== info.running || $[16] !== info.skills || $[17] !== scope) {
140
- t6 = [scope, chatId, info.skills, info.running];
141
- $[14] = chatId;
142
- $[15] = info.running;
143
- $[16] = info.skills;
144
- $[17] = scope;
145
- $[18] = t6;
46
+ $[1] = chatId;
47
+ $[2] = scope.chats;
48
+ $[3] = t2;
146
49
  } else {
147
- t6 = $[18];
50
+ t2 = $[3];
148
51
  }
149
- useEffect(t5, t6);
52
+ let t3;
53
+ if ($[4] !== chatId || $[5] !== info.running || $[6] !== info.skills || $[7] !== scope) {
54
+ t3 = [scope, chatId, info.skills, info.running];
55
+ $[4] = chatId;
56
+ $[5] = info.running;
57
+ $[6] = info.skills;
58
+ $[7] = scope;
59
+ $[8] = t3;
60
+ } else {
61
+ t3 = $[8];
62
+ }
63
+ useEffect(t2, t3);
64
+ const t4 = capabilities?.mentions === false ? null : info.cwd;
65
+ const t5 = info.slashCommands;
66
+ const t6 = capabilities?.goals !== undefined;
150
67
  let t7;
151
- if ($[19] !== text) {
152
- t7 = text.startsWith("/") && !text.includes("\n") ? text.slice(1).trim().toLowerCase() : null;
153
- $[19] = text;
154
- $[20] = t7;
68
+ if ($[9] !== t) {
69
+ t7 = t("composer.inputLabel");
70
+ $[9] = t;
71
+ $[10] = t7;
155
72
  } else {
156
- t7 = $[20];
73
+ t7 = $[10];
157
74
  }
158
- const commandQuery = t7;
159
75
  let t8;
160
- bb0: {
161
- if (commandQuery === null) {
162
- let t9;
163
- if ($[21] === Symbol.for("react.memo_cache_sentinel")) {
164
- t9 = [];
165
- $[21] = t9;
166
- } else {
167
- t9 = $[21];
168
- }
169
- t8 = t9;
170
- break bb0;
171
- }
172
- let t9;
173
- if ($[22] !== skills) {
174
- t9 = new Set(skills.map(_temp3));
175
- $[22] = skills;
176
- $[23] = t9;
177
- } else {
178
- t9 = $[23];
179
- }
180
- const known = t9;
181
- let t10;
182
- if ($[24] !== commandQuery || $[25] !== goals || $[26] !== info.slashCommands || $[27] !== known || $[28] !== providerName || $[29] !== t) {
183
- const own = LOCAL_COMMANDS.map(name => ({
184
- name,
185
- hint: t(`composer.commands.${name}`),
186
- local: true,
187
- skill: false
188
- }));
189
- const goal = goals === undefined ? [] : [{
190
- name: "goal",
191
- hint: t("composer.commands.goal"),
192
- local: false,
193
- skill: false
194
- }];
195
- const cli = usableSlashCommands(info.slashCommands).filter(name_0 => !LOCAL_COMMANDS.includes(name_0) && (goals === undefined || name_0 !== "goal")).map(name_1 => ({
196
- name: name_1,
197
- hint: known.has(name_1) ? t("composer.commands.skill") : t("composer.commands.cli", {
198
- cli: providerName ?? t("composer.commands.anyCli")
199
- }),
200
- local: false,
201
- skill: known.has(name_1)
202
- }));
203
- t10 = [...own, ...goal, ...cli].filter(command => command.name.startsWith(commandQuery)).slice(0, 8);
204
- $[24] = commandQuery;
205
- $[25] = goals;
206
- $[26] = info.slashCommands;
207
- $[27] = known;
208
- $[28] = providerName;
209
- $[29] = t;
210
- $[30] = t10;
211
- } else {
212
- t10 = $[30];
213
- }
214
- t8 = t10;
215
- }
216
- const commands = t8;
217
- let t9;
218
- bb1: {
219
- if (skillQuery === null) {
220
- let t10;
221
- if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
222
- t10 = [];
223
- $[31] = t10;
224
- } else {
225
- t10 = $[31];
226
- }
227
- t9 = t10;
228
- break bb1;
229
- }
230
- let t10;
231
- if ($[32] !== skillQuery.query || $[33] !== skills) {
232
- const query = skillQuery.query.toLowerCase();
233
- t10 = skills.filter(skill_0 => skill_0.name.toLowerCase().includes(query)).slice(0, 8);
234
- $[32] = skillQuery.query;
235
- $[33] = skills;
236
- $[34] = t10;
237
- } else {
238
- t10 = $[34];
239
- }
240
- t9 = t10;
241
- }
242
- const skillMatches = t9;
243
- const commandMenuOpen = commandQuery !== null && commands.length > 0;
244
- const skillMenuOpen = !commandMenuOpen && skillQuery !== null && skillMatches.length > 0;
245
- const mentionMenuOpen = !commandMenuOpen && !skillMenuOpen && mention !== null;
246
- const files_0 = mention === null ? [] : searched.files;
247
- const mentionCount = files_0.length;
248
- let t10;
249
- if ($[35] !== referables.chatsOnly) {
250
- t10 = item => !referables.chatsOnly || item.kind === "chat";
251
- $[35] = referables.chatsOnly;
252
- $[36] = t10;
253
- } else {
254
- t10 = $[36];
255
- }
256
- const offersReferences = referables.items.some(t10);
257
- const referenceMenuOpen = !commandMenuOpen && !skillMenuOpen && !mentionMenuOpen && referenceQuery !== null && offersReferences;
258
- const referenceMatches = referenceMenuOpen ? referenceSuggestions(referables, referenceQuery.query, [chatId, ...draft.chats, ...draft.references], REFERENCE_RESULTS) : [];
259
- let t11;
260
- if ($[37] !== draft.chats || $[38] !== draft.referenceNames || $[39] !== draft.references || $[40] !== referables.items) {
261
- let t12;
262
- if ($[42] !== referables.items) {
263
- t12 = token => ({
264
- ...token,
265
- kind: referables.items.find(item_0 => item_0.id === token.id)?.kind ?? null
266
- });
267
- $[42] = referables.items;
268
- $[43] = t12;
269
- } else {
270
- t12 = $[43];
271
- }
272
- t11 = referenceTokens([...draft.chats, ...draft.references], referables.items, draft.referenceNames).map(t12);
273
- $[37] = draft.chats;
274
- $[38] = draft.referenceNames;
275
- $[39] = draft.references;
276
- $[40] = referables.items;
277
- $[41] = t11;
278
- } else {
279
- t11 = $[41];
280
- }
281
- const referenceChips = t11;
282
- const listId = useId();
283
- const menuOpen = commandMenuOpen || skillMenuOpen || mentionMenuOpen || referenceMenuOpen;
284
- const menuCount = commandMenuOpen ? commands.length : skillMenuOpen ? skillMatches.length : mentionMenuOpen ? mentionCount : referenceMatches.length;
285
- const activeIndex = clampMenuIndex(menuIndex, menuCount);
286
- const inputAria = composerMenuAria({
287
- label: t("composer.inputLabel"),
288
- listId,
289
- open: menuOpen,
290
- activeIndex,
291
- count: menuCount
292
- });
293
- let t12;
294
- if ($[44] !== capabilities?.mentions || $[45] !== draft.mentions || $[46] !== draft.skills || $[47] !== referenceChips) {
295
- t12 = (value, selection, state) => {
296
- const empty = selection.from === selection.to;
297
- const tree = empty ? ensureSyntaxTree(state, selection.from, 50) ?? syntaxTree(state) : null;
298
- const caret = tree !== null && !inCode(tree, value, selection.from) ? selection.from : null;
299
- const chips = caret === null ? [] : chipRanges(value, draft.mentions, draft.skills, [], referenceChips);
300
- const skill_1 = caret === null ? null : queryOutsideChips(findSkillQuery(value, caret), chips);
301
- setSkillQuery(current => sameQuery(current, skill_1) ? current : skill_1);
302
- const next = caret === null || capabilities?.mentions === false ? null : queryOutsideChips(findMentionQuery(value, caret), chips);
303
- setMention(current_0 => sameQuery(current_0, next) ? current_0 : next);
304
- const reference = caret === null ? null : queryOutsideChips(findReferenceQuery(value, caret), chips);
305
- setReferenceQuery(current_1 => sameQuery(current_1, reference) ? current_1 : reference);
306
- };
307
- $[44] = capabilities?.mentions;
308
- $[45] = draft.mentions;
309
- $[46] = draft.skills;
310
- $[47] = referenceChips;
311
- $[48] = t12;
312
- } else {
313
- t12 = $[48];
314
- }
315
- const trackTriggers = t12;
316
- let t13;
317
- if ($[49] !== inputRef) {
318
- t13 = caret_0 => {
319
- requestAnimationFrame(() => inputRef.current?.setCaret(caret_0));
320
- };
321
- $[49] = inputRef;
322
- $[50] = t13;
323
- } else {
324
- t13 = $[50];
325
- }
326
- const moveCaret = t13;
327
- let t14;
328
- if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
329
- t14 = () => {
330
- setMention(null);
331
- setSkillQuery(null);
332
- setReferenceQuery(null);
333
- };
334
- $[51] = t14;
335
- } else {
336
- t14 = $[51];
337
- }
338
- const close = t14;
339
- let t15;
340
- if ($[52] !== draft.mentions || $[53] !== mention || $[54] !== moveCaret || $[55] !== setText || $[56] !== text) {
341
- t15 = path => {
342
- if (!mention) {
343
- return;
344
- }
345
- const result = insertMention(text, mention, path);
346
- setText(result.text, draft.mentions.includes(path) ? draft.mentions : [...draft.mentions, path]);
347
- setMention(null);
348
- moveCaret(result.caret);
349
- };
350
- $[52] = draft.mentions;
351
- $[53] = mention;
352
- $[54] = moveCaret;
353
- $[55] = setText;
354
- $[56] = text;
355
- $[57] = t15;
356
- } else {
357
- t15 = $[57];
358
- }
359
- const chooseMention = t15;
360
- let t16;
361
- if ($[58] !== chooseMention || $[59] !== mention || $[60] !== searched) {
362
- t16 = index => {
363
- const path_0 = mention === null ? null : mentionPick(index, searched, mention.query);
364
- if (path_0 !== null) {
365
- chooseMention(path_0);
366
- }
367
- };
368
- $[58] = chooseMention;
369
- $[59] = mention;
370
- $[60] = searched;
371
- $[61] = t16;
372
- } else {
373
- t16 = $[61];
374
- }
375
- const chooseMentionAt = t16;
376
- let t17;
377
- if ($[62] !== moveCaret || $[63] !== referenceQuery || $[64] !== setDraft || $[65] !== text) {
378
- t17 = item_1 => {
379
- if (!referenceQuery) {
380
- return;
381
- }
382
- const result_0 = insertReference(text, referenceQuery, item_1.name);
383
- const chat = item_1.kind === "chat";
384
- const add = ids => ids.includes(item_1.id) ? ids : [...ids, item_1.id];
385
- setDraft(current_2 => ({
386
- ...current_2,
387
- text: result_0.text,
388
- chats: chat ? add(current_2.chats) : current_2.chats,
389
- references: chat ? current_2.references : add(current_2.references),
390
- referenceNames: {
391
- ...current_2.referenceNames,
392
- [item_1.id]: item_1.name
393
- }
394
- }));
395
- setReferenceQuery(null);
396
- moveCaret(result_0.caret);
397
- };
398
- $[62] = moveCaret;
399
- $[63] = referenceQuery;
400
- $[64] = setDraft;
401
- $[65] = text;
402
- $[66] = t17;
403
- } else {
404
- t17 = $[66];
405
- }
406
- const chooseReference = t17;
407
- let t18;
408
- if ($[67] !== chooseReference || $[68] !== referenceMatches) {
409
- t18 = index_0 => {
410
- const item_2 = referenceMatches[index_0] ?? referenceMatches[0];
411
- if (item_2 !== undefined) {
412
- chooseReference(item_2);
413
- }
414
- };
415
- $[67] = chooseReference;
416
- $[68] = referenceMatches;
417
- $[69] = t18;
418
- } else {
419
- t18 = $[69];
420
- }
421
- const chooseReferenceAt = t18;
422
- let t19;
423
- if ($[70] !== draft.mentions || $[71] !== draft.skills || $[72] !== moveCaret || $[73] !== setText || $[74] !== skillQuery || $[75] !== text) {
424
- t19 = name_2 => {
425
- const result_1 = skillQuery ? insertSkill(text, skillQuery, name_2) : {
426
- text: `$${name_2} `,
427
- caret: name_2.length + 2
428
- };
429
- setText(result_1.text, draft.mentions, draft.skills.includes(name_2) ? draft.skills : [...draft.skills, name_2]);
430
- setSkillQuery(null);
431
- moveCaret(result_1.caret);
432
- };
433
- $[70] = draft.mentions;
434
- $[71] = draft.skills;
435
- $[72] = moveCaret;
436
- $[73] = setText;
437
- $[74] = skillQuery;
438
- $[75] = text;
439
- $[76] = t19;
440
- } else {
441
- t19 = $[76];
442
- }
443
- const chooseSkill = t19;
444
- let t20;
445
- if ($[77] !== chooseSkill || $[78] !== inputRef || $[79] !== setText) {
446
- t20 = (command_0, index_1) => {
447
- setMenuIndex(index_1);
448
- if (command_0.skill) {
449
- chooseSkill(command_0.name);
450
- return;
451
- }
452
- setText(`/${command_0.name}`);
453
- inputRef.current?.focus();
454
- };
455
- $[77] = chooseSkill;
456
- $[78] = inputRef;
457
- $[79] = setText;
458
- $[80] = t20;
459
- } else {
460
- t20 = $[80];
461
- }
462
- const pickCommand = t20;
463
- let t21;
464
- if ($[81] === Symbol.for("react.memo_cache_sentinel")) {
465
- t21 = (key, count) => {
466
- if (key === "ArrowDown") {
467
- setMenuIndex(i => (i + 1) % count);
468
- return true;
469
- }
470
- if (key === "ArrowUp") {
471
- setMenuIndex(i_0 => (i_0 - 1 + count) % count);
472
- return true;
473
- }
474
- return false;
475
- };
476
- $[81] = t21;
477
- } else {
478
- t21 = $[81];
479
- }
480
- const moveInMenu = t21;
481
- const t22 = skills.length > 0;
482
- let t23;
483
- if ($[82] !== skills) {
484
- t23 = skills.map(_temp4);
485
- $[82] = skills;
486
- $[83] = t23;
487
- } else {
488
- t23 = $[83];
489
- }
490
- let t24;
491
- if ($[84] !== activeIndex || $[85] !== chooseMention || $[86] !== chooseMentionAt || $[87] !== chooseReference || $[88] !== chooseReferenceAt || $[89] !== chooseSkill || $[90] !== commandMenuOpen || $[91] !== commandQuery || $[92] !== commands || $[93] !== files_0 || $[94] !== inputAria || $[95] !== listId || $[96] !== mention || $[97] !== mentionCount || $[98] !== mentionMenuOpen || $[99] !== pickCommand || $[100] !== referables || $[101] !== referenceChips || $[102] !== referenceMatches || $[103] !== referenceMenuOpen || $[104] !== skillMatches || $[105] !== skillMenuOpen || $[106] !== t22 || $[107] !== t23 || $[108] !== trackTriggers) {
492
- t24 = {
493
- listId,
494
- activeIndex,
495
- inputAria,
496
- hasSkills: t22,
497
- skillNames: t23,
498
- commandQuery,
499
- commands,
500
- commandMenuOpen,
501
- skillMatches,
502
- skillMenuOpen,
503
- mention,
504
- mentionMenuOpen,
505
- mentionCount,
506
- files: files_0,
507
- referenceMenuOpen,
508
- referenceMatches,
76
+ if ($[11] !== chatId || $[12] !== draft || $[13] !== info.slashCommands || $[14] !== inputRef || $[15] !== providerName || $[16] !== referables || $[17] !== skills || $[18] !== t4 || $[19] !== t6 || $[20] !== t7) {
77
+ t8 = {
78
+ draft,
79
+ inputRef,
80
+ cwd: t4,
81
+ skills,
82
+ slashCommands: t5,
83
+ localCommands: LOCAL_COMMANDS,
84
+ goals: t6,
85
+ providerName,
509
86
  referables,
510
- referenceChips,
511
- setMenuIndex,
512
- trackTriggers,
513
- close,
514
- chooseMention,
515
- chooseMentionAt,
516
- chooseReference,
517
- chooseReferenceAt,
518
- chooseSkill,
519
- pickCommand,
520
- moveInMenu
87
+ ownId: chatId,
88
+ label: t7
521
89
  };
522
- $[84] = activeIndex;
523
- $[85] = chooseMention;
524
- $[86] = chooseMentionAt;
525
- $[87] = chooseReference;
526
- $[88] = chooseReferenceAt;
527
- $[89] = chooseSkill;
528
- $[90] = commandMenuOpen;
529
- $[91] = commandQuery;
530
- $[92] = commands;
531
- $[93] = files_0;
532
- $[94] = inputAria;
533
- $[95] = listId;
534
- $[96] = mention;
535
- $[97] = mentionCount;
536
- $[98] = mentionMenuOpen;
537
- $[99] = pickCommand;
538
- $[100] = referables;
539
- $[101] = referenceChips;
540
- $[102] = referenceMatches;
541
- $[103] = referenceMenuOpen;
542
- $[104] = skillMatches;
543
- $[105] = skillMenuOpen;
544
- $[106] = t22;
545
- $[107] = t23;
546
- $[108] = trackTriggers;
547
- $[109] = t24;
90
+ $[11] = chatId;
91
+ $[12] = draft;
92
+ $[13] = info.slashCommands;
93
+ $[14] = inputRef;
94
+ $[15] = providerName;
95
+ $[16] = referables;
96
+ $[17] = skills;
97
+ $[18] = t4;
98
+ $[19] = t6;
99
+ $[20] = t7;
100
+ $[21] = t8;
548
101
  } else {
549
- t24 = $[109];
102
+ t8 = $[21];
550
103
  }
551
- return t24;
552
- }
553
- function _temp4(skill_2) {
554
- return skill_2.name;
555
- }
556
- function _temp3(skill) {
557
- return skill.name;
104
+ return usePromptMenus(t8);
558
105
  }
559
- function _temp2() {}
560
106
  function _temp() {}
@@ -0,0 +1,73 @@
1
+ import { type Dispatch, type RefObject, type SetStateAction } from 'react';
2
+ import type { EditorState } from '@codemirror/state';
3
+ import type { ChatSkill } from '@adecore/agent-contracts';
4
+ import { type Referable, type Referables } from '../../chat-references.js';
5
+ import type { ChatDraft } from '../../drafts.js';
6
+ import { type MentionQuery, type TextRange } from '../../mentions.js';
7
+ import type { ComposerInputHandle } from '../ComposerInput.js';
8
+ export type PromptDraft = Pick<ChatDraft, 'text' | 'mentions' | 'skills' | 'chats' | 'references' | 'referenceNames'>;
9
+ export interface PromptDraftBox<D extends PromptDraft> {
10
+ draft: D;
11
+ setDraft: Dispatch<SetStateAction<D>>;
12
+ setText(next: string, mentions?: string[], skills?: string[]): void;
13
+ }
14
+ export interface ComposerCommand {
15
+ name: string;
16
+ hint: string;
17
+ local: boolean;
18
+ skill: boolean;
19
+ }
20
+ export interface PromptMenusInput<D extends PromptDraft> {
21
+ draft: PromptDraftBox<D>;
22
+ inputRef: RefObject<ComposerInputHandle | null>;
23
+ cwd: string | null;
24
+ skills: readonly ChatSkill[];
25
+ slashCommands: readonly string[];
26
+ localCommands?: readonly string[];
27
+ goals: boolean;
28
+ providerName: string | undefined;
29
+ referables: Referables;
30
+ ownId?: string;
31
+ label: string;
32
+ }
33
+ export declare function usePromptMenus<D extends PromptDraft>({ draft: { draft, setDraft, setText }, inputRef, cwd, skills, slashCommands, localCommands, goals, providerName, referables, ownId, label }: PromptMenusInput<D>): {
34
+ listId: string;
35
+ activeIndex: number;
36
+ inputAria: Record<string, string>;
37
+ menuOpen: boolean;
38
+ hasSkills: boolean;
39
+ skillNames: string[];
40
+ commandQuery: string | null;
41
+ commands: ComposerCommand[];
42
+ commandMenuOpen: boolean;
43
+ skillMatches: {
44
+ name: string;
45
+ description: string;
46
+ source: "plugin" | "project" | "user";
47
+ }[];
48
+ skillMenuOpen: boolean;
49
+ mention: MentionQuery | null;
50
+ mentionMenuOpen: boolean;
51
+ mentionCount: number;
52
+ files: string[];
53
+ referenceMenuOpen: boolean;
54
+ referenceMatches: Referable[];
55
+ referables: Referables;
56
+ referenceChips: {
57
+ id: string;
58
+ name: string;
59
+ kind: import("../../index.js").ReferableKind | null;
60
+ }[];
61
+ setMenuIndex: Dispatch<SetStateAction<number>>;
62
+ trackTriggers: (value: string, selection: TextRange, state: EditorState) => void;
63
+ close: () => void;
64
+ chooseMention: (path: string) => void;
65
+ chooseMentionAt: (index: number) => void;
66
+ chooseReference: (item: Referable) => void;
67
+ chooseReferenceAt: (index: number) => void;
68
+ chooseSkill: (name: string) => void;
69
+ pickCommand: (command: ComposerCommand, index: number) => void;
70
+ completeCommand: (command: ComposerCommand) => void;
71
+ moveInMenu: (key: string, count: number) => boolean;
72
+ };
73
+ export type PromptMenus = ReturnType<typeof usePromptMenus>;