@wonderwhy-er/desktop-commander 0.2.23 → 0.2.25
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.
- package/README.md +14 -55
- package/dist/config-manager.d.ts +5 -0
- package/dist/config-manager.js +9 -0
- package/dist/custom-stdio.d.ts +1 -0
- package/dist/custom-stdio.js +19 -0
- package/dist/handlers/filesystem-handlers.d.ts +4 -0
- package/dist/handlers/filesystem-handlers.js +120 -14
- package/dist/handlers/node-handlers.d.ts +6 -0
- package/dist/handlers/node-handlers.js +73 -0
- package/dist/index.js +5 -3
- package/dist/search-manager.d.ts +25 -0
- package/dist/search-manager.js +212 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.js +188 -73
- package/dist/terminal-manager.d.ts +56 -2
- package/dist/terminal-manager.js +169 -13
- package/dist/tools/edit.d.ts +28 -4
- package/dist/tools/edit.js +87 -4
- package/dist/tools/filesystem.d.ts +23 -12
- package/dist/tools/filesystem.js +201 -416
- package/dist/tools/improved-process-tools.d.ts +2 -2
- package/dist/tools/improved-process-tools.js +244 -214
- package/dist/tools/mime-types.d.ts +1 -0
- package/dist/tools/mime-types.js +7 -0
- package/dist/tools/pdf/extract-images.d.ts +34 -0
- package/dist/tools/pdf/extract-images.js +132 -0
- package/dist/tools/pdf/index.d.ts +6 -0
- package/dist/tools/pdf/index.js +3 -0
- package/dist/tools/pdf/lib/pdf2md.d.ts +36 -0
- package/dist/tools/pdf/lib/pdf2md.js +76 -0
- package/dist/tools/pdf/manipulations.d.ts +13 -0
- package/dist/tools/pdf/manipulations.js +96 -0
- package/dist/tools/pdf/markdown.d.ts +7 -0
- package/dist/tools/pdf/markdown.js +37 -0
- package/dist/tools/pdf/utils.d.ts +12 -0
- package/dist/tools/pdf/utils.js +34 -0
- package/dist/tools/schemas.d.ts +167 -12
- package/dist/tools/schemas.js +54 -5
- package/dist/types.d.ts +2 -1
- package/dist/utils/ab-test.d.ts +8 -0
- package/dist/utils/ab-test.js +76 -0
- package/dist/utils/capture.js +5 -0
- package/dist/utils/feature-flags.js +7 -4
- package/dist/utils/files/base.d.ts +167 -0
- package/dist/utils/files/base.js +5 -0
- package/dist/utils/files/binary.d.ts +21 -0
- package/dist/utils/files/binary.js +65 -0
- package/dist/utils/files/excel.d.ts +24 -0
- package/dist/utils/files/excel.js +416 -0
- package/dist/utils/files/factory.d.ts +40 -0
- package/dist/utils/files/factory.js +101 -0
- package/dist/utils/files/image.d.ts +21 -0
- package/dist/utils/files/image.js +78 -0
- package/dist/utils/files/index.d.ts +10 -0
- package/dist/utils/files/index.js +13 -0
- package/dist/utils/files/pdf.d.ts +32 -0
- package/dist/utils/files/pdf.js +142 -0
- package/dist/utils/files/text.d.ts +63 -0
- package/dist/utils/files/text.js +357 -0
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.js +43 -0
- package/dist/utils/ripgrep-resolver.js +3 -2
- package/dist/utils/system-info.d.ts +5 -0
- package/dist/utils/system-info.js +71 -3
- package/dist/utils/usageTracker.js +6 -0
- package/dist/utils/welcome-onboarding.d.ts +9 -0
- package/dist/utils/welcome-onboarding.js +37 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +14 -3
package/dist/server.js
CHANGED
|
@@ -8,7 +8,7 @@ const OS_GUIDANCE = getOSSpecificGuidance(SYSTEM_INFO);
|
|
|
8
8
|
const DEV_TOOL_GUIDANCE = getDevelopmentToolGuidance(SYSTEM_INFO);
|
|
9
9
|
const PATH_GUIDANCE = `IMPORTANT: ${getPathGuidance(SYSTEM_INFO)} Relative paths may fail as they depend on the current working directory. Tilde paths (~/...) might not work in all contexts. Unless the user explicitly asks for relative paths, use absolute paths.`;
|
|
10
10
|
const CMD_PREFIX_DESCRIPTION = `This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.`;
|
|
11
|
-
import { StartProcessArgsSchema, ReadProcessOutputArgsSchema, InteractWithProcessArgsSchema, ForceTerminateArgsSchema, ListSessionsArgsSchema, KillProcessArgsSchema, ReadFileArgsSchema, ReadMultipleFilesArgsSchema, WriteFileArgsSchema, CreateDirectoryArgsSchema, ListDirectoryArgsSchema, MoveFileArgsSchema, GetFileInfoArgsSchema, GetConfigArgsSchema, SetConfigValueArgsSchema, ListProcessesArgsSchema, EditBlockArgsSchema, GetUsageStatsArgsSchema, GiveFeedbackArgsSchema, StartSearchArgsSchema, GetMoreSearchResultsArgsSchema, StopSearchArgsSchema, ListSearchesArgsSchema, GetPromptsArgsSchema, GetRecentToolCallsArgsSchema, } from './tools/schemas.js';
|
|
11
|
+
import { StartProcessArgsSchema, ReadProcessOutputArgsSchema, InteractWithProcessArgsSchema, ForceTerminateArgsSchema, ListSessionsArgsSchema, KillProcessArgsSchema, ReadFileArgsSchema, ReadMultipleFilesArgsSchema, WriteFileArgsSchema, CreateDirectoryArgsSchema, ListDirectoryArgsSchema, MoveFileArgsSchema, GetFileInfoArgsSchema, GetConfigArgsSchema, SetConfigValueArgsSchema, ListProcessesArgsSchema, EditBlockArgsSchema, GetUsageStatsArgsSchema, GiveFeedbackArgsSchema, StartSearchArgsSchema, GetMoreSearchResultsArgsSchema, StopSearchArgsSchema, ListSearchesArgsSchema, GetPromptsArgsSchema, GetRecentToolCallsArgsSchema, WritePdfArgsSchema, } from './tools/schemas.js';
|
|
12
12
|
import { getConfig, setConfigValue } from './tools/config.js';
|
|
13
13
|
import { getUsageStats } from './tools/usage.js';
|
|
14
14
|
import { giveFeedbackToDesktopCommander } from './tools/feedback.js';
|
|
@@ -17,6 +17,7 @@ import { trackToolCall } from './utils/trackTools.js';
|
|
|
17
17
|
import { usageTracker } from './utils/usageTracker.js';
|
|
18
18
|
import { processDockerPrompt } from './utils/dockerPrompt.js';
|
|
19
19
|
import { toolHistory } from './utils/toolHistory.js';
|
|
20
|
+
import { handleWelcomePageOnboarding } from './utils/welcome-onboarding.js';
|
|
20
21
|
import { VERSION } from './version.js';
|
|
21
22
|
import { capture, capture_call_tool } from "./utils/capture.js";
|
|
22
23
|
import { logToStderr, logger } from './utils/logger.js';
|
|
@@ -77,6 +78,10 @@ server.setRequestHandler(InitializeRequestSchema, async (request) => {
|
|
|
77
78
|
}
|
|
78
79
|
// Defer client connection message until after initialization
|
|
79
80
|
deferLog('info', `Client connected: ${currentClient.name} v${currentClient.version}`);
|
|
81
|
+
// Welcome page for new claude-ai users (A/B test controlled)
|
|
82
|
+
if (currentClient.name === 'claude-ai' && !global.disableOnboarding) {
|
|
83
|
+
await handleWelcomePageOnboarding();
|
|
84
|
+
}
|
|
80
85
|
}
|
|
81
86
|
capture('run_server_mcp_initialized');
|
|
82
87
|
// Return standard initialization response
|
|
@@ -173,7 +178,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
173
178
|
{
|
|
174
179
|
name: "read_file",
|
|
175
180
|
description: `
|
|
176
|
-
Read
|
|
181
|
+
Read contents from files and URLs.
|
|
182
|
+
Read PDF files and extract content as markdown and images.
|
|
177
183
|
|
|
178
184
|
Prefer this over 'execute_command' with cat/type for viewing files.
|
|
179
185
|
|
|
@@ -200,9 +206,17 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
200
206
|
Can fetch content from URLs when isUrl parameter is set to true
|
|
201
207
|
(URLs are always read in full regardless of offset/length).
|
|
202
208
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
209
|
+
FORMAT HANDLING (by extension):
|
|
210
|
+
- Text: Uses offset/length for line-based pagination
|
|
211
|
+
- Excel (.xlsx, .xls, .xlsm): Returns JSON 2D array
|
|
212
|
+
* sheet: "Sheet1" (name) or "0" (index as string, 0-based)
|
|
213
|
+
* range: ALWAYS use FROM:TO format (e.g., "A1:D100", "C1:C1", "B2:B50")
|
|
214
|
+
* offset/length work as row pagination (optional fallback)
|
|
215
|
+
- Images (PNG, JPEG, GIF, WebP): Base64 encoded viewable content
|
|
216
|
+
- PDF: Extracts text content as markdown with page structure
|
|
217
|
+
* offset/length work as page pagination (0-based)
|
|
218
|
+
* Includes embedded images when available
|
|
219
|
+
|
|
206
220
|
${PATH_GUIDANCE}
|
|
207
221
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
208
222
|
inputSchema: zodToJsonSchema(ReadFileArgsSchema),
|
|
@@ -235,7 +249,9 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
235
249
|
{
|
|
236
250
|
name: "write_file",
|
|
237
251
|
description: `
|
|
238
|
-
Write or append to file contents.
|
|
252
|
+
Write or append to file contents.
|
|
253
|
+
|
|
254
|
+
IMPORTANT: DO NOT use this tool to create PDF files. Use 'write_pdf' for all PDF creation tasks.
|
|
239
255
|
|
|
240
256
|
CHUNKING IS STANDARD PRACTICE: Always write files in chunks of 25-30 lines maximum.
|
|
241
257
|
This is the normal, recommended way to write files - not an emergency measure.
|
|
@@ -251,16 +267,21 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
251
267
|
1. Any file expected to be longer than 25-30 lines
|
|
252
268
|
2. When writing multiple files in sequence
|
|
253
269
|
3. When creating documentation, code files, or configuration files
|
|
254
|
-
|
|
270
|
+
|
|
255
271
|
HANDLING CONTINUATION ("Continue" prompts):
|
|
256
272
|
If user asks to "Continue" after an incomplete operation:
|
|
257
273
|
1. Read the file to see what was successfully written
|
|
258
274
|
2. Continue writing ONLY the remaining content using {mode: 'append'}
|
|
259
275
|
3. Keep chunks to 25-30 lines each
|
|
260
|
-
|
|
276
|
+
|
|
277
|
+
FORMAT HANDLING (by extension):
|
|
278
|
+
- Text files: String content
|
|
279
|
+
- Excel (.xlsx, .xls, .xlsm): JSON 2D array or {"SheetName": [[...]]}
|
|
280
|
+
Example: '[["Name","Age"],["Alice",30]]'
|
|
281
|
+
|
|
261
282
|
Files over 50 lines will generate performance notes but are still written successfully.
|
|
262
283
|
Only works within allowed directories.
|
|
263
|
-
|
|
284
|
+
|
|
264
285
|
${PATH_GUIDANCE}
|
|
265
286
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
266
287
|
inputSchema: zodToJsonSchema(WriteFileArgsSchema),
|
|
@@ -271,6 +292,68 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
271
292
|
openWorldHint: false,
|
|
272
293
|
},
|
|
273
294
|
},
|
|
295
|
+
{
|
|
296
|
+
name: "write_pdf",
|
|
297
|
+
description: `
|
|
298
|
+
Create a new PDF file or modify an existing one.
|
|
299
|
+
|
|
300
|
+
THIS IS THE ONLY TOOL FOR CREATING AND MODIFYING PDF FILES.
|
|
301
|
+
|
|
302
|
+
RULES ABOUT FILENAMES:
|
|
303
|
+
- When creating a new PDF, 'outputPath' MUST be provided and MUST use a new unique filename (e.g., "result_01.pdf", "analysis_2025_01.pdf", etc.).
|
|
304
|
+
|
|
305
|
+
MODES:
|
|
306
|
+
1. CREATE NEW PDF:
|
|
307
|
+
- Pass a markdown string as 'content'.
|
|
308
|
+
write_pdf(path="doc.pdf", content="# Title\\n\\nBody text...")
|
|
309
|
+
|
|
310
|
+
2. MODIFY EXISTING PDF:
|
|
311
|
+
- Pass array of operations as 'content'.
|
|
312
|
+
- NEVER overwrite the original file.
|
|
313
|
+
- ALWAYS provide a new filename in 'outputPath'.
|
|
314
|
+
- After modifying, show original file path and new file path to user.
|
|
315
|
+
|
|
316
|
+
write_pdf(path="doc.pdf", content=[
|
|
317
|
+
{ type: "delete", pageIndexes: [0, 2] },
|
|
318
|
+
{ type: "insert", pageIndex: 1, markdown: "# New Page" }
|
|
319
|
+
])
|
|
320
|
+
|
|
321
|
+
OPERATIONS:
|
|
322
|
+
- delete: Remove pages by 0-based index.
|
|
323
|
+
{ type: "delete", pageIndexes: [0, 1, 5] }
|
|
324
|
+
|
|
325
|
+
- insert: Add pages at a specific 0-based index.
|
|
326
|
+
{ type: "insert", pageIndex: 0, markdown: "..." }
|
|
327
|
+
{ type: "insert", pageIndex: 5, sourcePdfPath: "/path/to/source.pdf" }
|
|
328
|
+
|
|
329
|
+
PAGE BREAKS:
|
|
330
|
+
To force a page break, use this HTML element:
|
|
331
|
+
<div style="page-break-before: always;"></div>
|
|
332
|
+
|
|
333
|
+
Example:
|
|
334
|
+
"# Page 1\\n\\n<div style=\\"page-break-before: always;\\"></div>\\n\\n# Page 2"
|
|
335
|
+
|
|
336
|
+
ADVANCED STYLING:
|
|
337
|
+
HTML/CSS and inline SVG are supported for:
|
|
338
|
+
- Text styling: colors, sizes, alignment, highlights
|
|
339
|
+
- Boxes: borders, backgrounds, padding, rounded corners
|
|
340
|
+
- SVG graphics: charts, diagrams, icons, shapes
|
|
341
|
+
- Images: <img src="/absolute/path/image.jpg" width="300" /> or 
|
|
342
|
+
|
|
343
|
+
Supports standard markdown features including headers, lists, code blocks, tables, and basic formatting.
|
|
344
|
+
|
|
345
|
+
Only works within allowed directories.
|
|
346
|
+
|
|
347
|
+
${PATH_GUIDANCE}
|
|
348
|
+
${CMD_PREFIX_DESCRIPTION}`,
|
|
349
|
+
inputSchema: zodToJsonSchema(WritePdfArgsSchema),
|
|
350
|
+
annotations: {
|
|
351
|
+
title: "Write/Modify PDF",
|
|
352
|
+
readOnlyHint: false,
|
|
353
|
+
destructiveHint: true,
|
|
354
|
+
openWorldHint: false,
|
|
355
|
+
},
|
|
356
|
+
},
|
|
274
357
|
{
|
|
275
358
|
name: "create_directory",
|
|
276
359
|
description: `
|
|
@@ -282,6 +365,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
282
365
|
${PATH_GUIDANCE}
|
|
283
366
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
284
367
|
inputSchema: zodToJsonSchema(CreateDirectoryArgsSchema),
|
|
368
|
+
annotations: {
|
|
369
|
+
title: "Create Directory",
|
|
370
|
+
readOnlyHint: false,
|
|
371
|
+
destructiveHint: false,
|
|
372
|
+
},
|
|
285
373
|
},
|
|
286
374
|
{
|
|
287
375
|
name: "list_directory",
|
|
@@ -421,6 +509,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
421
509
|
${PATH_GUIDANCE}
|
|
422
510
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
423
511
|
inputSchema: zodToJsonSchema(StartSearchArgsSchema),
|
|
512
|
+
annotations: {
|
|
513
|
+
title: "Start Search",
|
|
514
|
+
readOnlyHint: true,
|
|
515
|
+
},
|
|
424
516
|
},
|
|
425
517
|
{
|
|
426
518
|
name: "get_more_search_results",
|
|
@@ -466,6 +558,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
466
558
|
|
|
467
559
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
468
560
|
inputSchema: zodToJsonSchema(StopSearchArgsSchema),
|
|
561
|
+
annotations: {
|
|
562
|
+
title: "Stop Search",
|
|
563
|
+
readOnlyHint: false,
|
|
564
|
+
destructiveHint: false,
|
|
565
|
+
},
|
|
469
566
|
},
|
|
470
567
|
{
|
|
471
568
|
name: "list_searches",
|
|
@@ -489,13 +586,14 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
489
586
|
Retrieve detailed metadata about a file or directory including:
|
|
490
587
|
- size
|
|
491
588
|
- creation time
|
|
492
|
-
- last modified time
|
|
589
|
+
- last modified time
|
|
493
590
|
- permissions
|
|
494
591
|
- type
|
|
495
592
|
- lineCount (for text files)
|
|
496
593
|
- lastLine (zero-indexed number of last line, for text files)
|
|
497
594
|
- appendPosition (line number for appending, for text files)
|
|
498
|
-
|
|
595
|
+
- sheets (for Excel files - array of {name, rowCount, colCount})
|
|
596
|
+
|
|
499
597
|
Only works within allowed directories.
|
|
500
598
|
|
|
501
599
|
${PATH_GUIDANCE}
|
|
@@ -507,45 +605,54 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
507
605
|
},
|
|
508
606
|
},
|
|
509
607
|
// Note: list_allowed_directories removed - use get_config to check allowedDirectories
|
|
510
|
-
//
|
|
608
|
+
// Editing tools
|
|
511
609
|
{
|
|
512
610
|
name: "edit_block",
|
|
513
611
|
description: `
|
|
514
|
-
Apply surgical
|
|
515
|
-
|
|
612
|
+
Apply surgical edits to files.
|
|
613
|
+
|
|
516
614
|
BEST PRACTICE: Make multiple small, focused edits rather than one large edit.
|
|
517
|
-
Each edit_block call should change only what needs to be changed - include just enough
|
|
615
|
+
Each edit_block call should change only what needs to be changed - include just enough
|
|
518
616
|
context to uniquely identify the text being modified.
|
|
519
|
-
|
|
617
|
+
|
|
618
|
+
FORMAT HANDLING (by extension):
|
|
619
|
+
|
|
620
|
+
EXCEL FILES (.xlsx, .xls, .xlsm) - Range Update mode:
|
|
621
|
+
Takes:
|
|
622
|
+
- file_path: Path to the Excel file
|
|
623
|
+
- range: ALWAYS use FROM:TO format - "SheetName!A1:C10" or "SheetName!C1:C1"
|
|
624
|
+
- content: 2D array, e.g., [["H1","H2"],["R1","R2"]]
|
|
625
|
+
|
|
626
|
+
TEXT FILES - Find/Replace mode:
|
|
520
627
|
Takes:
|
|
521
628
|
- file_path: Path to the file to edit
|
|
522
629
|
- old_string: Text to replace
|
|
523
630
|
- new_string: Replacement text
|
|
524
|
-
- expected_replacements: Optional
|
|
525
|
-
|
|
631
|
+
- expected_replacements: Optional number of replacements (default: 1)
|
|
632
|
+
|
|
526
633
|
By default, replaces only ONE occurrence of the search text.
|
|
527
|
-
To replace multiple occurrences, provide
|
|
634
|
+
To replace multiple occurrences, provide expected_replacements with
|
|
528
635
|
the exact number of matches expected.
|
|
529
|
-
|
|
636
|
+
|
|
530
637
|
UNIQUENESS REQUIREMENT: When expected_replacements=1 (default), include the minimal
|
|
531
638
|
amount of context necessary (typically 1-3 lines) before and after the change point,
|
|
532
639
|
with exact whitespace and indentation.
|
|
533
|
-
|
|
640
|
+
|
|
534
641
|
When editing multiple sections, make separate edit_block calls for each distinct change
|
|
535
642
|
rather than one large replacement.
|
|
536
|
-
|
|
643
|
+
|
|
537
644
|
When a close but non-exact match is found, a character-level diff is shown in the format:
|
|
538
645
|
common_prefix{-removed-}{+added+}common_suffix to help you identify what's different.
|
|
539
|
-
|
|
646
|
+
|
|
540
647
|
Similar to write_file, there is a configurable line limit (fileWriteLineLimit) that warns
|
|
541
648
|
if the edited file exceeds this limit. If this happens, consider breaking your edits into
|
|
542
649
|
smaller, more focused changes.
|
|
543
|
-
|
|
650
|
+
|
|
544
651
|
${PATH_GUIDANCE}
|
|
545
652
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
546
653
|
inputSchema: zodToJsonSchema(EditBlockArgsSchema),
|
|
547
654
|
annotations: {
|
|
548
|
-
title: "Edit
|
|
655
|
+
title: "Edit Block",
|
|
549
656
|
readOnlyHint: false,
|
|
550
657
|
destructiveHint: true,
|
|
551
658
|
openWorldHint: false,
|
|
@@ -574,7 +681,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
574
681
|
|
|
575
682
|
COMMON FILE ANALYSIS PATTERNS:
|
|
576
683
|
• start_process("python3 -i") → Python REPL for data analysis (RECOMMENDED)
|
|
577
|
-
• start_process("node -i") → Node.js for JSON processing
|
|
684
|
+
• start_process("node -i") → Node.js REPL for JSON processing
|
|
685
|
+
• start_process("node:local") → Node.js on MCP server (stateless, ES imports, all code in one call)
|
|
578
686
|
• start_process("cut -d',' -f1 file.csv | sort | uniq -c") → Quick CSV analysis
|
|
579
687
|
• start_process("wc -l /path/file.csv") → Line counting
|
|
580
688
|
• start_process("head -10 /path/file.csv") → File preview
|
|
@@ -583,12 +691,15 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
583
691
|
For PDF, Excel, Word, archives, databases, and other binary formats, use process tools with appropriate libraries or command-line utilities.
|
|
584
692
|
|
|
585
693
|
INTERACTIVE PROCESSES FOR DATA ANALYSIS:
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
694
|
+
For code/calculations, use in this priority order:
|
|
695
|
+
1. start_process("python3 -i") - Python REPL (preferred)
|
|
696
|
+
2. start_process("node -i") - Node.js REPL (when Python unavailable)
|
|
697
|
+
3. start_process("node:local") - Node.js fallback (when node -i fails)
|
|
589
698
|
4. Use interact_with_process() to send commands
|
|
590
699
|
5. Use read_process_output() to get responses
|
|
591
|
-
|
|
700
|
+
When Python is unavailable, prefer Node.js over shell for calculations.
|
|
701
|
+
Node.js: Always use ES import syntax (import x from 'y'), not require().
|
|
702
|
+
|
|
592
703
|
SMART DETECTION:
|
|
593
704
|
- Detects REPL prompts (>>>, >, $, etc.)
|
|
594
705
|
- Identifies when process is waiting for input
|
|
@@ -624,35 +735,37 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
624
735
|
{
|
|
625
736
|
name: "read_process_output",
|
|
626
737
|
description: `
|
|
627
|
-
Read output from a running process with
|
|
738
|
+
Read output from a running process with file-like pagination support.
|
|
628
739
|
|
|
629
|
-
|
|
740
|
+
Supports partial output reading with offset and length parameters (like read_file):
|
|
741
|
+
- 'offset' (start line, default: 0)
|
|
742
|
+
* offset=0: Read NEW output since last read (default, like old behavior)
|
|
743
|
+
* Positive: Read from absolute line position
|
|
744
|
+
* Negative: Read last N lines from end (tail behavior)
|
|
745
|
+
- 'length' (max lines to read, default: configurable via 'fileReadLineLimit' setting)
|
|
630
746
|
|
|
631
|
-
|
|
632
|
-
-
|
|
633
|
-
-
|
|
634
|
-
-
|
|
635
|
-
-
|
|
747
|
+
Examples:
|
|
748
|
+
- offset: 0, length: 100 → First 100 NEW lines since last read
|
|
749
|
+
- offset: 0 → All new lines (respects config limit)
|
|
750
|
+
- offset: 500, length: 50 → Lines 500-549 (absolute position)
|
|
751
|
+
- offset: -20 → Last 20 lines (tail)
|
|
752
|
+
- offset: -50, length: 10 → Start 50 from end, read 10 lines
|
|
753
|
+
|
|
754
|
+
OUTPUT PROTECTION:
|
|
755
|
+
- Uses same fileReadLineLimit as read_file (default: 1000 lines)
|
|
756
|
+
- Returns status like: [Reading 100 lines from line 0 (total: 5000 lines, 4900 remaining)]
|
|
757
|
+
- Prevents context overflow from verbose processes
|
|
636
758
|
|
|
637
|
-
|
|
638
|
-
-
|
|
639
|
-
-
|
|
640
|
-
-
|
|
641
|
-
- Works with Python, Node.js, R, Julia, etc.
|
|
759
|
+
SMART FEATURES:
|
|
760
|
+
- For offset=0, waits up to timeout_ms for new output to arrive
|
|
761
|
+
- Detects REPL prompts and process completion
|
|
762
|
+
- Shows process state (waiting for input, finished, etc.)
|
|
642
763
|
|
|
643
764
|
DETECTION STATES:
|
|
644
765
|
Process waiting for input (ready for interact_with_process)
|
|
645
766
|
Process finished execution
|
|
646
767
|
Timeout reached (may still be running)
|
|
647
768
|
|
|
648
|
-
PERFORMANCE DEBUGGING (verbose_timing parameter):
|
|
649
|
-
Set verbose_timing: true to get detailed timing information including:
|
|
650
|
-
- Exit reason (early_exit_quick_pattern, early_exit_periodic_check, process_finished, timeout)
|
|
651
|
-
- Total duration and time to first output
|
|
652
|
-
- Complete timeline of all output events with timestamps
|
|
653
|
-
- Which detection mechanism triggered early exit
|
|
654
|
-
Use this to identify when timeouts could be reduced or detection patterns improved.
|
|
655
|
-
|
|
656
769
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
657
770
|
inputSchema: zodToJsonSchema(ReadProcessOutputArgsSchema),
|
|
658
771
|
annotations: {
|
|
@@ -692,7 +805,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
692
805
|
|
|
693
806
|
SUPPORTED REPLs:
|
|
694
807
|
- Python: python3 -i (RECOMMENDED for data analysis)
|
|
695
|
-
- Node.js: node -i
|
|
808
|
+
- Node.js: node -i
|
|
696
809
|
- R: R
|
|
697
810
|
- Julia: julia
|
|
698
811
|
- Shell: bash, zsh
|
|
@@ -781,9 +894,9 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
781
894
|
name: "kill_process",
|
|
782
895
|
description: `
|
|
783
896
|
Terminate a running process by PID.
|
|
784
|
-
|
|
897
|
+
|
|
785
898
|
Use with caution as this will forcefully terminate the specified process.
|
|
786
|
-
|
|
899
|
+
|
|
787
900
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
788
901
|
inputSchema: zodToJsonSchema(KillProcessArgsSchema),
|
|
789
902
|
annotations: {
|
|
@@ -864,6 +977,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
864
977
|
|
|
865
978
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
866
979
|
inputSchema: zodToJsonSchema(GiveFeedbackArgsSchema),
|
|
980
|
+
annotations: {
|
|
981
|
+
title: "Give Feedback",
|
|
982
|
+
readOnlyHint: false,
|
|
983
|
+
openWorldHint: true,
|
|
984
|
+
},
|
|
867
985
|
},
|
|
868
986
|
{
|
|
869
987
|
name: "get_prompts",
|
|
@@ -881,29 +999,20 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
881
999
|
|
|
882
1000
|
USAGE:
|
|
883
1001
|
When user says "1", "2", "3", "4", or "5" from onboarding:
|
|
884
|
-
- "1" → get_prompts(action='get_prompt', promptId='onb2_01'
|
|
885
|
-
- "2" → get_prompts(action='get_prompt', promptId='onb2_02'
|
|
886
|
-
- "3" → get_prompts(action='get_prompt', promptId='onb2_03'
|
|
887
|
-
- "4" → get_prompts(action='get_prompt', promptId='onb2_04'
|
|
888
|
-
- "5" → get_prompts(action='get_prompt', promptId='onb2_05'
|
|
889
|
-
|
|
890
|
-
ANONYMOUS USE CASE (REQUIRED):
|
|
891
|
-
Infer what GOAL or PROBLEM the user is trying to solve from conversation history.
|
|
892
|
-
Focus on the job-to-be-done, not just what they were doing.
|
|
893
|
-
|
|
894
|
-
GOOD (problem/goal focused):
|
|
895
|
-
"automating backup workflow", "converting PDFs to CSV", "debugging test failures",
|
|
896
|
-
"organizing project files", "monitoring server logs", "extracting data from documents"
|
|
897
|
-
|
|
898
|
-
BAD (too vague or contains PII):
|
|
899
|
-
"using Desktop Commander", "working on John's project", "fixing acme-corp bug"
|
|
900
|
-
|
|
901
|
-
If unclear from context, use: "exploring tool capabilities"
|
|
1002
|
+
- "1" → get_prompts(action='get_prompt', promptId='onb2_01')
|
|
1003
|
+
- "2" → get_prompts(action='get_prompt', promptId='onb2_02')
|
|
1004
|
+
- "3" → get_prompts(action='get_prompt', promptId='onb2_03')
|
|
1005
|
+
- "4" → get_prompts(action='get_prompt', promptId='onb2_04')
|
|
1006
|
+
- "5" → get_prompts(action='get_prompt', promptId='onb2_05')
|
|
902
1007
|
|
|
903
1008
|
The prompt content will be injected and execution begins immediately.
|
|
904
|
-
|
|
1009
|
+
|
|
905
1010
|
${CMD_PREFIX_DESCRIPTION}`,
|
|
906
1011
|
inputSchema: zodToJsonSchema(GetPromptsArgsSchema),
|
|
1012
|
+
annotations: {
|
|
1013
|
+
title: "Get Prompts",
|
|
1014
|
+
readOnlyHint: true,
|
|
1015
|
+
},
|
|
907
1016
|
}
|
|
908
1017
|
];
|
|
909
1018
|
// Filter tools based on current client
|
|
@@ -940,6 +1049,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
940
1049
|
}
|
|
941
1050
|
}
|
|
942
1051
|
capture_call_tool('server_call_tool', telemetryData);
|
|
1052
|
+
// Log every tool request name
|
|
1053
|
+
// logger.info(`Tool request: ${name}`, { toolName: name, timestamp: new Date().toISOString() });
|
|
943
1054
|
// Track tool call
|
|
944
1055
|
trackToolCall(name, args);
|
|
945
1056
|
// Using a more structured approach with dedicated handlers
|
|
@@ -1001,7 +1112,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1001
1112
|
category: prompt.categories[0] || 'uncategorized',
|
|
1002
1113
|
author: prompt.author,
|
|
1003
1114
|
verified: prompt.verified,
|
|
1004
|
-
|
|
1115
|
+
// Temporarily disabled for privacy review - Dec 2025
|
|
1116
|
+
// anonymous_use_case: (args as any).anonymous_user_use_case || null
|
|
1005
1117
|
});
|
|
1006
1118
|
}
|
|
1007
1119
|
}
|
|
@@ -1083,6 +1195,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1083
1195
|
case "write_file":
|
|
1084
1196
|
result = await handlers.handleWriteFile(args);
|
|
1085
1197
|
break;
|
|
1198
|
+
case "write_pdf":
|
|
1199
|
+
result = await handlers.handleWritePdf(args);
|
|
1200
|
+
break;
|
|
1086
1201
|
case "create_directory":
|
|
1087
1202
|
result = await handlers.handleCreateDirectory(args);
|
|
1088
1203
|
break;
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { TerminalSession, CommandExecutionResult, ActiveSession } from './types.js';
|
|
2
2
|
interface CompletedSession {
|
|
3
3
|
pid: number;
|
|
4
|
-
|
|
4
|
+
outputLines: string[];
|
|
5
5
|
exitCode: number | null;
|
|
6
6
|
startTime: Date;
|
|
7
7
|
endTime: Date;
|
|
8
8
|
}
|
|
9
|
+
export interface PaginatedOutputResult {
|
|
10
|
+
lines: string[];
|
|
11
|
+
totalLines: number;
|
|
12
|
+
readFrom: number;
|
|
13
|
+
readCount: number;
|
|
14
|
+
remaining: number;
|
|
15
|
+
isComplete: boolean;
|
|
16
|
+
exitCode?: number | null;
|
|
17
|
+
runtimeMs?: number;
|
|
18
|
+
}
|
|
9
19
|
export declare class TerminalManager {
|
|
10
20
|
private sessions;
|
|
11
21
|
private completedSessions;
|
|
@@ -17,7 +27,51 @@ export declare class TerminalManager {
|
|
|
17
27
|
*/
|
|
18
28
|
sendInputToProcess(pid: number, input: string): boolean;
|
|
19
29
|
executeCommand(command: string, timeoutMs?: number, shell?: string, collectTiming?: boolean): Promise<CommandExecutionResult>;
|
|
20
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Append text to a session's line buffer
|
|
32
|
+
* Handles partial lines and newline splitting
|
|
33
|
+
*/
|
|
34
|
+
private appendToLineBuffer;
|
|
35
|
+
/**
|
|
36
|
+
* Read process output with pagination (like file reading)
|
|
37
|
+
* @param pid Process ID
|
|
38
|
+
* @param offset Line offset: 0=from lastReadIndex, positive=absolute, negative=tail
|
|
39
|
+
* @param length Max lines to return
|
|
40
|
+
* @param updateReadIndex Whether to update lastReadIndex (default: true for offset=0)
|
|
41
|
+
*/
|
|
42
|
+
readOutputPaginated(pid: number, offset?: number, length?: number): PaginatedOutputResult | null;
|
|
43
|
+
/**
|
|
44
|
+
* Internal helper to read from a line buffer with offset/length
|
|
45
|
+
*/
|
|
46
|
+
private readFromLineBuffer;
|
|
47
|
+
/**
|
|
48
|
+
* Get total line count for a process
|
|
49
|
+
*/
|
|
50
|
+
getOutputLineCount(pid: number): number | null;
|
|
51
|
+
/**
|
|
52
|
+
* Legacy method for backward compatibility
|
|
53
|
+
* Returns all new output since last read
|
|
54
|
+
* @param maxLines Maximum lines to return (default: 1000 for context protection)
|
|
55
|
+
* @deprecated Use readOutputPaginated instead
|
|
56
|
+
*/
|
|
57
|
+
getNewOutput(pid: number, maxLines?: number): string | null;
|
|
58
|
+
/**
|
|
59
|
+
* Capture a snapshot of current output state for interaction tracking.
|
|
60
|
+
* Used by interactWithProcess to know what output existed before sending input.
|
|
61
|
+
*/
|
|
62
|
+
captureOutputSnapshot(pid: number): {
|
|
63
|
+
totalChars: number;
|
|
64
|
+
lineCount: number;
|
|
65
|
+
} | null;
|
|
66
|
+
/**
|
|
67
|
+
* Get output that appeared since a snapshot was taken.
|
|
68
|
+
* This handles the case where output is appended to the last line (REPL prompts).
|
|
69
|
+
* Also checks completed sessions in case process finished between snapshot and poll.
|
|
70
|
+
*/
|
|
71
|
+
getOutputSinceSnapshot(pid: number, snapshot: {
|
|
72
|
+
totalChars: number;
|
|
73
|
+
lineCount: number;
|
|
74
|
+
}): string | null;
|
|
21
75
|
/**
|
|
22
76
|
* Get a session by PID
|
|
23
77
|
* @param pid Process ID
|