@wonderwhy-er/desktop-commander 0.2.38 → 0.2.40

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 (263) hide show
  1. package/README.md +53 -2
  2. package/dist/handlers/filesystem-handlers.d.ts +5 -0
  3. package/dist/handlers/filesystem-handlers.js +14 -2
  4. package/dist/remote-device/desktop-commander-integration.js +1 -1
  5. package/dist/search-manager.js +31 -38
  6. package/dist/server.js +9 -4
  7. package/dist/terminal-manager.js +4 -2
  8. package/dist/tools/edit.js +34 -1
  9. package/dist/tools/filesystem.js +91 -3
  10. package/dist/tools/improved-process-tools.js +2 -1
  11. package/dist/ui/config-editor/config-editor-runtime.js +65 -14096
  12. package/dist/ui/config-editor/styles.css +2 -1
  13. package/dist/ui/file-preview/preview-runtime.js +435 -26533
  14. package/dist/ui/file-preview/shared/preview-file-types.d.ts +1 -1
  15. package/dist/ui/file-preview/src/app.d.ts +1 -5
  16. package/dist/ui/file-preview/src/app.js +384 -534
  17. package/dist/ui/file-preview/src/components/markdown-renderer.js +47 -9
  18. package/dist/ui/file-preview/src/directory-controller.d.ts +8 -0
  19. package/dist/ui/file-preview/src/directory-controller.js +233 -0
  20. package/dist/ui/file-preview/src/document-layout.d.ts +20 -0
  21. package/dist/ui/file-preview/src/document-layout.js +109 -0
  22. package/dist/ui/file-preview/src/document-outline.d.ts +17 -0
  23. package/dist/ui/file-preview/src/document-outline.js +97 -0
  24. package/dist/ui/file-preview/src/document-workspace.d.ts +19 -0
  25. package/dist/ui/file-preview/src/document-workspace.js +33 -0
  26. package/dist/ui/file-preview/src/file-type-handlers.d.ts +10 -0
  27. package/dist/ui/file-preview/src/file-type-handlers.js +98 -0
  28. package/dist/ui/file-preview/src/host/external-actions.d.ts +19 -0
  29. package/dist/ui/file-preview/src/host/external-actions.js +94 -0
  30. package/dist/ui/file-preview/src/host/selection-context.d.ts +9 -0
  31. package/dist/ui/file-preview/src/host/selection-context.js +106 -0
  32. package/dist/ui/file-preview/src/markdown/conflict-dialog.d.ts +40 -0
  33. package/dist/ui/file-preview/src/markdown/conflict-dialog.js +163 -0
  34. package/dist/ui/file-preview/src/markdown/controller.d.ts +44 -0
  35. package/dist/ui/file-preview/src/markdown/controller.js +1040 -0
  36. package/dist/ui/file-preview/src/markdown/editor.d.ts +131 -0
  37. package/dist/ui/file-preview/src/markdown/editor.js +1479 -0
  38. package/dist/ui/file-preview/src/markdown/linking.d.ts +16 -0
  39. package/dist/ui/file-preview/src/markdown/linking.js +228 -0
  40. package/dist/ui/file-preview/src/markdown/outline.d.ts +2 -0
  41. package/dist/ui/file-preview/src/markdown/outline.js +16 -0
  42. package/dist/ui/file-preview/src/markdown/parser.d.ts +30 -0
  43. package/dist/ui/file-preview/src/markdown/parser.js +38 -0
  44. package/dist/ui/file-preview/src/markdown/preview.d.ts +1 -0
  45. package/dist/ui/file-preview/src/markdown/preview.js +20 -0
  46. package/dist/ui/file-preview/src/markdown/slugify.d.ts +3 -0
  47. package/dist/ui/file-preview/src/markdown/slugify.js +31 -0
  48. package/dist/ui/file-preview/src/markdown/utils.d.ts +1 -0
  49. package/dist/ui/file-preview/src/markdown/utils.js +15 -0
  50. package/dist/ui/file-preview/src/model.d.ts +35 -0
  51. package/dist/ui/file-preview/src/panel-actions.d.ts +17 -0
  52. package/dist/ui/file-preview/src/panel-actions.js +182 -0
  53. package/dist/ui/file-preview/src/path-utils.d.ts +6 -0
  54. package/dist/ui/file-preview/src/path-utils.js +64 -0
  55. package/dist/ui/file-preview/src/payload-utils.d.ts +11 -0
  56. package/dist/ui/file-preview/src/payload-utils.js +94 -0
  57. package/dist/ui/file-preview/styles.css +1066 -233
  58. package/dist/ui/shared/widget-state.d.ts +6 -1
  59. package/dist/ui/shared/widget-state.js +102 -4
  60. package/dist/utils/capture.js +1 -1
  61. package/dist/utils/files/base.d.ts +2 -0
  62. package/dist/utils/open-browser.js +1 -1
  63. package/dist/utils/toolHistory.d.ts +13 -0
  64. package/dist/utils/toolHistory.js +65 -0
  65. package/dist/version.d.ts +1 -1
  66. package/dist/version.js +1 -1
  67. package/package.json +12 -1
  68. package/dist/data/spec-kit-prompts.json +0 -123
  69. package/dist/handlers/macos-control-handlers.d.ts +0 -16
  70. package/dist/handlers/macos-control-handlers.js +0 -81
  71. package/dist/handlers/node-handlers.d.ts +0 -6
  72. package/dist/handlers/node-handlers.js +0 -73
  73. package/dist/handlers/test-crash-handler.d.ts +0 -11
  74. package/dist/handlers/test-crash-handler.js +0 -26
  75. package/dist/http-index.d.ts +0 -45
  76. package/dist/http-index.js +0 -51
  77. package/dist/http-server-auto-tunnel.js +0 -667
  78. package/dist/http-server-named-tunnel.d.ts +0 -2
  79. package/dist/http-server-named-tunnel.js +0 -167
  80. package/dist/http-server-tunnel.d.ts +0 -2
  81. package/dist/http-server-tunnel.js +0 -111
  82. package/dist/http-server.d.ts +0 -2
  83. package/dist/http-server.js +0 -270
  84. package/dist/index-oauth.d.ts +0 -2
  85. package/dist/index-oauth.js +0 -201
  86. package/dist/lib.d.ts +0 -10
  87. package/dist/lib.js +0 -10
  88. package/dist/oauth/auth-middleware.d.ts +0 -20
  89. package/dist/oauth/auth-middleware.js +0 -62
  90. package/dist/oauth/index.d.ts +0 -3
  91. package/dist/oauth/index.js +0 -3
  92. package/dist/oauth/oauth-manager.d.ts +0 -80
  93. package/dist/oauth/oauth-manager.js +0 -179
  94. package/dist/oauth/oauth-routes.d.ts +0 -3
  95. package/dist/oauth/oauth-routes.js +0 -377
  96. package/dist/oauth/provider.d.ts +0 -22
  97. package/dist/oauth/provider.js +0 -124
  98. package/dist/oauth/server.d.ts +0 -18
  99. package/dist/oauth/server.js +0 -160
  100. package/dist/oauth/types.d.ts +0 -54
  101. package/dist/oauth/types.js +0 -2
  102. package/dist/remote-device/templates/auth-success.d.ts +0 -1
  103. package/dist/remote-device/templates/auth-success.js +0 -30
  104. package/dist/setup.log +0 -275
  105. package/dist/test-docx.d.ts +0 -1
  106. package/dist/test-setup.js +0 -14
  107. package/dist/tools/docx/builders/html-builder.d.ts +0 -17
  108. package/dist/tools/docx/builders/html-builder.js +0 -92
  109. package/dist/tools/docx/builders/image.d.ts +0 -14
  110. package/dist/tools/docx/builders/image.js +0 -84
  111. package/dist/tools/docx/builders/index.d.ts +0 -11
  112. package/dist/tools/docx/builders/index.js +0 -11
  113. package/dist/tools/docx/builders/markdown-builder.d.ts +0 -2
  114. package/dist/tools/docx/builders/markdown-builder.js +0 -260
  115. package/dist/tools/docx/builders/paragraph.d.ts +0 -12
  116. package/dist/tools/docx/builders/paragraph.js +0 -29
  117. package/dist/tools/docx/builders/table.d.ts +0 -10
  118. package/dist/tools/docx/builders/table.js +0 -138
  119. package/dist/tools/docx/builders/utils.d.ts +0 -5
  120. package/dist/tools/docx/builders/utils.js +0 -18
  121. package/dist/tools/docx/constants.d.ts +0 -32
  122. package/dist/tools/docx/constants.js +0 -61
  123. package/dist/tools/docx/converters/markdown-to-html.d.ts +0 -17
  124. package/dist/tools/docx/converters/markdown-to-html.js +0 -111
  125. package/dist/tools/docx/create.d.ts +0 -21
  126. package/dist/tools/docx/create.js +0 -386
  127. package/dist/tools/docx/dom.d.ts +0 -139
  128. package/dist/tools/docx/dom.js +0 -448
  129. package/dist/tools/docx/errors.d.ts +0 -28
  130. package/dist/tools/docx/errors.js +0 -48
  131. package/dist/tools/docx/extractors/images.d.ts +0 -14
  132. package/dist/tools/docx/extractors/images.js +0 -40
  133. package/dist/tools/docx/extractors/metadata.d.ts +0 -14
  134. package/dist/tools/docx/extractors/metadata.js +0 -64
  135. package/dist/tools/docx/extractors/sections.d.ts +0 -14
  136. package/dist/tools/docx/extractors/sections.js +0 -61
  137. package/dist/tools/docx/html.d.ts +0 -17
  138. package/dist/tools/docx/html.js +0 -111
  139. package/dist/tools/docx/index.d.ts +0 -10
  140. package/dist/tools/docx/index.js +0 -10
  141. package/dist/tools/docx/markdown.d.ts +0 -84
  142. package/dist/tools/docx/markdown.js +0 -507
  143. package/dist/tools/docx/modify.d.ts +0 -28
  144. package/dist/tools/docx/modify.js +0 -271
  145. package/dist/tools/docx/operations/handlers/index.d.ts +0 -39
  146. package/dist/tools/docx/operations/handlers/index.js +0 -152
  147. package/dist/tools/docx/operations/html-manipulator.d.ts +0 -24
  148. package/dist/tools/docx/operations/html-manipulator.js +0 -352
  149. package/dist/tools/docx/operations/index.d.ts +0 -14
  150. package/dist/tools/docx/operations/index.js +0 -61
  151. package/dist/tools/docx/operations/operation-handlers.d.ts +0 -3
  152. package/dist/tools/docx/operations/operation-handlers.js +0 -67
  153. package/dist/tools/docx/operations/preprocessor.d.ts +0 -14
  154. package/dist/tools/docx/operations/preprocessor.js +0 -44
  155. package/dist/tools/docx/operations/xml-replacer.d.ts +0 -9
  156. package/dist/tools/docx/operations/xml-replacer.js +0 -35
  157. package/dist/tools/docx/operations.d.ts +0 -13
  158. package/dist/tools/docx/operations.js +0 -13
  159. package/dist/tools/docx/ops/delete-paragraph-at-body-index.d.ts +0 -11
  160. package/dist/tools/docx/ops/delete-paragraph-at-body-index.js +0 -23
  161. package/dist/tools/docx/ops/header-replace-text-exact.d.ts +0 -13
  162. package/dist/tools/docx/ops/header-replace-text-exact.js +0 -55
  163. package/dist/tools/docx/ops/index.d.ts +0 -17
  164. package/dist/tools/docx/ops/index.js +0 -70
  165. package/dist/tools/docx/ops/insert-image-after-text.d.ts +0 -24
  166. package/dist/tools/docx/ops/insert-image-after-text.js +0 -128
  167. package/dist/tools/docx/ops/insert-paragraph-after-text.d.ts +0 -12
  168. package/dist/tools/docx/ops/insert-paragraph-after-text.js +0 -74
  169. package/dist/tools/docx/ops/insert-table-after-text.d.ts +0 -19
  170. package/dist/tools/docx/ops/insert-table-after-text.js +0 -57
  171. package/dist/tools/docx/ops/replace-hyperlink-url.d.ts +0 -12
  172. package/dist/tools/docx/ops/replace-hyperlink-url.js +0 -37
  173. package/dist/tools/docx/ops/replace-paragraph-at-body-index.d.ts +0 -9
  174. package/dist/tools/docx/ops/replace-paragraph-at-body-index.js +0 -25
  175. package/dist/tools/docx/ops/replace-paragraph-text-exact.d.ts +0 -21
  176. package/dist/tools/docx/ops/replace-paragraph-text-exact.js +0 -36
  177. package/dist/tools/docx/ops/replace-table-cell-text.d.ts +0 -25
  178. package/dist/tools/docx/ops/replace-table-cell-text.js +0 -85
  179. package/dist/tools/docx/ops/set-color-for-paragraph-exact.d.ts +0 -9
  180. package/dist/tools/docx/ops/set-color-for-paragraph-exact.js +0 -24
  181. package/dist/tools/docx/ops/set-color-for-style.d.ts +0 -13
  182. package/dist/tools/docx/ops/set-color-for-style.js +0 -31
  183. package/dist/tools/docx/ops/set-paragraph-style-at-body-index.d.ts +0 -8
  184. package/dist/tools/docx/ops/set-paragraph-style-at-body-index.js +0 -57
  185. package/dist/tools/docx/ops/table-set-cell-text.d.ts +0 -9
  186. package/dist/tools/docx/ops/table-set-cell-text.js +0 -40
  187. package/dist/tools/docx/parsers/image-extractor.d.ts +0 -18
  188. package/dist/tools/docx/parsers/image-extractor.js +0 -61
  189. package/dist/tools/docx/parsers/index.d.ts +0 -9
  190. package/dist/tools/docx/parsers/index.js +0 -9
  191. package/dist/tools/docx/parsers/paragraph-parser.d.ts +0 -2
  192. package/dist/tools/docx/parsers/paragraph-parser.js +0 -88
  193. package/dist/tools/docx/parsers/table-parser.d.ts +0 -9
  194. package/dist/tools/docx/parsers/table-parser.js +0 -72
  195. package/dist/tools/docx/parsers/xml-parser.d.ts +0 -25
  196. package/dist/tools/docx/parsers/xml-parser.js +0 -71
  197. package/dist/tools/docx/parsers/zip-reader.d.ts +0 -23
  198. package/dist/tools/docx/parsers/zip-reader.js +0 -52
  199. package/dist/tools/docx/read.d.ts +0 -27
  200. package/dist/tools/docx/read.js +0 -308
  201. package/dist/tools/docx/relationships.d.ts +0 -22
  202. package/dist/tools/docx/relationships.js +0 -76
  203. package/dist/tools/docx/structure.d.ts +0 -25
  204. package/dist/tools/docx/structure.js +0 -102
  205. package/dist/tools/docx/styled-html-parser.d.ts +0 -23
  206. package/dist/tools/docx/styled-html-parser.js +0 -1262
  207. package/dist/tools/docx/types.d.ts +0 -213
  208. package/dist/tools/docx/types.js +0 -5
  209. package/dist/tools/docx/utils/escaping.d.ts +0 -13
  210. package/dist/tools/docx/utils/escaping.js +0 -26
  211. package/dist/tools/docx/utils/images.d.ts +0 -9
  212. package/dist/tools/docx/utils/images.js +0 -26
  213. package/dist/tools/docx/utils/index.d.ts +0 -12
  214. package/dist/tools/docx/utils/index.js +0 -17
  215. package/dist/tools/docx/utils/markdown.d.ts +0 -13
  216. package/dist/tools/docx/utils/markdown.js +0 -32
  217. package/dist/tools/docx/utils/paths.d.ts +0 -15
  218. package/dist/tools/docx/utils/paths.js +0 -27
  219. package/dist/tools/docx/utils/versioning.d.ts +0 -25
  220. package/dist/tools/docx/utils/versioning.js +0 -55
  221. package/dist/tools/docx/utils.d.ts +0 -101
  222. package/dist/tools/docx/utils.js +0 -299
  223. package/dist/tools/docx/validate.d.ts +0 -33
  224. package/dist/tools/docx/validate.js +0 -49
  225. package/dist/tools/docx/validators.d.ts +0 -13
  226. package/dist/tools/docx/validators.js +0 -40
  227. package/dist/tools/docx/write.d.ts +0 -17
  228. package/dist/tools/docx/write.js +0 -88
  229. package/dist/tools/docx/xml-view-test.d.ts +0 -1
  230. package/dist/tools/docx/xml-view-test.js +0 -63
  231. package/dist/tools/docx/xml-view.d.ts +0 -56
  232. package/dist/tools/docx/xml-view.js +0 -169
  233. package/dist/tools/docx/zip.d.ts +0 -21
  234. package/dist/tools/docx/zip.js +0 -35
  235. package/dist/tools/macos-control/ax-adapter.d.ts +0 -55
  236. package/dist/tools/macos-control/ax-adapter.js +0 -438
  237. package/dist/tools/macos-control/cdp-adapter.d.ts +0 -23
  238. package/dist/tools/macos-control/cdp-adapter.js +0 -402
  239. package/dist/tools/macos-control/orchestrator.d.ts +0 -77
  240. package/dist/tools/macos-control/orchestrator.js +0 -136
  241. package/dist/tools/macos-control/role-aliases.d.ts +0 -5
  242. package/dist/tools/macos-control/role-aliases.js +0 -34
  243. package/dist/tools/macos-control/types.d.ts +0 -129
  244. package/dist/tools/macos-control/types.js +0 -1
  245. package/dist/tools/pdf-processor.d.ts +0 -1
  246. package/dist/tools/pdf-processor.js +0 -3
  247. package/dist/tools/search.d.ts +0 -32
  248. package/dist/tools/search.js +0 -202
  249. package/dist/ui/file-preview/src/components/toolbar.d.ts +0 -6
  250. package/dist/ui/file-preview/src/components/toolbar.js +0 -75
  251. package/dist/ui/shared/host-lifecycle.d.ts +0 -16
  252. package/dist/ui/shared/host-lifecycle.js +0 -35
  253. package/dist/ui/shared/rpc-client.d.ts +0 -14
  254. package/dist/ui/shared/rpc-client.js +0 -72
  255. package/dist/ui/shared/theme-adaptation.d.ts +0 -10
  256. package/dist/ui/shared/theme-adaptation.js +0 -118
  257. package/dist/ui/shared/tool-header.d.ts +0 -9
  258. package/dist/ui/shared/tool-header.js +0 -25
  259. package/dist/utils/crash-logger.d.ts +0 -18
  260. package/dist/utils/crash-logger.js +0 -44
  261. package/dist/utils/dedent.d.ts +0 -8
  262. package/dist/utils/dedent.js +0 -38
  263. /package/dist/{http-server-auto-tunnel.d.ts → ui/file-preview/src/model.js} +0 -0
@@ -1,129 +0,0 @@
1
- export type MacosControlErrorCode = 'UNSUPPORTED_PLATFORM' | 'HELPER_NOT_FOUND' | 'HELPER_EXEC_FAILED' | 'HELPER_PROTOCOL_ERROR' | 'PERMISSION_DENIED' | 'INVALID_ARGUMENT' | 'NOT_FOUND' | 'TIMEOUT' | 'ACTION_FAILED' | 'CDP_CONNECT_FAILED' | 'CDP_NOT_CONNECTED' | 'CDP_CALL_FAILED' | 'INTERNAL_ERROR';
2
- export interface MacosControlError {
3
- code: MacosControlErrorCode;
4
- message: string;
5
- details?: Record<string, unknown>;
6
- retriable?: boolean;
7
- }
8
- export interface MacosControlResult<T = unknown> {
9
- ok: boolean;
10
- data?: T;
11
- error?: MacosControlError;
12
- }
13
- export interface AxElement {
14
- id: string;
15
- app: string;
16
- pid: number;
17
- role: string;
18
- title?: string;
19
- label?: string;
20
- desc?: string;
21
- text?: string;
22
- checked?: boolean;
23
- selected?: boolean;
24
- focused?: boolean;
25
- actions?: string[];
26
- bounds: [number, number, number, number];
27
- }
28
- export interface AxAppInfo {
29
- name: string;
30
- pid: number;
31
- bundleId?: string;
32
- active: boolean;
33
- }
34
- export interface AxStatus {
35
- platform: NodeJS.Platform;
36
- hasPermission: boolean;
37
- helperPath?: string;
38
- helperVersion?: string;
39
- processInfo?: string;
40
- }
41
- export interface AxBatchCommand {
42
- action: 'activate' | 'find' | 'click' | 'find_and_click' | 'type' | 'key' | 'wait' | 'wait_for' | 'get_state' | 'scroll';
43
- app?: string;
44
- text?: string;
45
- role?: string;
46
- id?: string;
47
- timeout_ms?: number;
48
- depth?: number;
49
- limit?: number;
50
- key?: string;
51
- modifiers?: string[];
52
- index?: number;
53
- if_exists?: boolean;
54
- ms?: number;
55
- x?: number;
56
- y?: number;
57
- direction?: 'up' | 'down';
58
- amount?: number;
59
- }
60
- export interface AxBatchResultItem {
61
- action: string;
62
- success: boolean;
63
- skipped?: boolean;
64
- element?: AxElement;
65
- error?: string;
66
- [key: string]: unknown;
67
- }
68
- export interface AxBatchResult {
69
- success: boolean;
70
- results: AxBatchResultItem[];
71
- failedAt: number | null;
72
- completed: number;
73
- total: number;
74
- }
75
- export interface ElectronDebugTarget {
76
- id: string;
77
- type: string;
78
- title: string;
79
- url: string;
80
- webSocketDebuggerUrl?: string;
81
- }
82
- export interface ElectronDebugAttachResult {
83
- sessionId: string;
84
- host: string;
85
- port: number;
86
- targetId: string;
87
- targetTitle: string;
88
- targetUrl: string;
89
- availableTargets: Array<{
90
- id: string;
91
- title: string;
92
- url: string;
93
- type: string;
94
- }>;
95
- }
96
- export interface ElectronDebugEvalResult {
97
- result?: unknown;
98
- type?: string;
99
- description?: string;
100
- subtype?: string;
101
- }
102
- export interface AxElementSignature {
103
- app: string;
104
- role: string;
105
- title?: string;
106
- label?: string;
107
- text?: string;
108
- bounds?: [number, number, number, number];
109
- }
110
- export interface HelperRequest {
111
- command: string;
112
- args?: Record<string, unknown>;
113
- requestId?: string;
114
- }
115
- export interface HelperError {
116
- code: string;
117
- message: string;
118
- details?: Record<string, unknown>;
119
- }
120
- export interface HelperResponse<T = unknown> {
121
- ok: boolean;
122
- data?: T;
123
- error?: HelperError;
124
- meta?: {
125
- requestId?: string;
126
- durationMs?: number;
127
- [key: string]: unknown;
128
- };
129
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export {};
2
- // PDF processing is no longer needed - PDFs are handled like images as base64 documents
3
- // This file is kept for potential future enhancements but currently unused
@@ -1,32 +0,0 @@
1
- export interface SearchResult {
2
- file: string;
3
- line: number;
4
- match: string;
5
- }
6
- export declare function searchCode(options: {
7
- rootPath: string;
8
- pattern: string;
9
- filePattern?: string;
10
- ignoreCase?: boolean;
11
- maxResults?: number;
12
- includeHidden?: boolean;
13
- contextLines?: number;
14
- }): Promise<SearchResult[]>;
15
- export declare function searchCodeFallback(options: {
16
- rootPath: string;
17
- pattern: string;
18
- filePattern?: string;
19
- ignoreCase?: boolean;
20
- maxResults?: number;
21
- excludeDirs?: string[];
22
- contextLines?: number;
23
- }): Promise<SearchResult[]>;
24
- export declare function searchTextInFiles(options: {
25
- rootPath: string;
26
- pattern: string;
27
- filePattern?: string;
28
- ignoreCase?: boolean;
29
- maxResults?: number;
30
- includeHidden?: boolean;
31
- contextLines?: number;
32
- }): Promise<SearchResult[]>;
@@ -1,202 +0,0 @@
1
- import { spawn } from 'child_process';
2
- import path from 'path';
3
- import fs from 'fs/promises';
4
- import { validatePath } from './filesystem.js';
5
- import { rgPath } from '@vscode/ripgrep';
6
- import { capture } from "../utils/capture.js";
7
- // Function to search file contents using ripgrep
8
- export async function searchCode(options) {
9
- const { rootPath, pattern, filePattern, ignoreCase = true, maxResults = 1000, includeHidden = false, contextLines = 0 } = options;
10
- // Validate path for security
11
- const validPath = await validatePath(rootPath);
12
- // Build command arguments
13
- const args = [
14
- '--json', // Output in JSON format for easier parsing
15
- '--line-number', // Include line numbers
16
- ];
17
- if (ignoreCase) {
18
- args.push('-i');
19
- }
20
- if (maxResults) {
21
- args.push('-m', maxResults.toString());
22
- }
23
- if (includeHidden) {
24
- args.push('--hidden');
25
- }
26
- if (contextLines > 0) {
27
- args.push('-C', contextLines.toString());
28
- }
29
- if (filePattern) {
30
- const patterns = filePattern
31
- .split('|')
32
- .map(p => p.trim()) // remove surrounding spaces
33
- .filter(Boolean); // drop empty tokens
34
- // If all patterns were empty, return no results
35
- if (patterns.length === 0) {
36
- return [];
37
- }
38
- patterns.forEach(p => args.push('-g', p));
39
- }
40
- // Add pattern and path
41
- args.push(pattern, validPath);
42
- // Run ripgrep command
43
- return new Promise((resolve, reject) => {
44
- const results = [];
45
- const rg = spawn(rgPath, args);
46
- let stdoutBuffer = '';
47
- // Store a reference to the child process for potential termination
48
- const childProcess = rg;
49
- // Store in a process list - this could be expanded to a global registry
50
- // of running search processes if needed for management
51
- globalThis.currentSearchProcess = childProcess;
52
- rg.stdout.on('data', (data) => {
53
- stdoutBuffer += data.toString();
54
- });
55
- rg.stderr.on('data', (data) => {
56
- console.error(`ripgrep error: ${data}`);
57
- });
58
- rg.on('close', (code) => {
59
- // Clean up the global reference
60
- if (globalThis.currentSearchProcess === childProcess) {
61
- delete globalThis.currentSearchProcess;
62
- }
63
- if (code === 0 || code === 1) {
64
- // Process the buffered output
65
- const lines = stdoutBuffer.trim().split('\n');
66
- for (const line of lines) {
67
- if (!line)
68
- continue;
69
- try {
70
- const result = JSON.parse(line);
71
- if (result.type === 'match') {
72
- result.data.submatches.forEach((submatch) => {
73
- results.push({
74
- file: result.data.path.text,
75
- line: result.data.line_number,
76
- match: submatch.match.text
77
- });
78
- });
79
- }
80
- else if (result.type === 'context' && contextLines > 0) {
81
- results.push({
82
- file: result.data.path.text,
83
- line: result.data.line_number,
84
- match: result.data.lines.text.trim()
85
- });
86
- }
87
- }
88
- catch (error) {
89
- const errorMessage = error instanceof Error ? error.message : String(error);
90
- capture('server_request_error', { error: `Error parsing ripgrep output: ${errorMessage}` });
91
- console.error(`Error parsing ripgrep output: ${errorMessage}`);
92
- }
93
- }
94
- resolve(results);
95
- }
96
- else {
97
- reject(new Error(`ripgrep process exited with code ${code}`));
98
- }
99
- });
100
- });
101
- }
102
- // Fallback implementation using Node.js for environments without ripgrep
103
- export async function searchCodeFallback(options) {
104
- const { rootPath, pattern, filePattern, ignoreCase = true, maxResults = 1000, excludeDirs = ['node_modules', '.git'], contextLines = 0 } = options;
105
- const validPath = await validatePath(rootPath);
106
- const results = [];
107
- const regex = new RegExp(pattern, ignoreCase ? 'i' : '');
108
- // Handle filePattern similarly to main implementation
109
- let fileRegex = null;
110
- if (filePattern) {
111
- const patterns = filePattern
112
- .split('|')
113
- .map(p => p.trim())
114
- .filter(Boolean);
115
- // If all patterns were empty, return no results
116
- if (patterns.length === 0) {
117
- return [];
118
- }
119
- // Create a regex that matches any of the patterns
120
- const combinedPattern = patterns.map(p => p.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\?/g, '.')).join('|');
121
- fileRegex = new RegExp(`^(${combinedPattern})$`);
122
- }
123
- async function searchDir(dirPath) {
124
- if (results.length >= maxResults)
125
- return;
126
- try {
127
- const entries = await fs.readdir(dirPath, { withFileTypes: true });
128
- for (const entry of entries) {
129
- if (results.length >= maxResults)
130
- break;
131
- const fullPath = path.join(dirPath, entry.name);
132
- try {
133
- await validatePath(fullPath);
134
- if (entry.isDirectory()) {
135
- if (!excludeDirs.includes(entry.name)) {
136
- await searchDir(fullPath);
137
- }
138
- }
139
- else if (entry.isFile()) {
140
- if (!fileRegex || fileRegex.test(entry.name)) {
141
- const content = await fs.readFile(fullPath, 'utf-8');
142
- const lines = content.split('\n');
143
- for (let i = 0; i < lines.length; i++) {
144
- if (regex.test(lines[i])) {
145
- // Add the matched line
146
- results.push({
147
- file: fullPath,
148
- line: i + 1,
149
- match: lines[i].trim()
150
- });
151
- // Add context lines
152
- if (contextLines > 0) {
153
- const startIdx = Math.max(0, i - contextLines);
154
- const endIdx = Math.min(lines.length - 1, i + contextLines);
155
- for (let j = startIdx; j <= endIdx; j++) {
156
- if (j !== i) { // Skip the match line as it's already added
157
- results.push({
158
- file: fullPath,
159
- line: j + 1,
160
- match: lines[j].trim()
161
- });
162
- }
163
- }
164
- }
165
- if (results.length >= maxResults)
166
- break;
167
- }
168
- }
169
- }
170
- }
171
- }
172
- catch (error) {
173
- // Skip files/directories we can't access
174
- continue;
175
- }
176
- }
177
- }
178
- catch (error) {
179
- // Skip directories we can't read
180
- }
181
- }
182
- await searchDir(validPath);
183
- return results;
184
- }
185
- // Main function that tries ripgrep first, falls back to native implementation
186
- export async function searchTextInFiles(options) {
187
- try {
188
- // For better performance and consistency, prefer the search session manager
189
- // when doing content search, but keep the original direct ripgrep approach as primary
190
- return await searchCode(options);
191
- }
192
- catch (error) {
193
- capture('searchTextInFiles_ripgrep_fallback', {
194
- error: error instanceof Error ? error.message : 'Unknown error'
195
- });
196
- // Use consistent exclusions - remove 'dist' to match ripgrep behavior
197
- return searchCodeFallback({
198
- ...options,
199
- excludeDirs: ['node_modules', '.git']
200
- });
201
- }
202
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Toolbar component for preview controls (view mode, metadata, actions). It isolates UI control rendering and event plumbing from core preview orchestration.
3
- */
4
- import type { FilePreviewStructuredContent } from '../../../../types.js';
5
- import type { HtmlPreviewMode } from '../types.js';
6
- export declare function renderToolbar(payload: FilePreviewStructuredContent, canCopy: boolean, htmlMode: HtmlPreviewMode, isExpanded: boolean, canOpenInFolder: boolean): string;
@@ -1,75 +0,0 @@
1
- import { renderToolHeader } from '../../../shared/tool-header.js';
2
- function inferFilePill(payload) {
3
- if (payload.fileType === 'markdown') {
4
- return { label: 'MD', className: 'file-pill--md' };
5
- }
6
- if (payload.fileType === 'html') {
7
- return { label: 'HTML', className: 'file-pill--html' };
8
- }
9
- const extensionMatch = payload.filePath.toLowerCase().match(/\.([a-z0-9]+)$/);
10
- const extension = extensionMatch ? extensionMatch[1] : 'txt';
11
- if (extension === 'json') {
12
- return { label: 'JSON', className: 'file-pill--json' };
13
- }
14
- return { label: extension.slice(0, 4).toUpperCase(), className: 'file-pill--text' };
15
- }
16
- export function renderToolbar(payload, canCopy, htmlMode, isExpanded, canOpenInFolder) {
17
- const supportsPreview = payload.fileType !== 'unsupported';
18
- const copyDisabled = canCopy ? '' : 'disabled';
19
- const copyTitle = canCopy ? 'Copy source' : 'Copy unavailable';
20
- const copyIcon = `
21
- <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
22
- <path d="M8 8h10v12H8z"></path>
23
- <path d="M6 4h10v2H8v10H6z"></path>
24
- </svg>
25
- `;
26
- const folderDisabled = canOpenInFolder ? '' : 'disabled';
27
- const folderTitle = canOpenInFolder ? 'Open in folder' : 'Open in folder unavailable';
28
- const folderIcon = `
29
- <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
30
- <path d="M10 4l2 2h8v12H4V4z"></path>
31
- </svg>
32
- `;
33
- const previewIcon = isExpanded
34
- ? `<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M7 14l5-5 5 5z"></path></svg>`
35
- : `<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M7 10l5 5 5-5z"></path></svg>`;
36
- const htmlModeButton = payload.fileType === 'html'
37
- ? `
38
- <button class="icon-button icon-button--secondary" id="toggle-html-mode" title="${htmlMode === 'rendered' ? 'Show source' : 'Show rendered'}" aria-label="${htmlMode === 'rendered' ? 'Show source' : 'Show rendered'}">
39
- ${htmlMode === 'rendered'
40
- ? `<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 5c5.2 0 9.3 4.4 10.6 6-1.3 1.6-5.4 6-10.6 6S2.7 12.6 1.4 11C2.7 9.4 6.8 5 12 5zm0 2.2A3.8 3.8 0 1 0 12 14.8a3.8 3.8 0 0 0 0-7.6z"></path></svg>`
41
- : `<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M9.4 16.6L4.8 12l4.6-4.6L8 6 2 12l6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"></path></svg>`}
42
- </button>
43
- `
44
- : '';
45
- const filePill = inferFilePill(payload);
46
- const leadingActions = supportsPreview
47
- ? `
48
- <button class="icon-button" id="toggle-expand" title="${isExpanded ? 'Hide preview' : 'Show preview'}" aria-label="${isExpanded ? 'Hide preview' : 'Show preview'}">
49
- ${previewIcon}
50
- </button>
51
- `
52
- : '';
53
- const trailingActions = supportsPreview
54
- ? `
55
- ${htmlModeButton}
56
- <button class="icon-button" id="copy-source" ${copyDisabled} title="${copyTitle}" aria-label="${copyTitle}">
57
- ${copyIcon}
58
- </button>
59
- `
60
- : '';
61
- return renderToolHeader({
62
- pillLabel: filePill.label,
63
- pillClassName: filePill.className,
64
- title: payload.fileName,
65
- subtitle: payload.filePath,
66
- badges: [],
67
- actionsHtml: `
68
- ${leadingActions}
69
- <button class="icon-button" id="open-in-folder" ${folderDisabled} title="${folderTitle}" aria-label="${folderTitle}">
70
- ${folderIcon}
71
- </button>
72
- ${trailingActions}
73
- `
74
- });
75
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Cross-tool lifecycle helpers for host readiness, teardown, and event subscriptions. It standardizes app lifecycle behavior across UI surfaces.
3
- */
4
- import type { RpcClient } from './rpc-client.js';
5
- interface UiHostLifecycleOptions {
6
- appName: string;
7
- appVersion?: string;
8
- getRootElement?: () => Element | null;
9
- }
10
- export interface UiHostLifecycle {
11
- notifyRender: () => void;
12
- observeResize: () => void;
13
- initialize: () => void;
14
- }
15
- export declare function createUiHostLifecycle(rpcClient: RpcClient, options: UiHostLifecycleOptions): UiHostLifecycle;
16
- export {};
@@ -1,35 +0,0 @@
1
- export function createUiHostLifecycle(rpcClient, options) {
2
- const { appName, appVersion = '1.0.0', getRootElement } = options;
3
- const resolveRootElement = () => getRootElement?.() ?? (document.getElementById('app')?.firstElementChild ?? document.getElementById('app'));
4
- const notifySizeChanged = () => {
5
- const node = resolveRootElement();
6
- const height = Math.max(28, Math.ceil(node?.getBoundingClientRect().height ?? 0));
7
- rpcClient.notify('ui/notifications/size-changed', { height });
8
- };
9
- return {
10
- notifyRender: () => {
11
- notifySizeChanged();
12
- setTimeout(notifySizeChanged, 80);
13
- },
14
- observeResize: () => {
15
- if (!window.ResizeObserver) {
16
- return;
17
- }
18
- const observer = new ResizeObserver(() => notifySizeChanged());
19
- observer.observe(document.documentElement);
20
- },
21
- initialize: () => {
22
- void rpcClient.request('ui/initialize', {
23
- appInfo: { name: appName, version: appVersion },
24
- appCapabilities: {},
25
- protocolVersion: '2026-01-26',
26
- }).then(() => {
27
- rpcClient.notify('ui/notifications/initialized', {});
28
- }).catch(() => {
29
- // Initialization handshake failure should not break rendering.
30
- // Still send initialized in case host is lenient.
31
- rpcClient.notify('ui/notifications/initialized', {});
32
- });
33
- },
34
- };
35
- }
@@ -1,14 +0,0 @@
1
- export interface RpcClient {
2
- notify: (method: string, params: Record<string, unknown>) => void;
3
- request: (method: string, params: Record<string, unknown>) => Promise<unknown>;
4
- handleMessageEvent: (event: MessageEvent) => boolean;
5
- dispose: () => void;
6
- }
7
- export interface RpcClientOptions {
8
- targetWindow: Window;
9
- targetOrigin?: string;
10
- timeoutMs?: number;
11
- isTrustedSource?: (source: MessageEvent['source'] | null) => boolean;
12
- }
13
- export declare function isTrustedParentMessageSource(source: MessageEvent['source'] | null, expectedSource: Window): boolean;
14
- export declare function createWindowRpcClient(options: RpcClientOptions): RpcClient;
@@ -1,72 +0,0 @@
1
- function isObject(value) {
2
- return typeof value === 'object' && value !== null;
3
- }
4
- export function isTrustedParentMessageSource(source, expectedSource) {
5
- return source === expectedSource;
6
- }
7
- export function createWindowRpcClient(options) {
8
- const { targetWindow, targetOrigin = '*', timeoutMs = 15000, isTrustedSource = () => true, } = options;
9
- let requestId = 1;
10
- const pendingRequests = new Map();
11
- const postMessage = (payload) => {
12
- targetWindow.postMessage(payload, targetOrigin);
13
- };
14
- const notify = (method, params) => {
15
- postMessage({
16
- jsonrpc: '2.0',
17
- method,
18
- params,
19
- });
20
- };
21
- const request = (method, params) => {
22
- const id = requestId++;
23
- postMessage({
24
- jsonrpc: '2.0',
25
- id,
26
- method,
27
- params,
28
- });
29
- return new Promise((resolve, reject) => {
30
- const timer = setTimeout(() => {
31
- pendingRequests.delete(id);
32
- reject(new Error(`Request timed out for method ${method}`));
33
- }, timeoutMs);
34
- pendingRequests.set(id, { resolve, reject, timer });
35
- });
36
- };
37
- const handleMessageEvent = (event) => {
38
- if (!isTrustedSource(event.source)) {
39
- return false;
40
- }
41
- if (!isObject(event.data) || typeof event.data.id !== 'number') {
42
- return false;
43
- }
44
- const pending = pendingRequests.get(event.data.id);
45
- if (!pending) {
46
- return false;
47
- }
48
- clearTimeout(pending.timer);
49
- pendingRequests.delete(event.data.id);
50
- if (isObject(event.data.error)) {
51
- const errorShape = event.data.error;
52
- const message = typeof errorShape.message === 'string' ? errorShape.message : 'Unknown RPC error';
53
- pending.reject(new Error(message));
54
- return true;
55
- }
56
- pending.resolve(event.data.result);
57
- return true;
58
- };
59
- const dispose = () => {
60
- for (const [id, pending] of pendingRequests) {
61
- clearTimeout(pending.timer);
62
- pending.reject(new Error('RPC client disposed'));
63
- pendingRequests.delete(id);
64
- }
65
- };
66
- return {
67
- notify,
68
- request,
69
- handleMessageEvent,
70
- dispose,
71
- };
72
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Theme synchronization utilities that adapt embedded UI styles to host light/dark context. It centralizes theme event handling and class/token updates.
3
- */
4
- type ThemeMode = 'light' | 'dark';
5
- export declare function resolveThemeMode(value: unknown): ThemeMode | undefined;
6
- export interface UiThemeAdapter {
7
- applyFromData: (data: unknown) => boolean;
8
- }
9
- export declare function createUiThemeAdapter(root?: HTMLElement): UiThemeAdapter;
10
- export {};