mirror of
https://github.com/aljazceru/mcp-code.git
synced 2025-12-17 04:35:19 +01:00
feat: Add zap command for sending Bitcoin Lightning tips
- Implemented the `zap` command in the CLI to allow users to send sats to a user, event, or snippet using a NIP-60 wallet. - Created a new `zap.ts` file to handle the command logic and integrated it into the MCP server. - Added wallet balance command to check the balance of a user's wallet. - Enhanced the MCP server to register the new zap command and wallet balance command. - Introduced caching for wallets to optimize performance and reduce redundant network requests. - Updated database schema to include snippets table for storing code snippets. - Improved logging functionality for better debugging and tracking of operations. - Added functionality to save snippets to the database upon retrieval. - Updated project overview documentation to reflect new features and structure. - Refactored existing commands and logic for better modularity and maintainability.
This commit is contained in:
@@ -1,5 +1,30 @@
|
||||
import * as fs from "node:fs";
|
||||
import { promises as fsPromises } from "node:fs";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
|
||||
const timeZero = Date.now();
|
||||
|
||||
/**
|
||||
* Simple logging utility
|
||||
* @param message Message to log
|
||||
* @param logFilePath Optional custom log file path
|
||||
*/
|
||||
export function log(_message: string): void {}
|
||||
export function log(
|
||||
message: string,
|
||||
logFilePath: string = path.join(os.homedir(), ".mcp-code23.log")
|
||||
): void {
|
||||
// Ensure the directory exists
|
||||
const logDir = path.dirname(logFilePath);
|
||||
fs.mkdirSync(logDir, { recursive: true });
|
||||
|
||||
const now = new Date();
|
||||
const timestamp = new Date().toISOString();
|
||||
const relativeTime = now.getTime() - timeZero;
|
||||
const logMessage = `[${relativeTime}ms] ${timestamp} - ${message}\n`;
|
||||
fs.appendFile(logFilePath, logMessage, (err) => {
|
||||
if (err) {
|
||||
console.error("Error writing to log file:", err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user