@wonderwhy-er/desktop-commander 0.2.52 → 0.3.0

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 (118) hide show
  1. package/dist/command-manager.d.ts +7 -2
  2. package/dist/command-manager.js +16 -11
  3. package/dist/config-manager.d.ts +55 -3
  4. package/dist/config-manager.js +329 -87
  5. package/dist/config-recovery.d.ts +28 -0
  6. package/dist/config-recovery.js +81 -0
  7. package/dist/config.d.ts +1 -0
  8. package/dist/config.js +9 -0
  9. package/dist/handlers/filesystem-handlers.d.ts +1 -1
  10. package/dist/handlers/filesystem-handlers.js +26 -16
  11. package/dist/handlers/search-answers.d.ts +58 -0
  12. package/dist/handlers/search-answers.js +172 -0
  13. package/dist/handlers/search-handlers.js +4 -92
  14. package/dist/index.js +14 -7
  15. package/dist/npm-scripts/remote.js +17 -3
  16. package/dist/remote-device/desktop-commander-integration.d.ts +1 -0
  17. package/dist/remote-device/desktop-commander-integration.js +19 -25
  18. package/dist/remote-device/device.d.ts +14 -0
  19. package/dist/remote-device/device.js +137 -30
  20. package/dist/remote-device/diagnostics/device-log.d.ts +63 -0
  21. package/dist/remote-device/diagnostics/device-log.js +219 -0
  22. package/dist/remote-device/diagnostics/redact.d.ts +1 -0
  23. package/dist/remote-device/diagnostics/redact.js +76 -0
  24. package/dist/remote-device/diagnostics/report.d.ts +118 -0
  25. package/dist/remote-device/diagnostics/report.js +748 -0
  26. package/dist/remote-device/diagnostics/upload.d.ts +11 -0
  27. package/dist/remote-device/diagnostics/upload.js +59 -0
  28. package/dist/remote-device/realtime-health-telemetry.d.ts +35 -0
  29. package/dist/remote-device/realtime-health-telemetry.js +110 -0
  30. package/dist/remote-device/remote-channel.d.ts +36 -4
  31. package/dist/remote-device/remote-channel.js +230 -50
  32. package/dist/remote-device/scripts/blocking-offline-update.js +108 -69
  33. package/dist/remote-device/transport-telemetry.d.ts +32 -0
  34. package/dist/remote-device/transport-telemetry.js +48 -0
  35. package/dist/search-manager.d.ts +239 -27
  36. package/dist/search-manager.js +746 -312
  37. package/dist/server.js +124 -222
  38. package/dist/terminal-manager.d.ts +138 -21
  39. package/dist/terminal-manager.js +300 -215
  40. package/dist/tools/config.d.ts +1 -1
  41. package/dist/tools/config.js +21 -70
  42. package/dist/tools/edit.js +12 -4
  43. package/dist/tools/filesystem.d.ts +30 -6
  44. package/dist/tools/filesystem.js +246 -140
  45. package/dist/tools/improved-process-tools.d.ts +9 -3
  46. package/dist/tools/improved-process-tools.js +171 -68
  47. package/dist/tools/pdf/extract-images.d.ts +2 -0
  48. package/dist/tools/pdf/extract-images.js +4 -1
  49. package/dist/tools/pdf/index.d.ts +5 -3
  50. package/dist/tools/pdf/index.js +4 -3
  51. package/dist/tools/pdf/lib/pdf2md.d.ts +8 -1
  52. package/dist/tools/pdf/lib/pdf2md.js +12 -5
  53. package/dist/tools/pdf/manipulations.d.ts +12 -1
  54. package/dist/tools/pdf/manipulations.js +17 -4
  55. package/dist/tools/pdf/markdown.d.ts +96 -0
  56. package/dist/tools/pdf/markdown.js +485 -20
  57. package/dist/tools/pdf/utils.d.ts +2 -2
  58. package/dist/tools/pdf/utils.js +4 -4
  59. package/dist/tools/process.js +8 -5
  60. package/dist/tools/schemas.d.ts +1 -11
  61. package/dist/tools/schemas.js +15 -14
  62. package/dist/types.d.ts +1 -1
  63. package/dist/ui/config-editor/config-editor-runtime.js +53 -53
  64. package/dist/ui/config-editor/src/app.js +2 -15
  65. package/dist/ui/file-preview/preview-runtime.js +190 -182
  66. package/dist/utils/ab-test.js +27 -9
  67. package/dist/utils/atomic-write.d.ts +14 -0
  68. package/dist/utils/atomic-write.js +80 -0
  69. package/dist/utils/capture.d.ts +17 -1
  70. package/dist/utils/capture.js +177 -68
  71. package/dist/utils/exit-process.d.ts +24 -0
  72. package/dist/utils/exit-process.js +31 -0
  73. package/dist/utils/feature-flags.js +2 -1
  74. package/dist/utils/files/base.d.ts +3 -1
  75. package/dist/utils/files/docx.d.ts +3 -0
  76. package/dist/utils/files/docx.js +24 -9
  77. package/dist/utils/files/excel.d.ts +10 -0
  78. package/dist/utils/files/excel.js +93 -33
  79. package/dist/utils/files/factory.d.ts +22 -1
  80. package/dist/utils/files/factory.js +59 -4
  81. package/dist/utils/files/image.d.ts +12 -4
  82. package/dist/utils/files/image.js +19 -8
  83. package/dist/utils/files/index.d.ts +5 -3
  84. package/dist/utils/files/index.js +4 -3
  85. package/dist/utils/files/pdf.js +18 -36
  86. package/dist/utils/files/text.d.ts +21 -5
  87. package/dist/utils/files/text.js +90 -86
  88. package/dist/utils/internal-facts.d.ts +3 -0
  89. package/dist/utils/internal-facts.js +23 -0
  90. package/dist/utils/lazy-package.d.ts +25 -0
  91. package/dist/utils/lazy-package.js +44 -0
  92. package/dist/utils/open-browser.js +2 -1
  93. package/dist/utils/process-detection.d.ts +24 -5
  94. package/dist/utils/process-detection.js +199 -89
  95. package/dist/utils/process-tree.d.ts +14 -0
  96. package/dist/utils/process-tree.js +223 -0
  97. package/dist/utils/rename.d.ts +9 -0
  98. package/dist/utils/rename.js +74 -0
  99. package/dist/utils/ripgrep-resolver.js +9 -14
  100. package/dist/utils/shell.d.ts +42 -0
  101. package/dist/utils/shell.js +187 -0
  102. package/dist/utils/system-info.d.ts +1 -0
  103. package/dist/utils/system-info.js +40 -25
  104. package/dist/utils/trackTools.js +2 -1
  105. package/dist/utils/usageTracker.d.ts +0 -39
  106. package/dist/utils/usageTracker.js +1 -161
  107. package/dist/version.d.ts +1 -1
  108. package/dist/version.js +1 -1
  109. package/node_modules/@desktop-commander/telemetry-contract/README.md +56 -0
  110. package/node_modules/@desktop-commander/telemetry-contract/package.json +32 -0
  111. package/node_modules/@desktop-commander/telemetry-contract/transport.d.ts +38 -0
  112. package/node_modules/@desktop-commander/telemetry-contract/transport.js +164 -0
  113. package/package.json +32 -16
  114. package/vendor/telemetry-contract/README.md +56 -0
  115. package/vendor/telemetry-contract/package.json +32 -0
  116. package/vendor/telemetry-contract/transport.d.ts +38 -0
  117. package/vendor/telemetry-contract/transport.js +164 -0
  118. package/vendor/telemetry-contract/transport.test.js +39 -0
@@ -1,7 +1,7 @@
1
- import { execSync } from 'child_process';
2
1
  import { existsSync, chmodSync } from 'fs';
3
2
  import path from 'path';
4
3
  import os from 'os';
4
+ import { resolveShellPath } from './shell.js';
5
5
  let cachedRgPath = null;
6
6
  /**
7
7
  * Resolve ripgrep binary path with multiple fallback strategies
@@ -31,23 +31,18 @@ export async function getRipgrepPath() {
31
31
  catch (e) {
32
32
  // @vscode/ripgrep import or binary resolution failed, continue to fallbacks
33
33
  }
34
- // Strategy 2: Try system ripgrep using 'which' (Unix) or 'where' (Windows)
35
- try {
36
- const systemRg = process.platform === 'win32' ? 'rg.exe' : 'rg';
37
- const whichCmd = process.platform === 'win32' ? 'where' : 'which';
38
- const result = execSync(`${whichCmd} ${systemRg}`, { encoding: 'utf-8' }).trim().split(/\r?\n/)[0];
39
- if (result && existsSync(result)) {
40
- cachedRgPath = result;
41
- return result;
42
- }
43
- }
44
- catch (e) {
45
- // System rg not found via which
34
+ // Strategy 2: system ripgrep on PATH (never the working folder, which
35
+ // 'where' searched first on Windows)
36
+ const systemRg = resolveShellPath(process.platform === 'win32' ? 'rg.exe' : 'rg');
37
+ if (systemRg) {
38
+ cachedRgPath = systemRg;
39
+ return systemRg;
46
40
  }
47
41
  // Strategy 3: Try common installation paths
48
42
  const commonPaths = [];
49
43
  if (process.platform === 'win32') {
50
- commonPaths.push('C:\\Program Files\\Ripgrep\\rg.exe', 'C:\\Program Files (x86)\\Ripgrep\\rg.exe', path.join(os.homedir(), 'scoop', 'apps', 'ripgrep', 'current', 'rg.exe'), path.join(os.homedir(), '.cargo', 'bin', 'rg.exe'));
44
+ // Windows' own Program Files folders, which aren't always on C:
45
+ commonPaths.push(path.join(process.env.ProgramFiles ?? 'C:\\Program Files', 'Ripgrep', 'rg.exe'), path.join(process.env['ProgramFiles(x86)'] ?? 'C:\\Program Files (x86)', 'Ripgrep', 'rg.exe'), path.join(os.homedir(), 'scoop', 'apps', 'ripgrep', 'current', 'rg.exe'), path.join(os.homedir(), '.cargo', 'bin', 'rg.exe'));
51
46
  }
52
47
  else {
53
48
  commonPaths.push('/usr/local/bin/rg', '/usr/bin/rg', path.join(os.homedir(), '.cargo', 'bin', 'rg'), '/opt/homebrew/bin/rg' // Apple Silicon Homebrew
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Resolves a shell or other program name ("pwsh", "bash.exe", "where") or path
3
+ * ("/bin/zsh") to an executable file. Bare names are searched in PATH's
4
+ * folders only, never the working folder. Returns null when it can't be found.
5
+ */
6
+ export declare function resolveShellPath(shell: string): string | null;
7
+ export declare function isShellAvailable(shell: string): boolean;
8
+ /**
9
+ * The full path to start a program by: the one found on PATH. Windows looks
10
+ * for a bare name ("powershell.exe", "cmd", "tasklist") in the working folder
11
+ * before PATH, so a file of that name there would run instead; every program
12
+ * Desktop Commander starts by name goes through here. On Windows a bare name
13
+ * not found on PATH is an error rather than a name Windows would look up in
14
+ * the working folder. A path (absolute, or with a folder in it) is kept as
15
+ * given, and so is a bare name elsewhere, where the working folder isn't searched.
16
+ */
17
+ export declare function resolveProgramPath(program: string): string;
18
+ /**
19
+ * The shell used when the user hasn't configured one.
20
+ * Windows: Windows PowerShell, falling back to %ComSpec%.
21
+ * macOS/Linux: $SHELL, falling back to the OS default shell.
22
+ */
23
+ export declare function getDefaultShell(): string;
24
+ /**
25
+ * Shells installed on this machine, default shell first. Only shells that
26
+ * resolve to an executable are returned.
27
+ */
28
+ export declare function detectAvailableShells(): string[];
29
+ /**
30
+ * Configuration for spawning a shell with appropriate flags
31
+ */
32
+ export interface ShellSpawnConfig {
33
+ executable: string;
34
+ args: string[];
35
+ useShellOption: string | boolean;
36
+ windowsVerbatim?: boolean;
37
+ }
38
+ /**
39
+ * Get the appropriate spawn configuration for a given shell
40
+ * This handles login shell flags for different shell types
41
+ */
42
+ export declare function getShellSpawnArgs(shellPath: string, command: string): ShellSpawnConfig;
@@ -0,0 +1,187 @@
1
+ import fs from 'fs';
2
+ import os from 'os';
3
+ import path from 'path';
4
+ /**
5
+ * Single source of truth for shells: which shell is the default on this
6
+ * machine, which shells are installed, and how to invoke each of them.
7
+ * Config defaults, system info, process tools, the terminal manager and the
8
+ * config editor all derive their shell choices from here.
9
+ */
10
+ // Shell executables Windows can host. Which of them exist is resolved on PATH.
11
+ const WINDOWS_SHELLS = ['powershell.exe', 'pwsh.exe', 'cmd.exe', 'bash.exe'];
12
+ function isWindows() {
13
+ return os.platform() === 'win32';
14
+ }
15
+ function isExecutableFile(filePath) {
16
+ try {
17
+ fs.accessSync(filePath, isWindows() ? fs.constants.F_OK : fs.constants.X_OK);
18
+ return fs.statSync(filePath).isFile();
19
+ }
20
+ catch {
21
+ // Missing or not executable: this candidate isn't a usable shell, the next one is tried
22
+ return false;
23
+ }
24
+ }
25
+ function windowsExecutableExtensions() {
26
+ const fromEnv = (process.env.PATHEXT ?? '').split(';').map((ext) => ext.trim()).filter(Boolean);
27
+ return [...new Set(['.EXE', ...fromEnv])];
28
+ }
29
+ /**
30
+ * Resolves a shell or other program name ("pwsh", "bash.exe", "where") or path
31
+ * ("/bin/zsh") to an executable file. Bare names are searched in PATH's
32
+ * folders only, never the working folder. Returns null when it can't be found.
33
+ */
34
+ export function resolveShellPath(shell) {
35
+ const name = shell.trim();
36
+ if (!name)
37
+ return null;
38
+ if (path.isAbsolute(name) || name.includes('/') || name.includes('\\')) {
39
+ return isExecutableFile(name) ? name : null;
40
+ }
41
+ const extensions = isWindows() && !path.extname(name) ? windowsExecutableExtensions() : [''];
42
+ const pathDirs = (process.env.PATH ?? '').split(path.delimiter)
43
+ .map((dir) => dir.trim().replace(/^"(.*)"$/, '$1'))
44
+ .filter(Boolean);
45
+ for (const dir of pathDirs) {
46
+ for (const ext of extensions) {
47
+ const candidate = path.join(dir, name + ext);
48
+ if (isExecutableFile(candidate))
49
+ return candidate;
50
+ }
51
+ }
52
+ return null;
53
+ }
54
+ export function isShellAvailable(shell) {
55
+ return resolveShellPath(shell) !== null;
56
+ }
57
+ /**
58
+ * The full path to start a program by: the one found on PATH. Windows looks
59
+ * for a bare name ("powershell.exe", "cmd", "tasklist") in the working folder
60
+ * before PATH, so a file of that name there would run instead; every program
61
+ * Desktop Commander starts by name goes through here. On Windows a bare name
62
+ * not found on PATH is an error rather than a name Windows would look up in
63
+ * the working folder. A path (absolute, or with a folder in it) is kept as
64
+ * given, and so is a bare name elsewhere, where the working folder isn't searched.
65
+ */
66
+ export function resolveProgramPath(program) {
67
+ const resolved = resolveShellPath(program);
68
+ if (resolved)
69
+ return resolved;
70
+ const name = program.trim();
71
+ if (isWindows() && !name.includes('/') && !name.includes('\\')) {
72
+ throw new Error(`${name} was not found on PATH`);
73
+ }
74
+ return program;
75
+ }
76
+ /**
77
+ * The shell used when the user hasn't configured one.
78
+ * Windows: Windows PowerShell, falling back to %ComSpec%.
79
+ * macOS/Linux: $SHELL, falling back to the OS default shell.
80
+ */
81
+ export function getDefaultShell() {
82
+ if (isWindows()) {
83
+ if (isShellAvailable('powershell.exe'))
84
+ return 'powershell.exe';
85
+ return process.env.ComSpec || 'cmd.exe';
86
+ }
87
+ const userShell = process.env.SHELL;
88
+ if (userShell && isShellAvailable(userShell))
89
+ return userShell;
90
+ // $SHELL may be unset when launched from a GUI app such as Claude Desktop.
91
+ // zsh is the macOS default since Catalina; /bin/sh is guaranteed by POSIX.
92
+ return os.platform() === 'darwin' ? '/bin/zsh' : '/bin/sh';
93
+ }
94
+ // Login programs /etc/shells can list that don't run a command given with -c,
95
+ // the way every command here starts: terminal multiplexers (screen, tmux),
96
+ // git-shell (git commands only), and programs that refuse a login
97
+ const NOT_COMMAND_SHELLS = new Set(['nologin', 'false', 'true', 'sync', 'git-shell', 'screen', 'tmux']);
98
+ function readEtcShells() {
99
+ try {
100
+ return fs.readFileSync('/etc/shells', 'utf8')
101
+ .split(/\r?\n/)
102
+ .map((line) => line.trim())
103
+ .filter((line) => line.length > 0 && !line.startsWith('#'))
104
+ .filter((line) => !NOT_COMMAND_SHELLS.has(path.basename(line)));
105
+ }
106
+ catch {
107
+ // Best-effort discovery only: no readable /etc/shells means no extra shells to list
108
+ return [];
109
+ }
110
+ }
111
+ /**
112
+ * Shells installed on this machine, default shell first. Only shells that
113
+ * resolve to an executable are returned.
114
+ */
115
+ export function detectAvailableShells() {
116
+ const shells = new Set();
117
+ const add = (shell) => {
118
+ const value = shell?.trim();
119
+ if (value && isShellAvailable(value))
120
+ shells.add(value);
121
+ };
122
+ add(getDefaultShell());
123
+ if (isWindows()) {
124
+ WINDOWS_SHELLS.forEach(add);
125
+ }
126
+ else {
127
+ add(process.env.SHELL);
128
+ readEtcShells().forEach(add);
129
+ }
130
+ return [...shells];
131
+ }
132
+ /**
133
+ * Get the appropriate spawn configuration for a given shell
134
+ * This handles login shell flags for different shell types
135
+ */
136
+ export function getShellSpawnArgs(shellPath, command) {
137
+ const shellName = path.basename(shellPath).toLowerCase();
138
+ const executable = resolveProgramPath(shellPath);
139
+ // Unix shells with login flag support
140
+ if (shellName.includes('bash') || shellName.includes('zsh')) {
141
+ return {
142
+ executable,
143
+ args: ['-l', '-c', command],
144
+ useShellOption: false
145
+ };
146
+ }
147
+ // PowerShell Core (cross-platform, supports -Login)
148
+ if (shellName === 'pwsh' || shellName === 'pwsh.exe') {
149
+ return {
150
+ executable,
151
+ args: ['-Login', '-Command', command],
152
+ useShellOption: false
153
+ };
154
+ }
155
+ // Windows PowerShell 5.1 (no login flag support)
156
+ if (shellName === 'powershell' || shellName === 'powershell.exe') {
157
+ return {
158
+ executable,
159
+ args: ['-Command', command],
160
+ useShellOption: false
161
+ };
162
+ }
163
+ // CMD
164
+ if (shellName === 'cmd' || shellName === 'cmd.exe') {
165
+ return {
166
+ executable,
167
+ args: ['/c', command],
168
+ windowsVerbatim: true,
169
+ useShellOption: false
170
+ };
171
+ }
172
+ // Fish shell (uses -l for login, -c for command)
173
+ if (shellName.includes('fish')) {
174
+ return {
175
+ executable,
176
+ args: ['-l', '-c', command],
177
+ useShellOption: false
178
+ };
179
+ }
180
+ // Unknown/other shells - use shell option for safety
181
+ // This provides a fallback for shells we don't explicitly handle
182
+ return {
183
+ executable: command,
184
+ args: [],
185
+ useShellOption: executable
186
+ };
187
+ }
@@ -3,6 +3,7 @@ export interface DockerMount {
3
3
  containerPath: string;
4
4
  type: 'bind' | 'volume';
5
5
  readOnly: boolean;
6
+ verifiedMount: boolean;
6
7
  description: string;
7
8
  }
8
9
  export interface ContainerInfo {
@@ -1,7 +1,8 @@
1
1
  import os from 'os';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
- import { execSync } from 'child_process';
4
+ import { execFileSync } from 'child_process';
5
+ import { getDefaultShell, resolveShellPath } from './shell.js';
5
6
  /**
6
7
  * Detect container environment and type
7
8
  */
@@ -166,6 +167,7 @@ function discoverContainerMounts(isContainer) {
166
167
  containerPath: mountPoint,
167
168
  type: 'bind',
168
169
  readOnly: isReadOnly,
170
+ verifiedMount: true,
169
171
  description: `Mounted directory: ${path.basename(mountPoint)}`
170
172
  });
171
173
  }
@@ -193,7 +195,8 @@ function discoverContainerMounts(isContainer) {
193
195
  containerPath: itemPath,
194
196
  type: 'bind',
195
197
  readOnly: false,
196
- description: `Mounted folder: ${item}`
198
+ verifiedMount: false,
199
+ description: `Candidate folder under /mnt: ${item}`
197
200
  });
198
201
  }
199
202
  }
@@ -230,7 +233,8 @@ function discoverContainerMounts(isContainer) {
230
233
  containerPath: itemPath,
231
234
  type: 'bind',
232
235
  readOnly: false,
233
- description: `Host folder: ${item}`
236
+ verifiedMount: false,
237
+ description: `Candidate folder under /home: ${item}`
234
238
  });
235
239
  }
236
240
  }
@@ -370,8 +374,13 @@ function detectPythonInfo() {
370
374
  ? ['python', 'python3', 'py'] // Windows: 'python' is common, 'py' launcher
371
375
  : ['python3', 'python']; // Unix: prefer python3
372
376
  for (const cmd of pythonCommands) {
377
+ // The python on PATH, never one in the working folder (which Windows
378
+ // searches first for a bare name); not on PATH means not available
379
+ const program = resolveShellPath(cmd);
380
+ if (!program)
381
+ continue;
373
382
  try {
374
- const version = execSync(`${cmd} --version`, {
383
+ const version = execFileSync(program, ['--version'], {
375
384
  encoding: 'utf8',
376
385
  timeout: 5000,
377
386
  stdio: ['pipe', 'pipe', 'pipe']
@@ -403,12 +412,11 @@ export function getSystemInfo() {
403
412
  const containerDetection = detectContainerEnvironment();
404
413
  const mountPoints = containerDetection.isContainer ? discoverContainerMounts(containerDetection.isContainer) : [];
405
414
  let platformName;
406
- let defaultShell;
415
+ const defaultShell = getDefaultShell();
407
416
  let pathSeparator;
408
417
  let examplePaths;
409
418
  if (isWindows) {
410
419
  platformName = 'Windows';
411
- defaultShell = 'powershell.exe';
412
420
  pathSeparator = '\\';
413
421
  examplePaths = {
414
422
  home: 'C:\\Users\\username',
@@ -418,7 +426,6 @@ export function getSystemInfo() {
418
426
  }
419
427
  else if (isMacOS) {
420
428
  platformName = 'macOS';
421
- defaultShell = 'zsh';
422
429
  pathSeparator = '/';
423
430
  examplePaths = {
424
431
  home: '/Users/username',
@@ -428,7 +435,6 @@ export function getSystemInfo() {
428
435
  }
429
436
  else if (isLinux) {
430
437
  platformName = 'Linux';
431
- defaultShell = 'bash';
432
438
  pathSeparator = '/';
433
439
  examplePaths = {
434
440
  home: '/home/username',
@@ -439,7 +445,6 @@ export function getSystemInfo() {
439
445
  else {
440
446
  // Fallback for other Unix-like systems
441
447
  platformName = 'Unix';
442
- defaultShell = 'bash';
443
448
  pathSeparator = '/';
444
449
  examplePaths = {
445
450
  home: '/home/username',
@@ -570,25 +575,26 @@ This Desktop Commander instance is running inside a ${docker.containerType || 'c
570
575
  if (docker.mountPoints.length > 0) {
571
576
  guidance += `
572
577
 
573
- AVAILABLE MOUNTED DIRECTORIES:`;
578
+ AVAILABLE MOUNT LOCATIONS:`;
574
579
  for (const mount of docker.mountPoints) {
575
580
  const access = mount.readOnly ? '(read-only)' : '(read-write)';
581
+ const verification = mount.verifiedMount ? '[verified mount]' : '[unverified candidate]';
576
582
  guidance += `
577
- - ${mount.containerPath} ${access} - ${mount.description}`;
583
+ - ${mount.containerPath} ${access} ${verification} - ${mount.description}`;
578
584
  }
579
585
  guidance += `
580
586
 
581
- IMPORTANT: When users ask about files, FIRST check mounted directories above.
582
- Files outside these paths will be lost when the container stops.
583
- Always suggest using mounted directories for file operations.
587
+ Entries marked [verified mount] are suitable for persistent file work.
588
+ Entries marked [unverified candidate] are inferred from common container paths and may not persist.
589
+ Files outside verified mounts may be lost when the container stops.
584
590
 
585
591
  PATH TRANSLATION IN DOCKER:
586
- When users provide host paths, translate to container paths:
592
+ Host paths may require translation to their corresponding container paths:
587
593
 
588
594
  Windows: "C:\\projects\\data\\file.txt" → "/home/projects/data/file.txt"
589
595
  Linux/Mac: "/Users/john/projects/data/file.txt" → "/home/projects/data/file.txt"
590
596
 
591
- Rules: Remove drive letter/user prefix, keep full folder structure, mount to /home/
597
+ Typical translation removes the drive letter or user prefix, keeps the full folder structure, and maps it under /home/.
592
598
 
593
599
  NOTE: Desktop Commander Docker installer mounts host folders to /home/[folder-name].`;
594
600
  }
@@ -597,7 +603,7 @@ NOTE: Desktop Commander Docker installer mounts host folders to /home/[folder-na
597
603
 
598
604
  ⚠️ WARNING: No mounted directories detected.
599
605
  Files created outside mounted volumes will be lost when the container stops.
600
- Suggest user remount directories using Docker installer or -v flag when running Docker.
606
+ Persistent file work requires a mounted directory, available through the Docker installer or a -v mount.
601
607
  Desktop Commander Docker installer typically mounts folders to /home/[folder-name].`;
602
608
  }
603
609
  if (docker.containerEnvironment?.containerName) {
@@ -610,10 +616,10 @@ Container: ${docker.containerEnvironment.containerName}`;
610
616
 
611
617
  WINDOWS-SPECIFIC TROUBLESHOOTING:
612
618
  - If Node.js/Python commands fail with "not recognized" errors:
613
- * Try different shells: specify shell parameter as "cmd" or "powershell.exe"
619
+ * Alternative shells include "cmd" and "powershell.exe"
614
620
  * PowerShell may have execution policy restrictions for some tools
615
621
  * CMD typically has better compatibility with development tools
616
- * Use set_config_value to change defaultShell if needed
622
+ * defaultShell can be changed with set_config_value if needed
617
623
  - Windows services and processes use different commands (Get-Process vs ps)
618
624
  - Package managers: choco, winget, scoop instead of apt/brew
619
625
  - Environment variables: $env:VAR instead of $VAR
@@ -627,8 +633,8 @@ MACOS-SPECIFIC NOTES:
627
633
  - Python 3 might be 'python3' command, not 'python'
628
634
  - Some GNU tools have different names (e.g., gsed instead of sed)
629
635
  - System Integrity Protection (SIP) may block certain operations
630
- - Use 'open' command to open files/applications from terminal
631
- - For file search: Use mdfind (Spotlight) for fastest exact filename searches`;
636
+ - The 'open' command opens files and applications from the terminal
637
+ - mdfind (Spotlight) provides fast exact filename searches`;
632
638
  }
633
639
  else {
634
640
  guidance += `
@@ -697,16 +703,25 @@ ${envInfo}`;
697
703
  * Get path guidance (simplified since paths are normalized)
698
704
  */
699
705
  export function getPathGuidance(systemInfo) {
700
- let guidance = `Always use absolute paths for reliability. Paths are automatically normalized regardless of slash direction.`;
706
+ let guidance = `Absolute paths are the most reliable because they do not depend on the current working directory. Paths are automatically normalized regardless of slash direction.`;
701
707
  if (systemInfo.docker.isContainer && systemInfo.docker.mountPoints.length > 0) {
702
708
  const containerLabel = systemInfo.docker.containerType === 'kubernetes' ? 'KUBERNETES' :
703
709
  systemInfo.docker.containerType === 'docker' ? 'DOCKER' :
704
710
  systemInfo.docker.containerType === 'podman' ? 'PODMAN' :
705
711
  'CONTAINER';
706
- guidance += `
712
+ const verifiedMounts = systemInfo.docker.mountPoints.filter(m => m.verifiedMount).map(m => m.containerPath);
713
+ const unverifiedCandidates = systemInfo.docker.mountPoints.filter(m => !m.verifiedMount).map(m => m.containerPath);
714
+ if (verifiedMounts.length > 0) {
715
+ guidance += `
707
716
 
708
- 🐳 ${containerLabel}: Prefer paths within mounted directories: ${systemInfo.docker.mountPoints.map(m => m.containerPath).join(', ')}.
709
- When users ask about file locations, check these mounted paths first.`;
717
+ 🐳 ${containerLabel}: Verified mounts for persistent file operations: ${verifiedMounts.join(', ')}.
718
+ Files outside verified mounts may not persist after the container stops.`;
719
+ }
720
+ if (unverifiedCandidates.length > 0) {
721
+ guidance += `
722
+
723
+ 🐳 ${containerLabel}: Unverified mount candidates: ${unverifiedCandidates.join(', ')}. These paths are inferred from common container directories and may not persist.`;
724
+ }
710
725
  }
711
726
  return guidance;
712
727
  }
@@ -1,6 +1,7 @@
1
1
  import * as fs from 'fs';
2
2
  import * as path from 'path';
3
3
  import { TOOL_CALL_FILE, TOOL_CALL_FILE_MAX_SIZE } from '../config.js';
4
+ import { renameWithRetry } from './rename.js';
4
5
  // Ensure the directory for the log file exists
5
6
  const logDir = path.dirname(TOOL_CALL_FILE);
6
7
  await fs.promises.mkdir(logDir, { recursive: true });
@@ -34,7 +35,7 @@ export async function trackToolCall(toolName, args) {
34
35
  const rotateTimestamp = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}_${String(date.getHours()).padStart(2, '0')}-${String(date.getMinutes()).padStart(2, '0')}-${String(date.getSeconds()).padStart(2, '0')}`;
35
36
  const newFileName = path.join(dirName, `${fileBase}_${rotateTimestamp}${fileExt}`);
36
37
  // Rename the current file
37
- await fs.promises.rename(TOOL_CALL_FILE, newFileName);
38
+ await renameWithRetry(TOOL_CALL_FILE, newFileName);
38
39
  }
39
40
  // Append to log file (if file was renamed, this will create a new file)
40
41
  await fs.promises.appendFile(TOOL_CALL_FILE, logEntry, 'utf8');
@@ -16,11 +16,6 @@ export interface ToolUsageStats {
16
16
  lastFeedbackPromptDate?: string;
17
17
  feedbackAttempts?: number;
18
18
  }
19
- export interface OnboardingState {
20
- promptsUsed: boolean;
21
- attemptsShown: number;
22
- lastShownAt: number;
23
- }
24
19
  export interface UsageSession {
25
20
  sessionStart: number;
26
21
  lastActivity: number;
@@ -85,41 +80,7 @@ declare class UsageTracker {
85
80
  * Get usage summary for debugging/admin purposes
86
81
  */
87
82
  getUsageSummary(): Promise<string>;
88
- /**
89
- * Get onboarding state from config
90
- */
91
- getOnboardingState(): Promise<OnboardingState>;
92
- /**
93
- * Save onboarding state to config
94
- */
95
- saveOnboardingState(state: OnboardingState): Promise<void>;
96
- /**
97
- * Check if user should see onboarding invitation - SIMPLE VERSION
98
- */
99
- shouldShowOnboarding(): Promise<boolean>;
100
- /**
101
- * Get onboarding message for new users - DIRECT 5-OPTION LIST (V2)
102
- */
103
- getOnboardingMessage(): Promise<{
104
- variant: string;
105
- message: string;
106
- }>;
107
- /**
108
- * Mark that onboarding message was shown - SIMPLE VERSION
109
- */
110
- markOnboardingShown(variant: string): Promise<void>;
111
- /**
112
- * Mark that user used prompts after seeing onboarding invitation - SIMPLE VERSION
113
- */
114
- markOnboardingPromptsUsed(): Promise<void>;
115
- /**
116
- * Mark that user has used a specific prompt (for analytics)
117
- */
118
83
  markPromptUsed(promptId: string, category: string): Promise<void>;
119
- /**
120
- * Reset onboarding state for testing purposes - SIMPLE VERSION
121
- */
122
- resetOnboardingState(): Promise<void>;
123
84
  }
124
85
  export declare const usageTracker: UsageTracker;
125
86
  export {};