diff --git a/packages/ai-repomap/CHANGELOG.md b/packages/ai-repomap/CHANGELOG.md index e322ca2..d3749ea 100644 --- a/packages/ai-repomap/CHANGELOG.md +++ b/packages/ai-repomap/CHANGELOG.md @@ -1,5 +1,11 @@ # @tokenizin/ai-repomap +## 2.0.0 + +### Major Changes + +- up + ## 1.0.0 ### Major Changes diff --git a/packages/ai-repomap/bin/mapper.ts b/packages/ai-repomap/bin/mapper.ts index 911791d..4d9bb60 100755 --- a/packages/ai-repomap/bin/mapper.ts +++ b/packages/ai-repomap/bin/mapper.ts @@ -1,12 +1,19 @@ #!/usr/bin/env node import { readdirSync, readFileSync, existsSync } from 'fs'; -import { join, extname } from 'path'; +import { join, extname, resolve } from 'path'; import Parser from 'tree-sitter'; import JavaScript from 'tree-sitter-javascript'; import TypeScript from 'tree-sitter-typescript'; import { execSync } from 'child_process'; +// Get target directory from command line args or use current directory +const targetDir = process.argv[2] ? resolve(process.argv[2]) : '.'; +if (!existsSync(targetDir)) { + console.error(`Error: Directory "${targetDir}" does not exist`); + process.exit(1); +} + /** * Represents information about a symbol (function or class) found in the code * @interface SymbolInfo @@ -86,7 +93,7 @@ interface FileInfo { } const IGNORE_DIRS = new Set(['node_modules', '.git', 'build', '.dart_tool', '.pub-cache']); -const ROOT_DIR = '.'; +const ROOT_DIR = targetDir; // Add Flutter/Dart specific elements const FLUTTER_WIDGETS = new Set([ @@ -623,36 +630,44 @@ function parseAndroidManifest(content: string): { package?: string; components?: */ function getGitInfo() { try { - // Check if git repo exists first - execSync('git rev-parse --git-dir', { stdio: 'ignore' }); - - const branch = execSync('git rev-parse --abbrev-ref HEAD', { - encoding: 'utf8', - stdio: ['pipe', 'pipe', 'ignore'], - }).trim(); - const remoteUrl = execSync('git config --get remote.origin.url', { - encoding: 'utf8', - stdio: ['pipe', 'pipe', 'ignore'], - }).trim(); - const lastCommit = execSync('git log -1 --format=%H', { - encoding: 'utf8', - stdio: ['pipe', 'pipe', 'ignore'], - }).trim(); - const authorName = execSync('git config user.name', { - encoding: 'utf8', - stdio: ['pipe', 'pipe', 'ignore'], - }).trim(); - const authorEmail = execSync('git config user.email', { - encoding: 'utf8', - stdio: ['pipe', 'pipe', 'ignore'], - }).trim(); - - return { - branch, - remoteUrl, - lastCommit, - author: { name: authorName, email: authorEmail }, - }; + // Check if git repo exists first and change to ROOT_DIR + const originalDir = process.cwd(); + process.chdir(ROOT_DIR); + + try { + execSync('git rev-parse --git-dir', { stdio: 'ignore' }); + + const branch = execSync('git rev-parse --abbrev-ref HEAD', { + encoding: 'utf8', + stdio: ['pipe', 'pipe', 'ignore'], + }).trim(); + const remoteUrl = execSync('git config --get remote.origin.url', { + encoding: 'utf8', + stdio: ['pipe', 'pipe', 'ignore'], + }).trim(); + const lastCommit = execSync('git log -1 --format=%H', { + encoding: 'utf8', + stdio: ['pipe', 'pipe', 'ignore'], + }).trim(); + const authorName = execSync('git config user.name', { + encoding: 'utf8', + stdio: ['pipe', 'pipe', 'ignore'], + }).trim(); + const authorEmail = execSync('git config user.email', { + encoding: 'utf8', + stdio: ['pipe', 'pipe', 'ignore'], + }).trim(); + + return { + branch, + remoteUrl, + lastCommit, + author: { name: authorName, email: authorEmail }, + }; + } finally { + // Always restore original directory + process.chdir(originalDir); + } } catch { return null; } @@ -702,6 +717,7 @@ for (const file of getJSFiles(ROOT_DIR)) { // Create final output with project metadata const output = { timestamp: new Date().toISOString(), + targetDirectory: ROOT_DIR, project: { git: getGitInfo(), package: getPackageJson(), diff --git a/packages/ai-repomap/package.json b/packages/ai-repomap/package.json index 574a72e..35646bc 100644 --- a/packages/ai-repomap/package.json +++ b/packages/ai-repomap/package.json @@ -1,6 +1,7 @@ { "name": "@tokenizin/ai-repomap", - "version": "1.0.0", + "version": "2.1.0", + "description": "AI-powered codebase mapping tool that analyzes and generates a detailed map of your project structure, with support for JavaScript, TypeScript, Flutter, Dart, and Android.", "type": "module", "bin": { "tokenizin-repomap": "./dist/mapper.js" @@ -11,13 +12,14 @@ "clean": "rm -rf dist", "prepublishOnly": "pnpm run build", "dev": "tsx watch bin/mapper.ts", - "release": "pnpm run build && changeset publish" + "release": "pnpm run build && changeset publish", + "full-release": "pnpm run build && pnpm changeset && git add . && git commit -m \"chore: add changeset\" && pnpm changeset version && git add . && git commit -m \"chore: update versions\" && pnpm changeset publish && git push --follow-tags" }, "dependencies": { "tree-sitter": "^0.20.6", "tree-sitter-javascript": "^0.20.1", "tree-sitter-typescript": "^0.20.3", - "tree-sitter-dart": "^0.1.1", + "tree-sitter-dart": "^1.0.0", "ignore": "^5.3.0" }, "devDependencies": { @@ -32,5 +34,24 @@ }, "engines": { "node": ">=18" - } + }, + "keywords": [ + "codebase-analysis", + "code-mapping", + "static-analysis", + "javascript", + "typescript", + "flutter", + "dart", + "android" + ], + "repository": { + "type": "git", + "url": "https://github.com/tokenizin/tokigen.git" + }, + "bugs": { + "url": "https://github.com/tokenizin/tokigen/issues" + }, + "homepage": "https://github.com/tokenizin/tokigen#readme", + "usage": "tokenizin-repomap [directory-path]" }