UNPKG

nohandcoder

Version:

An AI agent for code editing, searching, and project analysis

70 lines (69 loc) 2.29 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AnalyzeProjectTool = void 0; const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); const glob_1 = require("glob"); const chalk_1 = __importDefault(require("chalk")); class AnalyzeProjectTool { constructor(workspaceRoot) { this.workspaceRoot = workspaceRoot; } getDefinition() { return { type: "function", function: { name: "analyzeProject", description: "Analyze the project structure", parameters: { type: "object", properties: {}, additionalProperties: false, }, strict: true, }, }; } async execute() { console.log(chalk_1.default.blue("Analyzing project structure...")); const files = await (0, glob_1.glob)("**/*", { cwd: this.workspaceRoot, ignore: [ "**/node_modules/**", "**/.git/**", "**/dist/**", "**/.env*", "**/package-lock.json", ], dot: false, }); const structure = { files: [], directories: [], totalFiles: 0, totalSize: 0, }; for (const file of files) { console.log(chalk_1.default.green("\nAnalyzing file:", file)); const fullPath = path_1.default.join(this.workspaceRoot, file); const stats = await fs_1.default.promises.stat(fullPath); if (stats.isDirectory()) { structure.directories.push(file); } else { structure.files.push({ path: file, size: stats.size, modified: stats.mtime, }); structure.totalFiles++; structure.totalSize += stats.size; } } return structure; } } exports.AnalyzeProjectTool = AnalyzeProjectTool;