@deepseek-harness-tui/dsh-tui 0.20.0 → 0.20.2

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 (180) hide show
  1. package/README.md +18 -3
  2. package/bin/dsh-tui.js +26 -8
  3. package/guide/dsh-tui-guide/claude-backend.en.md +6 -5
  4. package/guide/dsh-tui-guide/claude-backend.md +5 -5
  5. package/guide/dsh-tui-guide/configuration.en.md +26 -12
  6. package/guide/dsh-tui-guide/configuration.md +18 -9
  7. package/guide/dsh-tui-guide/getting-started.en.md +17 -9
  8. package/guide/dsh-tui-guide/getting-started.md +11 -7
  9. package/guide/dsh-tui-guide/interaction.en.md +1 -0
  10. package/guide/dsh-tui-guide/interaction.md +1 -0
  11. package/guide/dsh-tui-guide/migrate.en.md +5 -0
  12. package/guide/dsh-tui-guide/migrate.md +4 -0
  13. package/guide/dsh-tui-guide/plugins.en.md +17 -1
  14. package/guide/dsh-tui-guide/plugins.md +12 -1
  15. package/guide/dsh-tui-guide/themes.en.md +1 -1
  16. package/guide/dsh-tui-guide/themes.md +1 -1
  17. package/guide/dsh-tui-guide/user-guide.en.md +8 -2
  18. package/guide/dsh-tui-guide/user-guide.md +8 -2
  19. package/lib/settings.json +19 -3
  20. package/lib/types/adapter/kernel/host-facade.d.ts +3 -1
  21. package/lib/types/adapter/kernel/host-facade.d.ts.map +1 -1
  22. package/lib/types/adapter/kernel/host-facade.js +6 -0
  23. package/lib/types/adapter/kernel/runtime.d.ts.map +1 -1
  24. package/lib/types/adapter/kernel/runtime.js +5 -0
  25. package/lib/types/adapter/kernel/slices/extensions.d.ts +1 -0
  26. package/lib/types/adapter/kernel/slices/extensions.d.ts.map +1 -1
  27. package/lib/types/adapter/kernel/slices/extensions.js +6 -1
  28. package/lib/types/adapter/kernel/slices/index.d.ts +1 -1
  29. package/lib/types/adapter/kernel/slices/index.d.ts.map +1 -1
  30. package/lib/types/adapter/kernel/slices/index.js +3 -2
  31. package/lib/types/adapter/ports/channel-catalog.d.ts +19 -0
  32. package/lib/types/adapter/ports/channel-catalog.d.ts.map +1 -1
  33. package/lib/types/adapter/ports/channel-settings.d.ts +6 -0
  34. package/lib/types/adapter/ports/channel-settings.d.ts.map +1 -1
  35. package/lib/types/adapter/ports/channel-view.d.ts +28 -2
  36. package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
  37. package/lib/types/adapter/ports/extensions.d.ts +9 -0
  38. package/lib/types/adapter/ports/extensions.d.ts.map +1 -1
  39. package/lib/types/adapter/ports/index.d.ts +1 -1
  40. package/lib/types/adapter/ports/index.d.ts.map +1 -1
  41. package/lib/types/adapter/upstream/extensions-driver.d.ts +4 -1
  42. package/lib/types/adapter/upstream/extensions-driver.d.ts.map +1 -1
  43. package/lib/types/adapter/upstream/extensions-driver.js +111 -1
  44. package/lib/types/adapter/upstream/index.d.ts +1 -1
  45. package/lib/types/adapter/upstream/index.d.ts.map +1 -1
  46. package/lib/types/adapter/upstream/index.js +1 -1
  47. package/lib/types/api.d.ts +1 -1
  48. package/lib/types/api.d.ts.map +1 -1
  49. package/lib/types/backends/claude/backend.d.ts.map +1 -1
  50. package/lib/types/backends/claude/backend.js +7 -2
  51. package/lib/types/backends/claude/session/lifecycle.d.ts.map +1 -1
  52. package/lib/types/backends/claude/session/lifecycle.js +11 -9
  53. package/lib/types/backends/claude/side-query.d.ts +2 -0
  54. package/lib/types/backends/claude/side-query.d.ts.map +1 -1
  55. package/lib/types/backends/claude/side-query.js +30 -13
  56. package/lib/types/components/FileSuggestions.d.ts +2 -2
  57. package/lib/types/components/FileSuggestions.d.ts.map +1 -1
  58. package/lib/types/components/FileSuggestions.js +25 -5
  59. package/lib/types/components/PromptInput.d.ts +7 -1
  60. package/lib/types/components/PromptInput.d.ts.map +1 -1
  61. package/lib/types/components/PromptInput.js +81 -23
  62. package/lib/types/components/messages/AssistantToolUseMessage.d.ts +1 -1
  63. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  64. package/lib/types/components/messages/AssistantToolUseMessage.js +228 -27
  65. package/lib/types/components/messages/presentCardBackground.d.ts +28 -0
  66. package/lib/types/components/messages/presentCardBackground.d.ts.map +1 -0
  67. package/lib/types/components/messages/presentCardBackground.js +23 -0
  68. package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
  69. package/lib/types/dsh-adapter/backend/translate.js +28 -1
  70. package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
  71. package/lib/types/dsh-adapter/channel/core/files.d.ts.map +1 -1
  72. package/lib/types/dsh-adapter/channel/file-actions.d.ts +1 -1
  73. package/lib/types/dsh-adapter/channel/file-actions.d.ts.map +1 -1
  74. package/lib/types/dsh-adapter/channel/file-actions.js +11 -4
  75. package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
  76. package/lib/types/dsh-adapter/channel/settings-host.js +78 -12
  77. package/lib/types/dsh-adapter/channel/state.d.ts +4 -3
  78. package/lib/types/dsh-adapter/channel/state.d.ts.map +1 -1
  79. package/lib/types/dsh-adapter/channel/state.js +4 -3
  80. package/lib/types/dsh-adapter/channel/types.d.ts +1 -1
  81. package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
  82. package/lib/types/dsh-adapter/channel.d.ts +1 -1
  83. package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
  84. package/lib/types/dsh-adapter/childStderr.d.ts +1 -1
  85. package/lib/types/dsh-adapter/childStderr.d.ts.map +1 -1
  86. package/lib/types/dsh-adapter/childStderr.js +5 -0
  87. package/lib/types/dsh-adapter/contract.d.ts +23 -8
  88. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  89. package/lib/types/dsh-adapter/contract.js +27 -7
  90. package/lib/types/dsh-adapter/extensions.d.ts +3 -2
  91. package/lib/types/dsh-adapter/extensions.d.ts.map +1 -1
  92. package/lib/types/dsh-adapter/extensions.js +5 -2
  93. package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
  94. package/lib/types/dsh-adapter/host-contract.js +1 -1
  95. package/lib/types/dsh-adapter/host-dsh.d.ts +4 -0
  96. package/lib/types/dsh-adapter/host-dsh.d.ts.map +1 -1
  97. package/lib/types/dsh-adapter/host-dsh.js +26 -0
  98. package/lib/types/dsh-adapter/host-entry.js +4 -2
  99. package/lib/types/dsh-adapter/host-service-diagnostics.d.ts +61 -0
  100. package/lib/types/dsh-adapter/host-service-diagnostics.d.ts.map +1 -0
  101. package/lib/types/dsh-adapter/host-service-diagnostics.js +103 -0
  102. package/lib/types/dsh-adapter/index.d.ts +5 -0
  103. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  104. package/lib/types/dsh-adapter/index.js +1 -0
  105. package/lib/types/dsh-adapter/mention-providers.d.ts +91 -0
  106. package/lib/types/dsh-adapter/mention-providers.d.ts.map +1 -0
  107. package/lib/types/dsh-adapter/mention-providers.js +214 -0
  108. package/lib/types/dsh-adapter/migrate/entry.d.ts +2 -0
  109. package/lib/types/dsh-adapter/migrate/entry.d.ts.map +1 -0
  110. package/lib/types/dsh-adapter/migrate/entry.js +46 -0
  111. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  112. package/lib/types/dsh-adapter/plugin.js +42 -2
  113. package/lib/types/dsh-adapter/present-tool.d.ts +20 -0
  114. package/lib/types/dsh-adapter/present-tool.d.ts.map +1 -0
  115. package/lib/types/dsh-adapter/present-tool.js +96 -0
  116. package/lib/types/extensions.d.ts +2 -0
  117. package/lib/types/extensions.d.ts.map +1 -1
  118. package/lib/types/extensions.js +4 -1
  119. package/lib/types/i18n.d.ts +21 -2
  120. package/lib/types/i18n.d.ts.map +1 -1
  121. package/lib/types/i18n.js +9 -1
  122. package/lib/types/ink/components/ScrollBox.d.ts.map +1 -1
  123. package/lib/types/ink/components/ScrollBox.js +13 -0
  124. package/lib/types/ink/dom.d.ts +3 -0
  125. package/lib/types/ink/dom.d.ts.map +1 -1
  126. package/lib/types/ink/ink.d.ts.map +1 -1
  127. package/lib/types/ink/ink.js +30 -34
  128. package/lib/types/ink/render-node-to-output.d.ts +3 -0
  129. package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
  130. package/lib/types/ink/render-node-to-output.js +54 -40
  131. package/lib/types/ink/selection.d.ts +38 -28
  132. package/lib/types/ink/selection.d.ts.map +1 -1
  133. package/lib/types/ink/selection.js +201 -130
  134. package/lib/types/kernelPrefs.d.ts +5 -2
  135. package/lib/types/kernelPrefs.d.ts.map +1 -1
  136. package/lib/types/kernelPrefs.js +5 -2
  137. package/lib/types/screens/Chat.d.ts +4 -1
  138. package/lib/types/screens/Chat.d.ts.map +1 -1
  139. package/lib/types/screens/Chat.js +2 -2
  140. package/lib/types/settings/definitions.d.ts +12 -0
  141. package/lib/types/settings/definitions.d.ts.map +1 -1
  142. package/lib/types/settings/definitions.js +10 -2
  143. package/lib/types/theme.d.ts +4 -0
  144. package/lib/types/theme.d.ts.map +1 -1
  145. package/lib/types/theme.js +20 -2
  146. package/lib/types/tuiDisplayPrefs.d.ts +3 -0
  147. package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
  148. package/lib/types/tuiDisplayPrefs.js +10 -0
  149. package/lib/types/update.d.ts +74 -5
  150. package/lib/types/update.d.ts.map +1 -1
  151. package/lib/types/update.js +297 -46
  152. package/lib/types/updateHost.d.ts.map +1 -1
  153. package/lib/types/updateHost.js +16 -5
  154. package/lib/types/usageStats.d.ts +6 -0
  155. package/lib/types/usageStats.d.ts.map +1 -1
  156. package/lib/types/usageStats.js +8 -0
  157. package/lib/types/utils/colorMix.d.ts +19 -0
  158. package/lib/types/utils/colorMix.d.ts.map +1 -0
  159. package/lib/types/utils/colorMix.js +51 -0
  160. package/lib/types/utils/commandLine.d.ts +8 -0
  161. package/lib/types/utils/commandLine.d.ts.map +1 -0
  162. package/lib/types/utils/commandLine.js +37 -0
  163. package/lib/types/utils/desktopEntry.d.ts +32 -0
  164. package/lib/types/utils/desktopEntry.d.ts.map +1 -0
  165. package/lib/types/utils/desktopEntry.js +302 -0
  166. package/lib/types/utils/externalEditor.d.ts +2 -5
  167. package/lib/types/utils/externalEditor.d.ts.map +1 -1
  168. package/lib/types/utils/externalEditor.js +4 -36
  169. package/lib/types/utils/fileSuggestions.d.ts +14 -3
  170. package/lib/types/utils/fileSuggestions.d.ts.map +1 -1
  171. package/lib/types/utils/fileSuggestions.js +33 -0
  172. package/lib/types/utils/openExternal.d.ts +9 -0
  173. package/lib/types/utils/openExternal.d.ts.map +1 -1
  174. package/lib/types/utils/openExternal.js +87 -3
  175. package/lib/types/utils/terminalLaunch.d.ts +16 -0
  176. package/lib/types/utils/terminalLaunch.d.ts.map +1 -0
  177. package/lib/types/utils/terminalLaunch.js +121 -0
  178. package/package.json +116 -110
  179. package/tui-profile/feed/README.md +1 -1
  180. package/tui-profile/feed/first-party.json +1 -1
@@ -126,6 +126,14 @@ const flush = (dir, extraIndex) => {
126
126
  caches.set(dir, next);
127
127
  writeUsage(next, dir);
128
128
  };
129
+ /**
130
+ * 把当前进程缓存的时长补记到账本。供进程被 `execve` 原地替换前调用——
131
+ * `execve` 不触发 JS 的 `exit` 事件,退出钩子不会执行。
132
+ * @param dir - 数据目录(测试可注入)。
133
+ */
134
+ export function flushUsageStats(dir = DATA_DIR) {
135
+ flush(dir);
136
+ }
129
137
  /**
130
138
  * 记一次启动:累计次数 +1、开始计时,并挂上兜底落盘与退出补记。
131
139
  * 同一进程里对同一目录重复调用只生效一次(LogoV2 反复挂载也只 +1)。
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Blend theme colours for derived surfaces. Built-in palettes use the
3
+ * `rgb(r,g,b)` strings `rgb()` produces; user themes may use hex. ANSI-named
4
+ * colours (`ansi:blackBright`) cannot be mixed and come back unchanged so the
5
+ * caller keeps the palette's own surface instead of inventing one.
6
+ */
7
+ /**
8
+ * Blend `overlay` into `base` by `amount` (0–1); a colour the parser does not
9
+ * understand wins as-is.
10
+ * @param base - Palette colour the surface starts from.
11
+ * @param overlay - Tint colour.
12
+ * @param amount - Tint strength, clamped to 0–1.
13
+ */
14
+ export declare function mixColor(base: string, overlay: string, amount: number): string;
15
+ /** Nudge a colour toward white, preserving its hue (hover faces). */
16
+ export declare function lightenColor(color: string, amount: number): string;
17
+ /** sRGB luma (Rec. 601), or undefined when the colour cannot be parsed. */
18
+ export declare function colorLuma(color: string): number | undefined;
19
+ //# sourceMappingURL=colorMix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorMix.d.ts","sourceRoot":"","sources":["../../../src/utils/colorMix.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsBH;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQ9E;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG3D"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Blend theme colours for derived surfaces. Built-in palettes use the
3
+ * `rgb(r,g,b)` strings `rgb()` produces; user themes may use hex. ANSI-named
4
+ * colours (`ansi:blackBright`) cannot be mixed and come back unchanged so the
5
+ * caller keeps the palette's own surface instead of inventing one.
6
+ */
7
+ const RGB = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/u;
8
+ const HEX = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/iu;
9
+ function parse(color) {
10
+ const rgb = RGB.exec(color);
11
+ if (rgb !== null)
12
+ return [Number(rgb[1]), Number(rgb[2]), Number(rgb[3])];
13
+ const hex = HEX.exec(color);
14
+ if (hex === null)
15
+ return undefined;
16
+ const digits = hex[1];
17
+ if (digits.length === 3) {
18
+ const expand = (digit) => Number.parseInt(digit + digit, 16);
19
+ return [expand(digits[0]), expand(digits[1]), expand(digits[2])];
20
+ }
21
+ // The theme contract accepts #rrggbbaa with the alpha ignored.
22
+ const value = Number.parseInt(digits.slice(0, 6), 16);
23
+ return [(value >> 16) & 255, (value >> 8) & 255, value & 255];
24
+ }
25
+ const channel = (value) => Math.max(0, Math.min(255, Math.round(value)));
26
+ /**
27
+ * Blend `overlay` into `base` by `amount` (0–1); a colour the parser does not
28
+ * understand wins as-is.
29
+ * @param base - Palette colour the surface starts from.
30
+ * @param overlay - Tint colour.
31
+ * @param amount - Tint strength, clamped to 0–1.
32
+ */
33
+ export function mixColor(base, overlay, amount) {
34
+ const from = parse(base);
35
+ const to = parse(overlay);
36
+ if (from === undefined || to === undefined)
37
+ return base;
38
+ const alpha = Math.max(0, Math.min(1, amount));
39
+ return `rgb(${channel(from[0] * (1 - alpha) + to[0] * alpha)},`
40
+ + `${channel(from[1] * (1 - alpha) + to[1] * alpha)},`
41
+ + `${channel(from[2] * (1 - alpha) + to[2] * alpha)})`;
42
+ }
43
+ /** Nudge a colour toward white, preserving its hue (hover faces). */
44
+ export function lightenColor(color, amount) {
45
+ return mixColor(color, 'rgb(255,255,255)', amount);
46
+ }
47
+ /** sRGB luma (Rec. 601), or undefined when the colour cannot be parsed. */
48
+ export function colorLuma(color) {
49
+ const rgb = parse(color);
50
+ return rgb === undefined ? undefined : 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2];
51
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Split a shell-style command line into argv, honoring single/double quotes.
3
+ * Shared by the external-editor (`$VISUAL`/`$EDITOR`) and terminal-launch
4
+ * (`$TERMINAL`) paths, so a value like `code --wait`, `"C:\Program Files\
5
+ * nvim.exe" -f`, or `kitty -1` splits the same way.
6
+ */
7
+ export declare function splitCommandLine(commandLine: string): string[];
8
+ //# sourceMappingURL=commandLine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandLine.d.ts","sourceRoot":"","sources":["../../../src/utils/commandLine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CA0B9D"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Split a shell-style command line into argv, honoring single/double quotes.
3
+ * Shared by the external-editor (`$VISUAL`/`$EDITOR`) and terminal-launch
4
+ * (`$TERMINAL`) paths, so a value like `code --wait`, `"C:\Program Files\
5
+ * nvim.exe" -f`, or `kitty -1` splits the same way.
6
+ */
7
+ export function splitCommandLine(commandLine) {
8
+ const args = [];
9
+ let current = '';
10
+ let quote = null;
11
+ let hasToken = false;
12
+ for (const ch of commandLine) {
13
+ if (quote !== null) {
14
+ if (ch === quote)
15
+ quote = null;
16
+ else
17
+ current += ch;
18
+ continue;
19
+ }
20
+ if (ch === '"' || ch === "'") {
21
+ quote = ch;
22
+ hasToken = true;
23
+ continue;
24
+ }
25
+ if (/\s/.test(ch)) {
26
+ if (current !== '' || hasToken)
27
+ args.push(current);
28
+ current = '';
29
+ hasToken = false;
30
+ continue;
31
+ }
32
+ current += ch;
33
+ }
34
+ if (current !== '' || hasToken)
35
+ args.push(current);
36
+ return args;
37
+ }
@@ -0,0 +1,32 @@
1
+ /** One parsed `[Desktop Entry]` group. */
2
+ export interface DesktopEntry {
3
+ readonly id: string;
4
+ readonly path: string;
5
+ readonly exec: string;
6
+ readonly terminal: boolean;
7
+ readonly hidden: boolean;
8
+ readonly name?: string;
9
+ readonly tryExec?: string;
10
+ readonly workingDirectory?: string;
11
+ }
12
+ /**
13
+ * Parse the `[Desktop Entry]` group of a desktop file. Returns undefined when
14
+ * the group is missing or carries no `Exec=` line (a hidden entry with an Exec
15
+ * is still returned; callers check {@link DesktopEntry.hidden}). `locale`
16
+ * selects a `Name[locale]` variant for the `%c` field code.
17
+ */
18
+ export declare function parseDesktopEntry(text: string, id: string, path: string, locale?: string | undefined): DesktopEntry | undefined;
19
+ /**
20
+ * Resolve a desktop-file ID to its path under `$XDG_DATA_HOME` /
21
+ * `$XDG_DATA_DIRS`. IDs containing path separators or `..` are rejected, so a
22
+ * value coming from `xdg-mime` cannot escape the applications directories.
23
+ */
24
+ export declare function findDesktopEntry(id: string, env?: NodeJS.ProcessEnv): string | undefined;
25
+ /**
26
+ * Expand a desktop entry's `Exec` line for one target. Following the generic
27
+ * `xdg-open` path, append the target only when no file, URL, `%c` or `%i`
28
+ * substitution occurred. Returns undefined for malformed quoting or an
29
+ * unknown field code, so the caller can fall back to `xdg-open`.
30
+ */
31
+ export declare function expandExec(exec: string, target: string, entry: DesktopEntry): string[] | undefined;
32
+ //# sourceMappingURL=desktopEntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"desktopEntry.d.ts","sourceRoot":"","sources":["../../../src/utils/desktopEntry.ts"],"names":[],"mappings":"AAuBA,0CAA0C;AAC1C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACnC;AAsDD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,MAAM,GAAG,SAA6E,GAC7F,YAAY,GAAG,SAAS,CAsC1B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,GAAG,SAAS,CAmBrG;AAoHD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,EAAE,GAAG,SAAS,CAalG"}
@@ -0,0 +1,302 @@
1
+ /**
2
+ * Minimal XDG desktop-entry support for the Linux "open with the default
3
+ * handler" path. The generic `xdg-open` path executes an entry's `Exec`
4
+ * without a `Terminal=true` wrapper, so a terminal application such as
5
+ * `vim.desktop` is spawned with the TUI's non-tty stdio and exits at once.
6
+ * This module supplies the missing pieces:
7
+ *
8
+ * - locate an entry by desktop-file ID (`vim.desktop`) in the XDG data dirs,
9
+ * including the legacy `vendor-app.desktop` → `vendor/app.desktop` form;
10
+ * - parse the `[Desktop Entry]` group (`Exec`, `Terminal`, `Hidden`,
11
+ * `TryExec`, `Name`, `Path`), ignoring `[Desktop Action …]` groups;
12
+ * - expand the Exec field codes for one target path (`%f`/`%F`/`%u`/`%U`,
13
+ * `%%`, `%c`, `%k`; `%i` is dropped because a terminal app has no icon).
14
+ *
15
+ * Deliberately narrower than the full desktop-entry spec: unknown field codes
16
+ * and malformed quoting return `undefined`, and the caller falls back to
17
+ * `xdg-open` rather than guessing.
18
+ */
19
+ import { statSync } from 'node:fs';
20
+ import { homedir } from 'node:os';
21
+ import { join } from 'node:path';
22
+ import { pathToFileURL } from 'node:url';
23
+ const DEFAULT_DATA_DIRS = '/usr/local/share:/usr/share';
24
+ function isFile(path) {
25
+ try {
26
+ return statSync(path).isFile();
27
+ }
28
+ catch {
29
+ return false;
30
+ }
31
+ }
32
+ /** Unescape the desktop-entry string escapes (`\s`, `\n`, `\t`, `\r`, `\\`). */
33
+ function unescapeDesktopValue(value) {
34
+ let out = '';
35
+ for (let i = 0; i < value.length; i++) {
36
+ const ch = value[i];
37
+ if (ch !== '\\') {
38
+ out += ch;
39
+ continue;
40
+ }
41
+ const next = value[i + 1];
42
+ if (next === undefined) {
43
+ out += '\\';
44
+ continue;
45
+ }
46
+ i++;
47
+ switch (next) {
48
+ case 's':
49
+ out += ' ';
50
+ break;
51
+ case 'n':
52
+ out += '\n';
53
+ break;
54
+ case 't':
55
+ out += '\t';
56
+ break;
57
+ case 'r':
58
+ out += '\r';
59
+ break;
60
+ default:
61
+ out += next;
62
+ break;
63
+ }
64
+ }
65
+ return out;
66
+ }
67
+ /** Pick `Name[locale]` (with a language fallback) before the unlocalized Name. */
68
+ function localizedName(values, locale) {
69
+ const fallback = values.get('Name');
70
+ if (locale === undefined || locale.trim() === '')
71
+ return fallback;
72
+ const base = locale.trim().split('.')[0];
73
+ if (base === undefined || base === '')
74
+ return fallback;
75
+ const normalized = base.replace('-', '_');
76
+ const language = normalized.split('_')[0];
77
+ for (const candidate of [normalized, normalized.replace('_', '-'), language]) {
78
+ if (candidate === undefined || candidate === '')
79
+ continue;
80
+ const value = values.get(`Name[${candidate}]`);
81
+ if (value !== undefined && value !== '')
82
+ return value;
83
+ }
84
+ return fallback;
85
+ }
86
+ /**
87
+ * Parse the `[Desktop Entry]` group of a desktop file. Returns undefined when
88
+ * the group is missing or carries no `Exec=` line (a hidden entry with an Exec
89
+ * is still returned; callers check {@link DesktopEntry.hidden}). `locale`
90
+ * selects a `Name[locale]` variant for the `%c` field code.
91
+ */
92
+ export function parseDesktopEntry(text, id, path, locale = process.env.LC_ALL ?? process.env.LC_MESSAGES ?? process.env.LANG) {
93
+ const values = new Map();
94
+ let inEntry = false;
95
+ let foundEntry = false;
96
+ for (const raw of text.split(/\r?\n/)) {
97
+ const line = raw.trim();
98
+ if (line === '' || line.startsWith('#'))
99
+ continue;
100
+ if (line.startsWith('[') && line.endsWith(']')) {
101
+ const group = line.slice(1, -1);
102
+ if (group === 'Desktop Entry') {
103
+ inEntry = true;
104
+ foundEntry = true;
105
+ continue;
106
+ }
107
+ if (inEntry)
108
+ break;
109
+ continue;
110
+ }
111
+ if (!inEntry)
112
+ continue;
113
+ const eq = line.indexOf('=');
114
+ if (eq <= 0)
115
+ continue;
116
+ values.set(line.slice(0, eq).trim(), unescapeDesktopValue(line.slice(eq + 1).trim()));
117
+ }
118
+ if (!foundEntry)
119
+ return undefined;
120
+ const exec = values.get('Exec') ?? '';
121
+ if (exec === '')
122
+ return undefined;
123
+ const name = localizedName(values, locale);
124
+ const tryExec = values.get('TryExec');
125
+ const workingDirectory = values.get('Path');
126
+ return {
127
+ id,
128
+ path,
129
+ exec,
130
+ terminal: (values.get('Terminal') ?? '').trim().toLowerCase() === 'true',
131
+ hidden: (values.get('Hidden') ?? '').trim().toLowerCase() === 'true',
132
+ ...(name === undefined ? {} : { name }),
133
+ ...(tryExec === undefined ? {} : { tryExec }),
134
+ ...(workingDirectory === undefined || workingDirectory === '' ? {} : { workingDirectory }),
135
+ };
136
+ }
137
+ /**
138
+ * Resolve a desktop-file ID to its path under `$XDG_DATA_HOME` /
139
+ * `$XDG_DATA_DIRS`. IDs containing path separators or `..` are rejected, so a
140
+ * value coming from `xdg-mime` cannot escape the applications directories.
141
+ */
142
+ export function findDesktopEntry(id, env = process.env) {
143
+ const trimmed = id.trim();
144
+ if (trimmed === '' || trimmed.includes('/') || trimmed.includes('\\') || trimmed.includes('..'))
145
+ return undefined;
146
+ const names = trimmed.endsWith('.desktop') ? [trimmed] : [trimmed, `${trimmed}.desktop`];
147
+ const candidates = [];
148
+ for (const name of names) {
149
+ candidates.push(name);
150
+ if (name.includes('-'))
151
+ candidates.push(name.replace('-', '/'), name.replace(/-/g, '/'));
152
+ }
153
+ const dataHome = env.XDG_DATA_HOME?.trim() || join(env.HOME?.trim() || homedir(), '.local', 'share');
154
+ const dataDirs = (env.XDG_DATA_DIRS?.trim() || DEFAULT_DATA_DIRS).split(':');
155
+ for (const root of [dataHome, ...dataDirs]) {
156
+ if (root === '')
157
+ continue;
158
+ for (const candidate of candidates) {
159
+ const path = join(root, 'applications', candidate);
160
+ if (isFile(path))
161
+ return path;
162
+ }
163
+ }
164
+ return undefined;
165
+ }
166
+ /**
167
+ * Split an Exec line into tokens. Handles the desktop-entry quoting subset:
168
+ * double quotes group an argument and backslash escapes the next character;
169
+ * single quotes are ordinary characters, matching the spec.
170
+ */
171
+ function tokenizeExec(exec) {
172
+ const tokens = [];
173
+ let current = '';
174
+ let quoted = false;
175
+ let hasToken = false;
176
+ for (let i = 0; i < exec.length; i++) {
177
+ const ch = exec[i];
178
+ if (quoted) {
179
+ if (ch === '\\') {
180
+ const next = exec[i + 1];
181
+ if (next === undefined)
182
+ return undefined;
183
+ i++;
184
+ current += next;
185
+ }
186
+ else if (ch === '"') {
187
+ quoted = false;
188
+ }
189
+ else {
190
+ current += ch;
191
+ }
192
+ continue;
193
+ }
194
+ if (ch === '"') {
195
+ quoted = true;
196
+ hasToken = true;
197
+ continue;
198
+ }
199
+ if (ch === ' ' || ch === '\t') {
200
+ if (hasToken) {
201
+ tokens.push(current);
202
+ current = '';
203
+ hasToken = false;
204
+ }
205
+ continue;
206
+ }
207
+ if (ch === '\\') {
208
+ const next = exec[i + 1];
209
+ if (next === undefined) {
210
+ current += '\\';
211
+ }
212
+ else {
213
+ i++;
214
+ current += next;
215
+ }
216
+ hasToken = true;
217
+ continue;
218
+ }
219
+ current += ch;
220
+ hasToken = true;
221
+ }
222
+ if (quoted)
223
+ return undefined;
224
+ if (hasToken)
225
+ tokens.push(current);
226
+ return tokens;
227
+ }
228
+ /** Expand one Exec token; undefined means "unsupported, fall back". */
229
+ function expandToken(token, target, uri, entry, state) {
230
+ let out = '';
231
+ for (let i = 0; i < token.length; i++) {
232
+ const ch = token[i];
233
+ if (ch !== '%') {
234
+ out += ch;
235
+ continue;
236
+ }
237
+ const code = token[i + 1];
238
+ if (code === undefined)
239
+ return undefined;
240
+ i++;
241
+ switch (code) {
242
+ case '%':
243
+ out += '%';
244
+ break;
245
+ case 'f':
246
+ case 'F':
247
+ out += target;
248
+ state.replaced = true;
249
+ break;
250
+ case 'u':
251
+ case 'U':
252
+ out += uri;
253
+ state.replaced = true;
254
+ break;
255
+ case 'c':
256
+ out += entry.name ?? '';
257
+ state.replaced = true;
258
+ break;
259
+ case 'k':
260
+ out += entry.path;
261
+ break;
262
+ case 'i':
263
+ state.replaced = true;
264
+ break;
265
+ // Deprecated field codes are dropped rather than executed literally.
266
+ case 'd':
267
+ case 'D':
268
+ case 'n':
269
+ case 'N':
270
+ case 'v':
271
+ case 'm':
272
+ break;
273
+ default:
274
+ return undefined;
275
+ }
276
+ }
277
+ return out;
278
+ }
279
+ /**
280
+ * Expand a desktop entry's `Exec` line for one target. Following the generic
281
+ * `xdg-open` path, append the target only when no file, URL, `%c` or `%i`
282
+ * substitution occurred. Returns undefined for malformed quoting or an
283
+ * unknown field code, so the caller can fall back to `xdg-open`.
284
+ */
285
+ export function expandExec(exec, target, entry) {
286
+ const tokens = tokenizeExec(exec);
287
+ if (tokens === undefined)
288
+ return undefined;
289
+ const uri = pathToFileURL(target).href;
290
+ const state = { replaced: false };
291
+ const argv = [];
292
+ for (const token of tokens) {
293
+ const expanded = expandToken(token, target, uri, entry, state);
294
+ if (expanded === undefined)
295
+ return undefined;
296
+ if (expanded !== '' || token === '')
297
+ argv.push(expanded);
298
+ }
299
+ if (!state.replaced)
300
+ argv.push(target);
301
+ return argv.length === 0 ? undefined : argv;
302
+ }
@@ -54,11 +54,8 @@ export type EditorOutcome = {
54
54
  kind: 'failed';
55
55
  message: string;
56
56
  };
57
- /**
58
- * Split an `$EDITOR`-style command line into argv, honoring single/double
59
- * quotes (`code --wait`, `"C:\Program Files\...\nvim.exe" -f`).
60
- */
61
- export declare function splitEditorCommand(commandLine: string): string[];
57
+ /** `$EDITOR`-style command-line splitting (shared with the terminal launcher). */
58
+ export { splitCommandLine as splitEditorCommand } from './commandLine.js';
62
59
  /**
63
60
  * Resolve the editor argv from the environment. `$VISUAL` wins over
64
61
  * `$EDITOR` (readline convention); when neither is set there is no fallback
@@ -1 +1 @@
1
- {"version":3,"file":"externalEditor.d.ts","sourceRoot":"","sources":["../../../src/utils/externalEditor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;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AAM,aAAa,GACrB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvC,kFAAkF;AAClF,OAAO,EAAE,gBAAgB,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAEzE;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,EAAE,GAAG,SAAS,CAOtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAqBtC;AAKD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAA;CAAE,CAalD;AA8CD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAsDhF"}
@@ -39,42 +39,10 @@ import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
39
39
  import { tmpdir } from 'node:os';
40
40
  import { delimiter, join, win32 } from 'node:path';
41
41
  import instances from '../ink/instances.js';
42
+ import { splitCommandLine } from './commandLine.js';
42
43
  import { cmdEscapeArgument, cmdEscapeCommand } from './shellQuote.js';
43
- /**
44
- * Split an `$EDITOR`-style command line into argv, honoring single/double
45
- * quotes (`code --wait`, `"C:\Program Files\...\nvim.exe" -f`).
46
- */
47
- export function splitEditorCommand(commandLine) {
48
- const args = [];
49
- let current = '';
50
- let quote = null;
51
- let hasToken = false;
52
- for (const ch of commandLine) {
53
- if (quote !== null) {
54
- if (ch === quote)
55
- quote = null;
56
- else
57
- current += ch;
58
- continue;
59
- }
60
- if (ch === '"' || ch === "'") {
61
- quote = ch;
62
- hasToken = true;
63
- continue;
64
- }
65
- if (/\s/.test(ch)) {
66
- if (current !== '' || hasToken)
67
- args.push(current);
68
- current = '';
69
- hasToken = false;
70
- continue;
71
- }
72
- current += ch;
73
- }
74
- if (current !== '' || hasToken)
75
- args.push(current);
76
- return args;
77
- }
44
+ /** `$EDITOR`-style command-line splitting (shared with the terminal launcher). */
45
+ export { splitCommandLine as splitEditorCommand } from './commandLine.js';
78
46
  /**
79
47
  * Resolve the editor argv from the environment. `$VISUAL` wins over
80
48
  * `$EDITOR` (readline convention); when neither is set there is no fallback
@@ -83,7 +51,7 @@ export function splitEditorCommand(commandLine) {
83
51
  export function resolveEditorCommand(env = process.env) {
84
52
  const raw = (env.VISUAL ?? '').trim() || (env.EDITOR ?? '').trim();
85
53
  if (raw !== '') {
86
- const args = splitEditorCommand(raw);
54
+ const args = splitCommandLine(raw);
87
55
  return args.length > 0 ? args : undefined;
88
56
  }
89
57
  return undefined;
@@ -1,5 +1,5 @@
1
- import type { FileCandidate } from '../adapter/ports/channel-catalog.js';
2
- export type { FileCandidate, FileCandidateKind } from '../adapter/ports/channel-catalog.js';
1
+ import type { FileCandidate, MentionCandidate, ProvidedMentionCandidate } from '../adapter/ports/channel-catalog.js';
2
+ export type { FileCandidate, FileCandidateKind, MentionCandidate, ProvidedMentionCandidate } from '../adapter/ports/channel-catalog.js';
3
3
  export interface FileSuggestionOptions {
4
4
  topK?: number;
5
5
  maxFiles?: number;
@@ -8,5 +8,16 @@ export interface FileSuggestionOptions {
8
8
  export declare function isPathLikeQuery(query: string): boolean;
9
9
  export declare function fuzzySubsequenceScore(query: string, candidate: string): number | undefined;
10
10
  export declare function rankFileCandidates(candidates: readonly FileCandidate[], query: string, topK?: number): FileCandidate[];
11
- export declare function preserveSelection(previous: FileCandidate | undefined, next: readonly FileCandidate[], fallback?: number): number;
11
+ /**
12
+ * Merge plugin provider rows (tuiMentions) into the ranked file list. Files
13
+ * keep their order; a provider row is scored with the same fuzzy scorer on
14
+ * its label and placed before the first file it outscores (a tie goes to the
15
+ * file), and rows whose label does not match `query` follow in provider order.
16
+ * Returns `files` itself when there is nothing to merge, so a host without
17
+ * providers renders the file-only list unchanged.
18
+ */
19
+ export declare function mergeMentionCandidates(files: readonly FileCandidate[], provided: readonly ProvidedMentionCandidate[], query: string): readonly MentionCandidate[];
20
+ export declare function preserveSelection<T extends {
21
+ readonly id: string;
22
+ }>(previous: T | undefined, next: readonly T[], fallback?: number): number;
12
23
  //# sourceMappingURL=fileSuggestions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileSuggestions.d.ts","sourceRoot":"","sources":["../../../src/utils/fileSuggestions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAqB,MAAM,qCAAqC,CAAA;AAC3F,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAA;AAG3F,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAID,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAiB1F;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,SAA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CAMtI"}
@@ -30,6 +30,39 @@ export function rankFileCandidates(candidates, query, topK = 50) {
30
30
  .sort((a, b) => b.score - a.score || a.kind.localeCompare(b.kind) || a.path.localeCompare(b.path));
31
31
  return ranked.slice(0, Math.max(0, topK));
32
32
  }
33
+ /**
34
+ * Merge plugin provider rows (tuiMentions) into the ranked file list. Files
35
+ * keep their order; a provider row is scored with the same fuzzy scorer on
36
+ * its label and placed before the first file it outscores (a tie goes to the
37
+ * file), and rows whose label does not match `query` follow in provider order.
38
+ * Returns `files` itself when there is nothing to merge, so a host without
39
+ * providers renders the file-only list unchanged.
40
+ */
41
+ export function mergeMentionCandidates(files, provided, query) {
42
+ if (provided.length === 0)
43
+ return files;
44
+ const scored = provided.map((candidate, order) => ({
45
+ candidate,
46
+ order,
47
+ score: fuzzySubsequenceScore(query, candidate.label) ?? -Infinity,
48
+ }));
49
+ const matched = scored
50
+ .filter(entry => Number.isFinite(entry.score))
51
+ .sort((a, b) => b.score - a.score || a.order - b.order);
52
+ const merged = [];
53
+ let next = 0;
54
+ for (const file of files) {
55
+ while (next < matched.length && matched[next].score > file.score)
56
+ merged.push(matched[next++].candidate);
57
+ merged.push(file);
58
+ }
59
+ while (next < matched.length)
60
+ merged.push(matched[next++].candidate);
61
+ for (const entry of scored)
62
+ if (!Number.isFinite(entry.score))
63
+ merged.push(entry.candidate);
64
+ return merged;
65
+ }
33
66
  export function preserveSelection(previous, next, fallback = 0) {
34
67
  if (previous) {
35
68
  const index = next.findIndex(candidate => candidate.id === previous.id);
@@ -33,6 +33,15 @@ export declare function buildWin32OpenSpawn(target: string): {
33
33
  verbatim: boolean;
34
34
  detach: boolean;
35
35
  };
36
+ /**
37
+ * Resolve a local file's default handler and, when it is `Terminal=true`,
38
+ * build the terminal-wrapped spawn descriptor. Exported for the regression
39
+ * script; `undefined` means "keep using xdg-open".
40
+ */
41
+ export declare function resolveLinuxFileOpen(target: string, env?: NodeJS.ProcessEnv): Promise<{
42
+ file: string;
43
+ args: string[];
44
+ } | undefined>;
36
45
  /** Open a URL, file or directory with the platform's default handler. */
37
46
  export declare function openExternal(target: string): void;
38
47
  /** Open a file with its associated application (openExternal with a file). */
@@ -1 +1 @@
1
- {"version":3,"file":"openExternal.d.ts","sourceRoot":"","sources":["../../../src/utils/openExternal.ts"],"names":[],"mappings":"AAgEA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,IAAI,CAAA;CAAE,CAQnH;AAED;;gDAEgD;AAChD,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAMnD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAWxH;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAqBjD;AAED,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAgB1D"}
1
+ {"version":3,"file":"openExternal.d.ts","sourceRoot":"","sources":["../../../src/utils/openExternal.ts"],"names":[],"mappings":"AA6EA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,IAAI,CAAA;CAAE,CAQ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