@g-abhishek/gitx 0.1.2 → 0.1.5

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 (165) hide show
  1. package/README.md +386 -3
  2. package/dist/ai/claudeAi.d.ts +35 -0
  3. package/dist/ai/claudeAi.d.ts.map +1 -0
  4. package/dist/ai/claudeAi.js +396 -0
  5. package/dist/ai/claudeAi.js.map +1 -0
  6. package/dist/ai/claudeCliAi.d.ts +27 -0
  7. package/dist/ai/claudeCliAi.d.ts.map +1 -0
  8. package/dist/ai/claudeCliAi.js +312 -0
  9. package/dist/ai/claudeCliAi.js.map +1 -0
  10. package/dist/ai/localClaudeAi.d.ts +2 -0
  11. package/dist/ai/localClaudeAi.d.ts.map +1 -0
  12. package/dist/ai/localClaudeAi.js +4 -0
  13. package/dist/ai/localClaudeAi.js.map +1 -0
  14. package/dist/ai/mockAi.d.ts +8 -1
  15. package/dist/ai/mockAi.d.ts.map +1 -1
  16. package/dist/ai/mockAi.js +57 -0
  17. package/dist/ai/mockAi.js.map +1 -1
  18. package/dist/ai/openAiAi.d.ts +33 -0
  19. package/dist/ai/openAiAi.d.ts.map +1 -0
  20. package/dist/ai/openAiAi.js +388 -0
  21. package/dist/ai/openAiAi.js.map +1 -0
  22. package/dist/ai/reviewHelpers.d.ts +66 -0
  23. package/dist/ai/reviewHelpers.d.ts.map +1 -0
  24. package/dist/ai/reviewHelpers.js +574 -0
  25. package/dist/ai/reviewHelpers.js.map +1 -0
  26. package/dist/ai/types.d.ts +247 -0
  27. package/dist/ai/types.d.ts.map +1 -1
  28. package/dist/ai/types.js.map +1 -1
  29. package/dist/cli/commands/ask.d.ts +27 -0
  30. package/dist/cli/commands/ask.d.ts.map +1 -0
  31. package/dist/cli/commands/ask.js +230 -0
  32. package/dist/cli/commands/ask.js.map +1 -0
  33. package/dist/cli/commands/commit.d.ts +16 -0
  34. package/dist/cli/commands/commit.d.ts.map +1 -0
  35. package/dist/cli/commands/commit.js +163 -0
  36. package/dist/cli/commands/commit.js.map +1 -0
  37. package/dist/cli/commands/config.d.ts +4 -0
  38. package/dist/cli/commands/config.d.ts.map +1 -0
  39. package/dist/cli/commands/config.js +666 -0
  40. package/dist/cli/commands/config.js.map +1 -0
  41. package/dist/cli/commands/implement.d.ts.map +1 -1
  42. package/dist/cli/commands/implement.js +149 -31
  43. package/dist/cli/commands/implement.js.map +1 -1
  44. package/dist/cli/commands/init.d.ts +4 -0
  45. package/dist/cli/commands/init.d.ts.map +1 -1
  46. package/dist/cli/commands/init.js +7 -69
  47. package/dist/cli/commands/init.js.map +1 -1
  48. package/dist/cli/commands/port.d.ts +32 -0
  49. package/dist/cli/commands/port.d.ts.map +1 -0
  50. package/dist/cli/commands/port.js +554 -0
  51. package/dist/cli/commands/port.js.map +1 -0
  52. package/dist/cli/commands/pr/close.d.ts +15 -0
  53. package/dist/cli/commands/pr/close.d.ts.map +1 -0
  54. package/dist/cli/commands/pr/close.js +71 -0
  55. package/dist/cli/commands/pr/close.js.map +1 -0
  56. package/dist/cli/commands/pr/create.d.ts +17 -0
  57. package/dist/cli/commands/pr/create.d.ts.map +1 -1
  58. package/dist/cli/commands/pr/create.js +208 -7
  59. package/dist/cli/commands/pr/create.js.map +1 -1
  60. package/dist/cli/commands/pr/fixComments.d.ts +5 -2
  61. package/dist/cli/commands/pr/fixComments.d.ts.map +1 -1
  62. package/dist/cli/commands/pr/fixComments.js +5 -13
  63. package/dist/cli/commands/pr/fixComments.js.map +1 -1
  64. package/dist/cli/commands/pr/index.d.ts.map +1 -1
  65. package/dist/cli/commands/pr/index.js +6 -2
  66. package/dist/cli/commands/pr/index.js.map +1 -1
  67. package/dist/cli/commands/pr/list.d.ts.map +1 -1
  68. package/dist/cli/commands/pr/list.js +24 -4
  69. package/dist/cli/commands/pr/list.js.map +1 -1
  70. package/dist/cli/commands/pr/merge.d.ts +23 -0
  71. package/dist/cli/commands/pr/merge.d.ts.map +1 -0
  72. package/dist/cli/commands/pr/merge.js +191 -0
  73. package/dist/cli/commands/pr/merge.js.map +1 -0
  74. package/dist/cli/commands/pr/resolve.d.ts +3 -0
  75. package/dist/cli/commands/pr/resolve.d.ts.map +1 -0
  76. package/dist/cli/commands/pr/resolve.js +92 -0
  77. package/dist/cli/commands/pr/resolve.js.map +1 -0
  78. package/dist/cli/commands/pr/review.d.ts.map +1 -1
  79. package/dist/cli/commands/pr/review.js +121 -6
  80. package/dist/cli/commands/pr/review.js.map +1 -1
  81. package/dist/cli/commands/push.d.ts +16 -0
  82. package/dist/cli/commands/push.d.ts.map +1 -0
  83. package/dist/cli/commands/push.js +166 -0
  84. package/dist/cli/commands/push.js.map +1 -0
  85. package/dist/cli/commands/sync.d.ts +24 -0
  86. package/dist/cli/commands/sync.d.ts.map +1 -0
  87. package/dist/cli/commands/sync.js +414 -0
  88. package/dist/cli/commands/sync.js.map +1 -0
  89. package/dist/cli/index.d.ts.map +1 -1
  90. package/dist/cli/index.js +34 -6
  91. package/dist/cli/index.js.map +1 -1
  92. package/dist/config/config.d.ts +20 -3
  93. package/dist/config/config.d.ts.map +1 -1
  94. package/dist/config/config.js +98 -45
  95. package/dist/config/config.js.map +1 -1
  96. package/dist/config/schema.d.ts.map +1 -1
  97. package/dist/config/schema.js +61 -6
  98. package/dist/config/schema.js.map +1 -1
  99. package/dist/core/context.d.ts +6 -0
  100. package/dist/core/context.d.ts.map +1 -1
  101. package/dist/core/context.js.map +1 -1
  102. package/dist/core/gitx.d.ts +43 -0
  103. package/dist/core/gitx.d.ts.map +1 -1
  104. package/dist/core/gitx.js +187 -20
  105. package/dist/core/gitx.js.map +1 -1
  106. package/dist/index.d.ts +1 -5
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +4 -1
  109. package/dist/index.js.map +1 -1
  110. package/dist/providers/azure.d.ts +26 -0
  111. package/dist/providers/azure.d.ts.map +1 -0
  112. package/dist/providers/azure.js +256 -0
  113. package/dist/providers/azure.js.map +1 -0
  114. package/dist/providers/base.d.ts +104 -0
  115. package/dist/providers/base.d.ts.map +1 -0
  116. package/dist/providers/base.js +5 -0
  117. package/dist/providers/base.js.map +1 -0
  118. package/dist/providers/factory.d.ts +8 -0
  119. package/dist/providers/factory.d.ts.map +1 -0
  120. package/dist/providers/factory.js +25 -0
  121. package/dist/providers/factory.js.map +1 -0
  122. package/dist/providers/github.d.ts +19 -0
  123. package/dist/providers/github.d.ts.map +1 -0
  124. package/dist/providers/github.js +291 -0
  125. package/dist/providers/github.js.map +1 -0
  126. package/dist/providers/gitlab.d.ts +19 -0
  127. package/dist/providers/gitlab.d.ts.map +1 -0
  128. package/dist/providers/gitlab.js +186 -0
  129. package/dist/providers/gitlab.js.map +1 -0
  130. package/dist/types/config.d.ts +50 -7
  131. package/dist/types/config.d.ts.map +1 -1
  132. package/dist/types/config.js.map +1 -1
  133. package/dist/utils/azureAuth.d.ts +51 -0
  134. package/dist/utils/azureAuth.d.ts.map +1 -0
  135. package/dist/utils/azureAuth.js +172 -0
  136. package/dist/utils/azureAuth.js.map +1 -0
  137. package/dist/utils/git.d.ts +19 -0
  138. package/dist/utils/git.d.ts.map +1 -1
  139. package/dist/utils/git.js +45 -8
  140. package/dist/utils/git.js.map +1 -1
  141. package/dist/utils/gitOps.d.ts +125 -0
  142. package/dist/utils/gitOps.d.ts.map +1 -0
  143. package/dist/utils/gitOps.js +396 -0
  144. package/dist/utils/gitOps.js.map +1 -0
  145. package/dist/utils/lockFile.d.ts +13 -0
  146. package/dist/utils/lockFile.d.ts.map +1 -0
  147. package/dist/utils/lockFile.js +54 -0
  148. package/dist/utils/lockFile.js.map +1 -0
  149. package/dist/utils/retry.d.ts +10 -0
  150. package/dist/utils/retry.d.ts.map +1 -0
  151. package/dist/utils/retry.js +31 -0
  152. package/dist/utils/retry.js.map +1 -0
  153. package/dist/workflows/implement.d.ts +41 -0
  154. package/dist/workflows/implement.d.ts.map +1 -0
  155. package/dist/workflows/implement.js +219 -0
  156. package/dist/workflows/implement.js.map +1 -0
  157. package/dist/workflows/pr.d.ts +41 -0
  158. package/dist/workflows/pr.d.ts.map +1 -0
  159. package/dist/workflows/pr.js +291 -0
  160. package/dist/workflows/pr.js.map +1 -0
  161. package/dist/workflows/prAddress.d.ts +55 -0
  162. package/dist/workflows/prAddress.d.ts.map +1 -0
  163. package/dist/workflows/prAddress.js +349 -0
  164. package/dist/workflows/prAddress.js.map +1 -0
  165. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reviewHelpers.js","sourceRoot":"","sources":["../../src/ai/reviewHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,iFAAiF;AAEjF,MAAM,UAAU,uBAAuB;IACrC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsCP,CAAC;AACH,CAAC;AAED,iFAAiF;AAEjF;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,IAAY;IACnC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiD,CAAC;IACxE,IAAI,WAAW,GAAG,EAAE,CAAC;IAErB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAChD,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,WAAW,EAAE,CAAC;YACnD,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC;gBAAE,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAC1D,SAAS;QACX,CAAC;QAED,8BAA8B;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACxE,IAAI,SAAS,IAAI,WAAW,EAAE,CAAC;YAC7B,MAAM,KAAK,G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gB,CAAC,GAAW;IAC1C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAA2B,CAAC;QACzD,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,IAAI,EAAE;YAC3C,iBAAiB,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC;gBACxD,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC;gBAC5E,CAAC,CAAC,EAAE;SACP,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,iEAAiE;QACjE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,CAAC;IACvD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Shared helpers for the senior-developer PR review.\n *\n * buildSeniorReviewSystem() — the AI system prompt\n * buildSeniorReviewPrompt() — formats the user-facing context block\n * parseSeniorReview() — safely parses the AI JSON response\n */\n\nimport type { AiAskContext, AiAskResponse, AiDetailedReviewResponse, AiFixResponse } from \"./types.js\";\n\n// ─── System prompt ────────────────────────────────────────────────────────────\n\nexport function buildSeniorReviewSystem(): string {\n return `You are a principal software engineer and tech lead doing a thorough pull request review.\nYou have access to the CHANGED SECTIONS of each file (extracted around the exact lines that changed),\nplus supporting context files and the full unified diff.\n\nYour review MUST cover every one of these dimensions:\n 1. Correctness — logic errors, off-by-one, wrong conditions, silent failures\n 2. Security — injection, auth bypass, secret leakage, unvalidated input\n 3. Robustness — missing error handling, null/undefined guard, edge cases\n 4. Performance — unnecessary loops, N+1 queries, missing caching\n 5. Breaking changes — does this break existing API contracts, interfaces, or callers?\n 6. Best practices — naming, DRY, SOLID, idiomatic language usage\n 7. Test coverage — are critical paths tested? are tests meaningful?\n 8. Documentation — are public APIs documented? are complex sections explained?\n\nFor EVERY issue that maps to a specific line, add an inline comment.\nLine numbers shown in the excerpts are the REAL line numbers in the new file — use them exactly.\nOnly reference lines that appear in the excerpts you were given.\n\nVerdict rules:\n - \"approve\" → no critical or warning issues\n - \"request_changes\" → one or more critical/warning issues found\n - \"comment\" → only suggestions / minor observations\n\nRespond with ONLY valid JSON (no markdown fences, no prose outside JSON):\n{\n \"summary\": \"<3-5 sentence executive summary>\",\n \"verdict\": \"approve|request_changes|comment\",\n \"issues\": [\n { \"severity\": \"critical|warning|suggestion\", \"description\": \"<issue>\", \"file\": \"<path or null>\", \"line\": <number or null> }\n ],\n \"inlineComments\": [\n { \"path\": \"<relative file path>\", \"line\": <line number>, \"body\": \"<markdown comment>\", \"severity\": \"critical|warning|suggestion\", \"suggestion\": \"<replacement code or null>\" }\n ],\n \"positives\": [\"<good thing>\"],\n \"testingNotes\": \"<how to manually test>\",\n \"checklist\": [\n { \"area\": \"<Correctness|Security|Robustness|Performance|Breaking changes|Best practices|Tests|Documentation>\", \"status\": \"pass|warn|fail\", \"note\": \"<one sentence>\" }\n ]\n}`;\n}\n\n// ─── Diff parsing ─────────────────────────────────────────────────────────────\n\n/**\n * Parse a unified diff and return the NEW-file line ranges that were touched,\n * grouped by file path.\n *\n * A diff hunk header looks like: @@ -10,7 +12,8 @@\n * +12,8 → new file starts at line 12, hunk spans 8 lines\n */\nfunction parseHunkRanges(diff: string): Map<string, Array<{ start: number; end: number }>> {\n const result = new Map<string, Array<{ start: number; end: number }>>();\n let currentFile = \"\";\n\n for (const line of diff.split(\"\\n\")) {\n const fileMatch = line.match(/^\\+\\+\\+ b\\/(.+)/);\n if (fileMatch?.[1] && fileMatch[1] !== \"/dev/null\") {\n currentFile = fileMatch[1].trim();\n if (!result.has(currentFile)) result.set(currentFile, []);\n continue;\n }\n\n // @@ -old,count +new,count @@\n const hunkMatch = line.match(/^@@ -\\d+(?:,\\d+)? \\+(\\d+)(?:,(\\d+))? @@/);\n if (hunkMatch && currentFile) {\n const start = parseInt(hunkMatch[1]!, 10);\n const count = parseInt(hunkMatch[2] ?? \"1\", 10);\n result.get(currentFile)!.push({ start, end: start + Math.max(count - 1, 0) });\n }\n }\n\n return result;\n}\n\n/**\n * Scan BACKWARD from `fromLine` (1-based) to find where the containing\n * function / class / method starts.\n *\n * Recognises common declaration patterns for TypeScript, JavaScript, Python,\n * Go, Rust, Java, and C#. Falls back to `fromLine - fallback` if nothing\n * is found within `maxScan` lines.\n */\nfunction findContainerStart(\n lines: string[],\n fromLine: number,\n maxScan = 80,\n fallback = 30\n): number {\n // fromLine is 1-based; lines[] is 0-based\n const startIdx = Math.min(lines.length - 1, Math.max(0, fromLine - 2));\n\n for (let i = startIdx; i >= Math.max(0, startIdx - maxScan); i--) {\n const line = lines[i] ?? \"\";\n if (\n // TS/JS: export [default] [abstract] [async] function foo(\n /^\\s*(export\\s+)?(default\\s+)?(abstract\\s+)?(async\\s+)?function[\\s*]/.test(line) ||\n // TS/JS: export [abstract] class Foo\n /^\\s*(export\\s+)?(abstract\\s+)?class\\s+\\w/.test(line) ||\n // TS/JS class methods: [public|private|protected|static|override|async] methodName(\n /^\\s*(public|private|protected|static|override|async)(\\s+(public|private|protected|static|override|async))*\\s+\\w+\\s*[(<]/.test(line) ||\n // TS/JS arrow function assigned to const/let/var\n /^\\s*(export\\s+)?(const|let|var)\\s+\\w+\\s*=\\s*(async\\s+)?\\(/.test(line) ||\n // TS/JS shorthand method (no keyword): methodName(args) {\n /^\\s*\\w+\\s*\\([^)]*\\)\\s*(?::\\s*\\S+\\s*)?\\{/.test(line) ||\n // Python: def foo(\n /^\\s*def\\s+\\w+\\s*\\(/.test(line) ||\n // Go: func (recv) Foo(\n /^\\s*func\\s+/.test(line) ||\n // Rust: fn foo(\n /^\\s*(pub\\s+)?(async\\s+)?fn\\s+\\w+/.test(line) ||\n // Java/C#: returnType methodName(\n /^\\s*(public|private|protected|internal|static|virtual|override)\\s+\\S+\\s+\\w+\\s*\\(/.test(line)\n ) {\n return i + 1; // convert back to 1-based\n }\n }\n\n // Nothing found — fall back to a fixed number of lines above\n return Math.max(1, fromLine - fallback);\n}\n\n/**\n * Extract the sections of a file that were changed, always starting each\n * window at the nearest enclosing function/class boundary (or 30 lines up,\n * whichever is closer).\n *\n * Overlapping windows are merged so the same lines aren't shown twice.\n * The first HEADER_LINES of the file are always prepended (imports, class\n * declarations) so the AI understands module structure.\n *\n * Returns a line-numbered string ready to paste into the prompt.\n */\nfunction extractChangedSections(\n fileContent: string,\n hunks: Array<{ start: number; end: number }>,\n contextLinesBelow = 20 // lines below the hunk (above uses function-boundary scan)\n): string {\n const lines = fileContent.split(\"\\n\");\n const total = lines.length;\n\n // Always include file header (imports / module preamble) for structural context\n const HEADER_LINES = 20;\n\n // Build windows: above = scan to function start, below = fixed context\n const windows: Array<{ start: number; end: number }> = [];\n for (const hunk of hunks) {\n const windowStart = findContainerStart(lines, hunk.start);\n windows.push({\n start: windowStart,\n end: Math.min(total, hunk.end + contextLinesBelow),\n });\n }\n // Sort then merge\n windows.sort((a, b) => a.start - b.start);\n const merged: Array<{ start: number; end: number }> = [];\n for (const w of windows) {\n if (merged.length > 0 && w.start <= merged[merged.length - 1]!.end + 1) {\n merged[merged.length - 1]!.end = Math.max(merged[merged.length - 1]!.end, w.end);\n } else {\n merged.push({ ...w });\n }\n }\n\n const formatRange = (start: number, end: number): string =>\n lines\n .slice(start - 1, end)\n .map((l, i) => `${String(start + i).padStart(5, \" \")} | ${l}`)\n .join(\"\\n\");\n\n const sections: string[] = [];\n\n // File header (always included, unless the first window already covers it)\n const firstWindowStart = merged[0]?.start ?? 1;\n if (firstWindowStart > HEADER_LINES + 1) {\n sections.push(formatRange(1, Math.min(HEADER_LINES, total)));\n sections.push(\" … (lines omitted) …\");\n }\n\n for (let i = 0; i < merged.length; i++) {\n const { start, end } = merged[i]!;\n if (i > 0 && start > (merged[i - 1]!.end + 1)) {\n sections.push(\" … (lines omitted) …\");\n }\n sections.push(formatRange(start, end));\n }\n\n return sections.join(\"\\n\");\n}\n\n// ─── User prompt builder ──────────────────────────────────────────────────────\n\nexport function buildSeniorReviewPrompt(\n context: {\n prTitle: string;\n prBody: string;\n author: string;\n headBranch: string;\n baseBranch: string;\n diff: string;\n changedFiles: Record<string, string>;\n contextFiles: Record<string, string>;\n repoFileList: string[];\n existingComments: Array<{ author: string; body: string; path?: string; line?: number }>;\n }\n): string {\n const parts: string[] = [];\n\n parts.push(`## PR: ${context.prTitle}`);\n parts.push(`Author: ${context.author} | ${context.headBranch} → ${context.baseBranch}`);\n if (context.prBody.trim()) {\n parts.push(`\\n### Description\\n${context.prBody.slice(0, 1000)}`);\n }\n\n // ── Parse which lines actually changed per file ───────────────────────────\n const hunkRanges = parseHunkRanges(context.diff);\n\n // ── Budget constants ──────────────────────────────────────────────────────\n // Claude has a 200k-token context window. We stay well within that while\n // sending enough code for a thorough review.\n //\n // Strategy:\n // • Files ≤ FULL_FILE_THRESHOLD lines → send the ENTIRE file (best context)\n // • Larger files → smart section extraction around hunks\n // with generous context above (function boundary) and below (CONTEXT_LINES_BELOW)\n // • Hard per-file cap for huge files → PER_FILE_LINE_CAP lines of excerpts\n const FULL_FILE_THRESHOLD = 400; // files ≤ this many lines are sent whole\n const CONTEXT_LINES_BELOW = 60; // lines below each hunk in extraction mode\n const PER_FILE_LINE_CAP = 800; // hard cap on excerpt lines for very large files\n const DIFF_BUDGET = 30_000; // unified diff character budget (was 5k — way too small)\n const CTX_FILE_MAX = 4_000; // max chars per supporting context file (was 1.5k)\n\n const changedEntries = Object.entries(context.changedFiles);\n if (changedEntries.length > 0) {\n parts.push(`\\n### Changed files (line numbers are exact positions in the new file)`);\n\n for (const [path, content] of changedEntries) {\n const fileLines = content.split(\"\\n\");\n const hunks = hunkRanges.get(path) ?? [];\n\n let excerpt: string;\n let deliveryNote: string;\n\n if (fileLines.length <= FULL_FILE_THRESHOLD) {\n // Small file — send the whole thing. The AI gets complete context with no gaps.\n excerpt = fileLines\n .map((l, i) => `${String(i + 1).padStart(5, \" \")} | ${l}`)\n .join(\"\\n\");\n deliveryNote = `full file, ${fileLines.length} lines`;\n } else if (hunks.length === 0) {\n // No hunk data (binary / rename-only) — show first 100 lines as fallback\n excerpt = fileLines\n .slice(0, 100)\n .map((l, i) => `${String(i + 1).padStart(5, \" \")} | ${l}`)\n .join(\"\\n\");\n if (fileLines.length > 100)\n excerpt += `\\n … (file continues — only first 100 lines shown; no hunk data available)`;\n deliveryNote = `first 100 of ${fileLines.length} lines (no hunk data)`;\n } else {\n // Large file — extract sections around changed hunks with generous context\n excerpt = extractChangedSections(content, hunks, CONTEXT_LINES_BELOW);\n\n // Cap at PER_FILE_LINE_CAP complete lines — never mid-line\n const excerptLines = excerpt.split(\"\\n\");\n if (excerptLines.length > PER_FILE_LINE_CAP) {\n excerpt =\n excerptLines.slice(0, PER_FILE_LINE_CAP).join(\"\\n\") +\n `\\n … (${excerptLines.length - PER_FILE_LINE_CAP} more excerpt lines omitted` +\n ` — file has ${fileLines.length} total lines; see the diff below for full change)`;\n }\n deliveryNote = `${hunks.length} hunk${hunks.length > 1 ? \"s\" : \"\"}, ${fileLines.length} total lines`;\n }\n\n parts.push(`\\n#### ${path} (${deliveryNote})\\n\\`\\`\\`\\n${excerpt}\\n\\`\\`\\``);\n }\n }\n\n // ── Unified diff (the raw patch — gives the AI the exact before/after for every line)\n if (context.diff.trim()) {\n const diffSlice = context.diff.slice(0, DIFF_BUDGET);\n const diffTrunc = diffSlice.length < context.diff.length;\n parts.push(\n `\\n### Unified diff${diffTrunc ? ` (truncated to ${DIFF_BUDGET} chars — see file sections above for full content)` : \"\"}\\n\\`\\`\\`diff\\n${diffSlice}\\n\\`\\`\\``\n );\n }\n\n // ── Supporting context files (unchanged files the changes depend on) ──────\n const ctxEntries = Object.entries(context.contextFiles);\n if (ctxEntries.length > 0) {\n parts.push(`\\n### Supporting context files (unchanged — imported by changed files)`);\n for (const [path, content] of ctxEntries) {\n const ctxLines = content.split(\"\\n\");\n const ctxExcerpt = content.length <= CTX_FILE_MAX\n ? content\n : content.slice(0, CTX_FILE_MAX) + `\\n… (truncated — ${ctxLines.length} total lines)`;\n parts.push(`\\n#### ${path}\\n\\`\\`\\`\\n${ctxExcerpt}\\n\\`\\`\\``);\n }\n }\n\n // ── Existing PR comments ──────────────────────────────────────────────────\n if (context.existingComments.length > 0) {\n parts.push(`\\n### Existing review comments`);\n for (const c of context.existingComments.slice(0, 6)) {\n const loc = c.path ? ` (${c.path}${c.line ? `:${c.line}` : \"\"})` : \"\";\n parts.push(`- **${c.author}**${loc}: ${c.body.slice(0, 150)}`);\n }\n }\n\n // ── Repo file tree (structural awareness) ────────────────────────────────\n if (context.repoFileList.length > 0) {\n parts.push(`\\n### Repository file tree (top 60 files)\\n${context.repoFileList.slice(0, 60).join(\"\\n\")}`);\n }\n\n return parts.join(\"\\n\");\n}\n\n// ─── Response parser ──────────────────────────────────────────────────────────\n\nexport function parseSeniorReview(text: string): AiDetailedReviewResponse {\n let parsed: Partial<AiDetailedReviewResponse> = {};\n try {\n const fenced = text.match(/```(?:json)?\\s*([\\s\\S]*?)```/);\n const raw = fenced?.[1]?.trim() ?? text.trim();\n const start = raw.search(/\\{/);\n const end = raw.lastIndexOf(\"}\");\n const jsonStr = start !== -1 && end > start ? raw.slice(start, end + 1) : raw;\n parsed = JSON.parse(jsonStr) as Partial<AiDetailedReviewResponse>;\n } catch {\n return {\n summary: \"AI review could not be parsed. Please inspect the diff manually.\",\n verdict: \"comment\",\n issues: [],\n inlineComments: [],\n positives: [],\n testingNotes: \"Test the changed functionality manually.\",\n checklist: [],\n };\n }\n\n return {\n summary: parsed.summary ?? \"Review generated.\",\n verdict: ([\"approve\", \"request_changes\", \"comment\"].includes(parsed.verdict ?? \"\"))\n ? (parsed.verdict as AiDetailedReviewResponse[\"verdict\"])\n : \"comment\",\n issues: Array.isArray(parsed.issues) ? parsed.issues : [],\n inlineComments: Array.isArray(parsed.inlineComments)\n ? parsed.inlineComments.filter((c) => c.path && c.line > 0)\n : [],\n positives: Array.isArray(parsed.positives) ? parsed.positives : [],\n testingNotes: parsed.testingNotes ?? \"\",\n checklist: Array.isArray(parsed.checklist) ? parsed.checklist : [],\n };\n}\n\n// ─── Fix generation helpers ───────────────────────────────────────────────────\n\n/**\n * System prompt for the AI fix generator.\n * Instructs the model to produce a minimal, targeted line-range replacement.\n */\nexport function buildFixSystem(): string {\n return `You are a senior developer addressing a pull request review comment.\nYour job is to generate the MINIMAL code change that addresses the reviewer's concern.\n\nRules:\n- Change as few lines as possible — do not refactor surrounding code\n- Preserve the existing indentation style exactly\n- If the comment is a question or discussion (no code change needed), set isDiscussion: true\n- If you are unsure of the correct fix, set confidence: \"low\"\n- startLine and endLine are 1-based, inclusive line numbers in the CURRENT file\n\nRespond with ONLY valid JSON (no markdown fences, no prose outside JSON):\n{\n \"file\": \"<relative file path>\",\n \"startLine\": <1-based line where replacement starts>,\n \"endLine\": <1-based line where replacement ends, inclusive>,\n \"replacement\": \"<new code lines, newline-separated, preserving indentation>\",\n \"explanation\": \"<one sentence: what you changed and why>\",\n \"confidence\": \"high|low\",\n \"resolves\": true|false,\n \"isDiscussion\": true|false\n}`;\n}\n\n/**\n * Build the user prompt for a single fix request.\n * Includes the comment, file content with line numbers, and the relevant diff.\n */\nexport function buildFixPrompt(ctx: {\n comment: string;\n commentAuthor: string;\n filePath: string;\n line: number;\n fileContent: string;\n fileDiff: string;\n}): string {\n const lines = ctx.fileContent.split(\"\\n\");\n\n // Show a window of ±30 lines around the commented line (with real line numbers)\n const windowStart = Math.max(1, ctx.line - 30);\n const windowEnd = Math.min(lines.length, ctx.line + 30);\n const excerpt = lines\n .slice(windowStart - 1, windowEnd)\n .map((l, i) => `${String(windowStart + i).padStart(4, \" \")} | ${l}`)\n .join(\"\\n\");\n\n const diffSection = ctx.fileDiff.length > 3000\n ? ctx.fileDiff.slice(0, 3000) + \"\\n... (diff truncated)\"\n : ctx.fileDiff;\n\n return `## Review Comment\nAuthor: ${ctx.commentAuthor}\nFile: ${ctx.filePath} · Line: ${ctx.line}\n\n> ${ctx.comment.replace(/\\n/g, \"\\n> \")}\n\n## File Context (lines ${windowStart}–${windowEnd} of ${lines.length})\n\\`\\`\\`\n${excerpt}\n\\`\\`\\`\n\n## Diff for this file\n\\`\\`\\`diff\n${diffSection}\n\\`\\`\\`\n\nGenerate the fix JSON now.`;\n}\n\n/**\n * Safely parse the AI response for a fix request.\n * Returns a safe fallback (isDiscussion + low confidence) on parse failure.\n */\nexport function parseFixResponse(text: string, filePath: string, line: number): AiFixResponse {\n try {\n const jsonMatch = text.match(/\\{[\\s\\S]*\\}/);\n if (!jsonMatch) throw new Error(\"no JSON found\");\n const parsed = JSON.parse(jsonMatch[0]) as Partial<AiFixResponse>;\n\n if (parsed.isDiscussion) {\n return {\n file: parsed.file ?? filePath,\n startLine: line,\n endLine: line,\n replacement: \"\",\n explanation: parsed.explanation ?? \"This comment is a discussion — no code change needed.\",\n confidence: \"low\",\n resolves: parsed.resolves ?? false,\n isDiscussion: true,\n };\n }\n\n // Validate required fields; fall back to low confidence if anything is off\n const hasReplacement = typeof parsed.replacement === \"string\";\n const hasLines = typeof parsed.startLine === \"number\" && typeof parsed.endLine === \"number\";\n if (!hasReplacement || !hasLines) {\n throw new Error(\"missing required fields\");\n }\n\n return {\n file: parsed.file ?? filePath,\n startLine: parsed.startLine!,\n endLine: parsed.endLine!,\n replacement: parsed.replacement!,\n explanation: parsed.explanation ?? \"AI-generated fix.\",\n confidence: parsed.confidence === \"high\" ? \"high\" : \"low\",\n resolves: parsed.resolves ?? false,\n isDiscussion: false,\n };\n } catch {\n return {\n file: filePath,\n startLine: line,\n endLine: line,\n replacement: \"\",\n explanation: \"AI could not generate a fix for this comment.\",\n confidence: \"low\",\n resolves: false,\n isDiscussion: true, // treat parse failure as discussion → no code change\n };\n }\n}\n\n// ─── Ask command helpers ───────────────────────────────────────────────────────\n\n/** Command reference embedded into the ask system prompt. */\nconst GITX_COMMAND_REFERENCE = `\n## gitx Command Reference\n\n| Command | Description |\n|---------|-------------|\n| gitx init / gitx config setup | Interactive setup wizard — configure git & AI providers |\n| gitx config show | Display current configuration (secrets redacted) |\n| gitx config set <key> [value] | Set a single config value (provider, token, model, etc.) |\n| gitx commit [-m msg] [--push] [--dry-run] | AI-generate commit message → commit (optionally push) |\n| gitx push [-b branch] [--staged] [--dry-run] | Stage → AI-commit → push in one step; --staged uses already-staged files only |\n| gitx sync [--base branch] [--strategy merge|rebase] [--continue] [--abort] | Sync current branch with base; AI resolves conflicts |\n| gitx port <target…> [--base branch] [--no-pr] [--draft] [--continue] [--abort] | Cherry-pick commits onto other branches with incremental detection |\n| gitx implement \"<task>\" [--mode plan|guided|semi-auto|auto] [--dry-run] | AI-plan and implement a task end-to-end |\n| gitx pr list [--state open|closed|all] | List pull requests |\n| gitx pr create [--title T] [--body B] [--draft] [--dry-run] | AI-generate PR title/body → open PR |\n| gitx pr review <number> [--no-comment] [--inline] | Senior-dev AI review — posts inline comments to the PR |\n| gitx pr resolve <number> [--no-commit] [--no-push] [--dry-run] | AI-fix review comments in code; --no-commit applies fixes without committing |\n| gitx pr merge <number> [--strategy squash|merge|rebase] [--delete-branch] | Merge a PR |\n| gitx pr close <number> [-f] | Close a PR |\n| gitx ask \"<question>\" [--pr] | Ask a question about the repo using AI + live git context |\n\n## Supported Providers\n- Git hosts: GitHub, GitLab, Azure DevOps\n- AI backends: Anthropic Claude (API), OpenAI, Local Claude CLI\n\n## Environment Variables\n- ANTHROPIC_API_KEY — Anthropic API key (auto-selects Claude as AI provider)\n- OPENAI_API_KEY — OpenAI API key\n- GITX_AI_MODEL — Override the AI model name\n- GITX_DEBUG=1 — Print full stack traces on errors\n`.trim();\n\n/**\n * Builds the system prompt for `gitx ask`.\n * Includes the full command reference and setup guidance so the AI can answer\n * both \"how do I…\" questions and \"is X configured?\" diagnostics.\n */\nexport function buildAskSystem(): string {\n return `You are gitx-assistant, a smart support assistant embedded in the gitx CLI.\nYou help users with three types of questions:\n\n1. SETUP / DIAGNOSTIC — \"is my AI provider set up?\", \"why isn't gitx working?\", \"what provider am I using?\"\n → Use the GITX SETUP STATUS section in the context. Give a clear yes/no diagnostic and actionable fix steps.\n\n2. REPO STATE — \"what did I last commit?\", \"do I have unstaged changes?\", \"show me open PRs\"\n → Use the LIVE REPO CONTEXT section in the context.\n\n3. HOW-TO — \"how do I sync with main?\", \"how do I undo a commit?\", \"how do I create a PR?\"\n → Use the GITX COMMAND REFERENCE below. Show the exact command.\n\n${GITX_COMMAND_REFERENCE}\n\n## Setup Fix Guide (use when AI or provider is not configured)\n- No AI provider → Run: gitx config setup (or set ANTHROPIC_API_KEY / OPENAI_API_KEY env var)\n- AI provider configured in config but not working → Run: gitx config show to inspect; re-run gitx config set <provider>\n- No git provider token → Run: gitx config set github (or gitlab / azure)\n- Not inside a git repo → cd into your project folder first\n\nRules:\n- Answer concisely and accurately. Get to the point immediately.\n- For setup/diagnostic questions: state clearly whether it IS or IS NOT configured, then explain WHY and how to fix it.\n- Never fabricate details — only use what is in the provided context.\n- Format your answer in plain text. Use a code block only for commands or file paths.\n- When suggesting commands, put them in suggestedCommands so they render highlighted.\n\nRespond with ONLY valid JSON (no markdown fences):\n{\"answer\":\"<answer text>\",\"suggestedCommands\":[\"<cmd1>\",\"<cmd2>\"]}\n\nThe suggestedCommands array may be empty [] if no command applies.`;\n}\n\n/**\n * Builds the user-turn prompt for `gitx ask`, injecting live repo context\n * and the full gitx setup status so the AI can answer diagnostic questions accurately.\n */\nexport function buildAskPrompt(question: string, ctx: AiAskContext): string {\n const lines: string[] = [];\n\n // ── Section 1: gitx setup status ──────────────────────────────────────────\n lines.push(`## gitx Setup Status`);\n\n // AI provider\n const ai = ctx.aiSetup;\n lines.push(`- AI provider: ${ai.provider}`);\n lines.push(`- AI configured: ${ai.isConfigured ? \"YES\" : \"NO — not configured\"}`);\n if (ai.model) lines.push(`- AI model: ${ai.model}`);\n lines.push(`- AI key source: ${ai.keySource}`);\n\n // Git providers\n if (ctx.gitProviders.length > 0) {\n lines.push(`- Git providers configured:`);\n ctx.gitProviders.forEach((p) => {\n const tokenStatus = p.hasToken ? \"token ✓\" : \"token MISSING\";\n lines.push(` ${p.name}: ${tokenStatus}`);\n });\n } else {\n lines.push(`- Git providers configured: none`);\n }\n\n if (ctx.defaultBranch) {\n lines.push(`- Default base branch: ${ctx.defaultBranch}`);\n }\n\n // ── Section 2: live repo context ──────────────────────────────────────────\n lines.push(``);\n lines.push(`## Live Repo Context`);\n lines.push(`- Inside git repo: ${ctx.isInsideGitRepo ? \"YES\" : \"NO\"}`);\n\n if (ctx.isInsideGitRepo) {\n lines.push(`- Current branch: ${ctx.currentBranch}`);\n\n if (ctx.recentCommits.length > 0) {\n lines.push(`- Recent commits (newest first):`);\n ctx.recentCommits.forEach((c) => lines.push(` ${c}`));\n } else {\n lines.push(`- Recent commits: (none yet)`);\n }\n\n if (ctx.gitStatus.trim()) {\n lines.push(`- Working tree status:\\n${ctx.gitStatus}`);\n } else {\n lines.push(`- Working tree status: clean`);\n }\n\n if (ctx.stashes && ctx.stashes.length > 0) {\n lines.push(`- Stashes:`);\n ctx.stashes.forEach((s) => lines.push(` ${s}`));\n }\n\n if (ctx.openPRs && ctx.openPRs.length > 0) {\n lines.push(`- Open PRs:`);\n ctx.openPRs.forEach((pr) =>\n lines.push(` #${pr.number} [${pr.state}] \"${pr.title}\" (branch: ${pr.branch})`)\n );\n }\n }\n\n // ── Section 3: question ───────────────────────────────────────────────────\n lines.push(``);\n lines.push(`## Question`);\n lines.push(question);\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Safely parses the AI JSON response for `gitx ask`.\n * Falls back to using the raw text as the answer if JSON parsing fails.\n */\nexport function parseAskResponse(raw: string): AiAskResponse {\n try {\n const parsed = JSON.parse(raw) as Partial<AiAskResponse>;\n return {\n answer: parsed.answer?.trim() ?? raw.trim(),\n suggestedCommands: Array.isArray(parsed.suggestedCommands)\n ? parsed.suggestedCommands.filter((c): c is string => typeof c === \"string\")\n : [],\n };\n } catch {\n // If the AI returned plain text instead of JSON, use it directly\n return { answer: raw.trim(), suggestedCommands: [] };\n }\n}\n"]}
@@ -34,11 +34,258 @@ export interface AiSuggestFixesResponse {
34
34
  unifiedDiff: string;
35
35
  }>;
36
36
  }
37
+ export interface AiCommitMessageResponse {
38
+ /** Full conventional commit subject line, e.g. "feat(auth): add OAuth2 login flow" */
39
+ subject: string;
40
+ /** Optional multi-line body explaining WHY the change was made */
41
+ body?: string;
42
+ }
43
+ export interface AiPrContentResponse {
44
+ /** Short, human-readable PR title (not necessarily conventional-commit format) */
45
+ title: string;
46
+ /** Multi-paragraph PR description: what changed, why, how to test */
47
+ body: string;
48
+ }
49
+ export interface AiConflictResolutionResponse {
50
+ /** The full file content with ALL conflict markers removed and conflicts resolved. */
51
+ resolved: string;
52
+ /**
53
+ * "high" → AI is confident both sides are fully reconciled — safe to auto-apply.
54
+ * "low" → Changes are contradictory or ambiguous — show to user for confirmation.
55
+ */
56
+ confidence: "high" | "low";
57
+ /** One-sentence explanation of what the AI did (shown to the user). */
58
+ explanation: string;
59
+ }
60
+ /**
61
+ * AI-generated fix for a single PR review comment.
62
+ * Targets a specific line range in a file with a minimal replacement.
63
+ */
64
+ export interface AiFixResponse {
65
+ /** Relative path to the file that needs to change */
66
+ file: string;
67
+ /** 1-based line number where the replacement starts */
68
+ startLine: number;
69
+ /** 1-based line number where the replacement ends (inclusive) */
70
+ endLine: number;
71
+ /**
72
+ * The new code to replace lines startLine–endLine with.
73
+ * Must preserve surrounding indentation style.
74
+ */
75
+ replacement: string;
76
+ /** One-sentence explanation shown to the user */
77
+ explanation: string;
78
+ /**
79
+ * "high" → safe to auto-apply without confirmation.
80
+ * "low" → show diff and ask user before applying.
81
+ */
82
+ confidence: "high" | "low";
83
+ /** Does this fix fully resolve the comment (vs partially)? */
84
+ resolves: boolean;
85
+ /**
86
+ * true when the comment is a question / discussion with no code change needed.
87
+ * In this case startLine/endLine/replacement are empty and should be ignored.
88
+ */
89
+ isDiscussion: boolean;
90
+ }
91
+ /**
92
+ * Diagnostic snapshot of which AI provider is active and how it was resolved.
93
+ * Keys are never included — only whether they are present.
94
+ */
95
+ export interface AiSetupStatus {
96
+ /**
97
+ * Human-readable provider name, e.g. "claude (Anthropic API)", "openai", "claude-cli (local)", "none".
98
+ * "none" means no provider is configured and MockAi will be used.
99
+ */
100
+ provider: string;
101
+ /** Model in use, if applicable (e.g. "claude-3-5-haiku-20241022", "gpt-4o") */
102
+ model?: string;
103
+ /**
104
+ * Where the key / credential came from:
105
+ * "ANTHROPIC_API_KEY env var" | "OPENAI_API_KEY env var" | "config file" | "local CLI" | "none"
106
+ */
107
+ keySource: string;
108
+ /** true when at least one real AI provider is available */
109
+ isConfigured: boolean;
110
+ }
111
+ /**
112
+ * Status of a single configured git hosting provider.
113
+ * The actual token value is never included.
114
+ */
115
+ export interface GitProviderStatus {
116
+ /** "github" | "gitlab" | "azure" */
117
+ name: string;
118
+ /** true when a non-empty token exists for this provider */
119
+ hasToken: boolean;
120
+ }
121
+ /**
122
+ * Live repo context gathered by `gitx ask` and injected into the AI prompt.
123
+ * All fields are optional so partial context still produces useful answers.
124
+ */
125
+ export interface AiAskContext {
126
+ /** Whether the CWD is inside a git repository */
127
+ isInsideGitRepo: boolean;
128
+ /** Current checked-out branch name (only meaningful when isInsideGitRepo is true) */
129
+ currentBranch: string;
130
+ /** Last 10 commits as one-line summaries (hash + subject) */
131
+ recentCommits: string[];
132
+ /** Output of `git status --short` */
133
+ gitStatus: string;
134
+ /** Open pull requests from the remote provider */
135
+ openPRs?: Array<{
136
+ number: number;
137
+ title: string;
138
+ state: string;
139
+ branch: string;
140
+ }>;
141
+ /** Stash entries (e.g. "stash@{0}: WIP on feat/x: abc1234 msg") */
142
+ stashes?: string[];
143
+ /** Detailed status of the active AI provider */
144
+ aiSetup: AiSetupStatus;
145
+ /** All configured git hosting providers (github / gitlab / azure) */
146
+ gitProviders: GitProviderStatus[];
147
+ /** The configured default base branch, if any */
148
+ defaultBranch?: string;
149
+ }
150
+ /** Response returned by `AiClient.ask()` for the `gitx ask` command. */
151
+ export interface AiAskResponse {
152
+ /** Full answer in plain text or markdown */
153
+ answer: string;
154
+ /**
155
+ * Concrete gitx (or git) commands the user can run to act on the answer.
156
+ * Omit when not applicable.
157
+ */
158
+ suggestedCommands?: string[];
159
+ }
37
160
  export interface AiClient {
38
161
  analyzeTask(input: string): Promise<AiAnalyzeTaskResponse>;
39
162
  generatePlan(context: unknown): Promise<AiGeneratePlanResponse>;
40
163
  generateDiffs(step: unknown): Promise<AiGenerateDiffsResponse>;
41
164
  summarizeChanges(diff: unknown): Promise<AiSummarizeChangesResponse>;
42
165
  suggestFixes(comment: unknown): Promise<AiSuggestFixesResponse>;
166
+ reviewPR(context: unknown): Promise<AiReviewPRResponse>;
167
+ /** Generate a conventional commit message from a unified diff. */
168
+ generateCommitMessage(diff: string): Promise<AiCommitMessageResponse>;
169
+ /**
170
+ * Generate a PR title and description from branch commits + diff.
171
+ * Pass `stat` (output of `git diff --stat`) alongside the diff so the AI
172
+ * sees every changed file even when the detailed patch is truncated.
173
+ */
174
+ generatePrContent(commits: string[], diff: string, stat?: string): Promise<AiPrContentResponse>;
175
+ /**
176
+ * Resolve git merge conflict markers in a file.
177
+ * Returns the fully resolved file content + confidence level.
178
+ */
179
+ resolveConflict(filePath: string, conflictContent: string): Promise<AiConflictResolutionResponse>;
180
+ /**
181
+ * Generate a targeted fix for a single PR review comment.
182
+ * Returns a line-range replacement (startLine–endLine → replacement).
183
+ */
184
+ generateFix(context: {
185
+ /** The review comment text to address */
186
+ comment: string;
187
+ /** Author of the comment */
188
+ commentAuthor: string;
189
+ /** Relative file path the comment is on */
190
+ filePath: string;
191
+ /** 1-based line number the comment targets */
192
+ line: number;
193
+ /** Full current file content (after PR changes) */
194
+ fileContent: string;
195
+ /** The relevant diff section for this file */
196
+ fileDiff: string;
197
+ }): Promise<AiFixResponse>;
198
+ /**
199
+ * Answer a free-form question about the repo using live git context + AI.
200
+ * Used by `gitx ask "<question>"`.
201
+ *
202
+ * @param question The raw question string from the user.
203
+ * @param context Live repo state gathered by the ask command.
204
+ */
205
+ ask(question: string, context: AiAskContext): Promise<AiAskResponse>;
206
+ /**
207
+ * Senior-developer quality PR review with full codebase context.
208
+ * Returns inline comments, checklist, and a formal verdict.
209
+ */
210
+ reviewPRDetailed(context: {
211
+ /** PR title */
212
+ prTitle: string;
213
+ /** PR description */
214
+ prBody: string;
215
+ /** Author of the PR */
216
+ author: string;
217
+ /** Source branch name */
218
+ headBranch: string;
219
+ /** Target branch name */
220
+ baseBranch: string;
221
+ /** Full unified diff of the PR (may be truncated) */
222
+ diff: string;
223
+ /** Files changed — key: relative path, value: FULL file content after changes */
224
+ changedFiles: Record<string, string>;
225
+ /** Supporting context files the changes depend on */
226
+ contextFiles: Record<string, string>;
227
+ /** Flat list of all repo files (for structural awareness) */
228
+ repoFileList: string[];
229
+ /** Existing PR comments */
230
+ existingComments: Array<{
231
+ author: string;
232
+ body: string;
233
+ path?: string;
234
+ line?: number;
235
+ }>;
236
+ }): Promise<AiDetailedReviewResponse>;
237
+ }
238
+ export interface AiReviewPRResponse {
239
+ summary: string;
240
+ issues: Array<{
241
+ severity: "critical" | "warning" | "suggestion";
242
+ description: string;
243
+ file?: string;
244
+ line?: number;
245
+ }>;
246
+ positives: string[];
247
+ verdict: "approve" | "request_changes" | "comment";
248
+ }
249
+ /** Inline comment on a specific file + line produced by the senior-dev review. */
250
+ export interface AiInlineComment {
251
+ /** Relative path to the file being commented on */
252
+ path: string;
253
+ /** The line number in the NEW (right) version of the file */
254
+ line: number;
255
+ /** The comment body (markdown supported) */
256
+ body: string;
257
+ /** Severity for local display */
258
+ severity: "critical" | "warning" | "suggestion";
259
+ /** Optional drop-in code suggestion (replaces the commented line) */
260
+ suggestion?: string;
261
+ }
262
+ /**
263
+ * Rich structured review response from the senior-dev AI reviewer.
264
+ * Supersedes the basic AiReviewPRResponse for the `gitx pr review` command.
265
+ */
266
+ export interface AiDetailedReviewResponse {
267
+ /** 3-5 sentence executive summary of the PR */
268
+ summary: string;
269
+ /** Verdict to submit to the hosting platform */
270
+ verdict: "approve" | "request_changes" | "comment";
271
+ /** High-level issues not tied to a specific line */
272
+ issues: Array<{
273
+ severity: "critical" | "warning" | "suggestion";
274
+ description: string;
275
+ file?: string;
276
+ line?: number;
277
+ }>;
278
+ /** Specific inline comments on changed lines */
279
+ inlineComments: AiInlineComment[];
280
+ /** Things done well in this PR */
281
+ positives: string[];
282
+ /** How to manually test the changes */
283
+ testingNotes: string;
284
+ /** Which review dimensions were checked */
285
+ checklist: Array<{
286
+ area: string;
287
+ status: "pass" | "warn" | "fail";
288
+ note: string;
289
+ }>;
43
290
  }
44
291
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,KAAK,CAAC;QAAE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IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,QAAQ,EAAE,UAAU,GAAG,SAAS,GAAG,YAAY,CAAC;IAChD,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,OAAO,EAAE,SAAS,GAAG,iBAAiB,GAAG,SAAS,CAAC;IACnD,oDAAoD;IACpD,MAAM,EAAE,KAAK,CAAC;QACZ,QAAQ,EAAE,UAAU,GAAG,SAAS,GAAG,YAAY,CAAC;QAChD,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IACH,gDAAgD;IAChD,cAAc,EAAE,eAAe,EAAE,CAAC;IAClC,kCAAkC;IAClC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,uCAAuC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,SAAS,EAAE,KAAK,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;QACjC,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;CACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface AiAnalyzeTaskResponse {\n task: string;\n intent: \"refactor\" | \"bugfix\" | \"feature\" | \"chore\" | \"unknown\";\n summary: string;\n assumptions: string[];\n risks: string[];\n}\n\nexport interface AiPlanStep {\n id: string;\n title: string;\n description: string;\n}\n\nexport interface AiGeneratePlanResponse {\n steps: AiPlanStep[];\n}\n\nexport interface AiGenerateDiffsResponse {\n stepId: string;\n diffs: Array<{ path: string; unifiedDiff: string }>;\n}\n\nexport interface AiSummarizeChangesResponse {\n summary: string;\n filesChanged: Array<{ path: string; changeType: \"add\" | \"modify\" | \"delete\" }>;\n}\n\nexport interface AiSuggestFixesResponse {\n suggestedEdits: Array<{ path: string; rationale: string; unifiedDiff: string }>;\n}\n\nexport interface AiClient {\n analyzeTask(input: string): Promise<AiAnalyzeTaskResponse>;\n generatePlan(context: unknown): Promise<AiGeneratePlanResponse>;\n generateDiffs(step: unknown): Promise<AiGenerateDiffsResponse>;\n summarizeChanges(diff: unknown): Promise<AiSummarizeChangesResponse>;\n suggestFixes(comment: unknown): Promise<AiSuggestFixesResponse>;\n}\n\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface AiAnalyzeTaskResponse {\n task: string;\n intent: \"refactor\" | \"bugfix\" | \"feature\" | \"chore\" | \"unknown\";\n summary: string;\n assumptions: string[];\n risks: string[];\n}\n\nexport interface AiPlanStep {\n id: string;\n title: string;\n description: string;\n}\n\nexport interface AiGeneratePlanResponse {\n steps: AiPlanStep[];\n}\n\nexport interface AiGenerateDiffsResponse {\n stepId: string;\n diffs: Array<{ path: string; unifiedDiff: string }>;\n}\n\nexport interface AiSummarizeChangesResponse {\n summary: string;\n filesChanged: Array<{ path: string; changeType: \"add\" | \"modify\" | \"delete\" }>;\n}\n\nexport interface AiSuggestFixesResponse {\n suggestedEdits: Array<{ path: string; rationale: string; unifiedDiff: string }>;\n}\n\nexport interface AiCommitMessageResponse {\n /** Full conventional commit subject line, e.g. \"feat(auth): add OAuth2 login flow\" */\n subject: string;\n /** Optional multi-line body explaining WHY the change was made */\n body?: string;\n}\n\nexport interface AiPrContentResponse {\n /** Short, human-readable PR title (not necessarily conventional-commit format) */\n title: string;\n /** Multi-paragraph PR description: what changed, why, how to test */\n body: string;\n}\n\nexport interface AiConflictResolutionResponse {\n /** The full file content with ALL conflict markers removed and conflicts resolved. */\n resolved: string;\n /**\n * \"high\" → AI is confident both sides are fully reconciled — safe to auto-apply.\n * \"low\" → Changes are contradictory or ambiguous — show to user for confirmation.\n */\n confidence: \"high\" | \"low\";\n /** One-sentence explanation of what the AI did (shown to the user). */\n explanation: string;\n}\n\n/**\n * AI-generated fix for a single PR review comment.\n * Targets a specific line range in a file with a minimal replacement.\n */\nexport interface AiFixResponse {\n /** Relative path to the file that needs to change */\n file: string;\n /** 1-based line number where the replacement starts */\n startLine: number;\n /** 1-based line number where the replacement ends (inclusive) */\n endLine: number;\n /**\n * The new code to replace lines startLine–endLine with.\n * Must preserve surrounding indentation style.\n */\n replacement: string;\n /** One-sentence explanation shown to the user */\n explanation: string;\n /**\n * \"high\" → safe to auto-apply without confirmation.\n * \"low\" → show diff and ask user before applying.\n */\n confidence: \"high\" | \"low\";\n /** Does this fix fully resolve the comment (vs partially)? */\n resolves: boolean;\n /**\n * true when the comment is a question / discussion with no code change needed.\n * In this case startLine/endLine/replacement are empty and should be ignored.\n */\n isDiscussion: boolean;\n}\n\n// ─── Ask command types ────────────────────────────────────────────────────────\n\n/**\n * Diagnostic snapshot of which AI provider is active and how it was resolved.\n * Keys are never included — only whether they are present.\n */\nexport interface AiSetupStatus {\n /**\n * Human-readable provider name, e.g. \"claude (Anthropic API)\", \"openai\", \"claude-cli (local)\", \"none\".\n * \"none\" means no provider is configured and MockAi will be used.\n */\n provider: string;\n /** Model in use, if applicable (e.g. \"claude-3-5-haiku-20241022\", \"gpt-4o\") */\n model?: string;\n /**\n * Where the key / credential came from:\n * \"ANTHROPIC_API_KEY env var\" | \"OPENAI_API_KEY env var\" | \"config file\" | \"local CLI\" | \"none\"\n */\n keySource: string;\n /** true when at least one real AI provider is available */\n isConfigured: boolean;\n}\n\n/**\n * Status of a single configured git hosting provider.\n * The actual token value is never included.\n */\nexport interface GitProviderStatus {\n /** \"github\" | \"gitlab\" | \"azure\" */\n name: string;\n /** true when a non-empty token exists for this provider */\n hasToken: boolean;\n}\n\n/**\n * Live repo context gathered by `gitx ask` and injected into the AI prompt.\n * All fields are optional so partial context still produces useful answers.\n */\nexport interface AiAskContext {\n /** Whether the CWD is inside a git repository */\n isInsideGitRepo: boolean;\n /** Current checked-out branch name (only meaningful when isInsideGitRepo is true) */\n currentBranch: string;\n /** Last 10 commits as one-line summaries (hash + subject) */\n recentCommits: string[];\n /** Output of `git status --short` */\n gitStatus: string;\n /** Open pull requests from the remote provider */\n openPRs?: Array<{ number: number; title: string; state: string; branch: string }>;\n /** Stash entries (e.g. \"stash@{0}: WIP on feat/x: abc1234 msg\") */\n stashes?: string[];\n /** Detailed status of the active AI provider */\n aiSetup: AiSetupStatus;\n /** All configured git hosting providers (github / gitlab / azure) */\n gitProviders: GitProviderStatus[];\n /** The configured default base branch, if any */\n defaultBranch?: string;\n}\n\n/** Response returned by `AiClient.ask()` for the `gitx ask` command. */\nexport interface AiAskResponse {\n /** Full answer in plain text or markdown */\n answer: string;\n /**\n * Concrete gitx (or git) commands the user can run to act on the answer.\n * Omit when not applicable.\n */\n suggestedCommands?: string[];\n}\n\nexport interface AiClient {\n analyzeTask(input: string): Promise<AiAnalyzeTaskResponse>;\n generatePlan(context: unknown): Promise<AiGeneratePlanResponse>;\n generateDiffs(step: unknown): Promise<AiGenerateDiffsResponse>;\n summarizeChanges(diff: unknown): Promise<AiSummarizeChangesResponse>;\n suggestFixes(comment: unknown): Promise<AiSuggestFixesResponse>;\n reviewPR(context: unknown): Promise<AiReviewPRResponse>;\n /** Generate a conventional commit message from a unified diff. */\n generateCommitMessage(diff: string): Promise<AiCommitMessageResponse>;\n /**\n * Generate a PR title and description from branch commits + diff.\n * Pass `stat` (output of `git diff --stat`) alongside the diff so the AI\n * sees every changed file even when the detailed patch is truncated.\n */\n generatePrContent(commits: string[], diff: string, stat?: string): Promise<AiPrContentResponse>;\n /**\n * Resolve git merge conflict markers in a file.\n * Returns the fully resolved file content + confidence level.\n */\n resolveConflict(filePath: string, conflictContent: string): Promise<AiConflictResolutionResponse>;\n\n /**\n * Generate a targeted fix for a single PR review comment.\n * Returns a line-range replacement (startLine–endLine → replacement).\n */\n generateFix(context: {\n /** The review comment text to address */\n comment: string;\n /** Author of the comment */\n commentAuthor: string;\n /** Relative file path the comment is on */\n filePath: string;\n /** 1-based line number the comment targets */\n line: number;\n /** Full current file content (after PR changes) */\n fileContent: string;\n /** The relevant diff section for this file */\n fileDiff: string;\n }): Promise<AiFixResponse>;\n\n /**\n * Answer a free-form question about the repo using live git context + AI.\n * Used by `gitx ask \"<question>\"`.\n *\n * @param question The raw question string from the user.\n * @param context Live repo state gathered by the ask command.\n */\n ask(question: string, context: AiAskContext): Promise<AiAskResponse>;\n\n /**\n * Senior-developer quality PR review with full codebase context.\n * Returns inline comments, checklist, and a formal verdict.\n */\n reviewPRDetailed(context: {\n /** PR title */\n prTitle: string;\n /** PR description */\n prBody: string;\n /** Author of the PR */\n author: string;\n /** Source branch name */\n headBranch: string;\n /** Target branch name */\n baseBranch: string;\n /** Full unified diff of the PR (may be truncated) */\n diff: string;\n /** Files changed — key: relative path, value: FULL file content after changes */\n changedFiles: Record<string, string>;\n /** Supporting context files the changes depend on */\n contextFiles: Record<string, string>;\n /** Flat list of all repo files (for structural awareness) */\n repoFileList: string[];\n /** Existing PR comments */\n existingComments: Array<{ author: string; body: string; path?: string; line?: number }>;\n }): Promise<AiDetailedReviewResponse>;\n}\n\nexport interface AiReviewPRResponse {\n summary: string;\n issues: Array<{\n severity: \"critical\" | \"warning\" | \"suggestion\";\n description: string;\n file?: string;\n line?: number;\n }>;\n positives: string[];\n verdict: \"approve\" | \"request_changes\" | \"comment\";\n}\n\n/** Inline comment on a specific file + line produced by the senior-dev review. */\nexport interface AiInlineComment {\n /** Relative path to the file being commented on */\n path: string;\n /** The line number in the NEW (right) version of the file */\n line: number;\n /** The comment body (markdown supported) */\n body: string;\n /** Severity for local display */\n severity: \"critical\" | \"warning\" | \"suggestion\";\n /** Optional drop-in code suggestion (replaces the commented line) */\n suggestion?: string;\n}\n\n/**\n * Rich structured review response from the senior-dev AI reviewer.\n * Supersedes the basic AiReviewPRResponse for the `gitx pr review` command.\n */\nexport interface AiDetailedReviewResponse {\n /** 3-5 sentence executive summary of the PR */\n summary: string;\n /** Verdict to submit to the hosting platform */\n verdict: \"approve\" | \"request_changes\" | \"comment\";\n /** High-level issues not tied to a specific line */\n issues: Array<{\n severity: \"critical\" | \"warning\" | \"suggestion\";\n description: string;\n file?: string;\n line?: number;\n }>;\n /** Specific inline comments on changed lines */\n inlineComments: AiInlineComment[];\n /** Things done well in this PR */\n positives: string[];\n /** How to manually test the changes */\n testingNotes: string;\n /** Which review dimensions were checked */\n checklist: Array<{\n area: string; // e.g. \"Security\", \"Performance\", \"Error handling\"\n status: \"pass\" | \"warn\" | \"fail\";\n note: string;\n }>;\n}\n"]}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * `gitx ask "<question>"` — Smart support assistant for your repo.
3
+ *
4
+ * Acts as a support agent that can answer three types of questions:
5
+ *
6
+ * 1. SETUP / DIAGNOSTIC — "is my AI provider set up?", "why isn't gitx working?",
7
+ * "do I have a GitHub token configured?"
8
+ * → Reads your live gitx config and reports real status (no fabrication).
9
+ *
10
+ * 2. REPO STATE — "what did I last commit?", "do I have unstaged changes?",
11
+ * "show me all open PRs"
12
+ * → Reads live git state (branch, commits, status, stashes).
13
+ *
14
+ * 3. HOW-TO — "how do I sync with main?", "how do I undo my last commit?",
15
+ * "what command creates a PR?"
16
+ * → Uses built-in gitx command reference embedded in every prompt.
17
+ *
18
+ * Examples:
19
+ * gitx ask "is my AI provider set up?"
20
+ * gitx ask "what did I last commit?"
21
+ * gitx ask "how do I sync my branch with main?"
22
+ * gitx ask "do I have any open PRs?" --pr
23
+ * gitx ask "why is gitx not working?"
24
+ */
25
+ import type { Command } from "commander";
26
+ export declare function registerAskCommand(program: Command): void;
27
+ //# sourceMappingURL=ask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ask.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/ask.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyHzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8GzD"}