@wonderwhy-er/desktop-commander 0.2.52 → 0.3.1-alpha.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 (137) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +1152 -1152
  3. package/dist/bootstrap.js +0 -0
  4. package/dist/command-manager.d.ts +7 -2
  5. package/dist/command-manager.js +16 -11
  6. package/dist/config-field-definitions.js +0 -0
  7. package/dist/config-manager.d.ts +55 -3
  8. package/dist/config-manager.js +329 -87
  9. package/dist/config-recovery.d.ts +28 -0
  10. package/dist/config-recovery.js +81 -0
  11. package/dist/config.d.ts +1 -0
  12. package/dist/config.js +9 -0
  13. package/dist/custom-stdio.js +0 -0
  14. package/dist/data/onboarding-prompts.json +70 -70
  15. package/dist/error-handlers.js +0 -0
  16. package/dist/handlers/filesystem-handlers.d.ts +1 -1
  17. package/dist/handlers/filesystem-handlers.js +28 -18
  18. package/dist/handlers/search-answers.d.ts +58 -0
  19. package/dist/handlers/search-answers.js +172 -0
  20. package/dist/handlers/search-handlers.js +4 -92
  21. package/dist/index.js +14 -7
  22. package/dist/npm-scripts/remote.js +36 -22
  23. package/dist/remote-device/desktop-commander-integration.js +19 -25
  24. package/dist/remote-device/device.d.ts +14 -0
  25. package/dist/remote-device/device.js +137 -30
  26. package/dist/remote-device/diagnostics/device-log.d.ts +63 -0
  27. package/dist/remote-device/diagnostics/device-log.js +219 -0
  28. package/dist/remote-device/diagnostics/redact.d.ts +1 -0
  29. package/dist/remote-device/diagnostics/redact.js +76 -0
  30. package/dist/remote-device/diagnostics/report.d.ts +118 -0
  31. package/dist/remote-device/diagnostics/report.js +748 -0
  32. package/dist/remote-device/diagnostics/upload.d.ts +11 -0
  33. package/dist/remote-device/diagnostics/upload.js +59 -0
  34. package/dist/remote-device/remote-channel.d.ts +12 -0
  35. package/dist/remote-device/remote-channel.js +55 -8
  36. package/dist/remote-device/scripts/blocking-offline-update.js +133 -96
  37. package/dist/remote-device/transport-telemetry.d.ts +32 -0
  38. package/dist/remote-device/transport-telemetry.js +48 -0
  39. package/dist/search-manager.d.ts +239 -27
  40. package/dist/search-manager.js +746 -312
  41. package/dist/server.js +654 -621
  42. package/dist/setup-claude-server.js +942 -942
  43. package/dist/terminal-manager.d.ts +138 -21
  44. package/dist/terminal-manager.js +300 -215
  45. package/dist/tools/config.d.ts +1 -1
  46. package/dist/tools/config.js +21 -70
  47. package/dist/tools/edit.js +14 -6
  48. package/dist/tools/filesystem.d.ts +30 -6
  49. package/dist/tools/filesystem.js +246 -140
  50. package/dist/tools/fuzzySearch.js +9 -9
  51. package/dist/tools/improved-process-tools.d.ts +9 -3
  52. package/dist/tools/improved-process-tools.js +181 -78
  53. package/dist/tools/pdf/extract-images.d.ts +2 -0
  54. package/dist/tools/pdf/extract-images.js +4 -1
  55. package/dist/tools/pdf/index.d.ts +5 -3
  56. package/dist/tools/pdf/index.js +4 -3
  57. package/dist/tools/pdf/lib/pdf2md.d.ts +8 -1
  58. package/dist/tools/pdf/lib/pdf2md.js +12 -5
  59. package/dist/tools/pdf/manipulations.d.ts +12 -1
  60. package/dist/tools/pdf/manipulations.js +17 -4
  61. package/dist/tools/pdf/markdown.d.ts +96 -0
  62. package/dist/tools/pdf/markdown.js +485 -20
  63. package/dist/tools/pdf/utils.d.ts +2 -2
  64. package/dist/tools/pdf/utils.js +4 -4
  65. package/dist/tools/process.js +8 -5
  66. package/dist/tools/prompts.js +1 -1
  67. package/dist/tools/schemas.d.ts +1 -1
  68. package/dist/tools/schemas.js +15 -6
  69. package/dist/track-installation.js +387 -387
  70. package/dist/types.d.ts +1 -1
  71. package/dist/types.js +0 -0
  72. package/dist/ui/config-editor/config-editor-runtime.js +6 -6
  73. package/dist/ui/config-editor/index.html +13 -13
  74. package/dist/ui/config-editor/src/app.js +32 -45
  75. package/dist/ui/config-editor/src/array-modal.js +32 -32
  76. package/dist/ui/config-editor/styles.css +586 -586
  77. package/dist/ui/file-preview/index.html +16 -16
  78. package/dist/ui/file-preview/src/app.js +8 -8
  79. package/dist/ui/file-preview/src/document-layout.js +31 -31
  80. package/dist/ui/file-preview/src/document-outline.js +8 -8
  81. package/dist/ui/file-preview/src/markdown/conflict-dialog.js +33 -33
  82. package/dist/ui/file-preview/src/markdown/controller.js +9 -9
  83. package/dist/ui/file-preview/src/markdown/editor.js +31 -31
  84. package/dist/ui/file-preview/styles.css +1630 -1630
  85. package/dist/uninstall-claude-server.js +745 -745
  86. package/dist/utils/ab-test.js +27 -9
  87. package/dist/utils/atomic-write.d.ts +14 -0
  88. package/dist/utils/atomic-write.js +80 -0
  89. package/dist/utils/capture.d.ts +17 -1
  90. package/dist/utils/capture.js +177 -68
  91. package/dist/utils/exit-process.d.ts +24 -0
  92. package/dist/utils/exit-process.js +31 -0
  93. package/dist/utils/feature-flags.js +2 -1
  94. package/dist/utils/files/base.d.ts +3 -1
  95. package/dist/utils/files/binary.js +4 -4
  96. package/dist/utils/files/docx.d.ts +3 -0
  97. package/dist/utils/files/docx.js +24 -9
  98. package/dist/utils/files/excel.d.ts +10 -0
  99. package/dist/utils/files/excel.js +96 -36
  100. package/dist/utils/files/factory.d.ts +22 -1
  101. package/dist/utils/files/factory.js +59 -4
  102. package/dist/utils/files/image.d.ts +12 -4
  103. package/dist/utils/files/image.js +19 -8
  104. package/dist/utils/files/index.d.ts +5 -3
  105. package/dist/utils/files/index.js +4 -3
  106. package/dist/utils/files/pdf.js +18 -36
  107. package/dist/utils/files/text.d.ts +21 -5
  108. package/dist/utils/files/text.js +90 -86
  109. package/dist/utils/internal-facts.d.ts +3 -0
  110. package/dist/utils/internal-facts.js +23 -0
  111. package/dist/utils/lazy-package.d.ts +23 -0
  112. package/dist/utils/lazy-package.js +42 -0
  113. package/dist/utils/open-browser.js +2 -1
  114. package/dist/utils/process-detection.d.ts +24 -5
  115. package/dist/utils/process-detection.js +199 -89
  116. package/dist/utils/process-tree.d.ts +14 -0
  117. package/dist/utils/process-tree.js +223 -0
  118. package/dist/utils/rename.d.ts +9 -0
  119. package/dist/utils/rename.js +74 -0
  120. package/dist/utils/ripgrep-resolver.js +9 -14
  121. package/dist/utils/shell.d.ts +42 -0
  122. package/dist/utils/shell.js +187 -0
  123. package/dist/utils/system-info.js +99 -97
  124. package/dist/utils/trackTools.js +2 -1
  125. package/dist/utils/usageTracker.js +49 -49
  126. package/dist/version.d.ts +1 -1
  127. package/dist/version.js +1 -1
  128. package/node_modules/@desktop-commander/telemetry-contract/README.md +56 -0
  129. package/node_modules/@desktop-commander/telemetry-contract/package.json +32 -0
  130. package/node_modules/@desktop-commander/telemetry-contract/transport.d.ts +38 -0
  131. package/node_modules/@desktop-commander/telemetry-contract/transport.js +164 -0
  132. package/package.json +10 -3
  133. package/vendor/telemetry-contract/README.md +56 -0
  134. package/vendor/telemetry-contract/package.json +32 -0
  135. package/vendor/telemetry-contract/transport.d.ts +38 -0
  136. package/vendor/telemetry-contract/transport.js +164 -0
  137. package/vendor/telemetry-contract/transport.test.js +39 -0
package/dist/bootstrap.js CHANGED
File without changes
@@ -1,7 +1,12 @@
1
1
  declare class CommandManager {
2
2
  getBaseCommand(command: string): string;
3
- extractCommands(commandString: string): string[];
4
- extractBaseCommand(commandStr: string): string | null;
3
+ /**
4
+ * The command name of each command in a command line (chained, piped, in $(), ...).
5
+ * asTyped: each first word as typed instead of its base name, for telemetry,
6
+ * which then replaces a path whole (a base name alone can't be told from one).
7
+ */
8
+ extractCommands(commandString: string, asTyped?: boolean): string[];
9
+ extractBaseCommand(commandStr: string, asTyped?: boolean): string | null;
5
10
  validateCommand(command: string): Promise<boolean>;
6
11
  }
7
12
  export declare const commandManager: CommandManager;
@@ -5,7 +5,12 @@ class CommandManager {
5
5
  getBaseCommand(command) {
6
6
  return command.split(' ')[0].toLowerCase().trim();
7
7
  }
8
- extractCommands(commandString) {
8
+ /**
9
+ * The command name of each command in a command line (chained, piped, in $(), ...).
10
+ * asTyped: each first word as typed instead of its base name, for telemetry,
11
+ * which then replaces a path whole (a base name alone can't be told from one).
12
+ */
13
+ extractCommands(commandString, asTyped = false) {
9
14
  try {
10
15
  // Trim any leading/trailing whitespace
11
16
  commandString = commandString.trim();
@@ -59,7 +64,7 @@ class CommandManager {
59
64
  }
60
65
  if (j <= commandString.length && openParens === 0) {
61
66
  const subContent = commandString.substring(i + 2, j - 1);
62
- const subCommands = this.extractCommands(subContent);
67
+ const subCommands = this.extractCommands(subContent, asTyped);
63
68
  commands.push(...subCommands);
64
69
  i = j - 1;
65
70
  if (!inQuote) {
@@ -80,7 +85,7 @@ class CommandManager {
80
85
  }
81
86
  if (j < commandString.length) {
82
87
  const subContent = commandString.substring(i + 1, j);
83
- const subCommands = this.extractCommands(subContent);
88
+ const subCommands = this.extractCommands(subContent, asTyped);
84
89
  commands.push(...subCommands);
85
90
  i = j;
86
91
  if (!inQuote) {
@@ -113,7 +118,7 @@ class CommandManager {
113
118
  if (j <= commandString.length && openParens === 0) {
114
119
  const subshellContent = commandString.substring(i + 1, j - 1);
115
120
  // Recursively extract commands from the subshell
116
- const subCommands = this.extractCommands(subshellContent);
121
+ const subCommands = this.extractCommands(subshellContent, asTyped);
117
122
  commands.push(...subCommands);
118
123
  // Move position past the subshell
119
124
  i = j - 1;
@@ -126,7 +131,7 @@ class CommandManager {
126
131
  if (commandString.startsWith(separator, i)) {
127
132
  // We found a separator - extract the command before it
128
133
  if (currentCmd.trim()) {
129
- const baseCommand = this.extractBaseCommand(currentCmd.trim());
134
+ const baseCommand = this.extractBaseCommand(currentCmd.trim(), asTyped);
130
135
  if (baseCommand)
131
136
  commands.push(baseCommand);
132
137
  }
@@ -143,7 +148,7 @@ class CommandManager {
143
148
  }
144
149
  // Don't forget to add the last command
145
150
  if (currentCmd.trim()) {
146
- const baseCommand = this.extractBaseCommand(currentCmd.trim());
151
+ const baseCommand = this.extractBaseCommand(currentCmd.trim(), asTyped);
147
152
  if (baseCommand)
148
153
  commands.push(baseCommand);
149
154
  }
@@ -155,12 +160,12 @@ class CommandManager {
155
160
  capture('server_request_error', {
156
161
  error: 'Error extracting commands'
157
162
  });
158
- const baseCmd = this.extractBaseCommand(commandString);
163
+ const baseCmd = this.extractBaseCommand(commandString, asTyped);
159
164
  return baseCmd ? [baseCmd] : [];
160
165
  }
161
166
  }
162
- // This extracts the actual command name from a command string
163
- extractBaseCommand(commandStr) {
167
+ // This extracts the actual command name from a command string (asTyped: see extractCommands)
168
+ extractBaseCommand(commandStr, asTyped = false) {
164
169
  try {
165
170
  // Remove environment variables (patterns like KEY=value)
166
171
  const withoutEnvVars = commandStr.replace(/\w+=\S+\s*/g, '').trim();
@@ -193,12 +198,12 @@ class CommandManager {
193
198
  const inner = firstToken.slice(2, -1).trim();
194
199
  if (inner) {
195
200
  const innerTokens = inner.split(/\s+/);
196
- return path.basename(innerTokens[0]).toLowerCase();
201
+ return (asTyped ? innerTokens[0] : path.basename(innerTokens[0])).toLowerCase();
197
202
  }
198
203
  return null;
199
204
  }
200
205
  // strip path prefix so /usr/bin/sudo gets caught as "sudo"
201
- const baseName = path.basename(firstToken);
206
+ const baseName = asTyped ? firstToken : path.basename(firstToken);
202
207
  return baseName.toLowerCase();
203
208
  }
204
209
  catch (error) {
File without changes
@@ -15,6 +15,12 @@ export interface ClientInfo {
15
15
  }
16
16
  export declare function normalizeTelemetryEnabledValue(value: unknown): unknown;
17
17
  export declare function isTelemetryDisabledValue(value: unknown): boolean;
18
+ /**
19
+ * Parses config.json's text. Editors saving "UTF-8 with BOM" (Notepad,
20
+ * PowerShell 5's Set-Content -Encoding UTF8) put U+FEFF first, which
21
+ * JSON.parse rejects although the config is complete.
22
+ */
23
+ export declare function parseConfig(text: string): ServerConfig;
18
24
  /**
19
25
  * Singleton config manager for the server
20
26
  */
@@ -28,6 +34,9 @@ declare class ConfigManager {
28
34
  private pendingMutations;
29
35
  private watcher;
30
36
  private reloadTimer;
37
+ private failedSaves;
38
+ private saveRetry;
39
+ private heldRecoveryEvents;
31
40
  constructor();
32
41
  /**
33
42
  * Initialize configuration - load from disk or create default.
@@ -35,6 +44,18 @@ declare class ConfigManager {
35
44
  * normal writes so two processes starting together cannot clobber each other.
36
45
  */
37
46
  init(): Promise<void>;
47
+ /**
48
+ * Reads config.json at start. A missing one is created (a first run), a corrupt
49
+ * one is recovered, and one written before the welcome page existed is marked
50
+ * as an existing install. If it can't be read, recovered or saved, the session
51
+ * starts without saving it.
52
+ */
53
+ private loadStartupConfig;
54
+ /**
55
+ * Starts the session on `config` and leaves config.json as it is. `warning`
56
+ * tells the user why; saves are tried again every HELD_SAVE_RETRY_MS.
57
+ */
58
+ private startWithoutSaving;
38
59
  /**
39
60
  * Alias for init() to maintain backward compatibility
40
61
  */
@@ -44,12 +65,33 @@ declare class ConfigManager {
44
65
  */
45
66
  private getDefaultConfig;
46
67
  private readConfigFromDisk;
68
+ /**
69
+ * Recovers a corrupt config.json; the caller holds the config lock. It is backed
70
+ * up once, then rewritten as buildRecoveredConfig(). Returns the config now on disk.
71
+ */
72
+ private recoverCorruptConfig;
73
+ /** Sends a recovery event. Telemetry reads the config, so events from before init() is done wait for it. */
74
+ private reportRecovery;
75
+ private emitCorruptConfigTelemetry;
47
76
  private writeConfigAtomically;
77
+ /** config.json's text, or null when there is none */
78
+ private readConfigText;
48
79
  private acquireConfigLock;
80
+ /** Runs `fn` holding the config lock; `lockLost()` tells whether the lock was lost meanwhile. */
81
+ private withConfigLock;
82
+ /**
83
+ * Read config.json, apply `mutate`, write it back, all under the cross-process
84
+ * lock. If the lock was lost, or config.json changed, before the write
85
+ * committed, nothing was written: it runs again under a new lock, so the
86
+ * change lands on what the other process saved.
87
+ */
49
88
  private performConfigMutation;
89
+ private mutateLockedConfig;
50
90
  private queueMutation;
51
91
  /** Non-blocking, coalesced persistence for high-frequency state updates. */
52
92
  scheduleSave(): void;
93
+ /** Saves the queued changes in `ms`; until then scheduleSave() waits for it */
94
+ private retrySaves;
53
95
  private startConfigWatcher;
54
96
  private reloadConfigFromDisk;
55
97
  /**
@@ -60,9 +102,19 @@ declare class ConfigManager {
60
102
  * Get a specific configuration value
61
103
  */
62
104
  getValue(key: string): Promise<any>;
63
- /** Set a specific configuration value and wait for durable persistence. */
64
- setValue(key: string, value: any): Promise<void>;
65
- /** Update one value under the cross-process lock and return the durable value. */
105
+ /**
106
+ * Set a specific configuration value and wait until it is saved: the data is
107
+ * flushed to disk before the rename; the folder flush after it is best effort.
108
+ * With holdIfNotSaved, a value whose save fails is still in effect, and is
109
+ * queued to be saved with later writes (the call still rejects).
110
+ */
111
+ setValue(key: string, value: any, options?: {
112
+ holdIfNotSaved?: boolean;
113
+ }): Promise<void>;
114
+ /**
115
+ * Update one value under the cross-process lock and return it once saved: the
116
+ * data is flushed to disk before the rename; the folder flush after it is best effort.
117
+ */
66
118
  updateValue(key: string, updater: (current: any) => any): Promise<any>;
67
119
  /**
68
120
  * Set a value without waiting on disk. The queued operation is applied to the