cast-code 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/common/services/multi-llm.service.js +19 -0
  2. package/dist/common/services/multi-llm.service.js.map +1 -1
  3. package/dist/modules/config/services/config-commands.service.js +86 -6
  4. package/dist/modules/config/services/config-commands.service.js.map +1 -1
  5. package/dist/modules/config/types/config.types.js +5 -0
  6. package/dist/modules/config/types/config.types.js.map +1 -1
  7. package/dist/modules/config/types/config.types.spec.js +60 -0
  8. package/dist/modules/config/types/config.types.spec.js.map +1 -0
  9. package/dist/modules/core/services/deep-agent.service.js +40 -4
  10. package/dist/modules/core/services/deep-agent.service.js.map +1 -1
  11. package/dist/modules/git/git.module.js +5 -2
  12. package/dist/modules/git/git.module.js.map +1 -1
  13. package/dist/modules/git/git.module.spec.js +54 -0
  14. package/dist/modules/git/git.module.spec.js.map +1 -0
  15. package/dist/modules/git/services/pr-generator.service.js +70 -69
  16. package/dist/modules/git/services/pr-generator.service.js.map +1 -1
  17. package/dist/modules/git/services/unit-test-generator.service.js +557 -0
  18. package/dist/modules/git/services/unit-test-generator.service.js.map +1 -0
  19. package/dist/modules/git/services/unit-test-generator.service.spec.js +119 -0
  20. package/dist/modules/git/services/unit-test-generator.service.spec.js.map +1 -0
  21. package/dist/modules/repl/services/commands/git-commands.service.js +97 -2
  22. package/dist/modules/repl/services/commands/git-commands.service.js.map +1 -1
  23. package/dist/modules/repl/services/commands/repl-commands.service.js +1 -0
  24. package/dist/modules/repl/services/commands/repl-commands.service.js.map +1 -1
  25. package/dist/modules/repl/services/commands/repl-commands.service.spec.js +69 -0
  26. package/dist/modules/repl/services/commands/repl-commands.service.spec.js.map +1 -0
  27. package/dist/modules/repl/services/repl.service.js +11 -1
  28. package/dist/modules/repl/services/repl.service.js.map +1 -1
  29. package/dist/modules/repl/services/repl.service.spec.js +137 -0
  30. package/dist/modules/repl/services/repl.service.spec.js.map +1 -0
  31. package/package.json +1 -1
  32. package/dist/modules/agents/definitions/architect.md +0 -35
  33. package/dist/modules/agents/definitions/backend.md +0 -43
  34. package/dist/modules/agents/definitions/coder.md +0 -34
  35. package/dist/modules/agents/definitions/devops.md +0 -42
  36. package/dist/modules/agents/definitions/frontend.md +0 -46
  37. package/dist/modules/agents/definitions/reviewer.md +0 -35
  38. package/dist/modules/agents/definitions/tester.md +0 -41
  39. package/dist/modules/skills/definitions/general/file-operations.md +0 -60
  40. package/dist/modules/skills/definitions/general/git-operations.md +0 -59
  41. package/dist/modules/skills/definitions/general/planning.md +0 -86
  42. package/dist/modules/skills/definitions/general/search.md +0 -59
  43. package/dist/modules/skills/definitions/specialized/api-design.md +0 -85
  44. package/dist/modules/skills/definitions/specialized/database-operations.md +0 -78
  45. package/dist/modules/skills/definitions/specialized/frontend-bootstrap.md +0 -71
  46. package/dist/modules/skills/definitions/specialized/react-patterns.md +0 -77
  47. package/dist/modules/skills/definitions/specialized/testing-strategies.md +0 -79
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/modules/git/services/pr-generator.service.ts"],"sourcesContent":["import { Injectable } from '@nestjs/common';\nimport { execSync } from 'child_process';\nimport { HumanMessage, SystemMessage } from '@langchain/core/messages';\nimport { MultiLlmService } from '../../../common/services/multi-llm.service';\nimport { MonorepoDetectorService } from './monorepo-detector.service';\n\nexport interface CommitInfo {\n hash: string;\n message: string;\n author: string;\n date: string;\n files: string[];\n diff: string;\n}\n\nexport interface PRDescription {\n title: string;\n description: string;\n commits: { hash: string; summary: string; details: string }[];\n}\n\nexport interface PRCreationResult {\n success: boolean;\n url?: string;\n error?: string;\n description?: string;\n platform: 'github' | 'azure' | 'gitlab' | 'bitbucket' | 'unknown';\n}\n\n@Injectable()\nexport class PrGeneratorService {\n constructor(\n private readonly multiLlmService: MultiLlmService,\n private readonly monorepoDetector: MonorepoDetectorService,\n ) {}\n\n getCurrentBranch(): string {\n try {\n return execSync('git branch --show-current', { \n cwd: process.cwd(), \n encoding: 'utf-8' \n }).trim();\n } catch {\n return 'unknown';\n }\n }\n\n detectDefaultBaseBranch(): string {\n try {\n const cwd = process.cwd();\n const candidates = ['main', 'master', 'develop'];\n \n for (const branch of candidates) {\n try {\n execSync(`git rev-parse --verify ${branch} 2>/dev/null || git rev-parse --verify origin/${branch} 2>/dev/null`, { \n cwd, \n stdio: 'ignore' \n });\n return branch;\n } catch {\n }\n }\n \n return 'main';\n } catch {\n return 'main';\n }\n }\n\n detectPlatform(): { platform: 'github' | 'azure' | 'gitlab' | 'bitbucket' | 'unknown'; url: string } {\n try {\n const remoteUrl = execSync('git remote get-url origin', { \n cwd: process.cwd(), \n encoding: 'utf-8' \n }).trim();\n\n if (remoteUrl.includes('github.com')) {\n return { platform: 'github', url: remoteUrl };\n }\n if (remoteUrl.includes('dev.azure.com') || remoteUrl.includes('visualstudio.com')) {\n return { platform: 'azure', url: remoteUrl };\n }\n if (remoteUrl.includes('gitlab.com') || remoteUrl.includes('gitlab')) {\n return { platform: 'gitlab', url: remoteUrl };\n }\n if (remoteUrl.includes('bitbucket.org')) {\n return { platform: 'bitbucket', url: remoteUrl };\n }\n\n return { platform: 'unknown', url: remoteUrl };\n } catch {\n return { platform: 'unknown', url: '' };\n }\n }\n\n getCommitsNotInBase(baseBranch: string = 'develop'): CommitInfo[] {\n try {\n const cwd = process.cwd();\n \n try {\n execSync(`git rev-parse --verify ${baseBranch}`, { cwd, stdio: 'ignore' });\n } catch {\n try {\n execSync(`git rev-parse --verify origin/${baseBranch}`, { cwd, stdio: 'ignore' });\n } catch {\n return [];\n }\n }\n\n const logOutput = execSync(\n `git log ${baseBranch}..HEAD --pretty=format:\"%H|%s|%an|%ad\" --date=short`,\n { cwd, encoding: 'utf-8' }\n );\n\n if (!logOutput.trim()) {\n return [];\n }\n\n const commits: CommitInfo[] = [];\n const lines = logOutput.trim().split('\\n');\n\n for (const line of lines) {\n const [hash, message, author, date] = line.split('|');\n if (!hash) continue;\n\n const filesOutput = execSync(\n `git diff-tree --no-commit-id --name-only -r ${hash}`,\n { cwd, encoding: 'utf-8' }\n );\n const files = filesOutput.trim().split('\\n').filter(f => f);\n\n const diffOutput = execSync(\n `git show ${hash} --stat`,\n { cwd, encoding: 'utf-8' }\n );\n\n commits.push({\n hash: hash.slice(0, 7),\n message,\n author,\n date,\n files,\n diff: diffOutput,\n });\n }\n\n return commits.reverse();\n } catch (error) {\n return [];\n }\n }\n\n async analyzeCommit(commit: CommitInfo): Promise<{ summary: string; details: string }> {\n const llm = this.multiLlmService.createModel('cheap');\n\n const prompt = this.buildCommitAnalysisPrompt(commit);\n\n const response = await llm.invoke([\n new SystemMessage(this.getCommitAnalysisSystemPrompt()),\n new HumanMessage(prompt),\n ]);\n\n const content = this.extractContent(response.content);\n return this.parseCommitAnalysis(content);\n }\n\n async generatePRDescription(\n branchName: string, \n commits: CommitInfo[],\n baseBranch: string = 'develop',\n ): Promise<PRDescription> {\n const llm = this.multiLlmService.createModel('cheap');\n const prompt = this.buildSinglePrompt(branchName, commits, baseBranch);\n\n const response = await llm.invoke([\n new SystemMessage(this.getSingleAgentSystemPrompt()),\n new HumanMessage(prompt),\n ]);\n\n const content = this.extractContent(response.content);\n const { title, description, commitSummaries } = this.parseSingleResponse(content, commits);\n\n return {\n title: title || this.generateDefaultTitle(branchName),\n description,\n commits: commitSummaries,\n };\n }\n\n async createPR(\n title: string, \n description: string, \n baseBranch: string = 'develop'\n ): Promise<PRCreationResult> {\n const { platform } = this.detectPlatform();\n const branch = this.getCurrentBranch();\n\n if (platform !== 'github') {\n return {\n success: false,\n error: `Automatic PR creation not supported for ${platform}. Description generated and copied to clipboard.`,\n description: this.formatPRForClipboard(title, description, baseBranch),\n platform,\n };\n }\n\n try {\n execSync('which gh', { cwd: process.cwd() });\n } catch {\n return {\n success: false,\n error: 'GitHub CLI (gh) not found. Install from https://cli.github.com/',\n description: this.formatPRForClipboard(title, description, baseBranch),\n platform,\n };\n }\n\n try {\n const cwd = process.cwd();\n\n const tempFile = `/tmp/pr-body-${Date.now()}.md`;\n require('fs').writeFileSync(tempFile, description);\n\n try {\n const result = execSync(\n `gh pr create --title \"${title.replace(/\"/g, '\\\\\"')}\" --body-file \"${tempFile}\" --base \"${baseBranch}\"`,\n { cwd, encoding: 'utf-8' }\n );\n \n const urlMatch = result.match(/https:\\/\\/github\\.com\\/[^\\s]+/);\n \n return { \n success: true, \n url: urlMatch ? urlMatch[0] : undefined,\n platform,\n };\n } finally {\n try {\n require('fs').unlinkSync(tempFile);\n } catch {}\n }\n } catch (error: any) {\n const message = error.message || 'Failed to create PR';\n if (message.includes('already exists')) {\n return { \n success: false, \n error: 'A PR already exists for this branch',\n description: this.formatPRForClipboard(title, description, baseBranch),\n platform,\n };\n }\n return { \n success: false, \n error: message,\n description: this.formatPRForClipboard(title, description, baseBranch),\n platform,\n };\n }\n }\n\n copyToClipboard(text: string): boolean {\n try {\n const platform = process.platform;\n \n if (platform === 'darwin') {\n execSync(`echo ${JSON.stringify(text)} | pbcopy`);\n return true;\n } else if (platform === 'linux') {\n try {\n execSync(`echo ${JSON.stringify(text)} | xclip -selection clipboard`);\n return true;\n } catch {\n try {\n execSync(`echo ${JSON.stringify(text)} | xsel --clipboard --input`);\n return true;\n } catch {\n return false;\n }\n }\n } else if (platform === 'win32') {\n execSync(`echo ${JSON.stringify(text)} | clip`);\n return true;\n }\n \n return false;\n } catch {\n return false;\n }\n }\n\n formatPRForClipboard(title: string, description: string, baseBranch: string): string {\n return `# ${title}\\n\\n${description}\\n\\n---\\n**Base Branch:** ${baseBranch}\\n**Generated by:** Cast Code`;\n }\n\n getPRCreateUrl(platform: string, baseBranch: string): string | null {\n try {\n const remoteUrl = execSync('git remote get-url origin', { \n cwd: process.cwd(), \n encoding: 'utf-8' \n }).trim();\n\n const branch = this.getCurrentBranch();\n\n let httpsUrl = remoteUrl\n .replace(/^git@github\\.com:/, 'https://github.com/')\n .replace(/^git@gitlab\\.com:/, 'https://gitlab.com/')\n .replace(/^git@bitbucket\\.org:/, 'https://bitbucket.org/')\n .replace(/\\.git$/, '');\n\n switch (platform) {\n case 'github':\n return `${httpsUrl}/compare/${baseBranch}...${branch}?expand=1`;\n case 'gitlab':\n return `${httpsUrl}/merge_requests/new?merge_request[source_branch]=${branch}&merge_request[target_branch]=${baseBranch}`;\n case 'bitbucket':\n return `${httpsUrl}/pull-requests/new?source=${branch}&dest=${baseBranch}`;\n case 'azure':\n return null;\n default:\n return null;\n }\n } catch {\n return null;\n }\n }\n\n private buildCommitAnalysisPrompt(commit: CommitInfo): string {\n const monorepoInfo = this.monorepoDetector.detectMonorepo(process.cwd());\n const scope = this.monorepoDetector.determineScope(commit.files, monorepoInfo);\n\n return `Analyze this commit:\\n\\n**Commit:** ${commit.hash}\\n**Message:** ${commit.message}\\n**Author:** ${commit.author}\\n**Date:** ${commit.date}\\n**Scope:** ${scope || 'general'}\\n\\n**Files Changed:**\\n${commit.files.join('\\n')}\\n\\n**Diff Stats:**\\n${commit.diff}\\n\\nProvide:\\n1. A one-line summary (max 100 chars)\\n2. Detailed explanation of changes, approach, and impact`;\n }\n\n private buildPRDescriptionPrompt(\n branchName: string, \n commits: { hash: string; message: string; summary: string; details: string }[],\n baseBranch: string,\n ): string {\n const commitsSummary = commits.map((c, i) => \n `${i + 1}. **${c.hash}** - ${c.summary}\\n ${c.details.slice(0, 200)}...`\n ).join('\\n\\n');\n\n return `Create a PR description for branch \"${branchName}\" to \"${baseBranch}\".\\n\\n**Commits:**\\n${commitsSummary}\\n\\nGenerate:\\n1. PR title (use branch name as inspiration)\\n2. Description with: Overview, Changes, Technical Details, Testing`;\n }\n\n private getCommitAnalysisSystemPrompt(): string {\n return `Analyze a git commit. Provide:\\n\\n1. **Summary**: One sentence (max 100 chars)\\n2. **Details**: Detailed paragraph about changes\\n\\nFormat:\\nSUMMARY: <summary>\\n\\nDETAILS: <details>`;\n }\n\n private getPRDescriptionSystemPrompt(): string {\n return `Create a Pull Request description.\\n\\n**Title:** Concise, descriptive\\n\\n**Description Structure:**\\n\\`\\`\\`markdown\\n## Overview\\nBrief explanation\\n\\n## Changes\\n- Change 1\\n- Change 2\\n\\n## Technical Details\\nImplementation details\\n\\n## Testing\\nHow to test\\n\\`\\`\\``;\n }\n\n private parseCommitAnalysis(content: string): { summary: string; details: string } {\n const summaryMatch = content.match(/SUMMARY:\\s*(.+?)(?=\\n\\n|DETAILS:|$)/is);\n const detailsMatch = content.match(/DETAILS:\\s*(.+?)$/is);\n\n return {\n summary: summaryMatch ? summaryMatch[1].trim() : 'No summary available',\n details: detailsMatch ? detailsMatch[1].trim() : content,\n };\n }\n\n private parsePRDescription(content: string): { title: string; description: string } {\n const titleMatch = content.match(/^#?\\s*Title:?\\s*(.+?)(?=\\n\\n|\\n##|$)/i);\n const lines = content.split('\\n');\n const title = titleMatch ? titleMatch[1].trim() : lines[0].replace(/^#+\\s*/, '').trim();\n const description = titleMatch \n ? content.slice(content.indexOf(titleMatch[0]) + titleMatch[0].length).trim()\n : lines.slice(1).join('\\n').trim();\n\n return { title, description };\n }\n\n private buildSinglePrompt(branchName: string, commits: CommitInfo[], baseBranch: string): string {\n const commitsInfo = commits.map((c, i) => \n `${i + 1}. **${c.hash}** - ${c.message}\\n Files: ${c.files.slice(0, 5).join(', ')}${c.files.length > 5 ? '...' : ''}\\n Stats: ${c.diff.split('\\n').slice(-3, -1).join(' ')}`\n ).join('\\n\\n');\n\n return `Branch: ${branchName}\\nBase: ${baseBranch}\\nCommits: ${commits.length}\\n\\n${commitsInfo}`;\n }\n\n private getSingleAgentSystemPrompt(): string {\n return `You are a senior developer creating a Pull Request description. Analyze ALL commits and generate a comprehensive PR description.\n\n**OUTPUT FORMAT:**\nTITLE: <PR title based on branch name and overall changes>\n\nOVERVIEW: <2-3 sentences explaining what this PR accomplishes>\n\nCHANGES:\n- <key change 1>\n- <key change 2>\n- ...\n\nTECHNICAL_DETAILS: <important implementation details, architecture decisions>\n\nCOMMITS:\n<hash>: <one-line summary of what this commit does>\n(repeat for each commit)\n\nTESTING: <how to test these changes>`;\n }\n\n private parseSingleResponse(content: string, commits: CommitInfo[]): { \n title: string; \n description: string; \n commitSummaries: { hash: string; summary: string; details: string }[] \n } {\n const titleMatch = content.match(/TITLE:\\s*(.+?)(?=\\n\\n|\\n[A-Z]|$)/i);\n const overviewMatch = content.match(/OVERVIEW:\\s*([\\s\\S]+?)(?=\\n\\nCHANGES:|CHANGES:)/i);\n const changesMatch = content.match(/CHANGES:\\s*([\\s\\S]+?)(?=\\n\\nTECHNICAL_DETAILS:|TECHNICAL_DETAILS:)/i);\n const technicalMatch = content.match(/TECHNICAL_DETAILS:\\s*([\\s\\S]+?)(?=\\n\\nCOMMITS:|COMMITS:)/i);\n const commitsMatch = content.match(/COMMITS:\\s*([\\s\\S]+?)(?=\\n\\nTESTING:|TESTING:|$)/i);\n const testingMatch = content.match(/TESTING:\\s*([\\s\\S]+)$/i);\n\n const title = titleMatch ? titleMatch[1].trim() : '';\n \n const parts: string[] = [];\n \n if (overviewMatch) {\n parts.push('## Overview\\n' + overviewMatch[1].trim());\n }\n \n if (changesMatch) {\n parts.push('## Changes\\n' + changesMatch[1].trim());\n }\n \n if (technicalMatch) {\n parts.push('## Technical Details\\n' + technicalMatch[1].trim());\n }\n \n if (testingMatch) {\n parts.push('## Testing\\n' + testingMatch[1].trim());\n }\n\n const description = parts.join('\\n\\n');\n\n const commitSummaries: { hash: string; summary: string; details: string }[] = [];\n \n if (commitsMatch) {\n const commitsText = commitsMatch[1].trim();\n const lines = commitsText.split('\\n');\n \n for (const line of lines) {\n const match = line.match(/^([a-f0-9]+):\\s*(.+)$/i);\n if (match) {\n commitSummaries.push({\n hash: match[1].slice(0, 7),\n summary: match[2].trim(),\n details: '',\n });\n }\n }\n }\n\n if (commitSummaries.length === 0) {\n for (const commit of commits) {\n commitSummaries.push({\n hash: commit.hash,\n summary: commit.message.slice(0, 60),\n details: '',\n });\n }\n }\n\n return { title, description, commitSummaries };\n }\n\n private generateDefaultTitle(branchName: string): string {\n return branchName\n .replace(/^(feature|fix|hotfix|release)\\//, '')\n .split(/[-_]/)\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n }\n\n private extractContent(content: unknown): string {\n if (typeof content === 'string') return content;\n if (Array.isArray(content) && content.length > 0) {\n const first = content[0];\n if (typeof first === 'object' && first !== null && 'text' in first) {\n return String(first.text);\n }\n }\n return String(content);\n }\n}\n"],"names":["PrGeneratorService","getCurrentBranch","execSync","cwd","process","encoding","trim","detectDefaultBaseBranch","candidates","branch","stdio","detectPlatform","remoteUrl","includes","platform","url","getCommitsNotInBase","baseBranch","logOutput","commits","lines","split","line","hash","message","author","date","filesOutput","files","filter","f","diffOutput","push","slice","diff","reverse","error","analyzeCommit","commit","llm","multiLlmService","createModel","prompt","buildCommitAnalysisPrompt","response","invoke","SystemMessage","getCommitAnalysisSystemPrompt","HumanMessage","content","extractContent","parseCommitAnalysis","generatePRDescription","branchName","buildSinglePrompt","getSingleAgentSystemPrompt","title","description","commitSummaries","parseSingleResponse","generateDefaultTitle","createPR","success","formatPRForClipboard","tempFile","Date","now","require","writeFileSync","result","replace","urlMatch","match","undefined","unlinkSync","copyToClipboard","text","JSON","stringify","getPRCreateUrl","httpsUrl","monorepoInfo","monorepoDetector","detectMonorepo","scope","determineScope","join","buildPRDescriptionPrompt","commitsSummary","map","c","i","summary","details","getPRDescriptionSystemPrompt","summaryMatch","detailsMatch","parsePRDescription","titleMatch","indexOf","length","commitsInfo","overviewMatch","changesMatch","technicalMatch","commitsMatch","testingMatch","parts","commitsText","word","charAt","toUpperCase","Array","isArray","first","String"],"mappings":";;;;+BA8BaA;;;eAAAA;;;wBA9Bc;+BACF;0BACmB;iCACZ;yCACQ;;;;;;;;;;AA0BjC,IAAA,AAAMA,qBAAN,MAAMA;IAMXC,mBAA2B;QACzB,IAAI;YACF,OAAOC,IAAAA,uBAAQ,EAAC,6BAA6B;gBAC3CC,KAAKC,QAAQD,GAAG;gBAChBE,UAAU;YACZ,GAAGC,IAAI;Q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QAAQF,MAAO;gBACxB,MAAMoD,QAAQlD,KAAKkD,KAAK,CAAC;gBACzB,IAAIA,OAAO;oBACTd,gBAAgB1B,IAAI,CAAC;wBACnBT,MAAMiD,KAAK,CAAC,EAAE,CAACvC,KAAK,CAAC,GAAG;wBACxB2D,SAASpB,KAAK,CAAC,EAAE,CAAClE,IAAI;wBACtBuF,SAAS;oBACX;gBACF;YACF;QACF;QAEA,IAAInC,gBAAgB0C,MAAM,KAAK,GAAG;YAChC,KAAK,MAAM9D,UAAUnB,QAAS;gBAC5BuC,gBAAgB1B,IAAI,CAAC;oBACnBT,MAAMe,OAAOf,IAAI;oBACjBqE,SAAStD,OAAOd,OAAO,CAACS,KAAK,CAAC,GAAG;oBACjC4D,SAAS;gBACX;YACF;QACF;QAEA,OAAO;YAAErC;YAAOC;YAAaC;QAAgB;IAC/C;IAEQE,qBAAqBP,UAAkB,EAAU;QACvD,OAAOA,WACJiB,OAAO,CAAC,mCAAmC,IAC3CjD,KAAK,CAAC,QACNoE,GAAG,CAACoB,CAAAA,OAAQA,KAAKC,MAAM,CAAC,GAAGC,WAAW,KAAKF,KAAK5E,KAAK,CAAC,IACtDqD,IAAI,CAAC;IACV;IAEQpC,eAAeD,OAAgB,EAAU;QAC/C,IAAI,OAAOA,YAAY,UAAU,OAAOA;QACxC,IAAI+D,MAAMC,OAAO,CAAChE,YAAYA,QAAQmD,MAAM,GAAG,GAAG;YAChD,MAAMc,QAAQjE,OAAO,CAAC,EAAE;YACxB,IAAI,OAAOiE,UAAU,YAAYA,UAAU,QAAQ,UAAUA,OAAO;gBAClE,OAAOC,OAAOD,MAAMtC,IAAI;YAC1B;QACF;QACA,OAAOuC,OAAOlE;IAChB;IAvcA,YACE,AAAiBT,eAAgC,EACjD,AAAiB0C,gBAAyC,CAC1D;aAFiB1C,kBAAAA;aACA0C,mBAAAA;IAChB;AAqcL"}
1
+ {"version":3,"sources":["../../../../src/modules/git/services/pr-generator.service.ts"],"sourcesContent":["import { Injectable } from '@nestjs/common';\nimport { execSync } from 'child_process';\nimport { HumanMessage, SystemMessage } from '@langchain/core/messages';\nimport { MultiLlmService } from '../../../common/services/multi-llm.service';\nimport { MonorepoDetectorService } from './monorepo-detector.service';\n\nexport interface CommitInfo {\n hash: string;\n message: string;\n author: string;\n date: string;\n files: string[];\n diff: string;\n}\n\nexport interface PRDescription {\n title: string;\n description: string;\n commits: { hash: string; summary: string; details: string }[];\n}\n\nexport interface PRCreationResult {\n success: boolean;\n url?: string;\n error?: string;\n description?: string;\n platform: 'github' | 'azure' | 'gitlab' | 'bitbucket' | 'unknown';\n}\n\n@Injectable()\nexport class PrGeneratorService {\n private prTemplateCache?: string;\n private readonly prTemplatePath = '/home/pedro-castanheira/Downloads/pull-request.template.md';\n\n constructor(\n private readonly multiLlmService: MultiLlmService,\n private readonly monorepoDetector: MonorepoDetectorService,\n ) {}\n\n getCurrentBranch(): string {\n try {\n return execSync('git branch --show-current', { \n cwd: process.cwd(), \n encoding: 'utf-8' \n }).trim();\n } catch {\n return 'unknown';\n }\n }\n\n detectDefaultBaseBranch(): string {\n try {\n const cwd = process.cwd();\n const candidates = ['main', 'master', 'develop'];\n \n for (const branch of candidates) {\n try {\n execSync(`git rev-parse --verify ${branch} 2>/dev/null || git rev-parse --verify origin/${branch} 2>/dev/null`, { \n cwd, \n stdio: 'ignore' \n });\n return branch;\n } catch {\n }\n }\n \n return 'main';\n } catch {\n return 'main';\n }\n }\n\n detectPlatform(): { platform: 'github' | 'azure' | 'gitlab' | 'bitbucket' | 'unknown'; url: string } {\n try {\n const remoteUrl = execSync('git remote get-url origin', { \n cwd: process.cwd(), \n encoding: 'utf-8' \n }).trim();\n\n if (remoteUrl.includes('github.com')) {\n return { platform: 'github', url: remoteUrl };\n }\n if (remoteUrl.includes('dev.azure.com') || remoteUrl.includes('visualstudio.com')) {\n return { platform: 'azure', url: remoteUrl };\n }\n if (remoteUrl.includes('gitlab.com') || remoteUrl.includes('gitlab')) {\n return { platform: 'gitlab', url: remoteUrl };\n }\n if (remoteUrl.includes('bitbucket.org')) {\n return { platform: 'bitbucket', url: remoteUrl };\n }\n\n return { platform: 'unknown', url: remoteUrl };\n } catch {\n return { platform: 'unknown', url: '' };\n }\n }\n\n getCommitsNotInBase(baseBranch: string = 'develop'): CommitInfo[] {\n try {\n const cwd = process.cwd();\n \n try {\n execSync(`git rev-parse --verify ${baseBranch}`, { cwd, stdio: 'ignore' });\n } catch {\n try {\n execSync(`git rev-parse --verify origin/${baseBranch}`, { cwd, stdio: 'ignore' });\n } catch {\n return [];\n }\n }\n\n const logOutput = execSync(\n `git log ${baseBranch}..HEAD --pretty=format:\"%H|%s|%an|%ad\" --date=short`,\n { cwd, encoding: 'utf-8' }\n );\n\n if (!logOutput.trim()) {\n return [];\n }\n\n const commits: CommitInfo[] = [];\n const lines = logOutput.trim().split('\\n');\n\n for (const line of lines) {\n const [hash, message, author, date] = line.split('|');\n if (!hash) continue;\n\n const filesOutput = execSync(\n `git diff-tree --no-commit-id --name-only -r ${hash}`,\n { cwd, encoding: 'utf-8' }\n );\n const files = filesOutput.trim().split('\\n').filter(f => f);\n\n const diffOutput = execSync(\n `git show ${hash} --stat`,\n { cwd, encoding: 'utf-8' }\n );\n\n commits.push({\n hash: hash.slice(0, 7),\n message,\n author,\n date,\n files,\n diff: diffOutput,\n });\n }\n\n return commits.reverse();\n } catch (error) {\n return [];\n }\n }\n\n async analyzeCommit(commit: CommitInfo): Promise<{ summary: string; details: string }> {\n const llm = this.multiLlmService.createModel('cheap');\n\n const prompt = this.buildCommitAnalysisPrompt(commit);\n\n const response = await llm.invoke([\n new SystemMessage(this.getCommitAnalysisSystemPrompt()),\n new HumanMessage(prompt),\n ]);\n\n const content = this.extractContent(response.content);\n return this.parseCommitAnalysis(content);\n }\n\n async generatePRDescription(\n branchName: string, \n commits: CommitInfo[],\n baseBranch: string = 'develop',\n ): Promise<PRDescription> {\n const llm = this.multiLlmService.createModel('cheap');\n const prompt = this.buildSinglePrompt(branchName, commits, baseBranch);\n\n const response = await llm.invoke([\n new SystemMessage(this.getSingleAgentSystemPrompt()),\n new HumanMessage(prompt),\n ]);\n\n const content = this.extractContent(response.content);\n const { title, description, commitSummaries } = this.parseSingleResponse(content, commits);\n\n return {\n title: title || this.generateDefaultTitle(branchName),\n description: description && description.trim().length > 0 ? description : this.getPRTemplate(),\n commits: commitSummaries,\n };\n }\n\n async createPR(\n title: string, \n description: string, \n baseBranch: string = 'develop'\n ): Promise<PRCreationResult> {\n const { platform } = this.detectPlatform();\n const branch = this.getCurrentBranch();\n\n if (platform !== 'github') {\n return {\n success: false,\n error: `Automatic PR creation not supported for ${platform}. Description generated and copied to clipboard.`,\n description: this.formatPRForClipboard(title, description, baseBranch),\n platform,\n };\n }\n\n try {\n execSync('which gh', { cwd: process.cwd() });\n } catch {\n return {\n success: false,\n error: 'GitHub CLI (gh) not found. Install from https://cli.github.com/',\n description: this.formatPRForClipboard(title, description, baseBranch),\n platform,\n };\n }\n\n try {\n const cwd = process.cwd();\n\n const tempFile = `/tmp/pr-body-${Date.now()}.md`;\n require('fs').writeFileSync(tempFile, description);\n\n try {\n const result = execSync(\n `gh pr create --title \"${title.replace(/\"/g, '\\\\\"')}\" --body-file \"${tempFile}\" --base \"${baseBranch}\"`,\n { cwd, encoding: 'utf-8' }\n );\n \n const urlMatch = result.match(/https:\\/\\/github\\.com\\/[^\\s]+/);\n \n return { \n success: true, \n url: urlMatch ? urlMatch[0] : undefined,\n platform,\n };\n } finally {\n try {\n require('fs').unlinkSync(tempFile);\n } catch {}\n }\n } catch (error: any) {\n const message = error.message || 'Failed to create PR';\n if (message.includes('already exists')) {\n return { \n success: false, \n error: 'A PR already exists for this branch',\n description: this.formatPRForClipboard(title, description, baseBranch),\n platform,\n };\n }\n return { \n success: false, \n error: message,\n description: this.formatPRForClipboard(title, description, baseBranch),\n platform,\n };\n }\n }\n\n copyToClipboard(text: string): boolean {\n try {\n const platform = process.platform;\n \n if (platform === 'darwin') {\n execSync(`echo ${JSON.stringify(text)} | pbcopy`);\n return true;\n } else if (platform === 'linux') {\n try {\n execSync(`echo ${JSON.stringify(text)} | xclip -selection clipboard`);\n return true;\n } catch {\n try {\n execSync(`echo ${JSON.stringify(text)} | xsel --clipboard --input`);\n return true;\n } catch {\n return false;\n }\n }\n } else if (platform === 'win32') {\n execSync(`echo ${JSON.stringify(text)} | clip`);\n return true;\n }\n \n return false;\n } catch {\n return false;\n }\n }\n\n formatPRForClipboard(title: string, description: string, baseBranch: string): string {\n return description;\n }\n\n getPRCreateUrl(platform: string, baseBranch: string): string | null {\n try {\n const remoteUrl = execSync('git remote get-url origin', { \n cwd: process.cwd(), \n encoding: 'utf-8' \n }).trim();\n\n const branch = this.getCurrentBranch();\n\n let httpsUrl = remoteUrl\n .replace(/^git@github\\.com:/, 'https://github.com/')\n .replace(/^git@gitlab\\.com:/, 'https://gitlab.com/')\n .replace(/^git@bitbucket\\.org:/, 'https://bitbucket.org/')\n .replace(/\\.git$/, '');\n\n switch (platform) {\n case 'github':\n return `${httpsUrl}/compare/${baseBranch}...${branch}?expand=1`;\n case 'gitlab':\n return `${httpsUrl}/merge_requests/new?merge_request[source_branch]=${branch}&merge_request[target_branch]=${baseBranch}`;\n case 'bitbucket':\n return `${httpsUrl}/pull-requests/new?source=${branch}&dest=${baseBranch}`;\n case 'azure':\n return null;\n default:\n return null;\n }\n } catch {\n return null;\n }\n }\n\n private buildCommitAnalysisPrompt(commit: CommitInfo): string {\n const monorepoInfo = this.monorepoDetector.detectMonorepo(process.cwd());\n const scope = this.monorepoDetector.determineScope(commit.files, monorepoInfo);\n\n return `Analyze this commit:\\n\\n**Commit:** ${commit.hash}\\n**Message:** ${commit.message}\\n**Author:** ${commit.author}\\n**Date:** ${commit.date}\\n**Scope:** ${scope || 'general'}\\n\\n**Files Changed:**\\n${commit.files.join('\\n')}\\n\\n**Diff Stats:**\\n${commit.diff}\\n\\nProvide:\\n1. A one-line summary (max 100 chars)\\n2. Detailed explanation of changes, approach, and impact`;\n }\n\n private getCommitAnalysisSystemPrompt(): string {\n return `Analyze a git commit. Provide:\\n\\n1. **Summary**: One sentence (max 100 chars)\\n2. **Details**: Detailed paragraph about changes\\n\\nFormat:\\nSUMMARY: <summary>\\n\\nDETAILS: <details>`;\n }\n\n private parseCommitAnalysis(content: string): { summary: string; details: string } {\n const summaryMatch = content.match(/SUMMARY:\\s*(.+?)(?=\\n\\n|DETAILS:|$)/is);\n const detailsMatch = content.match(/DETAILS:\\s*(.+?)$/is);\n\n return {\n summary: summaryMatch ? summaryMatch[1].trim() : 'No summary available',\n details: detailsMatch ? detailsMatch[1].trim() : content,\n };\n }\n\n private parsePRDescription(content: string): { title: string; description: string } {\n const titleMatch = content.match(/^#?\\s*Title:?\\s*(.+?)(?=\\n\\n|\\n##|$)/i);\n const lines = content.split('\\n');\n const title = titleMatch ? titleMatch[1].trim() : lines[0].replace(/^#+\\s*/, '').trim();\n const description = titleMatch \n ? content.slice(content.indexOf(titleMatch[0]) + titleMatch[0].length).trim()\n : lines.slice(1).join('\\n').trim();\n\n return { title, description };\n }\n\n private buildSinglePrompt(branchName: string, commits: CommitInfo[], baseBranch: string): string {\n const commitsInfo = commits.map((c, i) => \n `${i + 1}. **${c.hash}** - ${c.message}\\n Files: ${c.files.slice(0, 5).join(', ')}${c.files.length > 5 ? '...' : ''}\\n Stats: ${c.diff.split('\\n').slice(-3, -1).join(' ')}`\n ).join('\\n\\n');\n\n return `Branch: ${branchName}\\nBase: ${baseBranch}\\nCommits: ${commits.length}\\n\\n${commitsInfo}`;\n }\n\n private getSingleAgentSystemPrompt(): string {\n const template = this.getPRTemplate();\n return `You are a senior developer creating a Pull Request description. Analyze ALL commits and fill in the PR template below.\n\nRules:\n- Output ONLY the filled template.\n- Keep headings, checklists, and ordering exactly as shown.\n- Fill ONLY these sections with content: \"O que essa PR faz?\", \"O que foi mexido?\", \"O que eu fiz?\".\n- Leave the other sections blank for the user to fill in.\n- Do not add any extra sections beyond the template.\n- Keep the final reminder line.\n\nPR TEMPLATE:\n${template}`;\n }\n\n private parseSingleResponse(content: string, commits: CommitInfo[]): { \n title: string; \n description: string; \n commitSummaries: { hash: string; summary: string; details: string }[] \n } {\n const title = '';\n let description = content.trim();\n const requiredHeading = '## 🚀 O que essa PR faz?';\n const hasRequiredHeading = description.includes(requiredHeading);\n\n if (!hasRequiredHeading) {\n description = this.getPRTemplate();\n } else if (!description.includes('Não se esqueça de revisar essa descrição')) {\n description = `${description.trim()}\\n\\nNão se esqueça de revisar essa descrição`;\n }\n\n const commitSummaries: { hash: string; summary: string; details: string }[] = [];\n for (const commit of commits) {\n commitSummaries.push({\n hash: commit.hash,\n summary: commit.message.slice(0, 60),\n details: '',\n });\n }\n\n return { title, description, commitSummaries };\n }\n\n private generateDefaultTitle(branchName: string): string {\n return branchName;\n }\n\n private extractContent(content: unknown): string {\n if (typeof content === 'string') return content;\n if (Array.isArray(content) && content.length > 0) {\n const first = content[0];\n if (typeof first === 'object' && first !== null && 'text' in first) {\n return String(first.text);\n }\n }\n return String(content);\n }\n\n private getPRTemplate(): string {\n if (this.prTemplateCache) {\n return this.prTemplateCache;\n }\n\n try {\n const fs = require('fs');\n const raw = fs.readFileSync(this.prTemplatePath, 'utf-8').trimEnd();\n this.prTemplateCache = this.normalizeTemplate(raw);\n return this.prTemplateCache;\n } catch {\n const fallback = this.buildDefaultTemplate();\n this.prTemplateCache = fallback;\n return this.prTemplateCache;\n }\n }\n\n private normalizeTemplate(raw: string): string {\n const trimmed = raw.trimEnd();\n if (trimmed.includes('Não se esqueça de revisar essa descrição')) {\n return trimmed;\n }\n return `${trimmed}\\n\\nNão se esqueça de revisar essa descrição`;\n }\n\n private buildDefaultTemplate(): string {\n return [\n '## 🚀 O que essa PR faz?',\n '',\n '## 🛠️ O que foi mexido?',\n '',\n '## 💡 O que eu fiz? (Resumo técnico)',\n '',\n '## 🧪 Como testar?',\n '',\n '## ✅ Checklist do Dev',\n '',\n '## 📸 Prints / GIFs (Se for UI)',\n '',\n '## 🔗 Link da Task',\n '',\n 'Não se esqueça de revisar essa descrição',\n ].join('\\n');\n }\n}\n"],"names":["PrGeneratorService","getCurrentBranch","execSync","cwd","process","encoding","trim","detectDefaultBaseBranch","candidates","branch","stdio","detectPlatform","remoteUrl","includes","platform","url","getCommitsNotInBase","baseBranch","logOutput","commits","lines","split","line","hash","message","author","date","filesOutput","files","filter","f","diffOutput","push","slice","diff","reverse","error","analyzeCommit","commit","llm","multiLlmService","createModel","prompt","buildCommitAnalysisPrompt","response","invoke","SystemMessage","getCommitAnalysisSystemPrompt","HumanMessage","content","extractContent","parseCommitAnalysis","generatePRDescription","branchName","buildSinglePrompt","getSingleAgentSystemPrompt","title","description","commitSummaries","parseSingleResponse","generateDefaultTitle","length","getPRTemplate","createPR","success","formatPRForClipboard","tempFile","Date","now","require","writeFileSync","result","replace","urlMatch","match","undefined","unlinkSync","copyToClipboard","text","JSON","stringify","getPRCreateUrl","httpsUrl","monorepoInfo","monorepoDetector","detectMonorepo","scope","determineScope","join","summaryMatch","detailsMatch","summary","details","parsePRDescription","titleMatch","indexOf","commitsInfo","map","c","i","template","requiredHeading","hasRequiredHeading","Array","isArray","first","String","prTemplateCache","fs","raw","readFileSync","prTemplatePath","trimEnd","normalizeTemplate","fallback","buildDefaultTemplate","trimmed"],"mappings":";;;;+BA8BaA;;;eAAAA;;;wBA9Bc;+BACF;0BACmB;iCACZ;yCACQ;;;;;;;;;;AA0BjC,IAAA,AAAMA,qBAAN,MAAMA;IASXC,mBAA2B;QACzB,IAAI;YACF,OAAOC,IAAAA,uBAAQ,EAAC,6BAA6B;gBAC3CC,KAAKC,QAAQD,GAAG;gBAChBE,UAAU;YACZ,GAAGC,IAAI;QACT,EAAE,OAAM;YACN,OAAO;QACT;IACF;IAEAC,0BAAkC;QAChC,IAAI;YACF,MAAMJ,MAAMC,QAAQD,GAAG;YACvB,MAAMK,aAAa;gBAAC;gBAAQ;gBAAU;aAAU;YAEhD,KAAK,MAAMC,UAAUD,WAAY;gBAC/B,IAAI;oB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