UNPKG

@graphikartistry/cursor-doc-automation

Version:

Cursor IDE extension for autonomous documentation and ticket management

105 lines 4.92 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.DocumentationService = void 0; const child_process_1 = require("child_process"); const fs = __importStar(require("fs")); const path = __importStar(require("path")); const dotenv_1 = __importDefault(require("dotenv")); dotenv_1.default.config(); class DocumentationService { constructor(githubClient, jiraClient, fuelixClient) { this.githubClient = githubClient; this.jiraClient = jiraClient; this.fuelixClient = fuelixClient; } async analyzeChanges(content) { return await this.fuelixClient.analyzeChanges(content); } async createDocumentationPR(analysis) { const branchName = `docs/auto-doc-${Date.now()}`; // Create and switch to new branch (0, child_process_1.execSync)(`git checkout -b ${branchName}`); // Get additional information const commitHash = (0, child_process_1.execSync)('git rev-parse HEAD').toString().trim(); const currentBranch = (0, child_process_1.execSync)('git rev-parse --abbrev-ref HEAD').toString().trim(); const timestamp = new Date().toISOString(); // Create documentation file using template const docContent = this.generateDocumentationContent({ analysis, technical_details: await this.fuelixClient.generateTechnicalDetails(analysis), related_components: await this.fuelixClient.identifyRelatedComponents(analysis), timestamp, branch: currentBranch, commit_hash: commitHash, additional_notes: await this.fuelixClient.generateAdditionalNotes(analysis) }); // Ensure docs directory exists if (!fs.existsSync('docs')) { fs.mkdirSync('docs', { recursive: true }); } // Write documentation file fs.writeFileSync('docs/auto-generated.md', docContent); // Commit changes (0, child_process_1.execSync)('git add docs/auto-generated.md'); (0, child_process_1.execSync)('git commit -m "docs: Add auto-generated documentation"'); (0, child_process_1.execSync)(`git push origin ${branchName}`); // Create PR using GitHub client return await this.githubClient.createPullRequest({ title: "docs: Auto-generated documentation", body: analysis, branch: branchName }); } async createJiraBacklogItem(analysis, prUrl) { await this.jiraClient.createTicket('Documentation Update', `Automated documentation update based on recent changes.\n\n${analysis}\n\n${prUrl ? `Related PR: ${prUrl}` : ''}`, process.env.JIRA_PROJECT_KEY || ''); } generateDocumentationContent(data) { const template = fs.readFileSync(path.join('docs', 'templates', 'documentation-template.md'), 'utf-8'); return template .replace('{{analysis}}', data.analysis) .replace('{{technical_details}}', data.technical_details) .replace('{{related_components}}', data.related_components) .replace('{{timestamp}}', data.timestamp) .replace('{{branch}}', data.branch) .replace('{{commit_hash}}', data.commit_hash) .replace('{{additional_notes}}', data.additional_notes); } } exports.DocumentationService = DocumentationService; //# sourceMappingURL=documentationService.js.map