UNPKG

ai-dev-diary

Version:

Intelligent development diary system for AI-assisted projects

78 lines (75 loc) 3.17 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.installHooks = installHooks; const fs = __importStar(require("fs-extra")); const path = __importStar(require("path")); const chalk_1 = __importDefault(require("chalk")); const POST_COMMIT_HOOK = `#!/bin/bash # AI Dev Diary - Auto-generate entry from commit # Check if ai-diary is available if ! command -v ai-diary &> /dev/null; then exit 0 fi # Get commit info COMMIT_MSG=$(git log -1 --pretty=format:"%s") COMMIT_HASH=$(git rev-parse --short HEAD) FILES_CHANGED=$(git diff --name-only HEAD^ HEAD | wc -l) # Create a quick journey entry ai-diary journey "Commit: $COMMIT_MSG" -d "Commit $COMMIT_HASH changed $FILES_CHANGED files" `; async function installHooks() { const gitDir = path.join(process.cwd(), '.git'); if (!await fs.pathExists(gitDir)) { console.log(chalk_1.default.red('❌ Not a git repository')); return; } const hooksDir = path.join(gitDir, 'hooks'); await fs.ensureDir(hooksDir); const postCommitPath = path.join(hooksDir, 'post-commit'); if (await fs.pathExists(postCommitPath)) { console.log(chalk_1.default.yellow('⚠️ Post-commit hook already exists')); console.log(chalk_1.default.gray('Please manually add ai-diary integration to your existing hook')); return; } await fs.writeFile(postCommitPath, POST_COMMIT_HOOK); await fs.chmod(postCommitPath, 0o755); console.log(chalk_1.default.green('✅ Git hooks installed successfully!')); console.log(chalk_1.default.gray('Commits will now automatically create diary entries')); } //# sourceMappingURL=git-hooks.js.map