snow-ai 0.2.13 → 0.2.14
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/dist/mcp/filesystem.js +33 -25
- package/package.json +1 -1
package/dist/mcp/filesystem.js
CHANGED
|
@@ -471,31 +471,39 @@ export class FilesystemMCPService {
|
|
|
471
471
|
let finalTotalLines = newTotalLines;
|
|
472
472
|
let finalContextEnd = newContextEnd;
|
|
473
473
|
let finalContextContent = newContextContent;
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
.
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
474
|
+
// Check if Prettier supports this file type
|
|
475
|
+
const prettierSupportedExtensions = [
|
|
476
|
+
'.js', '.jsx', '.ts', '.tsx', '.json', '.css', '.scss', '.less',
|
|
477
|
+
'.html', '.vue', '.yaml', '.yml', '.md', '.graphql', '.gql'
|
|
478
|
+
];
|
|
479
|
+
const fileExtension = path.extname(fullPath).toLowerCase();
|
|
480
|
+
const shouldFormat = prettierSupportedExtensions.includes(fileExtension);
|
|
481
|
+
if (shouldFormat) {
|
|
482
|
+
try {
|
|
483
|
+
execSync(`npx prettier --write "${fullPath}"`, {
|
|
484
|
+
stdio: 'pipe',
|
|
485
|
+
encoding: 'utf-8',
|
|
486
|
+
});
|
|
487
|
+
// Re-read the file after formatting to get the formatted content
|
|
488
|
+
const formattedContent = await fs.readFile(fullPath, 'utf-8');
|
|
489
|
+
finalLines = formattedContent.split('\n');
|
|
490
|
+
finalTotalLines = finalLines.length;
|
|
491
|
+
// Recalculate the context end line based on formatted content
|
|
492
|
+
finalContextEnd = Math.min(finalTotalLines, contextStart + (newContextEnd - contextStart));
|
|
493
|
+
// Extract formatted content for context with line numbers
|
|
494
|
+
const formattedContextLines = finalLines.slice(contextStart - 1, finalContextEnd);
|
|
495
|
+
finalContextContent = formattedContextLines
|
|
496
|
+
.map((line, idx) => {
|
|
497
|
+
const lineNum = contextStart + idx;
|
|
498
|
+
const paddedNum = String(lineNum).padStart(String(finalContextEnd).length, ' ');
|
|
499
|
+
return `${paddedNum}→${line}`;
|
|
500
|
+
})
|
|
501
|
+
.join('\n');
|
|
502
|
+
}
|
|
503
|
+
catch (formatError) {
|
|
504
|
+
// If formatting fails, continue with the original content
|
|
505
|
+
// This ensures editing is not blocked by formatting issues
|
|
506
|
+
}
|
|
499
507
|
}
|
|
500
508
|
// Analyze code structure of the edited content (using formatted content if available)
|
|
501
509
|
const editedContentLines = finalLines.slice(startLine - 1, startLine - 1 + newContentLines.length);
|