mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
feat(mcp): add read_file tool and simplify edit/write returns
- edit_file: truncate diff to 15 lines, compact result format - write_file: return only path/bytes/message - read_file: new tool with multi-file, directory, regex support - paths: single file, array, or directory - pattern: glob filter (*.ts) - contentPattern: regex content search - maxDepth, maxFiles, includeContent options - Update tool-strategy.md documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,12 +24,9 @@ const ParamsSchema = z.object({
|
||||
|
||||
type Params = z.infer<typeof ParamsSchema>;
|
||||
|
||||
// Compact result for output
|
||||
interface WriteResult {
|
||||
success: boolean;
|
||||
path: string;
|
||||
created: boolean;
|
||||
overwritten: boolean;
|
||||
backupPath: string | null;
|
||||
bytes: number;
|
||||
message: string;
|
||||
}
|
||||
@@ -153,19 +150,24 @@ export async function handler(params: Record<string, unknown>): Promise<ToolResu
|
||||
// Write file
|
||||
try {
|
||||
writeFileSync(resolvedPath, content, { encoding });
|
||||
const bytes = Buffer.byteLength(content, encoding);
|
||||
|
||||
// Build compact message
|
||||
let message: string;
|
||||
if (fileExists) {
|
||||
message = backupPath
|
||||
? `Overwrote (${bytes}B, backup: ${basename(backupPath)})`
|
||||
: `Overwrote (${bytes}B)`;
|
||||
} else {
|
||||
message = `Created (${bytes}B)`;
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
result: {
|
||||
success: true,
|
||||
path: resolvedPath,
|
||||
created: !fileExists,
|
||||
overwritten: fileExists,
|
||||
backupPath,
|
||||
bytes: Buffer.byteLength(content, encoding),
|
||||
message: fileExists
|
||||
? `Successfully overwrote ${filePath}${backupPath ? ` (backup: ${backupPath})` : ''}`
|
||||
: `Successfully created ${filePath}`,
|
||||
bytes,
|
||||
message,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user