orquesta-cli 0.1.13 → 0.1.14

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 (539) hide show
  1. package/README.md +30 -4
  2. package/dist/cli.js +65 -4
  3. package/dist/core/config/config-manager.d.ts +13 -1
  4. package/dist/core/config/config-manager.js +83 -0
  5. package/dist/core/slash-command-handler.d.ts +1 -0
  6. package/dist/core/slash-command-handler.js +129 -0
  7. package/dist/orquesta/config-sync.d.ts +73 -0
  8. package/dist/orquesta/config-sync.js +230 -0
  9. package/dist/orquesta/prompt-reporter.d.ts +16 -0
  10. package/dist/orquesta/prompt-reporter.js +85 -0
  11. package/dist/setup/first-run-setup.d.ts +15 -0
  12. package/dist/setup/first-run-setup.js +238 -0
  13. package/dist/types/index.d.ts +11 -2
  14. package/dist/ui/TodoPanel.d.ts +1 -0
  15. package/dist/ui/TodoPanel.js +6 -1
  16. package/dist/ui/components/LLMSetupWizard.js +373 -7
  17. package/dist/ui/components/Logo.d.ts +2 -0
  18. package/dist/ui/components/Logo.js +10 -3
  19. package/dist/ui/components/OpenRouterModelBrowser.d.ts +13 -0
  20. package/dist/ui/components/OpenRouterModelBrowser.js +221 -0
  21. package/dist/ui/components/PlanExecuteApp.js +30 -4
  22. package/dist/ui/components/ProjectSelector.d.ts +8 -0
  23. package/dist/ui/components/ProjectSelector.js +119 -0
  24. package/dist/ui/components/StatusBar.d.ts +2 -0
  25. package/dist/ui/components/StatusBar.js +6 -1
  26. package/dist/ui/hooks/slashCommandProcessor.js +8 -4
  27. package/package.json +11 -5
  28. package/.eslintrc.json +0 -26
  29. package/.prettierrc.json +0 -10
  30. package/CLAUDE.md +0 -199
  31. package/SECURITY.md +0 -290
  32. package/TEST_LOCAL.md +0 -245
  33. package/dist/agents/base/base-agent.d.ts.map +0 -1
  34. package/dist/agents/base/base-agent.js.map +0 -1
  35. package/dist/agents/docs-search/index.d.ts.map +0 -1
  36. package/dist/agents/docs-search/index.js.map +0 -1
  37. package/dist/agents/index.d.ts.map +0 -1
  38. package/dist/agents/index.js.map +0 -1
  39. package/dist/agents/planner/index.d.ts.map +0 -1
  40. package/dist/agents/planner/index.js.map +0 -1
  41. package/dist/cli.d.ts.map +0 -1
  42. package/dist/cli.js.map +0 -1
  43. package/dist/constants.d.ts.map +0 -1
  44. package/dist/constants.js.map +0 -1
  45. package/dist/core/compact/compact-manager.d.ts.map +0 -1
  46. package/dist/core/compact/compact-manager.js.map +0 -1
  47. package/dist/core/compact/compact-prompts.d.ts.map +0 -1
  48. package/dist/core/compact/compact-prompts.js.map +0 -1
  49. package/dist/core/compact/context-tracker.d.ts.map +0 -1
  50. package/dist/core/compact/context-tracker.js.map +0 -1
  51. package/dist/core/compact/index.d.ts.map +0 -1
  52. package/dist/core/compact/index.js.map +0 -1
  53. package/dist/core/config/config-manager.d.ts.map +0 -1
  54. package/dist/core/config/config-manager.js.map +0 -1
  55. package/dist/core/config/index.d.ts.map +0 -1
  56. package/dist/core/config/index.js.map +0 -1
  57. package/dist/core/docs-manager.d.ts.map +0 -1
  58. package/dist/core/docs-manager.js.map +0 -1
  59. package/dist/core/git-auto-updater.d.ts.map +0 -1
  60. package/dist/core/git-auto-updater.js.map +0 -1
  61. package/dist/core/llm/index.d.ts.map +0 -1
  62. package/dist/core/llm/index.js.map +0 -1
  63. package/dist/core/llm/llm-client.d.ts.map +0 -1
  64. package/dist/core/llm/llm-client.js.map +0 -1
  65. package/dist/core/session/index.d.ts.map +0 -1
  66. package/dist/core/session/index.js.map +0 -1
  67. package/dist/core/session/session-manager.d.ts.map +0 -1
  68. package/dist/core/session/session-manager.js.map +0 -1
  69. package/dist/core/slash-command-handler.d.ts.map +0 -1
  70. package/dist/core/slash-command-handler.js.map +0 -1
  71. package/dist/core/usage-tracker.d.ts.map +0 -1
  72. package/dist/core/usage-tracker.js.map +0 -1
  73. package/dist/errors/base.d.ts.map +0 -1
  74. package/dist/errors/base.js.map +0 -1
  75. package/dist/errors/file.d.ts.map +0 -1
  76. package/dist/errors/file.js.map +0 -1
  77. package/dist/errors/index.d.ts.map +0 -1
  78. package/dist/errors/index.js.map +0 -1
  79. package/dist/errors/llm.d.ts.map +0 -1
  80. package/dist/errors/llm.js.map +0 -1
  81. package/dist/errors/network.d.ts.map +0 -1
  82. package/dist/errors/network.js.map +0 -1
  83. package/dist/errors/validation.d.ts.map +0 -1
  84. package/dist/errors/validation.js.map +0 -1
  85. package/dist/eval/eval-runner.d.ts.map +0 -1
  86. package/dist/eval/eval-runner.js.map +0 -1
  87. package/dist/eval/index.d.ts.map +0 -1
  88. package/dist/eval/index.js.map +0 -1
  89. package/dist/eval/types.d.ts.map +0 -1
  90. package/dist/eval/types.js.map +0 -1
  91. package/dist/index.d.ts.map +0 -1
  92. package/dist/index.js.map +0 -1
  93. package/dist/orchestration/index.d.ts.map +0 -1
  94. package/dist/orchestration/index.js.map +0 -1
  95. package/dist/orchestration/plan-executor.d.ts.map +0 -1
  96. package/dist/orchestration/plan-executor.js.map +0 -1
  97. package/dist/orchestration/types.d.ts.map +0 -1
  98. package/dist/orchestration/types.js.map +0 -1
  99. package/dist/orchestration/utils.d.ts.map +0 -1
  100. package/dist/orchestration/utils.js.map +0 -1
  101. package/dist/orquesta/connection.d.ts.map +0 -1
  102. package/dist/orquesta/connection.js.map +0 -1
  103. package/dist/prompts/agents/docs-search-decision.d.ts.map +0 -1
  104. package/dist/prompts/agents/docs-search-decision.js.map +0 -1
  105. package/dist/prompts/agents/docs-search.d.ts.map +0 -1
  106. package/dist/prompts/agents/docs-search.js.map +0 -1
  107. package/dist/prompts/agents/planning.d.ts.map +0 -1
  108. package/dist/prompts/agents/planning.js.map +0 -1
  109. package/dist/prompts/index.d.ts.map +0 -1
  110. package/dist/prompts/index.js.map +0 -1
  111. package/dist/prompts/shared/codebase-rules.d.ts.map +0 -1
  112. package/dist/prompts/shared/codebase-rules.js.map +0 -1
  113. package/dist/prompts/shared/git-rules.d.ts.map +0 -1
  114. package/dist/prompts/shared/git-rules.js.map +0 -1
  115. package/dist/prompts/shared/language-rules.d.ts.map +0 -1
  116. package/dist/prompts/shared/language-rules.js.map +0 -1
  117. package/dist/prompts/shared/tool-usage.d.ts.map +0 -1
  118. package/dist/prompts/shared/tool-usage.js.map +0 -1
  119. package/dist/prompts/system/compact.d.ts.map +0 -1
  120. package/dist/prompts/system/compact.js.map +0 -1
  121. package/dist/prompts/system/plan-execute.d.ts.map +0 -1
  122. package/dist/prompts/system/plan-execute.js.map +0 -1
  123. package/dist/tools/browser/browser-client.d.ts.map +0 -1
  124. package/dist/tools/browser/browser-client.js.map +0 -1
  125. package/dist/tools/browser/browser-tools.d.ts.map +0 -1
  126. package/dist/tools/browser/browser-tools.js.map +0 -1
  127. package/dist/tools/browser/index.d.ts.map +0 -1
  128. package/dist/tools/browser/index.js.map +0 -1
  129. package/dist/tools/index.d.ts.map +0 -1
  130. package/dist/tools/index.js.map +0 -1
  131. package/dist/tools/llm/agents/docs-search-tools.d.ts.map +0 -1
  132. package/dist/tools/llm/agents/docs-search-tools.js.map +0 -1
  133. package/dist/tools/llm/agents/index.d.ts.map +0 -1
  134. package/dist/tools/llm/agents/index.js.map +0 -1
  135. package/dist/tools/llm/index.d.ts.map +0 -1
  136. package/dist/tools/llm/index.js.map +0 -1
  137. package/dist/tools/llm/simple/ask-user-tool.d.ts.map +0 -1
  138. package/dist/tools/llm/simple/ask-user-tool.js.map +0 -1
  139. package/dist/tools/llm/simple/background-bash-tool.d.ts.map +0 -1
  140. package/dist/tools/llm/simple/background-bash-tool.js.map +0 -1
  141. package/dist/tools/llm/simple/background-powershell-tool.d.ts.map +0 -1
  142. package/dist/tools/llm/simple/background-powershell-tool.js.map +0 -1
  143. package/dist/tools/llm/simple/bash-tool.d.ts.map +0 -1
  144. package/dist/tools/llm/simple/bash-tool.js.map +0 -1
  145. package/dist/tools/llm/simple/docs-search-agent-tool.d.ts.map +0 -1
  146. package/dist/tools/llm/simple/docs-search-agent-tool.js.map +0 -1
  147. package/dist/tools/llm/simple/file-tools.d.ts.map +0 -1
  148. package/dist/tools/llm/simple/file-tools.js.map +0 -1
  149. package/dist/tools/llm/simple/final-response-tool.d.ts.map +0 -1
  150. package/dist/tools/llm/simple/final-response-tool.js.map +0 -1
  151. package/dist/tools/llm/simple/index.d.ts.map +0 -1
  152. package/dist/tools/llm/simple/index.js.map +0 -1
  153. package/dist/tools/llm/simple/planning-tools.d.ts.map +0 -1
  154. package/dist/tools/llm/simple/planning-tools.js.map +0 -1
  155. package/dist/tools/llm/simple/powershell-tool.d.ts.map +0 -1
  156. package/dist/tools/llm/simple/powershell-tool.js.map +0 -1
  157. package/dist/tools/llm/simple/simple-tool-executor.d.ts.map +0 -1
  158. package/dist/tools/llm/simple/simple-tool-executor.js.map +0 -1
  159. package/dist/tools/llm/simple/todo-tools.d.ts.map +0 -1
  160. package/dist/tools/llm/simple/todo-tools.js.map +0 -1
  161. package/dist/tools/llm/simple/user-interaction-tools.d.ts.map +0 -1
  162. package/dist/tools/llm/simple/user-interaction-tools.js.map +0 -1
  163. package/dist/tools/office/common/constants.d.ts.map +0 -1
  164. package/dist/tools/office/common/constants.js.map +0 -1
  165. package/dist/tools/office/common/index.d.ts.map +0 -1
  166. package/dist/tools/office/common/index.js.map +0 -1
  167. package/dist/tools/office/common/types.d.ts.map +0 -1
  168. package/dist/tools/office/common/types.js.map +0 -1
  169. package/dist/tools/office/common/utils.d.ts.map +0 -1
  170. package/dist/tools/office/common/utils.js.map +0 -1
  171. package/dist/tools/office/excel-client.d.ts.map +0 -1
  172. package/dist/tools/office/excel-client.js.map +0 -1
  173. package/dist/tools/office/excel-tools/cells.d.ts.map +0 -1
  174. package/dist/tools/office/excel-tools/cells.js.map +0 -1
  175. package/dist/tools/office/excel-tools/charts.d.ts.map +0 -1
  176. package/dist/tools/office/excel-tools/charts.js.map +0 -1
  177. package/dist/tools/office/excel-tools/comments.d.ts.map +0 -1
  178. package/dist/tools/office/excel-tools/comments.js.map +0 -1
  179. package/dist/tools/office/excel-tools/data-ops.d.ts.map +0 -1
  180. package/dist/tools/office/excel-tools/data-ops.js.map +0 -1
  181. package/dist/tools/office/excel-tools/export.d.ts.map +0 -1
  182. package/dist/tools/office/excel-tools/export.js.map +0 -1
  183. package/dist/tools/office/excel-tools/formatting.d.ts.map +0 -1
  184. package/dist/tools/office/excel-tools/formatting.js.map +0 -1
  185. package/dist/tools/office/excel-tools/index.d.ts.map +0 -1
  186. package/dist/tools/office/excel-tools/index.js.map +0 -1
  187. package/dist/tools/office/excel-tools/launch.d.ts.map +0 -1
  188. package/dist/tools/office/excel-tools/launch.js.map +0 -1
  189. package/dist/tools/office/excel-tools/media.d.ts.map +0 -1
  190. package/dist/tools/office/excel-tools/media.js.map +0 -1
  191. package/dist/tools/office/excel-tools/named-ranges.d.ts.map +0 -1
  192. package/dist/tools/office/excel-tools/named-ranges.js.map +0 -1
  193. package/dist/tools/office/excel-tools/protection.d.ts.map +0 -1
  194. package/dist/tools/office/excel-tools/protection.js.map +0 -1
  195. package/dist/tools/office/excel-tools/rows-columns.d.ts.map +0 -1
  196. package/dist/tools/office/excel-tools/rows-columns.js.map +0 -1
  197. package/dist/tools/office/excel-tools/sheets.d.ts.map +0 -1
  198. package/dist/tools/office/excel-tools/sheets.js.map +0 -1
  199. package/dist/tools/office/excel-tools/validation.d.ts.map +0 -1
  200. package/dist/tools/office/excel-tools/validation.js.map +0 -1
  201. package/dist/tools/office/excel-tools.d.ts.map +0 -1
  202. package/dist/tools/office/excel-tools.js.map +0 -1
  203. package/dist/tools/office/index.d.ts.map +0 -1
  204. package/dist/tools/office/index.js.map +0 -1
  205. package/dist/tools/office/office-client-base.d.ts.map +0 -1
  206. package/dist/tools/office/office-client-base.js.map +0 -1
  207. package/dist/tools/office/office-client.d.ts.map +0 -1
  208. package/dist/tools/office/office-client.js.map +0 -1
  209. package/dist/tools/office/powerpoint-client.d.ts.map +0 -1
  210. package/dist/tools/office/powerpoint-client.js.map +0 -1
  211. package/dist/tools/office/powerpoint-tools/effects.d.ts.map +0 -1
  212. package/dist/tools/office/powerpoint-tools/effects.js.map +0 -1
  213. package/dist/tools/office/powerpoint-tools/export.d.ts.map +0 -1
  214. package/dist/tools/office/powerpoint-tools/export.js.map +0 -1
  215. package/dist/tools/office/powerpoint-tools/index.d.ts.map +0 -1
  216. package/dist/tools/office/powerpoint-tools/index.js.map +0 -1
  217. package/dist/tools/office/powerpoint-tools/launch.d.ts.map +0 -1
  218. package/dist/tools/office/powerpoint-tools/launch.js.map +0 -1
  219. package/dist/tools/office/powerpoint-tools/media.d.ts.map +0 -1
  220. package/dist/tools/office/powerpoint-tools/media.js.map +0 -1
  221. package/dist/tools/office/powerpoint-tools/notes.d.ts.map +0 -1
  222. package/dist/tools/office/powerpoint-tools/notes.js.map +0 -1
  223. package/dist/tools/office/powerpoint-tools/sections.d.ts.map +0 -1
  224. package/dist/tools/office/powerpoint-tools/sections.js.map +0 -1
  225. package/dist/tools/office/powerpoint-tools/shapes.d.ts.map +0 -1
  226. package/dist/tools/office/powerpoint-tools/shapes.js.map +0 -1
  227. package/dist/tools/office/powerpoint-tools/slides.d.ts.map +0 -1
  228. package/dist/tools/office/powerpoint-tools/slides.js.map +0 -1
  229. package/dist/tools/office/powerpoint-tools/tables.d.ts.map +0 -1
  230. package/dist/tools/office/powerpoint-tools/tables.js.map +0 -1
  231. package/dist/tools/office/powerpoint-tools/text.d.ts.map +0 -1
  232. package/dist/tools/office/powerpoint-tools/text.js.map +0 -1
  233. package/dist/tools/office/powerpoint-tools.d.ts.map +0 -1
  234. package/dist/tools/office/powerpoint-tools.js.map +0 -1
  235. package/dist/tools/office/word-client.d.ts.map +0 -1
  236. package/dist/tools/office/word-client.js.map +0 -1
  237. package/dist/tools/office/word-tools/bookmarks.d.ts.map +0 -1
  238. package/dist/tools/office/word-tools/bookmarks.js.map +0 -1
  239. package/dist/tools/office/word-tools/comments.d.ts.map +0 -1
  240. package/dist/tools/office/word-tools/comments.js.map +0 -1
  241. package/dist/tools/office/word-tools/content.d.ts.map +0 -1
  242. package/dist/tools/office/word-tools/content.js.map +0 -1
  243. package/dist/tools/office/word-tools/export.d.ts.map +0 -1
  244. package/dist/tools/office/word-tools/export.js.map +0 -1
  245. package/dist/tools/office/word-tools/formatting.d.ts.map +0 -1
  246. package/dist/tools/office/word-tools/formatting.js.map +0 -1
  247. package/dist/tools/office/word-tools/headers-footers.d.ts.map +0 -1
  248. package/dist/tools/office/word-tools/headers-footers.js.map +0 -1
  249. package/dist/tools/office/word-tools/index.d.ts.map +0 -1
  250. package/dist/tools/office/word-tools/index.js.map +0 -1
  251. package/dist/tools/office/word-tools/launch.d.ts.map +0 -1
  252. package/dist/tools/office/word-tools/launch.js.map +0 -1
  253. package/dist/tools/office/word-tools/lists.d.ts.map +0 -1
  254. package/dist/tools/office/word-tools/lists.js.map +0 -1
  255. package/dist/tools/office/word-tools/navigation.d.ts.map +0 -1
  256. package/dist/tools/office/word-tools/navigation.js.map +0 -1
  257. package/dist/tools/office/word-tools/page-setup.d.ts.map +0 -1
  258. package/dist/tools/office/word-tools/page-setup.js.map +0 -1
  259. package/dist/tools/office/word-tools/tables.d.ts.map +0 -1
  260. package/dist/tools/office/word-tools/tables.js.map +0 -1
  261. package/dist/tools/office/word-tools/text.d.ts.map +0 -1
  262. package/dist/tools/office/word-tools/text.js.map +0 -1
  263. package/dist/tools/office/word-tools/undo-redo.d.ts.map +0 -1
  264. package/dist/tools/office/word-tools/undo-redo.js.map +0 -1
  265. package/dist/tools/office/word-tools/watermarks.d.ts.map +0 -1
  266. package/dist/tools/office/word-tools/watermarks.js.map +0 -1
  267. package/dist/tools/office/word-tools.d.ts.map +0 -1
  268. package/dist/tools/office/word-tools.js.map +0 -1
  269. package/dist/tools/registry.d.ts.map +0 -1
  270. package/dist/tools/registry.js.map +0 -1
  271. package/dist/tools/types.d.ts.map +0 -1
  272. package/dist/tools/types.js.map +0 -1
  273. package/dist/types/index.d.ts.map +0 -1
  274. package/dist/types/index.js.map +0 -1
  275. package/dist/ui/PlanExecuteView.d.ts.map +0 -1
  276. package/dist/ui/PlanExecuteView.js.map +0 -1
  277. package/dist/ui/TodoPanel.d.ts.map +0 -1
  278. package/dist/ui/TodoPanel.js.map +0 -1
  279. package/dist/ui/UpdateNotification.d.ts.map +0 -1
  280. package/dist/ui/UpdateNotification.js.map +0 -1
  281. package/dist/ui/components/ActivityIndicator.d.ts.map +0 -1
  282. package/dist/ui/components/ActivityIndicator.js.map +0 -1
  283. package/dist/ui/components/CommandBrowser.d.ts.map +0 -1
  284. package/dist/ui/components/CommandBrowser.js.map +0 -1
  285. package/dist/ui/components/CustomTextInput.d.ts.map +0 -1
  286. package/dist/ui/components/CustomTextInput.js.map +0 -1
  287. package/dist/ui/components/DocsSearchProgress.d.ts.map +0 -1
  288. package/dist/ui/components/DocsSearchProgress.js.map +0 -1
  289. package/dist/ui/components/FileBrowser.d.ts.map +0 -1
  290. package/dist/ui/components/FileBrowser.js.map +0 -1
  291. package/dist/ui/components/LLMSetupWizard.d.ts.map +0 -1
  292. package/dist/ui/components/LLMSetupWizard.js.map +0 -1
  293. package/dist/ui/components/Logo.d.ts.map +0 -1
  294. package/dist/ui/components/Logo.js.map +0 -1
  295. package/dist/ui/components/MarkdownRenderer.d.ts.map +0 -1
  296. package/dist/ui/components/MarkdownRenderer.js.map +0 -1
  297. package/dist/ui/components/ModelSelector.d.ts.map +0 -1
  298. package/dist/ui/components/ModelSelector.js.map +0 -1
  299. package/dist/ui/components/PlanExecuteApp.d.ts.map +0 -1
  300. package/dist/ui/components/PlanExecuteApp.js.map +0 -1
  301. package/dist/ui/components/ProgressBar.d.ts.map +0 -1
  302. package/dist/ui/components/ProgressBar.js.map +0 -1
  303. package/dist/ui/components/StatusBar.d.ts.map +0 -1
  304. package/dist/ui/components/StatusBar.js.map +0 -1
  305. package/dist/ui/components/ThinkingIndicator.d.ts.map +0 -1
  306. package/dist/ui/components/ThinkingIndicator.js.map +0 -1
  307. package/dist/ui/components/TodoListView.d.ts.map +0 -1
  308. package/dist/ui/components/TodoListView.js.map +0 -1
  309. package/dist/ui/components/ToolSelector.d.ts.map +0 -1
  310. package/dist/ui/components/ToolSelector.js.map +0 -1
  311. package/dist/ui/components/dialogs/ApprovalDialog.d.ts.map +0 -1
  312. package/dist/ui/components/dialogs/ApprovalDialog.js.map +0 -1
  313. package/dist/ui/components/dialogs/AskUserDialog.d.ts.map +0 -1
  314. package/dist/ui/components/dialogs/AskUserDialog.js.map +0 -1
  315. package/dist/ui/components/dialogs/DocsBrowser.d.ts.map +0 -1
  316. package/dist/ui/components/dialogs/DocsBrowser.js.map +0 -1
  317. package/dist/ui/components/dialogs/SettingsDialog.d.ts.map +0 -1
  318. package/dist/ui/components/dialogs/SettingsDialog.js.map +0 -1
  319. package/dist/ui/components/dialogs/index.d.ts.map +0 -1
  320. package/dist/ui/components/dialogs/index.js.map +0 -1
  321. package/dist/ui/components/index.d.ts.map +0 -1
  322. package/dist/ui/components/index.js.map +0 -1
  323. package/dist/ui/components/panels/LogPanel.d.ts.map +0 -1
  324. package/dist/ui/components/panels/LogPanel.js.map +0 -1
  325. package/dist/ui/components/panels/SessionPanel.d.ts.map +0 -1
  326. package/dist/ui/components/panels/SessionPanel.js.map +0 -1
  327. package/dist/ui/components/panels/index.d.ts.map +0 -1
  328. package/dist/ui/components/panels/index.js.map +0 -1
  329. package/dist/ui/components/views/ChatView.d.ts.map +0 -1
  330. package/dist/ui/components/views/ChatView.js.map +0 -1
  331. package/dist/ui/components/views/index.d.ts.map +0 -1
  332. package/dist/ui/components/views/index.js.map +0 -1
  333. package/dist/ui/contexts/TokenContext.d.ts.map +0 -1
  334. package/dist/ui/contexts/TokenContext.js.map +0 -1
  335. package/dist/ui/hooks/atFileProcessor.d.ts.map +0 -1
  336. package/dist/ui/hooks/atFileProcessor.js.map +0 -1
  337. package/dist/ui/hooks/index.d.ts.map +0 -1
  338. package/dist/ui/hooks/index.js.map +0 -1
  339. package/dist/ui/hooks/slashCommandProcessor.d.ts.map +0 -1
  340. package/dist/ui/hooks/slashCommandProcessor.js.map +0 -1
  341. package/dist/ui/hooks/useCommandBrowserState.d.ts.map +0 -1
  342. package/dist/ui/hooks/useCommandBrowserState.js.map +0 -1
  343. package/dist/ui/hooks/useFileBrowserState.d.ts.map +0 -1
  344. package/dist/ui/hooks/useFileBrowserState.js.map +0 -1
  345. package/dist/ui/hooks/useFileList.d.ts.map +0 -1
  346. package/dist/ui/hooks/useFileList.js.map +0 -1
  347. package/dist/ui/hooks/useInputHistory.d.ts.map +0 -1
  348. package/dist/ui/hooks/useInputHistory.js.map +0 -1
  349. package/dist/ui/hooks/usePlanExecution.d.ts.map +0 -1
  350. package/dist/ui/hooks/usePlanExecution.js.map +0 -1
  351. package/dist/ui/index.d.ts.map +0 -1
  352. package/dist/ui/index.js.map +0 -1
  353. package/dist/ui/ink-entry.d.ts.map +0 -1
  354. package/dist/ui/ink-entry.js.map +0 -1
  355. package/dist/utils/env-filter.d.ts.map +0 -1
  356. package/dist/utils/env-filter.js.map +0 -1
  357. package/dist/utils/file-system.d.ts.map +0 -1
  358. package/dist/utils/file-system.js.map +0 -1
  359. package/dist/utils/git-utils.d.ts.map +0 -1
  360. package/dist/utils/git-utils.js.map +0 -1
  361. package/dist/utils/json-stream-logger.d.ts.map +0 -1
  362. package/dist/utils/json-stream-logger.js.map +0 -1
  363. package/dist/utils/logger.d.ts.map +0 -1
  364. package/dist/utils/logger.js.map +0 -1
  365. package/dist/utils/platform-utils.d.ts.map +0 -1
  366. package/dist/utils/platform-utils.js.map +0 -1
  367. package/dist/utils/wsl-utils.d.ts.map +0 -1
  368. package/dist/utils/wsl-utils.js.map +0 -1
  369. package/electron.vite.config.ts +0 -63
  370. package/google374b9eba0c52b043.html +0 -1
  371. package/src/agents/base/base-agent.ts +0 -159
  372. package/src/agents/docs-search/index.ts +0 -365
  373. package/src/agents/index.ts +0 -34
  374. package/src/agents/planner/index.ts +0 -544
  375. package/src/cli.ts +0 -201
  376. package/src/constants.ts +0 -47
  377. package/src/core/compact/compact-manager.ts +0 -160
  378. package/src/core/compact/compact-prompts.ts +0 -150
  379. package/src/core/compact/context-tracker.ts +0 -164
  380. package/src/core/compact/index.ts +0 -25
  381. package/src/core/config/config-manager.ts +0 -460
  382. package/src/core/config/index.ts +0 -5
  383. package/src/core/docs-manager.ts +0 -678
  384. package/src/core/llm/index.ts +0 -7
  385. package/src/core/llm/llm-client.ts +0 -1550
  386. package/src/core/session/index.ts +0 -5
  387. package/src/core/session/session-manager.ts +0 -464
  388. package/src/core/slash-command-handler.ts +0 -410
  389. package/src/core/usage-tracker.ts +0 -438
  390. package/src/errors/base.ts +0 -81
  391. package/src/errors/file.ts +0 -183
  392. package/src/errors/index.ts +0 -95
  393. package/src/errors/llm.ts +0 -151
  394. package/src/errors/network.ts +0 -124
  395. package/src/errors/validation.ts +0 -111
  396. package/src/eval/eval-runner.ts +0 -456
  397. package/src/eval/index.ts +0 -8
  398. package/src/eval/types.ts +0 -139
  399. package/src/index.ts +0 -22
  400. package/src/orchestration/index.ts +0 -30
  401. package/src/orchestration/plan-executor.ts +0 -652
  402. package/src/orchestration/types.ts +0 -127
  403. package/src/orchestration/utils.ts +0 -119
  404. package/src/orquesta/connection.ts +0 -291
  405. package/src/prompts/agents/docs-search-decision.ts +0 -74
  406. package/src/prompts/agents/docs-search.ts +0 -84
  407. package/src/prompts/agents/planning.ts +0 -143
  408. package/src/prompts/index.ts +0 -31
  409. package/src/prompts/shared/codebase-rules.ts +0 -29
  410. package/src/prompts/shared/git-rules.ts +0 -94
  411. package/src/prompts/shared/language-rules.ts +0 -36
  412. package/src/prompts/shared/tool-usage.ts +0 -72
  413. package/src/prompts/system/compact.ts +0 -80
  414. package/src/prompts/system/plan-execute.ts +0 -89
  415. package/src/tools/browser/browser-client.ts +0 -1363
  416. package/src/tools/browser/browser-tools.ts +0 -1139
  417. package/src/tools/browser/index.ts +0 -65
  418. package/src/tools/index.ts +0 -23
  419. package/src/tools/llm/agents/docs-search-tools.ts +0 -368
  420. package/src/tools/llm/agents/index.ts +0 -22
  421. package/src/tools/llm/index.ts +0 -11
  422. package/src/tools/llm/simple/ask-user-tool.ts +0 -25
  423. package/src/tools/llm/simple/background-bash-tool.ts +0 -443
  424. package/src/tools/llm/simple/background-powershell-tool.ts +0 -421
  425. package/src/tools/llm/simple/bash-tool.ts +0 -238
  426. package/src/tools/llm/simple/docs-search-agent-tool.ts +0 -146
  427. package/src/tools/llm/simple/file-tools.ts +0 -1051
  428. package/src/tools/llm/simple/final-response-tool.ts +0 -180
  429. package/src/tools/llm/simple/index.ts +0 -42
  430. package/src/tools/llm/simple/planning-tools.ts +0 -143
  431. package/src/tools/llm/simple/powershell-tool.ts +0 -241
  432. package/src/tools/llm/simple/simple-tool-executor.ts +0 -279
  433. package/src/tools/llm/simple/todo-tools.ts +0 -207
  434. package/src/tools/llm/simple/user-interaction-tools.ts +0 -277
  435. package/src/tools/office/common/constants.ts +0 -335
  436. package/src/tools/office/common/index.ts +0 -133
  437. package/src/tools/office/common/types.ts +0 -286
  438. package/src/tools/office/common/utils.ts +0 -116
  439. package/src/tools/office/excel-client.ts +0 -1336
  440. package/src/tools/office/excel-tools/cells.ts +0 -359
  441. package/src/tools/office/excel-tools/charts.ts +0 -166
  442. package/src/tools/office/excel-tools/comments.ts +0 -155
  443. package/src/tools/office/excel-tools/data-ops.ts +0 -349
  444. package/src/tools/office/excel-tools/export.ts +0 -105
  445. package/src/tools/office/excel-tools/formatting.ts +0 -357
  446. package/src/tools/office/excel-tools/index.ts +0 -55
  447. package/src/tools/office/excel-tools/launch.ts +0 -303
  448. package/src/tools/office/excel-tools/media.ts +0 -117
  449. package/src/tools/office/excel-tools/named-ranges.ts +0 -148
  450. package/src/tools/office/excel-tools/protection.ts +0 -105
  451. package/src/tools/office/excel-tools/rows-columns.ts +0 -386
  452. package/src/tools/office/excel-tools/sheets.ts +0 -228
  453. package/src/tools/office/excel-tools/validation.ts +0 -226
  454. package/src/tools/office/excel-tools.ts +0 -9
  455. package/src/tools/office/index.ts +0 -259
  456. package/src/tools/office/office-client-base.ts +0 -242
  457. package/src/tools/office/office-client.ts +0 -377
  458. package/src/tools/office/powerpoint-client.ts +0 -1498
  459. package/src/tools/office/powerpoint-tools/effects.ts +0 -315
  460. package/src/tools/office/powerpoint-tools/export.ts +0 -138
  461. package/src/tools/office/powerpoint-tools/index.ts +0 -45
  462. package/src/tools/office/powerpoint-tools/launch.ts +0 -263
  463. package/src/tools/office/powerpoint-tools/media.ts +0 -291
  464. package/src/tools/office/powerpoint-tools/notes.ts +0 -220
  465. package/src/tools/office/powerpoint-tools/sections.ts +0 -140
  466. package/src/tools/office/powerpoint-tools/shapes.ts +0 -870
  467. package/src/tools/office/powerpoint-tools/slides.ts +0 -350
  468. package/src/tools/office/powerpoint-tools/tables.ts +0 -182
  469. package/src/tools/office/powerpoint-tools/text.ts +0 -473
  470. package/src/tools/office/powerpoint-tools.ts +0 -9
  471. package/src/tools/office/word-client.ts +0 -1697
  472. package/src/tools/office/word-tools/bookmarks.ts +0 -186
  473. package/src/tools/office/word-tools/comments.ts +0 -185
  474. package/src/tools/office/word-tools/content.ts +0 -229
  475. package/src/tools/office/word-tools/export.ts +0 -97
  476. package/src/tools/office/word-tools/formatting.ts +0 -161
  477. package/src/tools/office/word-tools/headers-footers.ts +0 -155
  478. package/src/tools/office/word-tools/index.ts +0 -57
  479. package/src/tools/office/word-tools/launch.ts +0 -312
  480. package/src/tools/office/word-tools/lists.ts +0 -97
  481. package/src/tools/office/word-tools/navigation.ts +0 -114
  482. package/src/tools/office/word-tools/page-setup.ts +0 -195
  483. package/src/tools/office/word-tools/tables.ts +0 -262
  484. package/src/tools/office/word-tools/text.ts +0 -294
  485. package/src/tools/office/word-tools/undo-redo.ts +0 -97
  486. package/src/tools/office/word-tools/watermarks.ts +0 -105
  487. package/src/tools/office/word-tools.ts +0 -9
  488. package/src/tools/registry.ts +0 -527
  489. package/src/tools/types.ts +0 -231
  490. package/src/types/index.ts +0 -181
  491. package/src/ui/PlanExecuteView.tsx +0 -119
  492. package/src/ui/TodoPanel.tsx +0 -240
  493. package/src/ui/UpdateNotification.tsx +0 -105
  494. package/src/ui/components/ActivityIndicator.tsx +0 -234
  495. package/src/ui/components/CommandBrowser.tsx +0 -114
  496. package/src/ui/components/CustomTextInput.tsx +0 -389
  497. package/src/ui/components/DocsSearchProgress.tsx +0 -85
  498. package/src/ui/components/FileBrowser.tsx +0 -93
  499. package/src/ui/components/LLMSetupWizard.tsx +0 -333
  500. package/src/ui/components/Logo.tsx +0 -125
  501. package/src/ui/components/MarkdownRenderer.tsx +0 -358
  502. package/src/ui/components/ModelSelector.tsx +0 -203
  503. package/src/ui/components/PlanExecuteApp.tsx +0 -2007
  504. package/src/ui/components/ProgressBar.tsx +0 -51
  505. package/src/ui/components/StatusBar.tsx +0 -302
  506. package/src/ui/components/ThinkingIndicator.tsx +0 -120
  507. package/src/ui/components/TodoListView.tsx +0 -140
  508. package/src/ui/components/ToolSelector.tsx +0 -215
  509. package/src/ui/components/dialogs/ApprovalDialog.tsx +0 -259
  510. package/src/ui/components/dialogs/AskUserDialog.tsx +0 -159
  511. package/src/ui/components/dialogs/DocsBrowser.tsx +0 -222
  512. package/src/ui/components/dialogs/SettingsDialog.tsx +0 -939
  513. package/src/ui/components/dialogs/index.ts +0 -13
  514. package/src/ui/components/index.ts +0 -27
  515. package/src/ui/components/panels/LogPanel.tsx +0 -385
  516. package/src/ui/components/panels/SessionPanel.tsx +0 -146
  517. package/src/ui/components/panels/index.ts +0 -13
  518. package/src/ui/components/views/ChatView.tsx +0 -447
  519. package/src/ui/components/views/index.ts +0 -5
  520. package/src/ui/contexts/TokenContext.tsx +0 -139
  521. package/src/ui/hooks/atFileProcessor.ts +0 -167
  522. package/src/ui/hooks/index.ts +0 -11
  523. package/src/ui/hooks/slashCommandProcessor.ts +0 -174
  524. package/src/ui/hooks/useCommandBrowserState.ts +0 -97
  525. package/src/ui/hooks/useFileBrowserState.ts +0 -116
  526. package/src/ui/hooks/useFileList.ts +0 -132
  527. package/src/ui/hooks/useInputHistory.ts +0 -89
  528. package/src/ui/hooks/usePlanExecution.ts +0 -339
  529. package/src/ui/index.ts +0 -10
  530. package/src/ui/ink-entry.tsx +0 -36
  531. package/src/utils/env-filter.ts +0 -164
  532. package/src/utils/file-system.ts +0 -133
  533. package/src/utils/git-utils.ts +0 -30
  534. package/src/utils/json-stream-logger.ts +0 -1259
  535. package/src/utils/logger.ts +0 -2767
  536. package/src/utils/platform-utils.ts +0 -256
  537. package/src/utils/wsl-utils.ts +0 -113
  538. package/tsconfig.electron.json +0 -39
  539. package/tsconfig.json +0 -64
@@ -1,1336 +0,0 @@
1
- /**
2
- * Excel Client
3
- *
4
- * Microsoft Excel automation via PowerShell COM.
5
- * Extends OfficeClientBase with Excel-specific operations.
6
- */
7
-
8
- import { OfficeClientBase, OfficeResponse, ScreenshotResponse } from './office-client-base.js';
9
-
10
- /**
11
- * Convert column letter (A, B, ..., Z, AA, AB, ...) to number (1, 2, ..., 26, 27, 28, ...)
12
- */
13
- function columnLetterToNumber(column: string): number {
14
- let result = 0;
15
- for (let i = 0; i < column.length; i++) {
16
- result = result * 26 + (column.charCodeAt(i) - 'A'.charCodeAt(0) + 1);
17
- }
18
- return result;
19
- }
20
-
21
- /**
22
- * Convert column number (1, 2, ..., 26, 27, 28, ...) to letter (A, B, ..., Z, AA, AB, ...)
23
- */
24
- function columnNumberToLetter(num: number): string {
25
- let result = '';
26
- while (num > 0) {
27
- num--;
28
- result = String.fromCharCode('A'.charCodeAt(0) + (num % 26)) + result;
29
- num = Math.floor(num / 26);
30
- }
31
- return result;
32
- }
33
-
34
- export class ExcelClient extends OfficeClientBase {
35
- async excelLaunch(): Promise<OfficeResponse> {
36
- return this.executePowerShell(`
37
- try {
38
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
39
- $excel.Visible = $true
40
- @{ success = $true; message = "Connected to existing Excel instance" } | ConvertTo-Json -Compress
41
- } catch {
42
- $excel = New-Object -ComObject Excel.Application
43
- $excel.Visible = $true
44
- @{ success = $true; message = "Launched new Excel instance" } | ConvertTo-Json -Compress
45
- }
46
- `);
47
- }
48
-
49
- async excelCreate(): Promise<OfficeResponse> {
50
- return this.executePowerShell(`
51
- try {
52
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
53
- } catch {
54
- $excel = New-Object -ComObject Excel.Application
55
- $excel.Visible = $true
56
- }
57
- $workbook = $excel.Workbooks.Add()
58
- @{ success = $true; message = "Created new workbook"; workbook_name = $workbook.Name } | ConvertTo-Json -Compress
59
- `);
60
- }
61
-
62
- async excelOpen(filePath: string): Promise<OfficeResponse> {
63
- const windowsPath = this.toWindowsPath(filePath).replace(/'/g, "''");
64
- return this.executePowerShell(`
65
- try {
66
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
67
- } catch {
68
- $excel = New-Object -ComObject Excel.Application
69
- $excel.Visible = $true
70
- }
71
- $workbook = $excel.Workbooks.Open('${windowsPath}')
72
- @{ success = $true; message = "Workbook opened"; workbook_name = $workbook.Name; path = $workbook.FullName } | ConvertTo-Json -Compress
73
- `);
74
- }
75
-
76
- async excelWriteCell(
77
- cell: string,
78
- value: unknown,
79
- sheet?: string,
80
- options?: { fontName?: string; fontSize?: number; bold?: boolean; asText?: boolean }
81
- ): Promise<OfficeResponse> {
82
- const strValue = String(value);
83
- const escapedValue = strValue.replace(/'/g, "''");
84
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
85
-
86
- // Auto-detect Korean and set font
87
- const hasKorean = /[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(strValue);
88
- const fontName = options?.fontName || (hasKorean ? 'Malgun Gothic' : '');
89
-
90
- // TEXT FIRST, FONT AFTER pattern (Microsoft recommended for Korean)
91
- const fontScript: string[] = [];
92
- if (fontName) fontScript.push(`$range.Font.Name = '${fontName.replace(/'/g, "''")}'`);
93
- if (options?.fontSize) fontScript.push(`$range.Font.Size = ${options.fontSize}`);
94
- if (options?.bold !== undefined) fontScript.push(`$range.Font.Bold = ${options.bold ? '$true' : '$false'}`);
95
-
96
- // Determine how to set the value:
97
- // - Numbers: set without quotes so Excel recognizes them
98
- // - Dates (YYYY-MM-DD, MM/DD/YYYY): use DateValue or let Excel parse
99
- // - asText option: force text format
100
- // - Otherwise: let Excel auto-detect (without forcing string)
101
- let valueScript: string;
102
-
103
- if (options?.asText) {
104
- // Force text format
105
- valueScript = `$range.NumberFormat = '@'; $range.Value = '${escapedValue}'`;
106
- } else if (typeof value === 'number' || (strValue !== '' && !isNaN(Number(strValue)) && strValue.trim() !== '')) {
107
- // Numeric value - don't quote
108
- valueScript = `$range.Value = ${strValue}`;
109
- } else if (/^\d{4}-\d{2}-\d{2}$/.test(strValue)) {
110
- // ISO date format (YYYY-MM-DD) - convert to Excel date
111
- const [year, month, day] = strValue.split('-');
112
- valueScript = `$range.Value = (Get-Date -Year ${year} -Month ${month} -Day ${day}).ToOADate()`;
113
- } else if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(strValue)) {
114
- // US date format (MM/DD/YYYY) - let Excel parse
115
- valueScript = `$range.Value = '${escapedValue}'`;
116
- } else {
117
- // Default: set as-is and let Excel auto-detect
118
- valueScript = `$range.Value = '${escapedValue}'`;
119
- }
120
-
121
- return this.executePowerShell(`
122
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
123
- $workbook = $excel.ActiveWorkbook
124
- ${sheetScript}
125
- $range = $sheet.Range('${cell}')
126
- ${valueScript}
127
- ${fontScript.join('\n')}
128
- @{ success = $true; message = "Value written to ${cell}" } | ConvertTo-Json -Compress
129
- `);
130
- }
131
-
132
- async excelReadCell(cell: string, sheet?: string): Promise<OfficeResponse> {
133
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
134
- return this.executePowerShell(`
135
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
136
- $workbook = $excel.ActiveWorkbook
137
- ${sheetScript}
138
- $value = $sheet.Range('${cell}').Value2
139
- @{ success = $true; cell = '${cell}'; value = $value } | ConvertTo-Json -Compress
140
- `);
141
- }
142
-
143
- async excelWriteRange(startCell: string, values: unknown[][], sheet?: string): Promise<OfficeResponse> {
144
- const rows = values.length;
145
- const cols = values[0]?.length || 0;
146
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
147
-
148
- // Check for Korean text in any cell
149
- let hasKorean = false;
150
-
151
- // Helper to convert value to PowerShell format
152
- const toPsValue = (v: unknown): string => {
153
- const str = String(v);
154
- if (/[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(str)) hasKorean = true;
155
-
156
- // Numbers: output without quotes
157
- if (typeof v === 'number' || (str !== '' && !isNaN(Number(str)) && str.trim() !== '')) {
158
- return str;
159
- }
160
- // ISO date (YYYY-MM-DD): convert to OADate expression
161
- if (/^\d{4}-\d{2}-\d{2}$/.test(str)) {
162
- const [year, month, day] = str.split('-');
163
- return `([DateTime]::new(${year},${month},${day})).ToOADate()`;
164
- }
165
- // Default: string with escaped quotes
166
- return `'${str.replace(/'/g, "''")}'`;
167
- };
168
-
169
- // Build PowerShell 2D array
170
- const arrayLines: string[] = [];
171
- for (let i = 0; i < values.length; i++) {
172
- const row = values[i];
173
- if (!row) continue;
174
- const rowValues = row.map(v => toPsValue(v)).join(',');
175
- arrayLines.push(`@(${rowValues})`);
176
- }
177
- const arrayScript = `@(${arrayLines.join(',')})`;
178
-
179
- // TEXT FIRST, FONT AFTER pattern (Microsoft recommended for Korean)
180
- const fontScript = hasKorean ? "$range.Font.Name = 'Malgun Gothic'" : '';
181
-
182
- return this.executePowerShell(`
183
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
184
- $workbook = $excel.ActiveWorkbook
185
- ${sheetScript}
186
- $startRange = $sheet.Range('${startCell}')
187
- $endCell = $sheet.Cells($startRange.Row + ${rows - 1}, $startRange.Column + ${cols - 1})
188
- $range = $sheet.Range($startRange, $endCell)
189
- $data = ${arrayScript}
190
- $range.Value = $data
191
- ${fontScript}
192
- @{ success = $true; message = "Range written from ${startCell} (${rows}x${cols})" } | ConvertTo-Json -Compress
193
- `);
194
- }
195
-
196
- async excelReadRange(range: string, sheet?: string): Promise<OfficeResponse> {
197
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
198
- return this.executePowerShell(`
199
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
200
- $workbook = $excel.ActiveWorkbook
201
- ${sheetScript}
202
- $range = $sheet.Range('${range}')
203
- $values = $range.Value2
204
- $rows = $range.Rows.Count
205
- $cols = $range.Columns.Count
206
- @{ success = $true; range = '${range}'; values = $values; rows = $rows; columns = $cols } | ConvertTo-Json -Compress -Depth 10
207
- `);
208
- }
209
-
210
- async excelSave(filePath?: string): Promise<OfficeResponse> {
211
- const windowsPath = filePath ? this.toWindowsPath(filePath).replace(/'/g, "''") : '';
212
- return this.executePowerShell(`
213
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
214
- $workbook = $excel.ActiveWorkbook
215
- ${windowsPath ? `$workbook.SaveAs('${windowsPath}')` : '$workbook.Save()'}
216
- @{ success = $true; message = "Workbook saved"; path = $workbook.FullName } | ConvertTo-Json -Compress
217
- `);
218
- }
219
-
220
- async excelClose(save: boolean = false): Promise<OfficeResponse> {
221
- return this.executePowerShell(`
222
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
223
- $workbook = $excel.ActiveWorkbook
224
- $workbook.Close(${save ? '$true' : '$false'})
225
- @{ success = $true; message = "Workbook closed" } | ConvertTo-Json -Compress
226
- `);
227
- }
228
-
229
- async excelQuit(save: boolean = false): Promise<OfficeResponse> {
230
- return this.executePowerShell(`
231
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
232
- if (${save ? '$true' : '$false'}) {
233
- foreach ($wb in $excel.Workbooks) { $wb.Save() }
234
- }
235
- $excel.Quit()
236
- @{ success = $true; message = "Excel closed" } | ConvertTo-Json -Compress
237
- `);
238
- }
239
-
240
- async excelSetFormula(cell: string, formula: string, sheet?: string): Promise<OfficeResponse> {
241
- const escapedFormula = formula.replace(/'/g, "''");
242
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
243
- return this.executePowerShell(`
244
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
245
- $workbook = $excel.ActiveWorkbook
246
- ${sheetScript}
247
- $sheet.Range('${cell}').Formula = '${escapedFormula}'
248
- @{ success = $true; message = "Formula set in ${cell}" } | ConvertTo-Json -Compress
249
- `);
250
- }
251
-
252
- async excelSetFont(
253
- range: string,
254
- options: {
255
- fontName?: string;
256
- fontSize?: number;
257
- bold?: boolean;
258
- italic?: boolean;
259
- underline?: boolean;
260
- color?: string;
261
- },
262
- sheet?: string
263
- ): Promise<OfficeResponse> {
264
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
265
- const commands: string[] = [];
266
- if (options.fontName) commands.push(`$range.Font.Name = '${options.fontName.replace(/'/g, "''")}'`);
267
- if (options.fontSize) commands.push(`$range.Font.Size = ${options.fontSize}`);
268
- if (options.bold !== undefined) commands.push(`$range.Font.Bold = ${options.bold ? '$true' : '$false'}`);
269
- if (options.italic !== undefined) commands.push(`$range.Font.Italic = ${options.italic ? '$true' : '$false'}`);
270
- if (options.underline !== undefined) commands.push(`$range.Font.Underline = ${options.underline ? '2' : '0'}`);
271
- if (options.color) {
272
- const rgb = this.hexToRgb(options.color);
273
- if (rgb) commands.push(`$range.Font.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`);
274
- }
275
-
276
- return this.executePowerShell(`
277
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
278
- $workbook = $excel.ActiveWorkbook
279
- ${sheetScript}
280
- $range = $sheet.Range('${range}')
281
- ${commands.join('\n')}
282
- @{ success = $true; message = "Font properties set for ${range}" } | ConvertTo-Json -Compress
283
- `);
284
- }
285
-
286
- async excelSetAlignment(
287
- range: string,
288
- options: {
289
- horizontal?: 'left' | 'center' | 'right';
290
- vertical?: 'top' | 'center' | 'bottom';
291
- wrapText?: boolean;
292
- orientation?: number;
293
- },
294
- sheet?: string
295
- ): Promise<OfficeResponse> {
296
- const hAlignMap: Record<string, number> = { left: -4131, center: -4108, right: -4152 };
297
- const vAlignMap: Record<string, number> = { top: -4160, center: -4108, bottom: -4107 };
298
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
299
- const commands: string[] = [];
300
- if (options.horizontal) commands.push(`$range.HorizontalAlignment = ${hAlignMap[options.horizontal]}`);
301
- if (options.vertical) commands.push(`$range.VerticalAlignment = ${vAlignMap[options.vertical]}`);
302
- if (options.wrapText !== undefined) commands.push(`$range.WrapText = ${options.wrapText ? '$true' : '$false'}`);
303
- if (options.orientation !== undefined) commands.push(`$range.Orientation = ${options.orientation}`);
304
-
305
- return this.executePowerShell(`
306
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
307
- $workbook = $excel.ActiveWorkbook
308
- ${sheetScript}
309
- $range = $sheet.Range('${range}')
310
- ${commands.join('\n')}
311
- @{ success = $true; message = "Alignment set for ${range}" } | ConvertTo-Json -Compress
312
- `);
313
- }
314
-
315
- async excelSetColumnWidth(column: string, width?: number, autoFit?: boolean, sheet?: string): Promise<OfficeResponse> {
316
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
317
- return this.executePowerShell(`
318
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
319
- $workbook = $excel.ActiveWorkbook
320
- ${sheetScript}
321
- $col = $sheet.Columns('${column}')
322
- ${autoFit ? '$col.AutoFit()' : `$col.ColumnWidth = ${width || 10}`}
323
- @{ success = $true; message = "Column ${column} width set" } | ConvertTo-Json -Compress
324
- `);
325
- }
326
-
327
- async excelSetRowHeight(row: number, height?: number, autoFit?: boolean, sheet?: string): Promise<OfficeResponse> {
328
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
329
- return this.executePowerShell(`
330
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
331
- $workbook = $excel.ActiveWorkbook
332
- ${sheetScript}
333
- $row = $sheet.Rows(${row})
334
- ${autoFit ? '$row.AutoFit()' : `$row.RowHeight = ${height || 15}`}
335
- @{ success = $true; message = "Row ${row} height set" } | ConvertTo-Json -Compress
336
- `);
337
- }
338
-
339
- async excelMergeCells(range: string, sheet?: string): Promise<OfficeResponse> {
340
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
341
- return this.executePowerShell(`
342
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
343
- $workbook = $excel.ActiveWorkbook
344
- ${sheetScript}
345
- $sheet.Range('${range}').Merge()
346
- @{ success = $true; message = "Cells merged: ${range}" } | ConvertTo-Json -Compress
347
- `);
348
- }
349
-
350
- async excelSetBorder(
351
- range: string,
352
- options: {
353
- style?: 'thin' | 'medium' | 'thick' | 'double' | 'dotted' | 'dashed';
354
- color?: string;
355
- edges?: ('left' | 'right' | 'top' | 'bottom' | 'all')[];
356
- },
357
- sheet?: string
358
- ): Promise<OfficeResponse> {
359
- // xlContinuous=1, xlDash=-4115, xlDot=-4118, xlDouble=-4119
360
- // For weight: xlThin=2, xlMedium=-4138, xlThick=4
361
- const styleMap: Record<string, number> = { thin: 1, medium: 1, thick: 1, double: -4119, dotted: -4118, dashed: -4115 };
362
- const weightMap: Record<string, number> = { thin: 2, medium: -4138, thick: 4, double: 2, dotted: 2, dashed: 2 };
363
- const edgeMap: Record<string, number> = { left: 7, right: 10, top: 8, bottom: 9, all: -1 };
364
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
365
- const edges = options.edges || ['all'];
366
- const borderStyle = options.style ? styleMap[options.style] : 1;
367
- const borderWeight = options.style ? weightMap[options.style] : 2;
368
-
369
- let borderScript = '';
370
- if (edges.includes('all')) {
371
- borderScript = `
372
- $range.Borders.LineStyle = ${borderStyle}
373
- $range.Borders.Weight = ${borderWeight}`;
374
- } else {
375
- borderScript = edges.map(e => `$range.Borders(${edgeMap[e]}).LineStyle = ${borderStyle}
376
- $range.Borders(${edgeMap[e]}).Weight = ${borderWeight}`).join('\n');
377
- }
378
-
379
- return this.executePowerShell(`
380
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
381
- $workbook = $excel.ActiveWorkbook
382
- ${sheetScript}
383
- $range = $sheet.Range('${range}')
384
- ${borderScript}
385
- @{ success = $true; message = "Border set for ${range}" } | ConvertTo-Json -Compress
386
- `);
387
- }
388
-
389
- async excelSetFill(range: string, color: string, sheet?: string): Promise<OfficeResponse> {
390
- const rgb = this.hexToRgb(color);
391
- const colorValue = rgb ? rgb.r + rgb.g * 256 + rgb.b * 65536 : 0;
392
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
393
- return this.executePowerShell(`
394
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
395
- $workbook = $excel.ActiveWorkbook
396
- ${sheetScript}
397
- $sheet.Range('${range}').Interior.Color = ${colorValue}
398
- @{ success = $true; message = "Fill color set for ${range}" } | ConvertTo-Json -Compress
399
- `);
400
- }
401
-
402
- async excelSetNumberFormat(range: string, format: string, sheet?: string): Promise<OfficeResponse> {
403
- const escapedFormat = format.replace(/'/g, "''");
404
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
405
- return this.executePowerShell(`
406
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
407
- $workbook = $excel.ActiveWorkbook
408
- ${sheetScript}
409
- $sheet.Range('${range}').NumberFormat = '${escapedFormat}'
410
- @{ success = $true; message = "Number format set for ${range}" } | ConvertTo-Json -Compress
411
- `);
412
- }
413
-
414
- async excelAddSheet(name?: string, position?: 'start' | 'end' | string): Promise<OfficeResponse> {
415
- const escapedName = name?.replace(/'/g, "''") || '';
416
- let positionScript = '';
417
- if (position === 'start') {
418
- positionScript = ', [ref]$workbook.Sheets(1)';
419
- } else if (position === 'end') {
420
- positionScript = ', , [ref]$workbook.Sheets($workbook.Sheets.Count)';
421
- } else if (position) {
422
- positionScript = `, , [ref]$workbook.Sheets('${position.replace(/'/g, "''")}')`;
423
- }
424
-
425
- return this.executePowerShell(`
426
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
427
- $workbook = $excel.ActiveWorkbook
428
- $newSheet = $workbook.Sheets.Add(${positionScript})
429
- ${escapedName ? `$newSheet.Name = '${escapedName}'` : ''}
430
- @{ success = $true; message = "Sheet added"; sheet_name = $newSheet.Name } | ConvertTo-Json -Compress
431
- `);
432
- }
433
-
434
- async excelDeleteSheet(name: string): Promise<OfficeResponse> {
435
- const escapedName = name.replace(/'/g, "''");
436
- return this.executePowerShell(`
437
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
438
- $workbook = $excel.ActiveWorkbook
439
- $excel.DisplayAlerts = $false
440
- $workbook.Sheets('${escapedName}').Delete()
441
- $excel.DisplayAlerts = $true
442
- @{ success = $true; message = "Sheet '${escapedName}' deleted" } | ConvertTo-Json -Compress
443
- `);
444
- }
445
-
446
- async excelRenameSheet(oldName: string, newName: string): Promise<OfficeResponse> {
447
- const escapedOld = oldName.replace(/'/g, "''");
448
- const escapedNew = newName.replace(/'/g, "''");
449
- return this.executePowerShell(`
450
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
451
- $workbook = $excel.ActiveWorkbook
452
- $workbook.Sheets('${escapedOld}').Name = '${escapedNew}'
453
- @{ success = $true; message = "Sheet renamed from '${escapedOld}' to '${escapedNew}'" } | ConvertTo-Json -Compress
454
- `);
455
- }
456
-
457
- async excelGetSheets(): Promise<OfficeResponse> {
458
- return this.executePowerShell(`
459
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
460
- $workbook = $excel.ActiveWorkbook
461
- $sheets = @()
462
- foreach ($sheet in $workbook.Sheets) {
463
- $sheets += $sheet.Name
464
- }
465
- @{ success = $true; sheets = $sheets; count = $sheets.Count } | ConvertTo-Json -Compress
466
- `);
467
- }
468
-
469
- async excelSortRange(
470
- range: string,
471
- sortColumn: string,
472
- ascending: boolean = true,
473
- hasHeader: boolean = true,
474
- sheet?: string
475
- ): Promise<OfficeResponse> {
476
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
477
- const order = ascending ? 1 : 2; // xlAscending = 1, xlDescending = 2
478
- const header = hasHeader ? 1 : 2; // xlYes = 1, xlNo = 2
479
-
480
- return this.executePowerShell(`
481
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
482
- $workbook = $excel.ActiveWorkbook
483
- ${sheetScript}
484
- $range = $sheet.Range('${range}')
485
- $sortKey = $sheet.Range('${sortColumn}1')
486
-
487
- # Use Sort object for better compatibility
488
- $sheet.Sort.SortFields.Clear()
489
- $sheet.Sort.SortFields.Add($sortKey, 0, ${order})
490
- $sheet.Sort.SetRange($range)
491
- $sheet.Sort.Header = ${header}
492
- $sheet.Sort.Apply()
493
-
494
- @{ success = $true; message = "Range sorted by column ${sortColumn}" } | ConvertTo-Json -Compress
495
- `);
496
- }
497
-
498
- async excelInsertRow(row: number, count: number = 1, sheet?: string): Promise<OfficeResponse> {
499
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
500
- return this.executePowerShell(`
501
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
502
- $workbook = $excel.ActiveWorkbook
503
- ${sheetScript}
504
- for ($i = 0; $i -lt ${count}; $i++) {
505
- $sheet.Rows(${row}).Insert()
506
- }
507
- @{ success = $true; message = "${count} row(s) inserted at row ${row}" } | ConvertTo-Json -Compress
508
- `);
509
- }
510
-
511
- async excelDeleteRow(row: number, count: number = 1, sheet?: string): Promise<OfficeResponse> {
512
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
513
- return this.executePowerShell(`
514
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
515
- $workbook = $excel.ActiveWorkbook
516
- ${sheetScript}
517
- $sheet.Rows("${row}:${row + count - 1}").Delete()
518
- @{ success = $true; message = "${count} row(s) deleted starting at row ${row}" } | ConvertTo-Json -Compress
519
- `);
520
- }
521
-
522
- async excelInsertColumn(column: string, count: number = 1, sheet?: string): Promise<OfficeResponse> {
523
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
524
- return this.executePowerShell(`
525
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
526
- $workbook = $excel.ActiveWorkbook
527
- ${sheetScript}
528
- for ($i = 0; $i -lt ${count}; $i++) {
529
- $sheet.Columns('${column}').Insert()
530
- }
531
- @{ success = $true; message = "${count} column(s) inserted at column ${column}" } | ConvertTo-Json -Compress
532
- `);
533
- }
534
-
535
- async excelDeleteColumn(column: string, count: number = 1, sheet?: string): Promise<OfficeResponse> {
536
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
537
- const startColNum = columnLetterToNumber(column.toUpperCase());
538
- const endCol = columnNumberToLetter(startColNum + count - 1);
539
- return this.executePowerShell(`
540
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
541
- $workbook = $excel.ActiveWorkbook
542
- ${sheetScript}
543
- $sheet.Columns("${column}:${endCol}").Delete()
544
- @{ success = $true; message = "${count} column(s) deleted starting at column ${column}" } | ConvertTo-Json -Compress
545
- `);
546
- }
547
-
548
- async excelFreezePanes(row?: number, column?: string, sheet?: string): Promise<OfficeResponse> {
549
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
550
- const cellRef = `${column || 'A'}${row || 1}`;
551
- return this.executePowerShell(`
552
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
553
- $workbook = $excel.ActiveWorkbook
554
- ${sheetScript}
555
- $sheet.Activate()
556
- $sheet.Range('${cellRef}').Select()
557
- $excel.ActiveWindow.FreezePanes = $true
558
- @{ success = $true; message = "Panes frozen at ${cellRef}" } | ConvertTo-Json -Compress
559
- `);
560
- }
561
-
562
- async excelAutoFilter(range: string, sheet?: string): Promise<OfficeResponse> {
563
- const sheetScript = sheet ? `$sheet = $workbook.Sheets('${sheet.replace(/'/g, "''")}')` : '$sheet = $workbook.ActiveSheet';
564
- return this.executePowerShell(`
565
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
566
- $workbook = $excel.ActiveWorkbook
567
- ${sheetScript}
568
- $sheet.Range('${range}').AutoFilter()
569
- @{ success = $true; message = "AutoFilter applied to ${range}" } | ConvertTo-Json -Compress
570
- `);
571
- }
572
-
573
- async excelScreenshot(): Promise<ScreenshotResponse> {
574
- const result = await this.executePowerShell(`
575
- Add-Type -AssemblyName System.Windows.Forms
576
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
577
- $sheet = $excel.ActiveWorkbook.ActiveSheet
578
-
579
- # Get used range and copy as picture
580
- $usedRange = $sheet.UsedRange
581
- $usedRange.CopyPicture(1, 2) # xlScreen=1, xlBitmap=2
582
-
583
- # Get image from clipboard
584
- Start-Sleep -Milliseconds 500
585
- $img = [System.Windows.Forms.Clipboard]::GetImage()
586
- if ($img -eq $null) {
587
- @{ success = $false; error = "Failed to capture screenshot" } | ConvertTo-Json -Compress
588
- return
589
- }
590
-
591
- # Convert to base64
592
- $ms = New-Object System.IO.MemoryStream
593
- $img.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
594
- $bytes = $ms.ToArray()
595
- $base64 = [Convert]::ToBase64String($bytes)
596
- $ms.Dispose()
597
- $img.Dispose()
598
-
599
- @{
600
- success = $true
601
- image = $base64
602
- format = "png"
603
- encoding = "base64"
604
- } | ConvertTo-Json -Compress
605
- `);
606
- return result as ScreenshotResponse;
607
- }
608
-
609
- // -------------------------------------------------------------------------
610
- // Excel Charts
611
- // -------------------------------------------------------------------------
612
-
613
- async excelAddChart(
614
- dataRange: string,
615
- chartType: 'column' | 'bar' | 'line' | 'pie' | 'area' | 'scatter' | 'doughnut',
616
- options?: {
617
- title?: string;
618
- left?: number;
619
- top?: number;
620
- width?: number;
621
- height?: number;
622
- sheet?: string;
623
- }
624
- ): Promise<OfficeResponse> {
625
- // Excel chart types
626
- const chartTypeMap: Record<string, number> = {
627
- column: 51, // xlColumnClustered
628
- bar: 57, // xlBarClustered
629
- line: 4, // xlLine
630
- pie: 5, // xlPie
631
- area: 1, // xlArea
632
- scatter: -4169, // xlXYScatter
633
- doughnut: -4120, // xlDoughnut
634
- };
635
- const xlChartType = chartTypeMap[chartType] ?? 51;
636
- const escapedTitle = options?.title?.replace(/'/g, "''") || '';
637
- const hasKorean = options?.title ? /[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(options.title) : false;
638
-
639
- const sheetScript = options?.sheet ?
640
- `$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
641
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
642
-
643
- const left = options?.left ?? 100;
644
- const top = options?.top ?? 100;
645
- const width = options?.width ?? 400;
646
- const height = options?.height ?? 300;
647
-
648
- // TEXT FIRST, FONT AFTER pattern (Microsoft recommended for Korean)
649
- const titleScript = escapedTitle ? `
650
- $chart.HasTitle = $true
651
- $chart.ChartTitle.Text = '${escapedTitle}'
652
- ${hasKorean ? "$chart.ChartTitle.Font.Name = 'Malgun Gothic'" : ''}` : '';
653
-
654
- return this.executePowerShell(`
655
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
656
- ${sheetScript}
657
- $range = $sheet.Range('${dataRange}')
658
- $chartObj = $sheet.ChartObjects().Add(${left}, ${top}, ${width}, ${height})
659
- $chart = $chartObj.Chart
660
- $chart.SetSourceData($range)
661
- $chart.ChartType = ${xlChartType}
662
- ${titleScript}
663
- @{ success = $true; message = "Chart added"; chart_name = $chartObj.Name } | ConvertTo-Json -Compress
664
- `);
665
- }
666
-
667
- async excelSetChartTitle(chartIndex: number, title: string, sheet?: string): Promise<OfficeResponse> {
668
- const escapedTitle = title.replace(/'/g, "''");
669
- const hasKorean = /[가-힣ㄱ-ㅎㅏ-ㅣ]/.test(title);
670
- const sheetScript = sheet ?
671
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
672
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
673
-
674
- // TEXT FIRST, FONT AFTER pattern (Microsoft recommended for Korean)
675
- return this.executePowerShell(`
676
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
677
- ${sheetScript}
678
- $chartObj = $sheet.ChartObjects(${chartIndex})
679
- $chart = $chartObj.Chart
680
- $chart.HasTitle = $true
681
- $chart.ChartTitle.Text = '${escapedTitle}'
682
- ${hasKorean ? "$chart.ChartTitle.Font.Name = 'Malgun Gothic'" : ''}
683
- @{ success = $true; message = "Chart title set" } | ConvertTo-Json -Compress
684
- `);
685
- }
686
-
687
- async excelDeleteChart(chartIndex: number, sheet?: string): Promise<OfficeResponse> {
688
- const sheetScript = sheet ?
689
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
690
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
691
-
692
- return this.executePowerShell(`
693
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
694
- ${sheetScript}
695
- $sheet.ChartObjects(${chartIndex}).Delete()
696
- @{ success = $true; message = "Chart deleted" } | ConvertTo-Json -Compress
697
- `);
698
- }
699
-
700
- // -------------------------------------------------------------------------
701
- // Excel Conditional Formatting
702
- // -------------------------------------------------------------------------
703
-
704
- async excelAddConditionalFormat(
705
- range: string,
706
- formatType: 'cellValue' | 'colorScale' | 'dataBar' | 'iconSet' | 'duplicates' | 'top10',
707
- options?: {
708
- operator?: 'greater' | 'less' | 'equal' | 'between' | 'notBetween';
709
- value1?: string | number;
710
- value2?: string | number;
711
- fillColor?: string;
712
- fontColor?: string;
713
- sheet?: string;
714
- }
715
- ): Promise<OfficeResponse> {
716
- const sheetScript = options?.sheet ?
717
- `$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
718
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
719
-
720
- // xlFormatConditionType: xlCellValue=1, xlColorScale=3, xlDataBar=4, xlIconSet=6, xlUniqueValues=8, xlTop10=5
721
- const typeMap: Record<string, number> = {
722
- cellValue: 1,
723
- colorScale: 3,
724
- dataBar: 4,
725
- iconSet: 6,
726
- duplicates: 8,
727
- top10: 5,
728
- };
729
- const conditionType = typeMap[formatType] ?? 1;
730
-
731
- // xlOperator: xlGreater=5, xlLess=6, xlEqual=3, xlBetween=1, xlNotBetween=2
732
- const operatorMap: Record<string, number> = {
733
- greater: 5,
734
- less: 6,
735
- equal: 3,
736
- between: 1,
737
- notBetween: 2,
738
- };
739
- const xlOperator = options?.operator ? operatorMap[options.operator] : 5;
740
-
741
- let formatScript = '';
742
- if (formatType === 'cellValue') {
743
- const formula1 = typeof options?.value1 === 'string' ? `"${options.value1}"` : options?.value1 ?? 0;
744
- const formula2 = options?.value2 !== undefined ?
745
- (typeof options.value2 === 'string' ? `"${options.value2}"` : options.value2) : '';
746
-
747
- formatScript = `
748
- $fc = $range.FormatConditions.Add(${conditionType}, ${xlOperator}, ${formula1}${formula2 ? `, ${formula2}` : ''})`;
749
-
750
- if (options?.fillColor) {
751
- const rgb = this.hexToRgb(options.fillColor);
752
- if (rgb) {
753
- formatScript += `\n$fc.Interior.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`;
754
- }
755
- }
756
- if (options?.fontColor) {
757
- const rgb = this.hexToRgb(options.fontColor);
758
- if (rgb) {
759
- formatScript += `\n$fc.Font.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`;
760
- }
761
- }
762
- } else if (formatType === 'colorScale') {
763
- formatScript = '$range.FormatConditions.AddColorScale(3)';
764
- } else if (formatType === 'dataBar') {
765
- formatScript = '$range.FormatConditions.AddDataBar()';
766
- } else if (formatType === 'iconSet') {
767
- formatScript = '$range.FormatConditions.AddIconSetCondition()';
768
- } else if (formatType === 'duplicates') {
769
- formatScript = `$fc = $range.FormatConditions.AddUniqueValues()
770
- $fc.DupeUnique = 1`; // xlDuplicate
771
- if (options?.fillColor) {
772
- const rgb = this.hexToRgb(options.fillColor);
773
- if (rgb) {
774
- formatScript += `\n$fc.Interior.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`;
775
- }
776
- }
777
- } else if (formatType === 'top10') {
778
- formatScript = `$fc = $range.FormatConditions.AddTop10()
779
- $fc.TopBottom = 1
780
- $fc.Rank = 10`;
781
- if (options?.fillColor) {
782
- const rgb = this.hexToRgb(options.fillColor);
783
- if (rgb) {
784
- formatScript += `\n$fc.Interior.Color = ${rgb.r + rgb.g * 256 + rgb.b * 65536}`;
785
- }
786
- }
787
- }
788
-
789
- return this.executePowerShell(`
790
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
791
- ${sheetScript}
792
- $range = $sheet.Range('${range}')
793
- ${formatScript}
794
- @{ success = $true; message = "Conditional format added to ${range}" } | ConvertTo-Json -Compress
795
- `);
796
- }
797
-
798
- async excelClearConditionalFormat(range: string, sheet?: string): Promise<OfficeResponse> {
799
- const sheetScript = sheet ?
800
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
801
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
802
-
803
- return this.executePowerShell(`
804
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
805
- ${sheetScript}
806
- $sheet.Range('${range}').FormatConditions.Delete()
807
- @{ success = $true; message = "Conditional formatting cleared from ${range}" } | ConvertTo-Json -Compress
808
- `);
809
- }
810
-
811
- // -------------------------------------------------------------------------
812
- // Excel Data Validation
813
- // -------------------------------------------------------------------------
814
-
815
- async excelSetDataValidation(
816
- range: string,
817
- validationType: 'list' | 'whole' | 'decimal' | 'date' | 'textLength' | 'custom',
818
- options: {
819
- formula1?: string;
820
- formula2?: string;
821
- operator?: 'between' | 'notBetween' | 'equal' | 'notEqual' | 'greater' | 'less' | 'greaterEqual' | 'lessEqual';
822
- showInputMessage?: boolean;
823
- inputTitle?: string;
824
- inputMessage?: string;
825
- showErrorMessage?: boolean;
826
- errorTitle?: string;
827
- errorMessage?: string;
828
- sheet?: string;
829
- }
830
- ): Promise<OfficeResponse> {
831
- const sheetScript = options?.sheet ?
832
- `$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
833
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
834
-
835
- // xlDVType: xlValidateList=3, xlValidateWholeNumber=1, xlValidateDecimal=2, xlValidateDate=4, xlValidateTextLength=6, xlValidateCustom=7
836
- const typeMap: Record<string, number> = {
837
- list: 3,
838
- whole: 1,
839
- decimal: 2,
840
- date: 4,
841
- textLength: 6,
842
- custom: 7,
843
- };
844
- const dvType = typeMap[validationType] ?? 3;
845
-
846
- // xlDVAlertStyle: xlValidAlertStop=1
847
- // xlOperator
848
- const operatorMap: Record<string, number> = {
849
- between: 1,
850
- notBetween: 2,
851
- equal: 3,
852
- notEqual: 4,
853
- greater: 5,
854
- less: 6,
855
- greaterEqual: 7,
856
- lessEqual: 8,
857
- };
858
- const xlOperator = options.operator ? operatorMap[options.operator] : 1;
859
-
860
- const formula1 = options.formula1?.replace(/'/g, "''") || '';
861
- const formula2 = options.formula2?.replace(/'/g, "''") || '';
862
-
863
- const additionalSettings: string[] = [];
864
- if (options.showInputMessage !== false && (options.inputTitle || options.inputMessage)) {
865
- additionalSettings.push('$validation.ShowInput = $true');
866
- if (options.inputTitle) additionalSettings.push(`$validation.InputTitle = '${options.inputTitle.replace(/'/g, "''")}'`);
867
- if (options.inputMessage) additionalSettings.push(`$validation.InputMessage = '${options.inputMessage.replace(/'/g, "''")}'`);
868
- }
869
- if (options.showErrorMessage !== false && (options.errorTitle || options.errorMessage)) {
870
- additionalSettings.push('$validation.ShowError = $true');
871
- if (options.errorTitle) additionalSettings.push(`$validation.ErrorTitle = '${options.errorTitle.replace(/'/g, "''")}'`);
872
- if (options.errorMessage) additionalSettings.push(`$validation.ErrorMessage = '${options.errorMessage.replace(/'/g, "''")}'`);
873
- }
874
-
875
- // For list validation, operator parameter is not used
876
- const validationParams = validationType === 'list'
877
- ? `${dvType}, 1, 1, '${formula1}'` // List: Type, AlertStyle, Operator (ignored), Formula1
878
- : `${dvType}, 1, ${xlOperator}, '${formula1}'${formula2 ? `, '${formula2}'` : ''}`;
879
-
880
- return this.executePowerShell(`
881
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
882
- ${sheetScript}
883
- $range = $sheet.Range('${range}')
884
- $range.Validation.Delete()
885
- $range.Validation.Add(${validationParams})
886
- $validation = $range.Validation
887
- ${additionalSettings.join('\n')}
888
- @{ success = $true; message = "Data validation set on ${range}" } | ConvertTo-Json -Compress
889
- `);
890
- }
891
-
892
- async excelClearDataValidation(range: string, sheet?: string): Promise<OfficeResponse> {
893
- const sheetScript = sheet ?
894
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
895
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
896
-
897
- return this.executePowerShell(`
898
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
899
- ${sheetScript}
900
- $sheet.Range('${range}').Validation.Delete()
901
- @{ success = $true; message = "Data validation cleared from ${range}" } | ConvertTo-Json -Compress
902
- `);
903
- }
904
-
905
- // -------------------------------------------------------------------------
906
- // Excel Named Ranges
907
- // -------------------------------------------------------------------------
908
-
909
- async excelCreateNamedRange(name: string, range: string, sheet?: string): Promise<OfficeResponse> {
910
- const escapedName = name.replace(/'/g, "''");
911
- const sheetScript = sheet ?
912
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
913
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
914
-
915
- return this.executePowerShell(`
916
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
917
- $workbook = $excel.ActiveWorkbook
918
- ${sheetScript}
919
- $range = $sheet.Range('${range}')
920
- $workbook.Names.Add('${escapedName}', $range)
921
- @{ success = $true; message = "Named range '${escapedName}' created" } | ConvertTo-Json -Compress
922
- `);
923
- }
924
-
925
- async excelGetNamedRanges(): Promise<OfficeResponse> {
926
- return this.executePowerShell(`
927
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
928
- $workbook = $excel.ActiveWorkbook
929
- $names = @()
930
- foreach ($n in $workbook.Names) {
931
- $names += @{
932
- name = $n.Name
933
- refersTo = $n.RefersTo
934
- value = $n.Value
935
- }
936
- }
937
- @{ success = $true; named_ranges = $names } | ConvertTo-Json -Compress -Depth 5
938
- `);
939
- }
940
-
941
- async excelDeleteNamedRange(name: string): Promise<OfficeResponse> {
942
- const escapedName = name.replace(/'/g, "''");
943
- return this.executePowerShell(`
944
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
945
- $workbook = $excel.ActiveWorkbook
946
- $workbook.Names('${escapedName}').Delete()
947
- @{ success = $true; message = "Named range '${escapedName}' deleted" } | ConvertTo-Json -Compress
948
- `);
949
- }
950
-
951
- // -------------------------------------------------------------------------
952
- // Excel Copy/Paste/Clear
953
- // -------------------------------------------------------------------------
954
-
955
- async excelCopyRange(range: string, sheet?: string): Promise<OfficeResponse> {
956
- const sheetScript = sheet ?
957
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
958
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
959
-
960
- return this.executePowerShell(`
961
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
962
- ${sheetScript}
963
- $sheet.Range('${range}').Copy()
964
- @{ success = $true; message = "Range ${range} copied to clipboard" } | ConvertTo-Json -Compress
965
- `);
966
- }
967
-
968
- async excelPasteRange(destination: string, sheet?: string): Promise<OfficeResponse> {
969
- const sheetScript = sheet ?
970
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
971
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
972
-
973
- return this.executePowerShell(`
974
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
975
- ${sheetScript}
976
- $sheet.Range('${destination}').Select()
977
- $sheet.Paste()
978
- @{ success = $true; message = "Pasted to ${destination}" } | ConvertTo-Json -Compress
979
- `);
980
- }
981
-
982
- async excelClearRange(
983
- range: string,
984
- clearType: 'all' | 'contents' | 'formats' | 'comments' = 'all',
985
- sheet?: string
986
- ): Promise<OfficeResponse> {
987
- const sheetScript = sheet ?
988
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
989
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
990
-
991
- const clearMethod = {
992
- all: 'Clear()',
993
- contents: 'ClearContents()',
994
- formats: 'ClearFormats()',
995
- comments: 'ClearComments()',
996
- }[clearType];
997
-
998
- return this.executePowerShell(`
999
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1000
- ${sheetScript}
1001
- $sheet.Range('${range}').${clearMethod}
1002
- @{ success = $true; message = "Range ${range} cleared (${clearType})" } | ConvertTo-Json -Compress
1003
- `);
1004
- }
1005
-
1006
- // -------------------------------------------------------------------------
1007
- // Excel Hide/Show Rows & Columns
1008
- // -------------------------------------------------------------------------
1009
-
1010
- async excelHideColumn(column: string, sheet?: string): Promise<OfficeResponse> {
1011
- const sheetScript = sheet ?
1012
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1013
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1014
-
1015
- return this.executePowerShell(`
1016
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1017
- ${sheetScript}
1018
- $sheet.Columns('${column}').Hidden = $true
1019
- @{ success = $true; message = "Column ${column} hidden" } | ConvertTo-Json -Compress
1020
- `);
1021
- }
1022
-
1023
- async excelShowColumn(column: string, sheet?: string): Promise<OfficeResponse> {
1024
- const sheetScript = sheet ?
1025
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1026
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1027
-
1028
- return this.executePowerShell(`
1029
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1030
- ${sheetScript}
1031
- $sheet.Columns('${column}').Hidden = $false
1032
- @{ success = $true; message = "Column ${column} shown" } | ConvertTo-Json -Compress
1033
- `);
1034
- }
1035
-
1036
- async excelHideRow(row: number, sheet?: string): Promise<OfficeResponse> {
1037
- const sheetScript = sheet ?
1038
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1039
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1040
-
1041
- return this.executePowerShell(`
1042
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1043
- ${sheetScript}
1044
- $sheet.Rows(${row}).Hidden = $true
1045
- @{ success = $true; message = "Row ${row} hidden" } | ConvertTo-Json -Compress
1046
- `);
1047
- }
1048
-
1049
- async excelShowRow(row: number, sheet?: string): Promise<OfficeResponse> {
1050
- const sheetScript = sheet ?
1051
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1052
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1053
-
1054
- return this.executePowerShell(`
1055
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1056
- ${sheetScript}
1057
- $sheet.Rows(${row}).Hidden = $false
1058
- @{ success = $true; message = "Row ${row} shown" } | ConvertTo-Json -Compress
1059
- `);
1060
- }
1061
-
1062
- // -------------------------------------------------------------------------
1063
- // Excel Image & Hyperlink
1064
- // -------------------------------------------------------------------------
1065
-
1066
- async excelAddImage(
1067
- imagePath: string,
1068
- cell: string,
1069
- options?: { width?: number; height?: number; sheet?: string }
1070
- ): Promise<OfficeResponse> {
1071
- const windowsPath = this.toWindowsPath(imagePath).replace(/'/g, "''");
1072
- const sheetScript = options?.sheet ?
1073
- `$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
1074
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1075
-
1076
- const sizeScript = [];
1077
- if (options?.width) sizeScript.push(`$pic.Width = ${options.width}`);
1078
- if (options?.height) sizeScript.push(`$pic.Height = ${options.height}`);
1079
-
1080
- return this.executePowerShell(`
1081
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1082
- ${sheetScript}
1083
- $cell = $sheet.Range('${cell}')
1084
- $pic = $sheet.Shapes.AddPicture('${windowsPath}', 0, -1, $cell.Left, $cell.Top, -1, -1)
1085
- ${sizeScript.join('\n')}
1086
- @{ success = $true; message = "Image added at ${cell}" } | ConvertTo-Json -Compress
1087
- `);
1088
- }
1089
-
1090
- async excelAddHyperlink(
1091
- cell: string,
1092
- url: string,
1093
- displayText?: string,
1094
- sheet?: string
1095
- ): Promise<OfficeResponse> {
1096
- const escapedUrl = url.replace(/'/g, "''");
1097
- const escapedText = displayText?.replace(/'/g, "''") || url;
1098
- const sheetScript = sheet ?
1099
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1100
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1101
-
1102
- return this.executePowerShell(`
1103
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1104
- ${sheetScript}
1105
- $range = $sheet.Range('${cell}')
1106
- $sheet.Hyperlinks.Add($range, '${escapedUrl}', '', '', '${escapedText}')
1107
- @{ success = $true; message = "Hyperlink added to ${cell}" } | ConvertTo-Json -Compress
1108
- `);
1109
- }
1110
-
1111
- // -------------------------------------------------------------------------
1112
- // Excel Export & Print
1113
- // -------------------------------------------------------------------------
1114
-
1115
- async excelExportPDF(outputPath: string, sheet?: string): Promise<OfficeResponse> {
1116
- const windowsPath = this.toWindowsPath(outputPath).replace(/'/g, "''");
1117
- const sheetScript = sheet ?
1118
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')
1119
- $sheet.ExportAsFixedFormat(0, '${windowsPath}')` :
1120
- `$excel.ActiveWorkbook.ExportAsFixedFormat(0, '${windowsPath}')`;
1121
-
1122
- return this.executePowerShell(`
1123
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1124
- ${sheetScript}
1125
- @{ success = $true; message = "Exported to PDF"; path = '${windowsPath}' } | ConvertTo-Json -Compress
1126
- `);
1127
- }
1128
-
1129
- async excelPrint(copies: number = 1, sheet?: string): Promise<OfficeResponse> {
1130
- const sheetScript = sheet ?
1131
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')
1132
- $sheet.PrintOut(1, 9999, ${copies})` :
1133
- `$excel.ActiveWorkbook.PrintOut(1, 9999, ${copies})`;
1134
-
1135
- return this.executePowerShell(`
1136
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1137
- ${sheetScript}
1138
- @{ success = $true; message = "Print job sent (${copies} copies)" } | ConvertTo-Json -Compress
1139
- `);
1140
- }
1141
-
1142
- // -------------------------------------------------------------------------
1143
- // Excel Comments
1144
- // -------------------------------------------------------------------------
1145
-
1146
- async excelAddComment(cell: string, text: string, _author?: string, sheet?: string): Promise<OfficeResponse> {
1147
- const escapedText = text.replace(/'/g, "''");
1148
- const sheetScript = sheet ?
1149
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1150
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1151
-
1152
- return this.executePowerShell(`
1153
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1154
- ${sheetScript}
1155
- $cell = $sheet.Range('${cell}')
1156
- if ($cell.Comment -ne $null) { $cell.Comment.Delete() }
1157
- $comment = $cell.AddComment('${escapedText}')
1158
- $comment.Visible = $false
1159
- @{ success = $true; message = "Comment added to ${cell}" } | ConvertTo-Json -Compress
1160
- `);
1161
- }
1162
-
1163
- async excelGetComment(cell: string, sheet?: string): Promise<OfficeResponse> {
1164
- const sheetScript = sheet ?
1165
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1166
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1167
-
1168
- return this.executePowerShell(`
1169
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1170
- ${sheetScript}
1171
- $cell = $sheet.Range('${cell}')
1172
- if ($cell.Comment -ne $null) {
1173
- @{ success = $true; has_comment = $true; text = $cell.Comment.Text() } | ConvertTo-Json -Compress
1174
- } else {
1175
- @{ success = $true; has_comment = $false } | ConvertTo-Json -Compress
1176
- }
1177
- `);
1178
- }
1179
-
1180
- async excelDeleteComment(cell: string, sheet?: string): Promise<OfficeResponse> {
1181
- const sheetScript = sheet ?
1182
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1183
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1184
-
1185
- return this.executePowerShell(`
1186
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1187
- ${sheetScript}
1188
- $cell = $sheet.Range('${cell}')
1189
- if ($cell.Comment -ne $null) {
1190
- $cell.Comment.Delete()
1191
- @{ success = $true; message = "Comment deleted from ${cell}" } | ConvertTo-Json -Compress
1192
- } else {
1193
- @{ success = $false; error = "No comment found at ${cell}" } | ConvertTo-Json -Compress
1194
- }
1195
- `);
1196
- }
1197
-
1198
- // -------------------------------------------------------------------------
1199
- // Excel Sheet Protection
1200
- // -------------------------------------------------------------------------
1201
-
1202
- async excelProtectSheet(password?: string, sheet?: string): Promise<OfficeResponse> {
1203
- const escapedPassword = password?.replace(/'/g, "''") || '';
1204
- const sheetScript = sheet ?
1205
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1206
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1207
-
1208
- return this.executePowerShell(`
1209
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1210
- ${sheetScript}
1211
- $sheet.Protect('${escapedPassword}')
1212
- @{ success = $true; message = "Sheet protected" } | ConvertTo-Json -Compress
1213
- `);
1214
- }
1215
-
1216
- async excelUnprotectSheet(password?: string, sheet?: string): Promise<OfficeResponse> {
1217
- const escapedPassword = password?.replace(/'/g, "''") || '';
1218
- const sheetScript = sheet ?
1219
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1220
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1221
-
1222
- return this.executePowerShell(`
1223
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1224
- ${sheetScript}
1225
- $sheet.Unprotect('${escapedPassword}')
1226
- @{ success = $true; message = "Sheet unprotected" } | ConvertTo-Json -Compress
1227
- `);
1228
- }
1229
-
1230
- // -------------------------------------------------------------------------
1231
- // Excel Unmerge Cells
1232
- // -------------------------------------------------------------------------
1233
-
1234
- async excelUnmergeCells(range: string, sheet?: string): Promise<OfficeResponse> {
1235
- const sheetScript = sheet ?
1236
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1237
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1238
-
1239
- return this.executePowerShell(`
1240
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1241
- ${sheetScript}
1242
- $sheet.Range('${range}').UnMerge()
1243
- @{ success = $true; message = "Cells unmerged: ${range}" } | ConvertTo-Json -Compress
1244
- `);
1245
- }
1246
-
1247
- // -------------------------------------------------------------------------
1248
- // Excel Select/Activate Sheet
1249
- // -------------------------------------------------------------------------
1250
-
1251
- async excelSelectSheet(name: string): Promise<OfficeResponse> {
1252
- const escapedName = name.replace(/'/g, "''");
1253
- return this.executePowerShell(`
1254
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1255
- $excel.ActiveWorkbook.Worksheets('${escapedName}').Activate()
1256
- @{ success = $true; message = "Sheet '${escapedName}' activated" } | ConvertTo-Json -Compress
1257
- `);
1258
- }
1259
-
1260
- // -------------------------------------------------------------------------
1261
- // Excel Find & Replace
1262
- // -------------------------------------------------------------------------
1263
-
1264
- async excelFindReplace(
1265
- find: string,
1266
- replace: string,
1267
- options?: {
1268
- matchCase?: boolean;
1269
- matchEntireCell?: boolean;
1270
- range?: string;
1271
- sheet?: string;
1272
- }
1273
- ): Promise<OfficeResponse> {
1274
- const escapedFind = find.replace(/'/g, "''");
1275
- const escapedReplace = replace.replace(/'/g, "''");
1276
- const sheetScript = options?.sheet ?
1277
- `$sheet = $excel.ActiveWorkbook.Worksheets('${options.sheet.replace(/'/g, "''")}')` :
1278
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1279
-
1280
- const rangeScript = options?.range ?
1281
- `$range = $sheet.Range('${options.range}')` :
1282
- '$range = $sheet.UsedRange';
1283
-
1284
- const matchCase = options?.matchCase ? '$true' : '$false';
1285
- const lookAt = options?.matchEntireCell ? '1' : '2'; // xlWhole=1, xlPart=2
1286
-
1287
- return this.executePowerShell(`
1288
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1289
- ${sheetScript}
1290
- ${rangeScript}
1291
- $replaced = $range.Replace('${escapedFind}', '${escapedReplace}', ${lookAt}, 1, ${matchCase})
1292
- @{ success = $true; message = "Find and replace completed" } | ConvertTo-Json -Compress
1293
- `);
1294
- }
1295
-
1296
- // -------------------------------------------------------------------------
1297
- // Excel Group Rows
1298
- // -------------------------------------------------------------------------
1299
-
1300
- async excelGroupRows(startRow: number, endRow: number, sheet?: string): Promise<OfficeResponse> {
1301
- const sheetScript = sheet ?
1302
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1303
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1304
-
1305
- return this.executePowerShell(`
1306
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1307
- ${sheetScript}
1308
- $sheet.Rows("${startRow}:${endRow}").Group()
1309
- @{ success = $true; message = "Rows ${startRow}-${endRow} grouped" } | ConvertTo-Json -Compress
1310
- `);
1311
- }
1312
-
1313
- async excelUngroupRows(startRow: number, endRow: number, sheet?: string): Promise<OfficeResponse> {
1314
- const sheetScript = sheet ?
1315
- `$sheet = $excel.ActiveWorkbook.Worksheets('${sheet.replace(/'/g, "''")}')` :
1316
- '$sheet = $excel.ActiveWorkbook.ActiveSheet';
1317
-
1318
- return this.executePowerShell(`
1319
- $excel = [Runtime.InteropServices.Marshal]::GetActiveObject("Excel.Application")
1320
- ${sheetScript}
1321
- $sheet.Rows("${startRow}:${endRow}").Ungroup()
1322
- @{ success = $true; message = "Rows ${startRow}-${endRow} ungrouped" } | ConvertTo-Json -Compress
1323
- `);
1324
- }
1325
-
1326
- // ===========================================================================
1327
- // Microsoft PowerPoint Operations
1328
- // ===========================================================================
1329
-
1330
-
1331
- }
1332
-
1333
- // Export singleton instance
1334
- export const excelClient = new ExcelClient();
1335
- export type { OfficeResponse, ScreenshotResponse };
1336
-