@pheem49/mint 1.5.5 → 1.6.1

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 (222) hide show
  1. package/.codex +0 -0
  2. package/.github/FUNDING.yml +2 -0
  3. package/.github/workflows/ci.yml +45 -0
  4. package/.github/workflows/release.yml +79 -0
  5. package/Cargo.lock +5792 -0
  6. package/Cargo.toml +32 -0
  7. package/README.md +387 -353
  8. package/assets/icon.png +0 -0
  9. package/bin/mint +0 -0
  10. package/crates/mint-cli/Cargo.toml +23 -0
  11. package/crates/mint-cli/src/agent.rs +851 -0
  12. package/crates/mint-cli/src/gmail.rs +216 -0
  13. package/crates/mint-cli/src/image.rs +142 -0
  14. package/crates/mint-cli/src/main.rs +2837 -0
  15. package/crates/mint-cli/src/mcp.rs +63 -0
  16. package/crates/mint-cli/src/onboard.rs +1149 -0
  17. package/crates/mint-cli/src/setup.rs +390 -0
  18. package/crates/mint-cli/src/skills.rs +8 -0
  19. package/crates/mint-cli/src/updater.rs +279 -0
  20. package/crates/mint-core/Cargo.toml +22 -0
  21. package/crates/mint-core/src/agent_loop.rs +94 -0
  22. package/crates/mint-core/src/api_server.rs +991 -0
  23. package/crates/mint-core/src/channels.rs +248 -0
  24. package/crates/mint-core/src/chat.rs +895 -0
  25. package/crates/mint-core/src/code_tools.rs +729 -0
  26. package/crates/mint-core/src/config.rs +368 -0
  27. package/crates/mint-core/src/files.rs +159 -0
  28. package/crates/mint-core/src/knowledge.rs +541 -0
  29. package/crates/mint-core/src/lib.rs +84 -0
  30. package/crates/mint-core/src/mcp.rs +273 -0
  31. package/crates/mint-core/src/memory.rs +673 -0
  32. package/crates/mint-core/src/orchestration.rs +2157 -0
  33. package/crates/mint-core/src/pictures.rs +314 -0
  34. package/crates/mint-core/src/plugins.rs +727 -0
  35. package/crates/mint-core/src/safety.rs +416 -0
  36. package/crates/mint-core/src/semantic.rs +254 -0
  37. package/crates/mint-core/src/shell.rs +317 -0
  38. package/crates/mint-core/src/skills.rs +71 -0
  39. package/crates/mint-core/src/symbols.rs +157 -0
  40. package/crates/mint-core/src/tasks.rs +308 -0
  41. package/crates/mint-core/src/tts.rs +92 -0
  42. package/crates/mint-core/src/weather.rs +93 -0
  43. package/crates/mint-core/src/web_search.rs +200 -0
  44. package/crates/mint-core/src/workflows.rs +81 -0
  45. package/crates/mint-core/tests/mcp_stdio.rs +45 -0
  46. package/crates/mint-core/tests/memory_persistence.rs +172 -0
  47. package/crates/mint-core/tests/pictures_storage.rs +14 -0
  48. package/crates/mint-core/tests/task_lifecycle.rs +87 -0
  49. package/package.json +35 -99
  50. package/src/bin/index.js +16 -0
  51. package/src/renderer/index-web.html +17 -0
  52. package/src/renderer/index.html +17 -0
  53. package/src/renderer/public/Live2DCubismCore.js +9 -0
  54. package/src/renderer/public/assets/icon.png +0 -0
  55. package/src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.model3.json +36 -0
  56. package/src/renderer/src/App.tsx +33 -0
  57. package/src/renderer/src/calculator.ts +47 -0
  58. package/src/renderer/src/components/ChatPanel.tsx +1598 -0
  59. package/src/renderer/src/components/DashboardSidebar.tsx +358 -0
  60. package/src/renderer/src/components/Live2DStage.tsx +374 -0
  61. package/src/renderer/src/components/MintDashboard.tsx +950 -0
  62. package/src/renderer/src/components/ModelPanel.tsx +154 -0
  63. package/src/renderer/src/components/PicturesLibrary.tsx +46 -0
  64. package/src/renderer/src/components/ProactiveGlow.tsx +19 -0
  65. package/src/renderer/src/components/ScreenPicker.tsx +579 -0
  66. package/src/renderer/src/components/SettingsWindow.tsx +1467 -0
  67. package/src/renderer/src/components/SpotlightWindow.tsx +280 -0
  68. package/src/renderer/src/components/WidgetWindow.tsx +36 -0
  69. package/src/renderer/src/components/WorkspacePanel.tsx +268 -0
  70. package/src/{UI → renderer/src/css}/settings.css +69 -16
  71. package/src/renderer/src/css/spotlight.css +113 -0
  72. package/src/renderer/src/css/styles.css +3722 -0
  73. package/src/renderer/src/css/widget.css +185 -0
  74. package/src/renderer/src/env.d.ts +116 -0
  75. package/src/renderer/src/index.css +379 -0
  76. package/src/renderer/src/main.tsx +13 -0
  77. package/src/renderer/src/tauri.ts +996 -0
  78. package/src/renderer/src-web/App.tsx +25 -0
  79. package/src/renderer/src-web/calculator.ts +47 -0
  80. package/src/renderer/src-web/components/ChatPanel.tsx +1662 -0
  81. package/src/renderer/src-web/components/DashboardSidebar.tsx +242 -0
  82. package/src/renderer/src-web/components/MintDashboard.tsx +763 -0
  83. package/src/renderer/src-web/components/PicturesLibrary.tsx +73 -0
  84. package/src/renderer/src-web/components/SettingsWindow.tsx +1500 -0
  85. package/src/renderer/src-web/css/settings.css +1100 -0
  86. package/src/{UI → renderer/src-web/css}/spotlight.css +4 -4
  87. package/src/{UI → renderer/src-web/css}/styles.css +1055 -159
  88. package/src/{UI → renderer/src-web/css}/widget.css +2 -2
  89. package/src/renderer/src-web/env.d.ts +107 -0
  90. package/src/renderer/src-web/index.css +379 -0
  91. package/src/renderer/src-web/main.tsx +13 -0
  92. package/src/renderer/src-web/tauri.ts +983 -0
  93. package/tsconfig.json +30 -0
  94. package/vite.config.ts +33 -0
  95. package/vite.config.web.ts +51 -0
  96. package/GUIDE_TH.md +0 -125
  97. package/assets/Agent_Mint.png +0 -0
  98. package/assets/CLI_Screen.png +0 -0
  99. package/assets/Settings.png +0 -0
  100. package/benchmark_ai.js +0 -71
  101. package/install.ps1 +0 -64
  102. package/install.sh +0 -54
  103. package/main.js +0 -139
  104. package/mint-cli-logic.js +0 -3
  105. package/mint-cli.js +0 -410
  106. package/models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.model3.json +0 -47
  107. package/models/Shiroko_Model/Shiroko//342/232/241/351/253/230/344/272/256/342/232/241/344/275/277/347/224/250/346/225/231/347/250/213/344/270/216/346/263/250/346/204/217/344/272/213/351/241/271.txt +0 -23
  108. package/preload-picker.js +0 -11
  109. package/preload-settings.js +0 -11
  110. package/preload.js +0 -41
  111. package/scripts/install_linux_desktop_entry.js +0 -48
  112. package/src/AI_Brain/Gemini_API.js +0 -813
  113. package/src/AI_Brain/agent_orchestrator.js +0 -73
  114. package/src/AI_Brain/autonomous_brain.js +0 -179
  115. package/src/AI_Brain/behavior_memory.js +0 -135
  116. package/src/AI_Brain/headless_agent.js +0 -143
  117. package/src/AI_Brain/knowledge_base.js +0 -349
  118. package/src/AI_Brain/memory_store.js +0 -662
  119. package/src/AI_Brain/proactive_engine.js +0 -172
  120. package/src/AI_Brain/provider_adapter.js +0 -365
  121. package/src/Automation_Layer/browser_automation.js +0 -149
  122. package/src/Automation_Layer/file_operations.js +0 -286
  123. package/src/Automation_Layer/open_app.js +0 -85
  124. package/src/Automation_Layer/open_website.js +0 -38
  125. package/src/CLI/approval_handler.js +0 -47
  126. package/src/CLI/chat_router.js +0 -247
  127. package/src/CLI/chat_ui.js +0 -1159
  128. package/src/CLI/cli_colors.js +0 -115
  129. package/src/CLI/cli_formatters.js +0 -94
  130. package/src/CLI/code_agent.js +0 -1667
  131. package/src/CLI/code_session_memory.js +0 -62
  132. package/src/CLI/gmail_auth.js +0 -210
  133. package/src/CLI/image_input.js +0 -90
  134. package/src/CLI/intent_detectors.js +0 -181
  135. package/src/CLI/interactive_chat.js +0 -658
  136. package/src/CLI/list_features.js +0 -64
  137. package/src/CLI/onboarding.js +0 -416
  138. package/src/CLI/repo_summarizer.js +0 -282
  139. package/src/CLI/semantic_code_search.js +0 -312
  140. package/src/CLI/skill_manager.js +0 -41
  141. package/src/CLI/slash_command_handler.js +0 -418
  142. package/src/CLI/symbol_indexer.js +0 -231
  143. package/src/CLI/updater.js +0 -230
  144. package/src/CLI/workspace_manager.js +0 -90
  145. package/src/Channels/brave_search_bridge.js +0 -35
  146. package/src/Channels/discord_bridge.js +0 -66
  147. package/src/Channels/google_search_bridge.js +0 -38
  148. package/src/Channels/line_bridge.js +0 -60
  149. package/src/Channels/slack_bridge.js +0 -48
  150. package/src/Channels/telegram_bridge.js +0 -41
  151. package/src/Channels/whatsapp_bridge.js +0 -57
  152. package/src/Command_Parser/parser.js +0 -45
  153. package/src/Plugins/dev_tools.js +0 -41
  154. package/src/Plugins/discord.js +0 -20
  155. package/src/Plugins/docker.js +0 -47
  156. package/src/Plugins/gmail.js +0 -251
  157. package/src/Plugins/google_calendar.js +0 -252
  158. package/src/Plugins/mcp_manager.js +0 -95
  159. package/src/Plugins/notion.js +0 -256
  160. package/src/Plugins/obsidian.js +0 -54
  161. package/src/Plugins/plugin_manager.js +0 -81
  162. package/src/Plugins/spotify.js +0 -173
  163. package/src/Plugins/system_metrics.js +0 -31
  164. package/src/Plugins/system_monitor.js +0 -72
  165. package/src/System/action_executor.js +0 -178
  166. package/src/System/bridge_manager.js +0 -76
  167. package/src/System/chat_history_manager.js +0 -83
  168. package/src/System/config_manager.js +0 -194
  169. package/src/System/custom_workflows.js +0 -163
  170. package/src/System/daemon_manager.js +0 -67
  171. package/src/System/google_tts_urls.js +0 -51
  172. package/src/System/granular_automation.js +0 -157
  173. package/src/System/ipc_handlers.js +0 -332
  174. package/src/System/notifications.js +0 -23
  175. package/src/System/optional_require.js +0 -23
  176. package/src/System/picture_store.js +0 -109
  177. package/src/System/proactive_loop.js +0 -153
  178. package/src/System/safety_manager.js +0 -273
  179. package/src/System/sandbox_runner.js +0 -182
  180. package/src/System/screen_capture.js +0 -175
  181. package/src/System/smart_context.js +0 -227
  182. package/src/System/system_automation.js +0 -162
  183. package/src/System/system_events.js +0 -79
  184. package/src/System/system_info.js +0 -125
  185. package/src/System/task_manager.js +0 -222
  186. package/src/System/tool_registry.js +0 -293
  187. package/src/System/window_manager.js +0 -220
  188. package/src/UI/floating.css +0 -80
  189. package/src/UI/floating.html +0 -17
  190. package/src/UI/floating.js +0 -67
  191. package/src/UI/live2d_manager.js +0 -600
  192. package/src/UI/preload-floating.js +0 -7
  193. package/src/UI/preload-spotlight.js +0 -11
  194. package/src/UI/preload-widget.js +0 -5
  195. package/src/UI/proactive-glow.html +0 -42
  196. package/src/UI/renderer.js +0 -2127
  197. package/src/UI/screenPicker.html +0 -214
  198. package/src/UI/screenPicker.js +0 -262
  199. package/src/UI/settings.html +0 -577
  200. package/src/UI/settings.js +0 -770
  201. package/src/UI/spotlight.html +0 -23
  202. package/src/UI/spotlight.js +0 -185
  203. package/src/UI/widget.html +0 -29
  204. package/src/UI/widget.js +0 -10
  205. /package/{models → src/renderer/public/models}/Shiroko_Model/Shiroko/Shiroko_Core/72d86db84cfa9730b894c241fd24c0db.png +0 -0
  206. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//345/233/264/350/243/231.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/apron.exp3.json} +0 -0
  207. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//347/214/253/345/222/252/346/273/244/351/225/234.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/catfilter.exp3.json} +0 -0
  208. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//347/202/271/344/270/200/344/270/213.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/click.exp3.json} +0 -0
  209. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//345/221/206/347/214/253.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/dazed.exp3.json} +0 -0
  210. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//345/221/206/347/214/253/347/234/274/347/217/240/346/221/207/346/231/203.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/dazedeyes.exp3.json} +0 -0
  211. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//347/234/274/351/225/234.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/glasses.exp3.json} +0 -0
  212. /package/{models → src/renderer/public/models}/Shiroko_Model/Shiroko/Shiroko_Core/items_pinned_to_model.json +0 -0
  213. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//346/213/277/347/254/224.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/pen.exp3.json} +0 -0
  214. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//346/213/215/347/205/247.exp3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/photo.exp3.json} +0 -0
  215. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.4096/texture_00.png" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.4096/texture_00.png} +0 -0
  216. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.4096/texture_01.png" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.4096/texture_01.png} +0 -0
  217. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.4096/texture_02.png" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.4096/texture_02.png} +0 -0
  218. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.4096/texture_03.png" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.4096/texture_03.png} +0 -0
  219. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.cdi3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.cdi3.json} +0 -0
  220. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.moc3" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.moc3} +0 -0
  221. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.physics3.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.physics3.json} +0 -0
  222. /package/{models/Shiroko_Model/Shiroko/Shiroko_Core//351/235/242/351/245/2740.vtube.json" → src/renderer/public/models/Shiroko_Model/Shiroko/Shiroko_Core/shiroko.vtube.json} +0 -0
@@ -1,286 +0,0 @@
1
- const { execFile } = require('child_process');
2
- let shell;
3
- try {
4
- shell = require('electron').shell;
5
- } catch (e) {
6
- shell = null;
7
- }
8
- const fs = require('fs');
9
- const path = require('path');
10
- const os = require('os');
11
-
12
- const IGNORED_DIRECTORY_NAMES = new Set([
13
- '.git',
14
- 'node_modules',
15
- '.cache',
16
- 'dist',
17
- 'build',
18
- 'coverage'
19
- ]);
20
-
21
- const COMMON_HOME_FOLDERS = ['Downloads', 'Desktop', 'Documents', 'Videos', 'Pictures', 'Music', 'vscode', 'Games'];
22
-
23
- function getSearchRoots() {
24
- return Array.from(new Set([
25
- process.cwd(),
26
- os.homedir()
27
- ]));
28
- }
29
-
30
- /**
31
- * Smartly resolves a path.
32
- * If a path starts with '/' but doesn't exist at root, checks if it exists relative to home.
33
- * Also handles '~/' expansion.
34
- */
35
- function resolveSmartPath(target) {
36
- if (!target) return target;
37
-
38
- const home = os.homedir();
39
- // 1. If it's already an absolute path and exists, use it
40
- if (path.isAbsolute(target) && fs.existsSync(target)) return target;
41
-
42
- // 2. If it starts with ~/ expand it
43
- if (target.startsWith('~/')) {
44
- const expanded = path.join(home, target.substring(2));
45
- if (fs.existsSync(expanded)) return expanded;
46
- }
47
-
48
- // 3. If it starts with / but doesn't exist at root, try home directory
49
- if (target.startsWith('/')) {
50
- const homeRelative = path.join(home, target.substring(1));
51
- if (fs.existsSync(homeRelative)) return homeRelative;
52
- }
53
-
54
- // 4. Check if the target itself starts with a common folder (e.g., "Downloads/resume.pdf")
55
- const parts = target.split(/[/\\]/);
56
- const firstPart = parts[0];
57
- if (COMMON_HOME_FOLDERS.includes(firstPart)) {
58
- const potentialPath = path.join(home, target);
59
- if (fs.existsSync(potentialPath)) return potentialPath;
60
- }
61
-
62
- // 5. Try searching the filename in all common folders
63
- for (const folder of COMMON_HOME_FOLDERS) {
64
- const potentialPath = path.join(home, folder, target);
65
- if (fs.existsSync(potentialPath)) return potentialPath;
66
- }
67
-
68
- // 6. Final fallback: just return as is (might be relative to CWD)
69
- return target;
70
- }
71
-
72
- function findPath(target, options = {}) {
73
- if (!target || !target.trim()) {
74
- return { success: false, message: 'No search query provided.', matches: [] };
75
- }
76
-
77
- const normalizedType = ['file', 'dir', 'any'].includes(options.type) ? options.type : 'any';
78
- const loweredQuery = target.trim().toLowerCase();
79
- const directPath = resolveSmartPath(target.trim());
80
- if (directPath && path.isAbsolute(directPath) && fs.existsSync(directPath)) {
81
- const stat = fs.statSync(directPath);
82
- const directType = stat.isDirectory() ? 'dir' : 'file';
83
- if (normalizedType === 'any' || normalizedType === directType) {
84
- return {
85
- success: true,
86
- matches: [{ path: directPath, type: directType }]
87
- };
88
- }
89
- }
90
-
91
- const exactMatches = [];
92
- const partialMatches = [];
93
- const visited = new Set();
94
- const maxResults = options.maxResults || 20;
95
- const searchRoots = Array.isArray(options.roots) && options.roots.length > 0
96
- ? options.roots
97
- : getSearchRoots();
98
-
99
- function buildMatch(entryPath, entryType, rootPath, exactNameMatch) {
100
- const relativeToCwd = path.relative(process.cwd(), entryPath);
101
- const pathDepth = entryPath.split(path.sep).length;
102
- return {
103
- path: entryPath,
104
- type: entryType,
105
- exactNameMatch,
106
- inCurrentWorkspace: !relativeToCwd.startsWith('..') && !path.isAbsolute(relativeToCwd),
107
- pathDepth,
108
- rootPath
109
- };
110
- }
111
-
112
- function sortMatches(matches) {
113
- return matches.sort((a, b) => {
114
- if (a.exactNameMatch !== b.exactNameMatch) return a.exactNameMatch ? -1 : 1;
115
- if (a.inCurrentWorkspace !== b.inCurrentWorkspace) return a.inCurrentWorkspace ? -1 : 1;
116
- if (a.pathDepth !== b.pathDepth) return a.pathDepth - b.pathDepth;
117
- return a.path.localeCompare(b.path);
118
- });
119
- }
120
-
121
- function visit(currentPath, rootPath) {
122
- let entries = [];
123
- try {
124
- entries = fs.readdirSync(currentPath, { withFileTypes: true });
125
- } catch (_) {
126
- return;
127
- }
128
-
129
- for (const entry of entries) {
130
- const absoluteEntryPath = path.join(currentPath, entry.name);
131
- if (visited.has(absoluteEntryPath)) continue;
132
- visited.add(absoluteEntryPath);
133
-
134
- const entryType = entry.isDirectory() ? 'dir' : 'file';
135
- if (entry.isDirectory() && IGNORED_DIRECTORY_NAMES.has(entry.name)) {
136
- continue;
137
- }
138
- const relativePath = path.relative(rootPath, absoluteEntryPath);
139
- const searchablePath = relativePath || entry.name;
140
- const matchesType = normalizedType === 'any' || normalizedType === entryType;
141
- const lowerEntryName = entry.name.toLowerCase();
142
- const exactNameMatch = lowerEntryName === loweredQuery;
143
- const partialMatch = lowerEntryName.includes(loweredQuery) || searchablePath.toLowerCase().includes(loweredQuery);
144
-
145
- if (matchesType && partialMatch) {
146
- const match = buildMatch(absoluteEntryPath, entryType, rootPath, exactNameMatch);
147
- if (exactNameMatch) {
148
- exactMatches.push(match);
149
- if (exactMatches.length >= maxResults) return;
150
- } else if (exactMatches.length === 0) {
151
- partialMatches.push(match);
152
- if (partialMatches.length >= maxResults) return;
153
- }
154
- }
155
-
156
- if (entry.isDirectory() && exactMatches.length < maxResults && partialMatches.length < maxResults) {
157
- visit(absoluteEntryPath, rootPath);
158
- if (exactMatches.length >= maxResults || partialMatches.length >= maxResults) return;
159
- }
160
- }
161
- }
162
-
163
- for (const rootPath of searchRoots) {
164
- if (!fs.existsSync(rootPath)) continue;
165
- visit(rootPath, rootPath);
166
- if (exactMatches.length >= maxResults || partialMatches.length >= maxResults) break;
167
- }
168
-
169
- const matches = exactMatches.length > 0
170
- ? sortMatches(exactMatches).slice(0, maxResults)
171
- : sortMatches(partialMatches).slice(0, maxResults);
172
-
173
- if (matches.length === 0) {
174
- return {
175
- success: false,
176
- message: `ไม่พบ${normalizedType === 'dir' ? 'โฟลเดอร์' : normalizedType === 'file' ? 'ไฟล์' : 'ไฟล์หรือโฟลเดอร์'}ที่ตรงกับ "${target}" ค่ะ`,
177
- matches: []
178
- };
179
- }
180
-
181
- return {
182
- success: true,
183
- matches: matches.map(({ path: matchPath, type }) => ({ path: matchPath, type }))
184
- };
185
- }
186
-
187
- /**
188
- * สร้างโฟลเดอร์ใหม่
189
- * target: ชื่อโฟลเดอร์ หรือ absolute path
190
- * ถ้าเป็นชื่อเดียว จะสร้างบน Desktop
191
- */
192
- function createFolder(target) {
193
- if (!target) return { success: false, message: 'No folder name provided.' };
194
-
195
- let folderPath = resolveSmartPath(target);
196
-
197
- // If still not absolute (was just a name), default to Desktop
198
- if (!path.isAbsolute(folderPath)) {
199
- const desktopPath = path.join(os.homedir(), 'Desktop');
200
- folderPath = path.join(desktopPath, folderPath);
201
- }
202
-
203
- try {
204
- fs.mkdirSync(folderPath, { recursive: true });
205
- console.log(`Folder created: ${folderPath}`);
206
- return { success: true, path: folderPath };
207
- } catch (err) {
208
- console.error('createFolder error:', err);
209
- return { success: false, message: err.message };
210
- }
211
- }
212
-
213
- /**
214
- * เปิดไฟล์หรือโฟลเดอร์ด้วย default app ของระบบ
215
- */
216
- async function openFile(target) {
217
- if (!target) return;
218
- const resolvedPath = resolveSmartPath(target);
219
-
220
- if (!fs.existsSync(resolvedPath)) {
221
- console.error(`[OpenFile] File not found: ${resolvedPath}`);
222
- return `ไม่พบไฟล์หรือโฟลเดอร์: ${target} ค่ะ`;
223
- }
224
-
225
- if (shell) {
226
- const result = await shell.openPath(resolvedPath);
227
- if (result) {
228
- console.error('openFile error:', result);
229
- return `เกิดข้อผิดพลาดในการเปิดไฟล์: ${result}`;
230
- }
231
- return true;
232
- } else {
233
- return new Promise((resolve) => {
234
- // บน Linux ลอง xdg-open แล้วค่อย gio open ถ้าอันแรกไม่ทำงาน
235
- const { exec } = require('child_process');
236
- const platformCmd = process.platform === 'darwin' ? 'open' : (process.platform === 'win32' ? 'start' : 'xdg-open');
237
-
238
- // ใช้ exec เพื่อให้รันผ่าน shell และรองรับการทำ fallback
239
- let cmd = `${platformCmd} "${resolvedPath}"`;
240
- if (process.platform === 'linux') {
241
- cmd = `xdg-open "${resolvedPath}" || gio open "${resolvedPath}" || nautilus "${resolvedPath}" || nemo "${resolvedPath}" || thunar "${resolvedPath}" || dolphin "${resolvedPath}"`;
242
- }
243
-
244
- exec(cmd, (err) => {
245
- if (err) {
246
- console.error("Failed to open path:", err);
247
- resolve(`ไม่สามารถเปิดได้ค่ะ: ${err.message}`);
248
- } else {
249
- resolve(true);
250
- }
251
- });
252
- });
253
- }
254
- }
255
-
256
-
257
- /**
258
- * ลบไฟล์หรือโฟลเดอร์ (ย้ายไป Trash)
259
- */
260
- async function deleteFile(target) {
261
- if (!target) return { success: false, message: 'No path provided.' };
262
- const resolvedPath = resolveSmartPath(target);
263
-
264
- if (shell) {
265
- try {
266
- await shell.trashItem(resolvedPath);
267
- return { success: true };
268
- } catch (err) {
269
- console.error('deleteFile error:', err);
270
- return { success: false, message: err.message };
271
- }
272
- } else {
273
- return new Promise((resolve) => {
274
- execFile('gio', ['trash', resolvedPath], (err) => {
275
- if (err) {
276
- console.error("Failed to trash item via gio trash:", err);
277
- resolve({ success: false, message: err.message });
278
- } else {
279
- resolve({ success: true });
280
- }
281
- });
282
- });
283
- }
284
- }
285
-
286
- module.exports = { createFolder, openFile, deleteFile, findPath, resolveSmartPath };
@@ -1,85 +0,0 @@
1
- const { execFile } = require('child_process');
2
-
3
- function execFilePromise(command, args) {
4
- return new Promise((resolve, reject) => {
5
- execFile(command, args, (error) => {
6
- if (error) {
7
- reject(error);
8
- return;
9
- }
10
- resolve();
11
- });
12
- });
13
- }
14
-
15
- async function tryCommands(commands) {
16
- let lastError = null;
17
- for (const { command, args } of commands) {
18
- try {
19
- await execFilePromise(command, args);
20
- return true;
21
- } catch (error) {
22
- lastError = error;
23
- }
24
- }
25
-
26
- if (lastError) {
27
- console.error(`exec error: ${lastError}`);
28
- }
29
- return false;
30
- }
31
-
32
- async function openApp(target) {
33
- if (!target) return;
34
-
35
- if (process.platform === 'win32') {
36
- await execFilePromise('cmd.exe', ['/c', 'start', '', target]).catch((error) => {
37
- console.error(`exec error: ${error}`);
38
- });
39
- return;
40
- }
41
-
42
- if (process.platform === 'darwin') {
43
- if (!target.includes('/')) {
44
- await tryCommands([
45
- { command: 'open', args: ['-X', '-a', target] },
46
- { command: 'open', args: ['-a', target] }
47
- ]);
48
- } else {
49
- await execFilePromise('open', [target]).catch((error) => {
50
- console.error(`exec error: ${error}`);
51
- });
52
- }
53
- return;
54
- }
55
-
56
- const tLower = target.toLowerCase();
57
- const tCapitalized = target.charAt(0).toUpperCase() + target.slice(1).toLowerCase();
58
-
59
- if (target.includes('/')) {
60
- await execFilePromise('xdg-open', [target]).catch((error) => {
61
- console.error(`exec error: ${error}`);
62
- });
63
- return;
64
- }
65
-
66
- await tryCommands([
67
- { command: 'gtk-launch', args: [target] },
68
- { command: 'gtk-launch', args: [tLower] },
69
- { command: 'gtk-launch', args: [tCapitalized] },
70
- { command: 'gtk-launch', args: [`com.${tLower}app.${tCapitalized}`] },
71
- { command: 'gtk-launch', args: [`com.${tLower}.${tCapitalized}`] },
72
- { command: target, args: [] },
73
- { command: tLower, args: [] },
74
- { command: 'flatpak', args: ['run', target] },
75
- { command: 'flatpak', args: ['run', `com.${tLower}app.${tCapitalized}`] },
76
- { command: 'flatpak', args: ['run', `com.${tLower}.${tCapitalized}`] },
77
- { command: 'flatpak', args: ['run', `com.${tLower}.Browser`] },
78
- { command: 'flatpak', args: ['run', `com.${tLower}.${target}`] },
79
- { command: 'flatpak', args: ['run', 'com.valvesoftware.Steam'] },
80
- { command: 'flatpak', args: ['run', 'net.lutris.Lutris'] },
81
- { command: 'snap', args: ['run', tLower] }
82
- ]);
83
- }
84
-
85
- module.exports = { openApp };
@@ -1,38 +0,0 @@
1
- const { execFile } = require('child_process');
2
-
3
- let shell;
4
- try {
5
- shell = require('electron').shell;
6
- } catch (e) {
7
- shell = null;
8
- }
9
-
10
- function openWebsite(targetUrl) {
11
- if (!targetUrl) return;
12
- let url = targetUrl;
13
- if (!url.startsWith('http')) {
14
- url = 'https://' + url;
15
- }
16
- if (shell) {
17
- shell.openExternal(url);
18
- } else {
19
- // Fallback for Node.js (Linux focus)
20
- execFile('xdg-open', [url], (err) => {
21
- if (err) console.error("Failed to open URL via xdg_open:", err);
22
- });
23
- }
24
- }
25
-
26
- function openSearch(query) {
27
- if (!query) return;
28
- const url = `https://www.google.com/search?q=${encodeURIComponent(query)}`;
29
- if (shell) {
30
- shell.openExternal(url);
31
- } else {
32
- execFile('xdg-open', [url], (err) => {
33
- if (err) console.error("Failed to open search via xdg-open:", err);
34
- });
35
- }
36
- }
37
-
38
- module.exports = { openWebsite, openSearch };
@@ -1,47 +0,0 @@
1
- 'use strict';
2
-
3
- const readline = require('readline');
4
- const { colors } = require('./cli_colors');
5
-
6
- /**
7
- * Prompts the user in the terminal to approve or deny a code-agent action.
8
- * Used by the non-interactive `mint code <task>` command.
9
- *
10
- * @param {{ type: string, label?: string, preview?: string }} request
11
- * @returns {Promise<boolean>} true = approved, false = denied
12
- */
13
- async function requestCodeApproval(request) {
14
- const typeLabel =
15
- request.type === 'shell' ? 'Shell Command' :
16
- request.type === 'patch' ? 'Patch Edit' :
17
- 'File Write';
18
-
19
- console.log(`\n${colors.yellow}${colors.bright}[Approval Required]${colors.reset} ${typeLabel}`);
20
- if (request.label) console.log(`${colors.gray}${request.label}${colors.reset}`);
21
- if (Array.isArray(request.warnings) && request.warnings.length > 0) {
22
- request.warnings.forEach((warning) => {
23
- console.log(`${colors.yellow}Warning:${colors.reset} ${warning}`);
24
- });
25
- }
26
- if (request.preview) console.log(`${colors.gray}${request.preview}${colors.reset}\n`);
27
-
28
- const rl = readline.createInterface({
29
- input: process.stdin,
30
- output: process.stdout
31
- });
32
-
33
- const answer = await new Promise((resolve) => {
34
- rl.question('Approve this action? [y/N]: ', (value) => {
35
- rl.close();
36
- resolve((value || '').trim().toLowerCase());
37
- });
38
- });
39
-
40
- const approved = answer === 'y' || answer === 'yes';
41
- console.log(approved
42
- ? `${colors.mint}[Mint Code] Approved.${colors.reset}\n`
43
- : `${colors.pink}[Mint Code] Denied.${colors.reset}\n`);
44
- return approved;
45
- }
46
-
47
- module.exports = { requestCodeApproval };