@ranger-testing/ranger-cli 2.0.5 → 2.0.6

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 (115) hide show
  1. package/build/cli.js +1 -914
  2. package/build/commands/addEnv.js +1 -1
  3. package/build/commands/authEncrypt.js +1 -36
  4. package/build/commands/clean.js +1 -1
  5. package/build/commands/config.js +1 -93
  6. package/build/commands/env.js +1 -98
  7. package/build/commands/feature.js +1 -653
  8. package/build/commands/hook.js +1 -33
  9. package/build/commands/hooks/autoPrompt.js +1 -32
  10. package/build/commands/hooks/disable.js +1 -33
  11. package/build/commands/hooks/enable.js +1 -58
  12. package/build/commands/hooks/exitPlanMode.js +1 -35
  13. package/build/commands/hooks/index.js +1 -12
  14. package/build/commands/hooks/output.js +1 -71
  15. package/build/commands/hooks/planReminder.js +1 -46
  16. package/build/commands/hooks/planStart.js +1 -30
  17. package/build/commands/hooks/postEdit.js +1 -43
  18. package/build/commands/hooks/preCompact.js +1 -30
  19. package/build/commands/hooks/sessionEnd.js +1 -25
  20. package/build/commands/hooks/sessionStart.js +1 -93
  21. package/build/commands/hooks/stopHook.js +1 -155
  22. package/build/commands/index.js +1 -12
  23. package/build/commands/login.js +1 -26
  24. package/build/commands/setupCi.js +1 -189
  25. package/build/commands/skillup.js +1 -80
  26. package/build/commands/start.js +1 -1
  27. package/build/commands/status.js +1 -198
  28. package/build/commands/update.js +1 -182
  29. package/build/commands/updateEnv.js +1 -1
  30. package/build/commands/useEnv.js +1 -1
  31. package/build/commands/utils/activeProfile.js +1 -76
  32. package/build/commands/utils/browserSessionsApi.js +1 -1
  33. package/build/commands/utils/claudeConfig.js +1 -73
  34. package/build/commands/utils/claudePlugin.js +1 -85
  35. package/build/commands/utils/crypto.js +1 -42
  36. package/build/commands/utils/desirePathLog.js +1 -139
  37. package/build/commands/utils/deviceAuth.js +1 -232
  38. package/build/commands/utils/environment.js +1 -65
  39. package/build/commands/utils/featureApi.js +1 -371
  40. package/build/commands/utils/featureReportGenerator.js +1 -204
  41. package/build/commands/utils/git.js +1 -44
  42. package/build/commands/utils/keychain.js +1 -1
  43. package/build/commands/utils/localAgentInstallationsApi.js +1 -1
  44. package/build/commands/utils/profileMessages.js +1 -8
  45. package/build/commands/utils/profileSetupBanner.js +1 -167
  46. package/build/commands/utils/rangerRoot.js +1 -60
  47. package/build/commands/utils/reportGenerator.js +1 -130
  48. package/build/commands/utils/retry.js +1 -25
  49. package/build/commands/utils/sessionCache.js +1 -299
  50. package/build/commands/utils/settings.js +1 -313
  51. package/build/commands/utils/skillContent.js +1 -28
  52. package/build/commands/utils/skills.js +1 -1
  53. package/build/commands/utils/telemetry.js +1 -254
  54. package/build/commands/utils/userApi.js +1 -32
  55. package/build/commands/utils/version.js +1 -62
  56. package/build/commands/verifyFeature.js +1 -1343
  57. package/build/commands/verifyInBrowser.js +1 -1
  58. package/package.json +1 -1
  59. package/build/cli.js.map +0 -1
  60. package/build/commands/addEnv.js.map +0 -1
  61. package/build/commands/authEncrypt.js.map +0 -1
  62. package/build/commands/clean.js.map +0 -1
  63. package/build/commands/config.js.map +0 -1
  64. package/build/commands/env.js.map +0 -1
  65. package/build/commands/feature.js.map +0 -1
  66. package/build/commands/hook.js.map +0 -1
  67. package/build/commands/hooks/autoPrompt.js.map +0 -1
  68. package/build/commands/hooks/disable.js.map +0 -1
  69. package/build/commands/hooks/enable.js.map +0 -1
  70. package/build/commands/hooks/exitPlanMode.js.map +0 -1
  71. package/build/commands/hooks/index.js.map +0 -1
  72. package/build/commands/hooks/output.js.map +0 -1
  73. package/build/commands/hooks/planReminder.js.map +0 -1
  74. package/build/commands/hooks/planStart.js.map +0 -1
  75. package/build/commands/hooks/postEdit.js.map +0 -1
  76. package/build/commands/hooks/preCompact.js.map +0 -1
  77. package/build/commands/hooks/sessionEnd.js.map +0 -1
  78. package/build/commands/hooks/sessionStart.js.map +0 -1
  79. package/build/commands/hooks/stopHook.js.map +0 -1
  80. package/build/commands/index.js.map +0 -1
  81. package/build/commands/login.js.map +0 -1
  82. package/build/commands/setupCi.js.map +0 -1
  83. package/build/commands/skillup.js.map +0 -1
  84. package/build/commands/start.js.map +0 -1
  85. package/build/commands/status.js.map +0 -1
  86. package/build/commands/update.js.map +0 -1
  87. package/build/commands/updateEnv.js.map +0 -1
  88. package/build/commands/useEnv.js.map +0 -1
  89. package/build/commands/utils/activeProfile.js.map +0 -1
  90. package/build/commands/utils/browserSessionsApi.js.map +0 -1
  91. package/build/commands/utils/claudeConfig.js.map +0 -1
  92. package/build/commands/utils/claudePlugin.js.map +0 -1
  93. package/build/commands/utils/crypto.js.map +0 -1
  94. package/build/commands/utils/desirePathLog.js.map +0 -1
  95. package/build/commands/utils/deviceAuth.js.map +0 -1
  96. package/build/commands/utils/environment.js.map +0 -1
  97. package/build/commands/utils/featureApi.js.map +0 -1
  98. package/build/commands/utils/featureReportGenerator.js.map +0 -1
  99. package/build/commands/utils/git.js.map +0 -1
  100. package/build/commands/utils/keychain.js.map +0 -1
  101. package/build/commands/utils/localAgentInstallationsApi.js.map +0 -1
  102. package/build/commands/utils/profileMessages.js.map +0 -1
  103. package/build/commands/utils/profileSetupBanner.js.map +0 -1
  104. package/build/commands/utils/rangerRoot.js.map +0 -1
  105. package/build/commands/utils/reportGenerator.js.map +0 -1
  106. package/build/commands/utils/retry.js.map +0 -1
  107. package/build/commands/utils/sessionCache.js.map +0 -1
  108. package/build/commands/utils/settings.js.map +0 -1
  109. package/build/commands/utils/skillContent.js.map +0 -1
  110. package/build/commands/utils/skills.js.map +0 -1
  111. package/build/commands/utils/telemetry.js.map +0 -1
  112. package/build/commands/utils/userApi.js.map +0 -1
  113. package/build/commands/utils/version.js.map +0 -1
  114. package/build/commands/verifyFeature.js.map +0 -1
  115. package/build/commands/verifyInBrowser.js.map +0 -1
@@ -1,299 +1 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import * as os from 'os';
4
- import { execSync } from 'child_process';
5
- const CACHE_FILE = path.join(os.homedir(), '.claude', '.ranger_cache.json');
6
- function createEmptyCache() {
7
- return { version: 3, sessions: {}, branches: {} };
8
- }
9
- function loadCache() {
10
- try {
11
- if (fs.existsSync(CACHE_FILE)) {
12
- const data = JSON.parse(fs.readFileSync(CACHE_FILE, 'utf-8'));
13
- return {
14
- version: 3,
15
- sessions: data.sessions || {},
16
- branches: data.branches || {},
17
- lastEnabledSessionClearedAt: data.lastEnabledSessionClearedAt,
18
- };
19
- }
20
- }
21
- catch {
22
- // Ignore errors
23
- }
24
- return createEmptyCache();
25
- }
26
- function saveCache(cache) {
27
- try {
28
- const dir = path.dirname(CACHE_FILE);
29
- if (!fs.existsSync(dir)) {
30
- fs.mkdirSync(dir, { recursive: true });
31
- }
32
- fs.writeFileSync(CACHE_FILE, JSON.stringify(cache, null, 2));
33
- }
34
- catch {
35
- // Ignore errors
36
- }
37
- }
38
- // ============ Git Helpers ============
39
- /**
40
- * Get the current git branch name.
41
- * Returns null if not in a git repo, in detached HEAD state, or on error.
42
- */
43
- export function getCurrentBranch() {
44
- try {
45
- const branch = execSync('git rev-parse --abbrev-ref HEAD', {
46
- encoding: 'utf-8',
47
- stdio: ['pipe', 'pipe', 'pipe'],
48
- }).trim();
49
- // Return null for empty string or detached HEAD state
50
- if (!branch || branch === 'HEAD') {
51
- return null;
52
- }
53
- return branch;
54
- }
55
- catch {
56
- return null;
57
- }
58
- }
59
- // ============ Branch Functions ============
60
- /**
61
- * Enable Ranger for a branch (persists across sessions)
62
- */
63
- export function enableBranch(branchName) {
64
- const cache = loadCache();
65
- cache.branches[branchName] = true;
66
- saveCache(cache);
67
- }
68
- /**
69
- * Disable Ranger for a branch
70
- */
71
- export function disableBranch(branchName) {
72
- const cache = loadCache();
73
- delete cache.branches[branchName];
74
- saveCache(cache);
75
- }
76
- /**
77
- * Check if Ranger is enabled for a branch
78
- */
79
- export function isBranchEnabled(branchName) {
80
- const cache = loadCache();
81
- return cache.branches[branchName] === true;
82
- }
83
- // ============ Session Functions ============
84
- /**
85
- * Get session entry, creating if needed
86
- */
87
- function getOrCreateSession(cache, sessionId) {
88
- if (!cache.sessions[sessionId]) {
89
- cache.sessions[sessionId] = {};
90
- }
91
- return cache.sessions[sessionId];
92
- }
93
- /**
94
- * Enable Ranger hooks for a Claude session.
95
- * If on a non-main branch, also enables that branch.
96
- */
97
- export function enableSession(claudeSessionId) {
98
- const cache = loadCache();
99
- const session = getOrCreateSession(cache, claudeSessionId);
100
- session.enabled = true;
101
- // Auto-enable branch if not on main
102
- const branch = getCurrentBranch();
103
- if (branch && branch !== 'main' && branch !== 'master') {
104
- cache.branches[branch] = true;
105
- session.currentBranch = branch;
106
- }
107
- saveCache(cache);
108
- }
109
- /**
110
- * Check if Ranger hooks are enabled for a Claude session.
111
- * - On main/master: only checks session-level enabled flag
112
- * - On other branches: enabled if branch is enabled OR session is enabled
113
- */
114
- export function isSessionEnabled(claudeSessionId) {
115
- const cache = loadCache();
116
- const branch = getCurrentBranch();
117
- // On main/master, only session-level enabling works
118
- if (!branch || branch === 'main' || branch === 'master') {
119
- return cache.sessions[claudeSessionId]?.enabled === true;
120
- }
121
- // On other branches: enabled if branch is enabled OR session is enabled
122
- const branchEnabled = cache.branches[branch] === true;
123
- const sessionEnabled = cache.sessions[claudeSessionId]?.enabled === true;
124
- return branchEnabled || sessionEnabled;
125
- }
126
- /**
127
- * Disable Ranger hooks for a Claude session
128
- */
129
- export function disableSession(claudeSessionId) {
130
- const cache = loadCache();
131
- const session = getOrCreateSession(cache, claudeSessionId);
132
- session.enabled = false;
133
- saveCache(cache);
134
- }
135
- /**
136
- * Update branch tracking on PostToolUse.
137
- * If session is enabled and switched to a new non-main branch, auto-enable it.
138
- */
139
- export function updateBranchTracking(claudeSessionId) {
140
- const cache = loadCache();
141
- const session = cache.sessions[claudeSessionId];
142
- if (!session?.enabled) {
143
- return;
144
- }
145
- const branch = getCurrentBranch();
146
- if (!branch || branch === 'main' || branch === 'master') {
147
- return;
148
- }
149
- // If we switched branches while enabled, auto-enable the new branch
150
- if (session.currentBranch !== branch) {
151
- cache.branches[branch] = true;
152
- session.currentBranch = branch;
153
- saveCache(cache);
154
- }
155
- }
156
- /**
157
- * Initialize branch tracking on session start.
158
- * If starting on an already-enabled branch, auto-enable the session.
159
- */
160
- export function initBranchTracking(claudeSessionId) {
161
- const cache = loadCache();
162
- const branch = getCurrentBranch();
163
- if (!branch || branch === 'main' || branch === 'master') {
164
- return;
165
- }
166
- // If branch is already enabled, auto-enable this session
167
- if (cache.branches[branch] === true) {
168
- const session = getOrCreateSession(cache, claudeSessionId);
169
- session.enabled = true;
170
- session.currentBranch = branch;
171
- saveCache(cache);
172
- }
173
- }
174
- // ============ Session Clear Tracking ============
175
- const CLEAR_AUTO_ENABLE_WINDOW_MS = 5000; // 5 seconds
176
- /**
177
- * Record that an enabled session was cleared.
178
- * Called on SessionEnd with reason === 'clear' if session was enabled.
179
- */
180
- export function recordEnabledSessionCleared(claudeSessionId) {
181
- const cache = loadCache();
182
- const session = cache.sessions[claudeSessionId];
183
- // Only record if the session was enabled
184
- if (session?.enabled) {
185
- cache.lastEnabledSessionClearedAt = Date.now();
186
- saveCache(cache);
187
- }
188
- }
189
- /**
190
- * Check if we should auto-enable due to a recent clear.
191
- * Returns true if source is 'clear' and within window of last enabled session clear.
192
- */
193
- export function shouldAutoEnableAfterClear(source) {
194
- if (source !== 'clear') {
195
- return false;
196
- }
197
- const cache = loadCache();
198
- const lastCleared = cache.lastEnabledSessionClearedAt;
199
- if (!lastCleared) {
200
- return false;
201
- }
202
- const elapsed = Date.now() - lastCleared;
203
- return elapsed <= CLEAR_AUTO_ENABLE_WINDOW_MS;
204
- }
205
- /**
206
- * Auto-enable a session after clear (preserves enabled state across /clear).
207
- */
208
- export function autoEnableAfterClear(claudeSessionId) {
209
- const cache = loadCache();
210
- const session = getOrCreateSession(cache, claudeSessionId);
211
- session.enabled = true;
212
- // Also track current branch
213
- const branch = getCurrentBranch();
214
- if (branch && branch !== 'main' && branch !== 'master') {
215
- session.currentBranch = branch;
216
- }
217
- // Clear the timestamp so we don't re-trigger
218
- delete cache.lastEnabledSessionClearedAt;
219
- saveCache(cache);
220
- }
221
- /**
222
- * Register a Claude session as working on a Ranger feature
223
- */
224
- export function registerSession(claudeSessionId, featureId) {
225
- const cache = loadCache();
226
- const session = getOrCreateSession(cache, claudeSessionId);
227
- session.featureId = featureId;
228
- session.registeredAt = new Date().toISOString();
229
- saveCache(cache);
230
- }
231
- /**
232
- * Get the feature info for a Claude session
233
- */
234
- export function getSessionEntry(claudeSessionId) {
235
- const cache = loadCache();
236
- const session = cache.sessions[claudeSessionId];
237
- if (session?.featureId && session?.registeredAt) {
238
- return {
239
- featureId: session.featureId,
240
- registeredAt: session.registeredAt,
241
- };
242
- }
243
- return null;
244
- }
245
- /**
246
- * Unregister a Claude session from its feature
247
- */
248
- export function unregisterSession(claudeSessionId) {
249
- const cache = loadCache();
250
- const session = cache.sessions[claudeSessionId];
251
- if (session) {
252
- delete session.featureId;
253
- delete session.registeredAt;
254
- saveCache(cache);
255
- }
256
- }
257
- // ============ Plan Reminder Functions ============
258
- const PLAN_REMINDER_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes
259
- /**
260
- * Check if plan reminder should be shown (rate-limited to once per 5 min per session)
261
- * Returns true if reminder should be shown, and updates the timestamp.
262
- */
263
- export function shouldShowPlanReminder(claudeSessionId) {
264
- const cache = loadCache();
265
- const session = getOrCreateSession(cache, claudeSessionId);
266
- const lastShown = session.lastPlanReminderAt || 0;
267
- const now = Date.now();
268
- if (now - lastShown >= PLAN_REMINDER_INTERVAL_MS) {
269
- session.lastPlanReminderAt = now;
270
- saveCache(cache);
271
- return true;
272
- }
273
- return false;
274
- }
275
- // ============ Auto-Prompt Functions ============
276
- /**
277
- * Check if the auto-prompt has already been shown for this session.
278
- */
279
- export function hasSessionBeenPrompted(claudeSessionId) {
280
- const cache = loadCache();
281
- return cache.sessions[claudeSessionId]?.prompted === true;
282
- }
283
- /**
284
- * Mark that the auto-prompt has been shown for this session.
285
- */
286
- export function markSessionPrompted(claudeSessionId) {
287
- const cache = loadCache();
288
- const session = getOrCreateSession(cache, claudeSessionId);
289
- session.prompted = true;
290
- saveCache(cache);
291
- }
292
- // ============ Cache Management ============
293
- /**
294
- * Get the cache file path (for cleanup)
295
- */
296
- export function getCacheFile() {
297
- return CACHE_FILE;
298
- }
299
- //# sourceMappingURL=sessionCache.js.map
1
+ const _0x2f0a6=_0x8f43;(function(_0x3514f7,_0x515aa0){const _0x41b5f3=_0x8f43,_0x4d8560=_0x3514f7();while(!![]){try{const _0x5f18e6=-parseInt(_0x41b5f3(0xa0))/0x1+parseInt(_0x41b5f3(0x74))/0x2*(parseInt(_0x41b5f3(0x88))/0x3)+parseInt(_0x41b5f3(0x87))/0x4+-parseInt(_0x41b5f3(0x73))/0x5*(-parseInt(_0x41b5f3(0x8c))/0x6)+-parseInt(_0x41b5f3(0x9e))/0x7+-parseInt(_0x41b5f3(0x77))/0x8+-parseInt(_0x41b5f3(0x90))/0x9*(parseInt(_0x41b5f3(0xa1))/0xa);if(_0x5f18e6===_0x515aa0)break;else _0x4d8560['push'](_0x4d8560['shift']());}catch(_0xa4f92c){_0x4d8560['push'](_0x4d8560['shift']());}}}(_0x1ace,0x746d0));import*as _0x412b15 from'fs';import*as _0x39a74c from'path';import*as _0x4cdd60 from'os';import{execSync}from'child_process';const CACHE_FILE=_0x39a74c['join'](_0x4cdd60['homedir'](),_0x2f0a6(0x94),'.ranger_cache.json');function createEmptyCache(){return{'version':0x3,'sessions':{},'branches':{}};}function loadCache(){const _0x17ee43=_0x2f0a6;try{if(_0x412b15[_0x17ee43(0x8a)](CACHE_FILE)){const _0x2b84b6=JSON['parse'](_0x412b15[_0x17ee43(0x76)](CACHE_FILE,'utf-8'));return{'version':0x3,'sessions':_0x2b84b6['sessions']||{},'branches':_0x2b84b6[_0x17ee43(0x84)]||{},'lastEnabledSessionClearedAt':_0x2b84b6['lastEnabledSessionClearedAt']};}}catch{}return createEmptyCache();}function saveCache(_0x2474db){const _0xca58a6=_0x2f0a6;try{const _0x2d367c=_0x39a74c['dirname'](CACHE_FILE);!_0x412b15[_0xca58a6(0x8a)](_0x2d367c)&&_0x412b15['mkdirSync'](_0x2d367c,{'recursive':!![]}),_0x412b15[_0xca58a6(0x86)](CACHE_FILE,JSON['stringify'](_0x2474db,null,0x2));}catch{}}export function getCurrentBranch(){const _0x128509=_0x2f0a6,_0x3e2269={'rTPCx':function(_0x4b2e19,_0x448e9c,_0x71400a){return _0x4b2e19(_0x448e9c,_0x71400a);},'vPFSf':'HEAD'};try{const _0x18cd72=_0x3e2269['rTPCx'](execSync,_0x128509(0x93),{'encoding':_0x128509(0x8d),'stdio':['pipe','pipe','pipe']})['trim']();if(!_0x18cd72||_0x18cd72===_0x3e2269['vPFSf'])return null;return _0x18cd72;}catch{return null;}}export function enableBranch(_0x130f57){const _0x494209=_0x2f0a6,_0x3db1f9={'wgpSc':function(_0x3a012c){return _0x3a012c();},'UxKAX':function(_0x5c9a9b,_0x43cf7f){return _0x5c9a9b(_0x43cf7f);}},_0x1f8cf5=_0x3db1f9['wgpSc'](loadCache);_0x1f8cf5[_0x494209(0x84)][_0x130f57]=!![],_0x3db1f9['UxKAX'](saveCache,_0x1f8cf5);}export function disableBranch(_0x13ec65){const _0x5dd77f=_0x2f0a6,_0x539bb8=loadCache();delete _0x539bb8[_0x5dd77f(0x84)][_0x13ec65],saveCache(_0x539bb8);}export function isBranchEnabled(_0x1aeb6e){const _0x4cf68=_0x2f0a6,_0xf44048={'Nmxov':function(_0x27e68b,_0x45a434){return _0x27e68b===_0x45a434;}},_0x2ff501=loadCache();return _0xf44048['Nmxov'](_0x2ff501[_0x4cf68(0x84)][_0x1aeb6e],!![]);}function getOrCreateSession(_0x2730f7,_0x256e53){const _0x1ba419=_0x2f0a6;return!_0x2730f7[_0x1ba419(0x9d)][_0x256e53]&&(_0x2730f7[_0x1ba419(0x9d)][_0x256e53]={}),_0x2730f7['sessions'][_0x256e53];}export function enableSession(_0x525977){const _0x338f29=_0x2f0a6,_0xac0b02={'BLNsP':function(_0x42b804,_0x1b937a){return _0x42b804!==_0x1b937a;},'QhWCT':function(_0x5540f7,_0x3f6769){return _0x5540f7(_0x3f6769);}},_0x410c9b=loadCache(),_0x29011e=getOrCreateSession(_0x410c9b,_0x525977);_0x29011e[_0x338f29(0x82)]=!![];const _0x4724d8=getCurrentBranch();_0x4724d8&&_0xac0b02['BLNsP'](_0x4724d8,_0x338f29(0x98))&&_0xac0b02[_0x338f29(0x7b)](_0x4724d8,_0x338f29(0x7a))&&(_0x410c9b[_0x338f29(0x84)][_0x4724d8]=!![],_0x29011e['currentBranch']=_0x4724d8),_0xac0b02['QhWCT'](saveCache,_0x410c9b);}export function isSessionEnabled(_0x4e67c4){const _0x8ee0e4=_0x2f0a6,_0x3793ef={'MJVbv':function(_0x373f18){return _0x373f18();},'AIRqA':function(_0x2b172d,_0x1c569a){return _0x2b172d===_0x1c569a;},'nsplc':_0x8ee0e4(0x98)},_0x9895fe=_0x3793ef['MJVbv'](loadCache),_0x395e6b=getCurrentBranch();if(!_0x395e6b||_0x3793ef[_0x8ee0e4(0x83)](_0x395e6b,_0x3793ef['nsplc'])||_0x395e6b===_0x8ee0e4(0x7a))return _0x3793ef['AIRqA'](_0x9895fe['sessions'][_0x4e67c4]?.['enabled'],!![]);const _0x40ccc1=_0x3793ef['AIRqA'](_0x9895fe[_0x8ee0e4(0x84)][_0x395e6b],!![]),_0x5a7903=_0x9895fe[_0x8ee0e4(0x9d)][_0x4e67c4]?.[_0x8ee0e4(0x82)]===!![];return _0x40ccc1||_0x5a7903;}export function disableSession(_0x1f91ff){const _0x318001=_0x2f0a6,_0x24ebcc={'EcnFI':function(_0x42a182){return _0x42a182();},'yXYgZ':function(_0x349c3c,_0x556474){return _0x349c3c(_0x556474);}},_0x808fcf=_0x24ebcc['EcnFI'](loadCache),_0x17cb80=getOrCreateSession(_0x808fcf,_0x1f91ff);_0x17cb80['enabled']=![],_0x24ebcc[_0x318001(0x85)](saveCache,_0x808fcf);}export function updateBranchTracking(_0x3ad4df){const _0x16b8ad=_0x2f0a6,_0xd1b3f4={'OKjVN':function(_0x3b0f4c){return _0x3b0f4c();},'sCedR':function(_0x3a0ed3,_0x370ea7){return _0x3a0ed3===_0x370ea7;},'ThkBQ':'main','cqxME':'master','VGjkl':function(_0x1c0d40,_0xfe9d2a){return _0x1c0d40(_0xfe9d2a);}},_0x2cf0af=_0xd1b3f4[_0x16b8ad(0x8f)](loadCache),_0x1e389f=_0x2cf0af[_0x16b8ad(0x9d)][_0x3ad4df];if(!_0x1e389f?.[_0x16b8ad(0x82)])return;const _0x1a36c5=_0xd1b3f4[_0x16b8ad(0x8f)](getCurrentBranch);if(!_0x1a36c5||_0xd1b3f4['sCedR'](_0x1a36c5,_0xd1b3f4['ThkBQ'])||_0x1a36c5===_0xd1b3f4['cqxME'])return;_0x1e389f['currentBranch']!==_0x1a36c5&&(_0x2cf0af['branches'][_0x1a36c5]=!![],_0x1e389f[_0x16b8ad(0x79)]=_0x1a36c5,_0xd1b3f4['VGjkl'](saveCache,_0x2cf0af));}export function initBranchTracking(_0x2bd3c9){const _0x56bbfc=_0x2f0a6,_0x43a098={'qvELj':function(_0x1cd752){return _0x1cd752();},'yvHyO':function(_0x169852,_0x2bd017){return _0x169852===_0x2bd017;},'lGgod':'main','RuQXV':function(_0x1cec4f,_0x421469){return _0x1cec4f(_0x421469);}},_0x45fa1b=loadCache(),_0xbb3ca1=_0x43a098[_0x56bbfc(0x99)](getCurrentBranch);if(!_0xbb3ca1||_0x43a098['yvHyO'](_0xbb3ca1,_0x43a098['lGgod'])||_0xbb3ca1===_0x56bbfc(0x7a))return;if(_0x45fa1b[_0x56bbfc(0x84)][_0xbb3ca1]===!![]){const _0x563cab=getOrCreateSession(_0x45fa1b,_0x2bd3c9);_0x563cab[_0x56bbfc(0x82)]=!![],_0x563cab['currentBranch']=_0xbb3ca1,_0x43a098[_0x56bbfc(0x8e)](saveCache,_0x45fa1b);}}const CLEAR_AUTO_ENABLE_WINDOW_MS=0x1388;export function recordEnabledSessionCleared(_0x2b8ddd){const _0x1ac6c3=_0x2f0a6,_0x66ce6e=loadCache(),_0x20151d=_0x66ce6e['sessions'][_0x2b8ddd];_0x20151d?.['enabled']&&(_0x66ce6e[_0x1ac6c3(0x78)]=Date['now'](),saveCache(_0x66ce6e));}export function shouldAutoEnableAfterClear(_0x4238cd){const _0x8f81bf=_0x2f0a6,_0x317df1={'alMIs':function(_0x548fb2,_0x1751ec){return _0x548fb2<=_0x1751ec;}};if(_0x4238cd!==_0x8f81bf(0x9c))return![];const _0x1367bc=loadCache(),_0x5286ef=_0x1367bc['lastEnabledSessionClearedAt'];if(!_0x5286ef)return![];const _0x4e8857=Date['now']()-_0x5286ef;return _0x317df1[_0x8f81bf(0x95)](_0x4e8857,CLEAR_AUTO_ENABLE_WINDOW_MS);}export function autoEnableAfterClear(_0x430683){const _0x3dd0fe=_0x2f0a6,_0x13883a={'KUxLl':function(_0x2c10b6){return _0x2c10b6();},'oOtUk':function(_0x3b8cdb,_0x39a747,_0x570072){return _0x3b8cdb(_0x39a747,_0x570072);},'ELfgG':function(_0x5c1bda,_0x23e980){return _0x5c1bda!==_0x23e980;},'IcLlA':_0x3dd0fe(0x7a)},_0xb8f7c1=_0x13883a[_0x3dd0fe(0x75)](loadCache),_0x33f2e2=_0x13883a[_0x3dd0fe(0x7f)](getOrCreateSession,_0xb8f7c1,_0x430683);_0x33f2e2['enabled']=!![];const _0x59e335=getCurrentBranch();_0x59e335&&_0x59e335!==_0x3dd0fe(0x98)&&_0x13883a[_0x3dd0fe(0x9b)](_0x59e335,_0x13883a[_0x3dd0fe(0x80)])&&(_0x33f2e2['currentBranch']=_0x59e335),delete _0xb8f7c1[_0x3dd0fe(0x78)],saveCache(_0xb8f7c1);}export function registerSession(_0x434ac0,_0x25363c){const _0x513913=_0x2f0a6,_0x1c5c91={'CJnTn':function(_0x502c14){return _0x502c14();},'qoNiZ':function(_0x16e79a,_0x1a0ce3,_0x356267){return _0x16e79a(_0x1a0ce3,_0x356267);},'Iyein':function(_0x2f2fd5,_0x5495ec){return _0x2f2fd5(_0x5495ec);}},_0x36d953=_0x1c5c91[_0x513913(0x92)](loadCache),_0xa20317=_0x1c5c91['qoNiZ'](getOrCreateSession,_0x36d953,_0x434ac0);_0xa20317[_0x513913(0x7e)]=_0x25363c,_0xa20317['registeredAt']=new Date()['toISOString'](),_0x1c5c91[_0x513913(0x8b)](saveCache,_0x36d953);}function _0x8f43(_0x1188ba,_0x27beaf){_0x1188ba=_0x1188ba-0x73;const _0x1aceec=_0x1ace();let _0x8f4303=_0x1aceec[_0x1188ba];return _0x8f4303;}function _0x1ace(){const _0xfab812=['writeFileSync','1857988BXSWcR','3bERGyc','LcZCw','existsSync','Iyein','24fbNhFk','utf-8','RuQXV','OKjVN','45xYwujT','ZvmhV','CJnTn','git\x20rev-parse\x20--abbrev-ref\x20HEAD','.claude','alMIs','tKpVI','lastPlanReminderAt','main','qvELj','now','ELfgG','clear','sessions','1139159phIDBQ','registeredAt','170498NuIRWu','377030szJPNy','428555mQwMNw','807558BZTITy','KUxLl','readFileSync','1699920DGMYRg','lastEnabledSessionClearedAt','currentBranch','master','BLNsP','FFudp','prompted','featureId','oOtUk','IcLlA','rCyMp','enabled','AIRqA','branches','yXYgZ'];_0x1ace=function(){return _0xfab812;};return _0x1ace();}export function getSessionEntry(_0x205d8b){const _0x9c1c10=_0x2f0a6,_0x389b7c={'VCKjQ':function(_0x423e1f){return _0x423e1f();}},_0x346931=_0x389b7c['VCKjQ'](loadCache),_0x14754d=_0x346931[_0x9c1c10(0x9d)][_0x205d8b];if(_0x14754d?.['featureId']&&_0x14754d?.[_0x9c1c10(0x9f)])return{'featureId':_0x14754d['featureId'],'registeredAt':_0x14754d[_0x9c1c10(0x9f)]};return null;}export function unregisterSession(_0x286231){const _0x492e09=_0x2f0a6,_0x5d7475=loadCache(),_0x3d2a07=_0x5d7475[_0x492e09(0x9d)][_0x286231];_0x3d2a07&&(delete _0x3d2a07[_0x492e09(0x7e)],delete _0x3d2a07[_0x492e09(0x9f)],saveCache(_0x5d7475));}const PLAN_REMINDER_INTERVAL_MS=0x5*0x3c*0x3e8;export function shouldShowPlanReminder(_0x231e75){const _0x34e1b4=_0x2f0a6,_0x5dfbf1={'tKpVI':function(_0xcc1ebd){return _0xcc1ebd();},'rCyMp':function(_0x4bf39d,_0x51b39c){return _0x4bf39d>=_0x51b39c;},'LcZCw':function(_0x337a4f,_0xed05ed){return _0x337a4f(_0xed05ed);}},_0x54fc27=_0x5dfbf1[_0x34e1b4(0x96)](loadCache),_0x535b43=getOrCreateSession(_0x54fc27,_0x231e75),_0x25ddaa=_0x535b43['lastPlanReminderAt']||0x0,_0x253bc9=Date[_0x34e1b4(0x9a)]();if(_0x5dfbf1[_0x34e1b4(0x81)](_0x253bc9-_0x25ddaa,PLAN_REMINDER_INTERVAL_MS))return _0x535b43[_0x34e1b4(0x97)]=_0x253bc9,_0x5dfbf1[_0x34e1b4(0x89)](saveCache,_0x54fc27),!![];return![];}export function hasSessionBeenPrompted(_0x33b468){const _0xaffb51=_0x2f0a6,_0x35f917={'FFudp':function(_0x5bdb53){return _0x5bdb53();},'vyXJw':function(_0x46e4ac,_0x473f09){return _0x46e4ac===_0x473f09;}},_0x1fd590=_0x35f917[_0xaffb51(0x7c)](loadCache);return _0x35f917['vyXJw'](_0x1fd590['sessions'][_0x33b468]?.[_0xaffb51(0x7d)],!![]);}export function markSessionPrompted(_0x5249ca){const _0x34cf16=_0x2f0a6,_0x4888f5={'ZvmhV':function(_0x404f60,_0x3b44a2,_0x30028f){return _0x404f60(_0x3b44a2,_0x30028f);},'szYyy':function(_0x1c85e3,_0x1e0dfa){return _0x1c85e3(_0x1e0dfa);}},_0x527875=loadCache(),_0x476100=_0x4888f5[_0x34cf16(0x91)](getOrCreateSession,_0x527875,_0x5249ca);_0x476100['prompted']=!![],_0x4888f5['szYyy'](saveCache,_0x527875);}export function getCacheFile(){return CACHE_FILE;}
@@ -1,313 +1 @@
1
- import { readFile, writeFile, mkdir, unlink } from 'fs/promises';
2
- import { join, dirname } from 'path';
3
- import { existsSync } from 'fs';
4
- import { tmpdir } from 'os';
5
- import { randomUUID } from 'crypto';
6
- import { decrypt } from './crypto.js';
7
- import { getToken } from './keychain.js';
8
- import { getRangerDir } from './rangerRoot.js';
9
- /**
10
- * Get the directory path for an environment, checking ci/, local/, and legacy root level.
11
- * For existing environments, returns the path where it exists.
12
- * For new environments, defaults to local/.
13
- */
14
- export function getEnvDir(env) {
15
- const rangerDir = getRangerDir();
16
- const ciDir = join(rangerDir, 'ci', env);
17
- const localDir = join(rangerDir, 'local', env);
18
- const legacyDir = join(rangerDir, env); // Legacy: .ranger/<env>/
19
- const legacyLocalDir = join(rangerDir, 'local');
20
- const legacyCiDir = join(rangerDir, 'ci');
21
- if (existsSync(ciDir))
22
- return ciDir;
23
- if (existsSync(localDir))
24
- return localDir;
25
- if (existsSync(legacyDir) &&
26
- (legacyDir !== legacyLocalDir && legacyDir !== legacyCiDir
27
- ? true
28
- : hasLegacyProfileFiles(legacyDir))) {
29
- return legacyDir; // Backward compatibility
30
- }
31
- return localDir; // Default for new envs
32
- }
33
- /**
34
- * Check if an environment name already exists in any location (ci, local, or legacy root).
35
- * Optionally filter by specific locations.
36
- * Returns the path where it exists and its location, or null if not found.
37
- */
38
- export function findExistingEnv(envName, options) {
39
- const rangerDir = getRangerDir();
40
- const locations = options?.locations ?? ['ci', 'local', 'legacy'];
41
- const legacyLocalDir = join(rangerDir, 'local');
42
- const legacyCiDir = join(rangerDir, 'ci');
43
- const dirs = [
44
- { location: 'ci', path: join(rangerDir, 'ci', envName) },
45
- { location: 'local', path: join(rangerDir, 'local', envName) },
46
- { location: 'legacy', path: join(rangerDir, envName) },
47
- ];
48
- for (const dir of dirs) {
49
- if (locations.includes(dir.location) && existsSync(dir.path)) {
50
- if (dir.location === 'legacy' &&
51
- (dir.path === legacyLocalDir || dir.path === legacyCiDir) &&
52
- !hasLegacyProfileFiles(dir.path)) {
53
- continue;
54
- }
55
- return { path: dir.path, location: dir.location };
56
- }
57
- }
58
- return null;
59
- }
60
- function hasLegacyProfileFiles(legacyDir) {
61
- return (existsSync(join(legacyDir, 'settings.json')) ||
62
- existsSync(join(legacyDir, 'auth.json')) ||
63
- existsSync(join(legacyDir, 'auth.json.enc')));
64
- }
65
- /**
66
- * Check if an environment is a CI environment (stored in ci/ directory)
67
- */
68
- export function isEnvCi(env) {
69
- return existsSync(join(getRangerDir(), 'ci', env));
70
- }
71
- /**
72
- * Clean up temporary files created during config building
73
- * Ignores ENOENT errors (file already deleted)
74
- */
75
- export async function cleanupTempFiles(result) {
76
- const filesToClean = [result.tempAuthPath, result.configPath].filter(Boolean);
77
- await Promise.all(filesToClean.map((filePath) => unlink(filePath).catch((err) => {
78
- // Ignore ENOENT (file doesn't exist), re-throw others
79
- if (err.code !== 'ENOENT') {
80
- console.warn(`Failed to clean up temp file ${filePath}:`, err.message);
81
- }
82
- })));
83
- }
84
- /**
85
- * Get the path to the settings.json file for an environment
86
- */
87
- export function getSettingsPath(env) {
88
- return join(getEnvDir(env), 'settings.json');
89
- }
90
- /**
91
- * Load settings.json for an environment
92
- */
93
- export async function loadSettings(env) {
94
- const settingsPath = getSettingsPath(env);
95
- if (!existsSync(settingsPath)) {
96
- return {};
97
- }
98
- try {
99
- const content = await readFile(settingsPath, 'utf-8');
100
- return JSON.parse(content);
101
- }
102
- catch {
103
- return {};
104
- }
105
- }
106
- /**
107
- * Save settings.json for an environment
108
- */
109
- export async function saveSettings(env, settings) {
110
- const settingsPath = getSettingsPath(env);
111
- const envDir = dirname(settingsPath);
112
- if (!existsSync(envDir)) {
113
- await mkdir(envDir, { recursive: true });
114
- }
115
- await writeFile(settingsPath, JSON.stringify(settings, null, 2));
116
- }
117
- /**
118
- * Replace ${VAR_NAME} patterns with environment variable values
119
- */
120
- export function resolveEnvVars(obj) {
121
- if (typeof obj === 'string') {
122
- return obj.replace(/\$\{(\w+)\}/g, (_, varName) => {
123
- const value = process.env[varName];
124
- if (value === undefined) {
125
- throw new Error(`Environment variable ${varName} is not set`);
126
- }
127
- return value;
128
- });
129
- }
130
- if (Array.isArray(obj)) {
131
- return obj.map(resolveEnvVars);
132
- }
133
- if (obj && typeof obj === 'object') {
134
- return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, resolveEnvVars(v)]));
135
- }
136
- return obj;
137
- }
138
- /**
139
- * Build a full Playwright config from settings and write it to a temp file
140
- * Returns paths to created temp files that should be cleaned up after use
141
- */
142
- export async function buildPlaywrightConfig(settings, env, sessionId, headed) {
143
- const envDir = getEnvDir(env);
144
- // Auto-detect auth file (encrypted takes priority)
145
- const encryptedAuthPath = join(envDir, 'auth.json.enc');
146
- const plaintextAuthPath = join(envDir, 'auth.json');
147
- let storageStatePath;
148
- let tempAuthPath;
149
- if (existsSync(encryptedAuthPath)) {
150
- // Decrypt to temp file
151
- try {
152
- const token = await getToken();
153
- if (!token) {
154
- throw new Error('No API token found. Run: ranger setup [token]');
155
- }
156
- const encrypted = await readFile(encryptedAuthPath);
157
- const decrypted = decrypt(encrypted, token);
158
- tempAuthPath = join(tmpdir(), `ranger-auth-${Date.now()}.json`);
159
- await writeFile(tempAuthPath, decrypted);
160
- storageStatePath = tempAuthPath;
161
- }
162
- catch (error) {
163
- const message = error instanceof Error ? error.message : String(error);
164
- throw new Error(`Failed to decrypt auth state: ${message}`);
165
- }
166
- }
167
- else if (existsSync(plaintextAuthPath)) {
168
- // Use plaintext for local dev (not a temp file, don't track for cleanup)
169
- storageStatePath = plaintextAuthPath;
170
- }
171
- // Build the full Playwright config
172
- const effectiveSessionId = sessionId || randomUUID();
173
- const outputDir = join(getRangerDir(), 'sessions', effectiveSessionId);
174
- const config = {
175
- name: env,
176
- browser: {
177
- isolated: true,
178
- browserName: 'chromium',
179
- launchOptions: {
180
- headless: headed ? false : (settings.headless ?? true),
181
- ...(process.getuid?.() === 0 && {
182
- args: ['--no-sandbox', '--disable-setuid-sandbox'],
183
- }),
184
- },
185
- contextOptions: {
186
- permissions: ['clipboard-read', 'clipboard-write'],
187
- userAgent: settings.userAgent || undefined,
188
- extraHTTPHeaders: settings.headers || {},
189
- storageState: storageStatePath,
190
- viewport: { width: 1280, height: 720 },
191
- },
192
- },
193
- capabilities: ['core', 'tabs', 'install', 'pdf', 'vision'],
194
- imageResponses: 'allow',
195
- saveTrace: true,
196
- saveVideo: { width: 1280, height: 720 },
197
- outputDir,
198
- };
199
- // Clean up undefined values from contextOptions
200
- const contextOptions = config.browser;
201
- const ctxOpts = contextOptions
202
- .contextOptions;
203
- if (ctxOpts.userAgent === undefined)
204
- delete ctxOpts.userAgent;
205
- if (ctxOpts.storageState === undefined)
206
- delete ctxOpts.storageState;
207
- // Write to temp file
208
- const tempDir = join(tmpdir(), 'ranger-config');
209
- if (!existsSync(tempDir)) {
210
- await mkdir(tempDir, { recursive: true });
211
- }
212
- const tempConfigPath = join(tempDir, `${env}-${Date.now()}.json`);
213
- await writeFile(tempConfigPath, JSON.stringify(config, null, 2));
214
- return {
215
- configPath: tempConfigPath,
216
- tempAuthPath,
217
- };
218
- }
219
- /**
220
- * Get a nested value from an object using dot notation
221
- * e.g., getNestedValue({ headers: { "X-Test": "1" } }, "headers.X-Test") => "1"
222
- */
223
- export function getNestedValue(obj, key) {
224
- const parts = parseKeyPath(key);
225
- let current = obj;
226
- for (const part of parts) {
227
- if (current === null ||
228
- current === undefined ||
229
- typeof current !== 'object') {
230
- return undefined;
231
- }
232
- current = current[part];
233
- }
234
- return current;
235
- }
236
- /**
237
- * Set a nested value in an object using dot notation
238
- * e.g., setNestedValue({}, "headers.X-Test", "1") => { headers: { "X-Test": "1" } }
239
- */
240
- export function setNestedValue(obj, key, value) {
241
- const parts = parseKeyPath(key);
242
- let current = obj;
243
- for (let i = 0; i < parts.length - 1; i++) {
244
- const part = parts[i];
245
- if (!(part in current) || typeof current[part] !== 'object') {
246
- current[part] = {};
247
- }
248
- current = current[part];
249
- }
250
- current[parts[parts.length - 1]] = value;
251
- }
252
- /**
253
- * Delete a nested value from an object using dot notation
254
- * e.g., deleteNestedValue({ headers: { "X-Test": "1" } }, "headers.X-Test")
255
- */
256
- export function deleteNestedValue(obj, key) {
257
- const parts = parseKeyPath(key);
258
- let current = obj;
259
- for (let i = 0; i < parts.length - 1; i++) {
260
- if (current === null ||
261
- current === undefined ||
262
- typeof current !== 'object') {
263
- return false;
264
- }
265
- current = current[parts[i]];
266
- }
267
- if (current === null ||
268
- current === undefined ||
269
- typeof current !== 'object') {
270
- return false;
271
- }
272
- const lastPart = parts[parts.length - 1];
273
- if (lastPart in current) {
274
- delete current[lastPart];
275
- return true;
276
- }
277
- return false;
278
- }
279
- /**
280
- * Parse a key path, handling dot notation
281
- * "header.X-Test-Mode" => ["header", "X-Test-Mode"]
282
- * Special case: "header.X-Test" becomes ["headers", "X-Test"]
283
- */
284
- function parseKeyPath(key) {
285
- const parts = key.split('.');
286
- // Handle "header.X-Key" => "headers.X-Key"
287
- if (parts[0] === 'header') {
288
- parts[0] = 'headers';
289
- }
290
- return parts;
291
- }
292
- /**
293
- * Format settings for display
294
- */
295
- export function formatSettings(settings, indent = 0) {
296
- const lines = [];
297
- const prefix = ' '.repeat(indent);
298
- for (const [key, value] of Object.entries(settings)) {
299
- if (value === undefined)
300
- continue;
301
- if (typeof value === 'object' && value !== null) {
302
- lines.push(`${prefix}${key}:`);
303
- for (const [subKey, subValue] of Object.entries(value)) {
304
- lines.push(`${prefix} ${subKey}: ${subValue}`);
305
- }
306
- }
307
- else {
308
- lines.push(`${prefix}${key}: ${value}`);
309
- }
310
- }
311
- return lines.join('\n');
312
- }
313
- //# sourceMappingURL=settings.js.map
1
+ (function(_0x22f1ca,_0x136083){const _0xa8cdc5=_0x4324,_0x53ebea=_0x22f1ca();while(!![]){try{const _0x218216=-parseInt(_0xa8cdc5(0xde))/0x1*(parseInt(_0xa8cdc5(0x121))/0x2)+-parseInt(_0xa8cdc5(0xdf))/0x3+-parseInt(_0xa8cdc5(0x10a))/0x4*(-parseInt(_0xa8cdc5(0x115))/0x5)+parseInt(_0xa8cdc5(0x10d))/0x6+parseInt(_0xa8cdc5(0x103))/0x7*(-parseInt(_0xa8cdc5(0xe1))/0x8)+-parseInt(_0xa8cdc5(0x108))/0x9*(parseInt(_0xa8cdc5(0x120))/0xa)+parseInt(_0xa8cdc5(0x119))/0xb;if(_0x218216===_0x136083)break;else _0x53ebea['push'](_0x53ebea['shift']());}catch(_0x110d64){_0x53ebea['push'](_0x53ebea['shift']());}}}(_0x5950,0x71a94));import{readFile,writeFile,mkdir,unlink}from'fs/promises';import{join,dirname}from'path';import{existsSync}from'fs';import{tmpdir}from'os';import{randomUUID}from'crypto';import{decrypt}from'./crypto.js';import{getToken}from'./keychain.js';function _0x4324(_0x2d2211,_0x58ca5f){_0x2d2211=_0x2d2211-0xd1;const _0x5950e3=_0x5950();let _0x43243d=_0x5950e3[_0x2d2211];return _0x43243d;}import{getRangerDir}from'./rangerRoot.js';export function getEnvDir(_0x36a2e4){const _0x1606b0=_0x4324,_0x1f328b={'egILE':function(_0xa0bc43){return _0xa0bc43();},'iTiJG':function(_0x54ee64,_0x3c992b,_0x2613d2,_0x366174){return _0x54ee64(_0x3c992b,_0x2613d2,_0x366174);},'mEzES':'local','PXijU':function(_0x3a3316,_0x2e6405){return _0x3a3316(_0x2e6405);}},_0x40ea72=_0x1f328b[_0x1606b0(0x10e)](getRangerDir),_0x47d978=_0x1f328b['iTiJG'](join,_0x40ea72,'ci',_0x36a2e4),_0x8a367f=_0x1f328b[_0x1606b0(0x106)](join,_0x40ea72,_0x1f328b[_0x1606b0(0xe8)],_0x36a2e4),_0x41aedf=join(_0x40ea72,_0x36a2e4),_0x396b55=join(_0x40ea72,'local'),_0x1eb989=join(_0x40ea72,'ci');if(_0x1f328b['PXijU'](existsSync,_0x47d978))return _0x47d978;if(existsSync(_0x8a367f))return _0x8a367f;if(existsSync(_0x41aedf)&&(_0x41aedf!==_0x396b55&&_0x41aedf!==_0x1eb989?!![]:hasLegacyProfileFiles(_0x41aedf)))return _0x41aedf;return _0x8a367f;}export function findExistingEnv(_0x5ce13d,_0x9dc7a9){const _0xe9200c=_0x4324,_0x5e369d={'kttCj':'local','vWqbl':function(_0x834b67,_0x51b5a3,_0x445229){return _0x834b67(_0x51b5a3,_0x445229);},'vZTSH':function(_0x3b2d8f,_0x5ba41a,_0x54ac1c,_0x4f9c88){return _0x3b2d8f(_0x5ba41a,_0x54ac1c,_0x4f9c88);},'EXaXV':function(_0x3abc17,_0x25c769,_0x540c4a){return _0x3abc17(_0x25c769,_0x540c4a);},'ptKkc':_0xe9200c(0xe0),'JCFyd':function(_0x1279a0,_0x226969){return _0x1279a0(_0x226969);}},_0x1cfec6=getRangerDir(),_0x4a6fbd=_0x9dc7a9?.['locations']??['ci','local','legacy'],_0x4d190b=join(_0x1cfec6,_0x5e369d[_0xe9200c(0xfe)]),_0x3a4fee=_0x5e369d[_0xe9200c(0xfc)](join,_0x1cfec6,'ci'),_0x2079f7=[{'location':'ci','path':join(_0x1cfec6,'ci',_0x5ce13d)},{'location':'local','path':_0x5e369d[_0xe9200c(0xf9)](join,_0x1cfec6,_0x5e369d[_0xe9200c(0xfe)],_0x5ce13d)},{'location':'legacy','path':_0x5e369d['EXaXV'](join,_0x1cfec6,_0x5ce13d)}];for(const _0x31aa9a of _0x2079f7){if(_0x4a6fbd[_0xe9200c(0xee)](_0x31aa9a['location'])&&existsSync(_0x31aa9a[_0xe9200c(0xd1)])){if(_0x31aa9a[_0xe9200c(0x116)]===_0x5e369d['ptKkc']&&(_0x31aa9a['path']===_0x4d190b||_0x31aa9a[_0xe9200c(0xd1)]===_0x3a4fee)&&!_0x5e369d['JCFyd'](hasLegacyProfileFiles,_0x31aa9a[_0xe9200c(0xd1)]))continue;return{'path':_0x31aa9a[_0xe9200c(0xd1)],'location':_0x31aa9a[_0xe9200c(0x116)]};}}return null;}function hasLegacyProfileFiles(_0x11832e){const _0x2451fb=_0x4324,_0x25bbb7={'vzJMd':function(_0xa8a505,_0x526594){return _0xa8a505(_0x526594);},'SOtuk':function(_0x5587b7,_0x15c61d,_0x39ae98){return _0x5587b7(_0x15c61d,_0x39ae98);},'YpZPf':_0x2451fb(0xdb),'qbYWA':function(_0x10b23c,_0xfb90f1,_0x47d9a5){return _0x10b23c(_0xfb90f1,_0x47d9a5);},'FSRGv':function(_0x952e5f,_0x44754b,_0x51d128){return _0x952e5f(_0x44754b,_0x51d128);}};return _0x25bbb7[_0x2451fb(0xe2)](existsSync,_0x25bbb7[_0x2451fb(0x100)](join,_0x11832e,_0x25bbb7[_0x2451fb(0xd6)]))||_0x25bbb7[_0x2451fb(0xe2)](existsSync,_0x25bbb7[_0x2451fb(0x102)](join,_0x11832e,'auth.json'))||existsSync(_0x25bbb7['FSRGv'](join,_0x11832e,_0x2451fb(0xf8)));}export function isEnvCi(_0x5c86ae){const _0x5a5d1a={'CCnHY':function(_0x31ca7d,_0x281fd6){return _0x31ca7d(_0x281fd6);},'aaJKv':function(_0x574549){return _0x574549();}};return _0x5a5d1a['CCnHY'](existsSync,join(_0x5a5d1a['aaJKv'](getRangerDir),'ci',_0x5c86ae));}export async function cleanupTempFiles(_0x397b43){const _0x5ec897=_0x4324,_0x2d7085={'bedno':'ENOENT'},_0x49ea14=[_0x397b43[_0x5ec897(0xf0)],_0x397b43[_0x5ec897(0x113)]]['filter'](Boolean);await Promise['all'](_0x49ea14['map'](_0x1b5ef0=>unlink(_0x1b5ef0)[_0x5ec897(0xd5)](_0x254776=>{const _0x4f3aad=_0x5ec897;_0x254776[_0x4f3aad(0xd7)]!==_0x2d7085['bedno']&&console['warn'](_0x4f3aad(0x109)+_0x1b5ef0+':',_0x254776[_0x4f3aad(0xed)]);})));}export function getSettingsPath(_0x60388){const _0x2c6829=_0x4324,_0x4fc076={'CeDcb':function(_0x48d0be,_0x2008e7,_0x13c092){return _0x48d0be(_0x2008e7,_0x13c092);},'uIRAM':function(_0x333842,_0x5a545a){return _0x333842(_0x5a545a);}};return _0x4fc076[_0x2c6829(0xd3)](join,_0x4fc076[_0x2c6829(0xfd)](getEnvDir,_0x60388),'settings.json');}export async function loadSettings(_0x41d5fe){const _0x3ec0d1=_0x4324,_0x438d22={'UMTBl':function(_0x46854e,_0xf65ea9){return _0x46854e(_0xf65ea9);},'iBAmo':function(_0x26afe1,_0x50f7e9,_0x331373){return _0x26afe1(_0x50f7e9,_0x331373);},'QkyAW':'utf-8'},_0x1446f2=_0x438d22[_0x3ec0d1(0x11c)](getSettingsPath,_0x41d5fe);if(!_0x438d22['UMTBl'](existsSync,_0x1446f2))return{};try{const _0x313daf=await _0x438d22[_0x3ec0d1(0x114)](readFile,_0x1446f2,_0x438d22[_0x3ec0d1(0x111)]);return JSON['parse'](_0x313daf);}catch{return{};}}export async function saveSettings(_0x2a747c,_0x239f21){const _0x84fa7f=_0x4324,_0x12ddad={'efDIw':function(_0x6f8dcc,_0x362709,_0x44b855){return _0x6f8dcc(_0x362709,_0x44b855);}},_0x4d16cd=getSettingsPath(_0x2a747c),_0x45f3bc=dirname(_0x4d16cd);!existsSync(_0x45f3bc)&&await _0x12ddad[_0x84fa7f(0x101)](mkdir,_0x45f3bc,{'recursive':!![]}),await _0x12ddad[_0x84fa7f(0x101)](writeFile,_0x4d16cd,JSON[_0x84fa7f(0x11d)](_0x239f21,null,0x2));}export function resolveEnvVars(_0x3ea375){const _0x123f96=_0x4324,_0x5db7dd={'bSxAC':function(_0x31ecc6,_0x1aed88){return _0x31ecc6===_0x1aed88;},'QVGLY':_0x123f96(0xef)};if(_0x5db7dd['bSxAC'](typeof _0x3ea375,_0x5db7dd[_0x123f96(0xe6)]))return _0x3ea375[_0x123f96(0xfb)](/\$\{(\w+)\}/g,(_0x8b4537,_0x2f3bb2)=>{const _0x3bd356=_0x123f96,_0x234487=process[_0x3bd356(0x10f)][_0x2f3bb2];if(_0x234487===undefined)throw new Error(_0x3bd356(0xdc)+_0x2f3bb2+_0x3bd356(0xd8));return _0x234487;});if(Array[_0x123f96(0x110)](_0x3ea375))return _0x3ea375[_0x123f96(0x117)](resolveEnvVars);if(_0x3ea375&&typeof _0x3ea375==='object')return Object[_0x123f96(0xfa)](Object['entries'](_0x3ea375)['map'](([_0x3baf57,_0x3ca8d4])=>[_0x3baf57,resolveEnvVars(_0x3ca8d4)]));return _0x3ea375;}export async function buildPlaywrightConfig(_0x58c1bb,_0x146d93,_0x399ee6,_0x1b3b5c){const _0x206d9b=_0x4324,_0x537e90={'HqmFg':function(_0x8bfe34,_0x555e23){return _0x8bfe34(_0x555e23);},'rKXoK':function(_0x41e78f,_0x573c4e,_0x4904fa){return _0x41e78f(_0x573c4e,_0x4904fa);},'bObIY':'auth.json','VEVTx':function(_0x5a1e83,_0x2372cf,_0x2de121){return _0x5a1e83(_0x2372cf,_0x2de121);},'jvpYi':function(_0x3deba2,_0x4ed53c){return _0x3deba2(_0x4ed53c);},'XgMno':function(_0x533c01){return _0x533c01();},'vCKcu':_0x206d9b(0xda),'FPSWY':'chromium','vOcvU':function(_0x7d928b,_0x42d1d9){return _0x7d928b===_0x42d1d9;},'jRkCN':'--disable-setuid-sandbox','tekYZ':'clipboard-read','qBLmS':'tabs','jOyNh':'install','Qxihh':_0x206d9b(0xd9),'ZseLS':'vision','wurar':function(_0x4e2d84){return _0x4e2d84();},'ylnMd':function(_0x2896d2,_0x544d89,_0x47f1df){return _0x2896d2(_0x544d89,_0x47f1df);}},_0x548b3f=_0x537e90['HqmFg'](getEnvDir,_0x146d93),_0x3a8547=_0x537e90['rKXoK'](join,_0x548b3f,_0x206d9b(0xf8)),_0x18ebef=join(_0x548b3f,_0x537e90[_0x206d9b(0xea)]);let _0x104997,_0x5d95a5;if(existsSync(_0x3a8547))try{const _0x34ff30=await getToken();if(!_0x34ff30)throw new Error('No\x20API\x20token\x20found.\x20Run:\x20ranger\x20setup\x20[token]');const _0x3989ee=await readFile(_0x3a8547),_0x1798cb=_0x537e90['VEVTx'](decrypt,_0x3989ee,_0x34ff30);_0x5d95a5=join(tmpdir(),_0x206d9b(0xf6)+Date['now']()+_0x206d9b(0x11b)),await writeFile(_0x5d95a5,_0x1798cb),_0x104997=_0x5d95a5;}catch(_0x24611c){const _0x5b2a09=_0x24611c instanceof Error?_0x24611c[_0x206d9b(0xed)]:_0x537e90[_0x206d9b(0xf1)](String,_0x24611c);throw new Error('Failed\x20to\x20decrypt\x20auth\x20state:\x20'+_0x5b2a09);}else _0x537e90['jvpYi'](existsSync,_0x18ebef)&&(_0x104997=_0x18ebef);const _0x395a3b=_0x399ee6||_0x537e90['XgMno'](randomUUID),_0x13b28f=join(getRangerDir(),_0x537e90['vCKcu'],_0x395a3b),_0x464225={'name':_0x146d93,'browser':{'isolated':!![],'browserName':_0x537e90['FPSWY'],'launchOptions':{'headless':_0x1b3b5c?![]:_0x58c1bb['headless']??!![],..._0x537e90['vOcvU'](process['getuid']?.(),0x0)&&{'args':[_0x206d9b(0x11e),_0x537e90[_0x206d9b(0xe3)]]}},'contextOptions':{'permissions':[_0x537e90[_0x206d9b(0xf2)],'clipboard-write'],'userAgent':_0x58c1bb[_0x206d9b(0xf5)]||undefined,'extraHTTPHeaders':_0x58c1bb[_0x206d9b(0xe7)]||{},'storageState':_0x104997,'viewport':{'width':0x500,'height':0x2d0}}},'capabilities':[_0x206d9b(0x11a),_0x537e90[_0x206d9b(0xd2)],_0x537e90['jOyNh'],_0x537e90['Qxihh'],_0x537e90['ZseLS']],'imageResponses':'allow','saveTrace':!![],'saveVideo':{'width':0x500,'height':0x2d0},'outputDir':_0x13b28f},_0x4f91f1=_0x464225[_0x206d9b(0x10c)],_0x7e8273=_0x4f91f1['contextOptions'];if(_0x7e8273['userAgent']===undefined)delete _0x7e8273[_0x206d9b(0xf5)];if(_0x7e8273[_0x206d9b(0x11f)]===undefined)delete _0x7e8273[_0x206d9b(0x11f)];const _0xb3216=join(_0x537e90[_0x206d9b(0x105)](tmpdir),'ranger-config');!existsSync(_0xb3216)&&await mkdir(_0xb3216,{'recursive':!![]});const _0x3f6d8c=_0x537e90['ylnMd'](join,_0xb3216,_0x146d93+'-'+Date[_0x206d9b(0xf4)]()+'.json');return await _0x537e90[_0x206d9b(0xdd)](writeFile,_0x3f6d8c,JSON['stringify'](_0x464225,null,0x2)),{'configPath':_0x3f6d8c,'tempAuthPath':_0x5d95a5};}export function getNestedValue(_0x53910b,_0x582f70){const _0x204910=_0x4324,_0x23709b={'aKWBD':function(_0x5626ed,_0x5497d8){return _0x5626ed(_0x5497d8);},'JJXva':_0x204910(0x104)},_0x272eaa=_0x23709b[_0x204910(0x112)](parseKeyPath,_0x582f70);let _0x59d8e0=_0x53910b;for(const _0x417368 of _0x272eaa){if(_0x59d8e0===null||_0x59d8e0===undefined||typeof _0x59d8e0!==_0x23709b['JJXva'])return undefined;_0x59d8e0=_0x59d8e0[_0x417368];}return _0x59d8e0;}export function setNestedValue(_0x309329,_0x59d432,_0xfee262){const _0x5116ca=_0x4324,_0x9627c3={'ZCOdl':function(_0x53130a,_0x574b7e){return _0x53130a(_0x574b7e);},'ZwaSf':function(_0x30c6df,_0x2f83bd){return _0x30c6df<_0x2f83bd;},'ItOsl':function(_0x2090b0,_0x1e15bc){return _0x2090b0-_0x1e15bc;},'nHZPX':function(_0x32d585,_0x377b66){return _0x32d585 in _0x377b66;},'LbGZK':function(_0x481694,_0x3844d1){return _0x481694!==_0x3844d1;},'XZuiM':_0x5116ca(0x104)},_0x2cd89d=_0x9627c3[_0x5116ca(0x10b)](parseKeyPath,_0x59d432);let _0x3522ea=_0x309329;for(let _0x416185=0x0;_0x9627c3['ZwaSf'](_0x416185,_0x9627c3[_0x5116ca(0xec)](_0x2cd89d['length'],0x1));_0x416185++){const _0x52f44f=_0x2cd89d[_0x416185];(!_0x9627c3[_0x5116ca(0xd4)](_0x52f44f,_0x3522ea)||_0x9627c3[_0x5116ca(0x107)](typeof _0x3522ea[_0x52f44f],_0x9627c3[_0x5116ca(0xeb)]))&&(_0x3522ea[_0x52f44f]={}),_0x3522ea=_0x3522ea[_0x52f44f];}_0x3522ea[_0x2cd89d[_0x2cd89d['length']-0x1]]=_0xfee262;}export function deleteNestedValue(_0x117232,_0x474582){const _0x3ff206=_0x4324,_0x17c9af={'cDbem':function(_0x422b7a,_0x5ad5f2){return _0x422b7a<_0x5ad5f2;},'kESbX':function(_0x4d3db9,_0x429bf1){return _0x4d3db9===_0x429bf1;},'somIU':function(_0x5ad0b5,_0x2b00f0){return _0x5ad0b5!==_0x2b00f0;},'UlEvR':function(_0x1cdd9d,_0x645325){return _0x1cdd9d===_0x645325;},'QayBU':function(_0x26549f,_0x15ea40){return _0x26549f!==_0x15ea40;}},_0x51aa33=parseKeyPath(_0x474582);let _0x3f6835=_0x117232;for(let _0x221c65=0x0;_0x17c9af[_0x3ff206(0xe9)](_0x221c65,_0x51aa33['length']-0x1);_0x221c65++){if(_0x17c9af['kESbX'](_0x3f6835,null)||_0x3f6835===undefined||_0x17c9af['somIU'](typeof _0x3f6835,_0x3ff206(0x104)))return![];_0x3f6835=_0x3f6835[_0x51aa33[_0x221c65]];}if(_0x3f6835===null||_0x17c9af['UlEvR'](_0x3f6835,undefined)||_0x17c9af[_0x3ff206(0xff)](typeof _0x3f6835,_0x3ff206(0x104)))return![];const _0x2ecd2a=_0x51aa33[_0x51aa33[_0x3ff206(0xf3)]-0x1];if(_0x2ecd2a in _0x3f6835)return delete _0x3f6835[_0x2ecd2a],!![];return![];}function _0x5950(){const _0x516d9b=['iBAmo','978715KtQlTp','location','map','split','20552422WAmWaZ','core','.json','UMTBl','stringify','--no-sandbox','storageState','20uOmqIX','897976UTNFQA','path','qBLmS','CeDcb','nHZPX','catch','YpZPf','code','\x20is\x20not\x20set','pdf','sessions','settings.json','Environment\x20variable\x20','VEVTx','1NXprcs','2002542qIRXgV','legacy','8648DDaiIK','vzJMd','jRkCN','entries','join','QVGLY','headers','mEzES','cDbem','bObIY','XZuiM','ItOsl','message','includes','string','tempAuthPath','HqmFg','tekYZ','length','now','userAgent','ranger-auth-','AuIue','auth.json.enc','vZTSH','fromEntries','replace','vWqbl','uIRAM','kttCj','QayBU','SOtuk','efDIw','qbYWA','1932IUIrUv','object','wurar','iTiJG','LbGZK','3011454wcHSYk','Failed\x20to\x20clean\x20up\x20temp\x20file\x20','12kSjZqM','ZCOdl','browser','563970fXeScI','egILE','env','isArray','QkyAW','aKWBD','configPath'];_0x5950=function(){return _0x516d9b;};return _0x5950();}function parseKeyPath(_0x16d481){const _0xc7f105=_0x4324,_0x10678c={'mqAOl':'header','AuIue':_0xc7f105(0xe7)},_0x345524=_0x16d481[_0xc7f105(0x118)]('.');return _0x345524[0x0]===_0x10678c['mqAOl']&&(_0x345524[0x0]=_0x10678c[_0xc7f105(0xf7)]),_0x345524;}export function formatSettings(_0x3647f2,_0x22813e=0x0){const _0x25fea8=_0x4324,_0x4b01ca={'gvGVp':function(_0x30b66c,_0x354017){return _0x30b66c===_0x354017;},'zFopG':function(_0x1ab652,_0x5b2450){return _0x1ab652!==_0x5b2450;}},_0x1cf5a3=[],_0x6e2981='\x20\x20'['repeat'](_0x22813e);for(const [_0x29f14c,_0x35f066]of Object[_0x25fea8(0xe4)](_0x3647f2)){if(_0x4b01ca['gvGVp'](_0x35f066,undefined))continue;if(typeof _0x35f066===_0x25fea8(0x104)&&_0x4b01ca['zFopG'](_0x35f066,null)){_0x1cf5a3['push'](''+_0x6e2981+_0x29f14c+':');for(const [_0x14a8e9,_0x482c97]of Object[_0x25fea8(0xe4)](_0x35f066)){_0x1cf5a3['push'](_0x6e2981+'\x20\x20'+_0x14a8e9+':\x20'+_0x482c97);}}else _0x1cf5a3['push'](''+_0x6e2981+_0x29f14c+':\x20'+_0x35f066);}return _0x1cf5a3[_0x25fea8(0xe5)]('\x0a');}