Commit 75f1520
feat: add platform provider abstraction for cross-platform support (#80)
* feat: add platform provider abstraction for cross-platform support
Introduce a platform provider pattern to centralize all platform-specific
logic (Windows, macOS, Linux) in one place. This fixes Windows shell
command execution issues and improves maintainability.
Changes:
- Add platform provider interface and implementations for Windows, macOS, Linux
- Refactor cli.ts to use platform provider for CLI installation
- Refactor terminal/env.ts to use platform provider for shell detection
- Refactor claude/env.ts to use platform provider for environment building
- Refactor claude-token.ts to use platform provider for PATH extension
- Fix path separator issues (use path.basename instead of split('/'))
The platform provider handles:
- Shell configuration and detection
- PATH building with common tool locations
- Environment variable setup
- CLI installation/uninstallation
- Locale detection
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: address PR review feedback
Based on PR #80 review by @serafimcloud:
1. Windows PATH limitation (Critical):
- Remove `setx PATH` which has 1024 char limit and can truncate PATH
- CLI install dir is already in buildExtendedPath() for app usage
- Return pathHint for users who want terminal access
2. Variable shadowing (Critical):
- Rename `path` to `filePath` in chats.ts to avoid shadowing
the imported `path` module
3. Electron coupling (Medium):
- Remove unused `app` import from windows.ts
- Remove unused `exec`, `promisify`, `lstatSync` imports
4. execCommand consistency (Low):
- Add documentation explaining execCommand is for simple commands
- Complex shell commands (osascript, pipes) may use exec directly
Co-Authored-By: Claude <noreply@anthropic.com>
* fix(windows): install CLI to ~/.local/bin instead of %LOCALAPPDATA%
- Install to ~/.local/bin which is already in buildExtendedPath()
- Avoids needing to modify system PATH or prompt user
- App can find CLI automatically via extended PATH
- Users with ~/.local/bin in their PATH can use it from terminal too
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e393091 commit 75f1520
12 files changed
Lines changed: 1218 additions & 187 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
245 | | - | |
246 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
247 | 251 | | |
248 | 252 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
| 253 | + | |
262 | 254 | | |
263 | 255 | | |
264 | 256 | | |
| |||
268 | 260 | | |
269 | 261 | | |
270 | 262 | | |
271 | | - | |
| 263 | + | |
272 | 264 | | |
273 | 265 | | |
274 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
7 | 14 | | |
8 | 15 | | |
9 | 16 | | |
| |||
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
40 | | - | |
| 47 | + | |
41 | 48 | | |
42 | 49 | | |
43 | 50 | | |
44 | 51 | | |
45 | 52 | | |
46 | 53 | | |
47 | | - | |
| 54 | + | |
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
51 | 58 | | |
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
55 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
56 | 67 | | |
57 | 68 | | |
58 | 69 | | |
59 | 70 | | |
60 | 71 | | |
61 | 72 | | |
62 | | - | |
| 73 | + | |
63 | 74 | | |
64 | 75 | | |
65 | 76 | | |
| |||
71 | 82 | | |
72 | 83 | | |
73 | 84 | | |
74 | | - | |
75 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
76 | 92 | | |
77 | 93 | | |
78 | 94 | | |
| |||
112 | 128 | | |
113 | 129 | | |
114 | 130 | | |
115 | | - | |
116 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
117 | 146 | | |
118 | 147 | | |
119 | 148 | | |
120 | 149 | | |
121 | 150 | | |
122 | 151 | | |
123 | 152 | | |
124 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
125 | 174 | | |
126 | 175 | | |
127 | 176 | | |
| |||
139 | 188 | | |
140 | 189 | | |
141 | 190 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 191 | + | |
150 | 192 | | |
151 | 193 | | |
152 | | - | |
| 194 | + | |
153 | 195 | | |
154 | 196 | | |
155 | 197 | | |
156 | 198 | | |
157 | 199 | | |
158 | 200 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
178 | 204 | | |
179 | | - | |
180 | | - | |
181 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
182 | 208 | | |
183 | 209 | | |
184 | 210 | | |
| |||
212 | 238 | | |
213 | 239 | | |
214 | 240 | | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
219 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
220 | 252 | | |
221 | 253 | | |
222 | 254 | | |
| |||
250 | 282 | | |
251 | 283 | | |
252 | 284 | | |
253 | | - | |
| 285 | + | |
254 | 286 | | |
255 | 287 | | |
256 | 288 | | |
257 | 289 | | |
258 | | - | |
| 290 | + | |
259 | 291 | | |
260 | 292 | | |
261 | | - | |
| 293 | + | |
262 | 294 | | |
263 | 295 | | |
264 | | - | |
| 296 | + | |
265 | 297 | | |
266 | 298 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
54 | | - | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
57 | 58 | | |
| 59 | + | |
58 | 60 | | |
59 | | - | |
| 61 | + | |
60 | 62 | | |
61 | | - | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 70 | + | |
77 | 71 | | |
78 | 72 | | |
79 | 73 | | |
80 | | - | |
81 | | - | |
| 74 | + | |
| 75 | + | |
82 | 76 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
114 | 82 | | |
115 | 83 | | |
116 | 84 | | |
117 | | - | |
118 | | - | |
| 85 | + | |
| 86 | + | |
119 | 87 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
138 | 93 | | |
0 commit comments