patchwise 0.9.2__tar.gz → 0.9.3__tar.gz

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 (140) hide show
  1. {patchwise-0.9.2 → patchwise-0.9.3}/PKG-INFO +1 -1
  2. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/default_config.yaml +2 -0
  3. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/main.py +1 -1
  4. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_review/ai_code_review.py +79 -1
  5. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/patch_review.py +3 -0
  6. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/utils/config.py +8 -0
  7. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise.egg-info/PKG-INFO +1 -1
  8. {patchwise-0.9.2 → patchwise-0.9.3}/pyproject.toml +1 -1
  9. {patchwise-0.9.2 → patchwise-0.9.3}/LICENSE.txt +0 -0
  10. {patchwise-0.9.2 → patchwise-0.9.3}/README.md +0 -0
  11. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/__init__.py +0 -0
  12. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/docker.py +0 -0
  13. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/dockerfiles/AiCodeReview.Dockerfile +0 -0
  14. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/dockerfiles/Checkpatch.Dockerfile +0 -0
  15. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/dockerfiles/Coccicheck.Dockerfile +0 -0
  16. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/dockerfiles/CrashdumpAgent.Dockerfile +0 -0
  17. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/dockerfiles/DtCheck.Dockerfile +0 -0
  18. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/dockerfiles/DtbsCheck.Dockerfile +0 -0
  19. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/dockerfiles/LLMCommitAudit.Dockerfile +0 -0
  20. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/dockerfiles/Sparse.Dockerfile +0 -0
  21. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/dockerfiles/base.Dockerfile +0 -0
  22. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/logger_setup.py +0 -0
  23. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/mail_handler/__init__.py +0 -0
  24. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/mail_handler/ai_models.py +0 -0
  25. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/mail_handler/cli.py +0 -0
  26. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/mail_handler/config.py +0 -0
  27. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/mail_handler/handler.py +0 -0
  28. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/mail_handler/mail_client.py +0 -0
  29. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/mail_handler/utils.py +0 -0
  30. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/__init__.py +0 -0
  31. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_agent/__init__.py +0 -0
  32. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_agent/agent.py +0 -0
  33. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_agent/crashdump_agent.py +0 -0
  34. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_agent/tool_definitions.py +0 -0
  35. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_fix/__init__.py +0 -0
  36. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_fix/ai_fix.py +0 -0
  37. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_fix/ai_patch_fix.py +0 -0
  38. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_fix/checkpatch_fixer.py +0 -0
  39. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_fix/kernel_docs_rag.py +0 -0
  40. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_fix/sparse_fixer.py +0 -0
  41. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_review/__init__.py +0 -0
  42. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_review/ai_review.py +0 -0
  43. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_review/fetch_reviewer_comment.py +0 -0
  44. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_review/llm_commit_audit.py +0 -0
  45. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_review/root_cause_analysis.py +0 -0
  46. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_review/ts_cache.py +0 -0
  47. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/ai_review/ts_indexer.py +0 -0
  48. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/decorators.py +0 -0
  49. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/kernel_tree.py +0 -0
  50. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/static_analysis/__init__.py +0 -0
  51. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/static_analysis/checkpatch.py +0 -0
  52. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/static_analysis/coccicheck.py +0 -0
  53. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/static_analysis/dt_check.py +0 -0
  54. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/static_analysis/dtbs_check.py +0 -0
  55. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/static_analysis/sparse.py +0 -0
  56. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/patch_review/static_analysis/static_analysis.py +0 -0
  57. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/stats/__init__.py +0 -0
  58. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/stats/dashboard.py +0 -0
  59. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/ui/__init__.py +0 -0
  60. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/ui/dashboard.py +0 -0
  61. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/ui/events.py +0 -0
  62. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/ui/screen.py +0 -0
  63. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/utils/decorators.py +0 -0
  64. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/utils/lru_cache.py +0 -0
  65. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/utils/repo_workspace.py +0 -0
  66. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise/utils/tui.py +0 -0
  67. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise.egg-info/SOURCES.txt +0 -0
  68. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise.egg-info/dependency_links.txt +0 -0
  69. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise.egg-info/entry_points.txt +0 -0
  70. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise.egg-info/requires.txt +0 -0
  71. {patchwise-0.9.2 → patchwise-0.9.3}/patchwise.egg-info/top_level.txt +0 -0
  72. {patchwise-0.9.2 → patchwise-0.9.3}/setup.cfg +0 -0
  73. {patchwise-0.9.2 → patchwise-0.9.3}/tests/test_mail_handler_series_refs.py +0 -0
  74. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/false-positive-guide.md +0 -0
  75. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/alignment.md +0 -0
  76. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/arm64.md +0 -0
  77. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/ata.md +0 -0
  78. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/block.md +0 -0
  79. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/bluetooth.md +0 -0
  80. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/boot-params.md +0 -0
  81. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/bpf.md +0 -0
  82. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/btf.md +0 -0
  83. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/btrfs.md +0 -0
  84. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/build.md +0 -0
  85. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/cleanup.md +0 -0
  86. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/cxl.md +0 -0
  87. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/dax.md +0 -0
  88. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/drm.md +0 -0
  89. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/dt-bindings.md +0 -0
  90. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/fscrypt.md +0 -0
  91. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/gic-v3.md +0 -0
  92. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/gic-v5.md +0 -0
  93. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/hid.md +0 -0
  94. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/hyp-arm64.md +0 -0
  95. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/i2c.md +0 -0
  96. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/input.md +0 -0
  97. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/io-accessors.md +0 -0
  98. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/io_uring.md +0 -0
  99. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/kconfig.md +0 -0
  100. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/kho.md +0 -0
  101. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/kvm-arm64.md +0 -0
  102. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/kvm.md +0 -0
  103. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/libbpf.md +0 -0
  104. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/locking.md +0 -0
  105. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/mips.md +0 -0
  106. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/mm-alloc.md +0 -0
  107. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/mm-folio.md +0 -0
  108. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/mm-largepage.md +0 -0
  109. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/mm-pagetable.md +0 -0
  110. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/mm-reclaim.md +0 -0
  111. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/mm-vma.md +0 -0
  112. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/netlink.md +0 -0
  113. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/networking-core.md +0 -0
  114. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/networking-drivers.md +0 -0
  115. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/nfsd.md +0 -0
  116. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/objtool.md +0 -0
  117. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/of.md +0 -0
  118. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/pci.md +0 -0
  119. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/perf.md +0 -0
  120. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/pm.md +0 -0
  121. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/pmdomain.md +0 -0
  122. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/rcu.md +0 -0
  123. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/rust.md +0 -0
  124. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/scheduler.md +0 -0
  125. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/selftests.md +0 -0
  126. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/smb-ksmbd.md +0 -0
  127. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/subjective-review.md +0 -0
  128. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/subsystem-template.md +0 -0
  129. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/subsystem.md +0 -0
  130. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/sunrpc.md +0 -0
  131. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/syscall.md +0 -0
  132. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/sysfs.md +0 -0
  133. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/timers.md +0 -0
  134. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/tracing.md +0 -0
  135. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/tty.md +0 -0
  136. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/usb-storage.md +0 -0
  137. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/vfs.md +0 -0
  138. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/wireless.md +0 -0
  139. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/subsystem/workqueue.md +0 -0
  140. {patchwise-0.9.2 → patchwise-0.9.3}/thirdparty/review-prompts/kernel/technical-patterns.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patchwise
3
- Version: 0.9.2
3
+ Version: 0.9.3
4
4
  Summary: AI Code Review, Root Cause Analysis and Static Analysis for the Linux kernel
5
5
  Author-email: "Qualcomm Technologies, Inc." <qc.opensource@qti.qualcomm.com>
6
6
  Maintainer-email: Aditya Chillara <achillar@qti.qualcomm.com>
@@ -30,6 +30,8 @@ ai:
30
30
  # models:
31
31
  # openai/Pro: "GPT-5"
32
32
  models: {}
33
+ # Accepts: "inline" or "gerrit".
34
+ output_format: "inline"
33
35
  api_key_disclaimer:
34
36
  message: "PatchWise uses LiteLLM to interact with your preferred model provider (default: OpenAI). LiteLLM will automatically retrieve the API key from your environment variables if it is set based on the API URL provided to LiteLLM (default: OpenAI). Please confirm that you acknowledge that your API key may be used, if set in your environment. Select 'Yes' to proceed, 'No' to abort, and 'Yes. Don't show again' to proceed and disable this prompt."
35
37
  options: ["Yes", "No", "Yes. Don't show again"]
@@ -211,7 +211,7 @@ def run_local_mode(args: argparse.Namespace) -> None:
211
211
  if not result_text:
212
212
  continue
213
213
  review_name = type(review).__name__
214
- output_file = output_dir / f"{review_name.lower()}.txt"
214
+ output_file = output_dir / f"{review_name.lower()}.{review.output_suffix}"
215
215
  if not result_text.endswith("\n"):
216
216
  result_text += "\n"
217
217
  with open(output_file, "w", encoding="utf-8") as f:
@@ -1,6 +1,7 @@
1
1
  # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2
2
  # SPDX-License-Identifier: BSD-3-Clause
3
3
 
4
+ import ast
4
5
  import datetime
5
6
  import json
6
7
  import os
@@ -23,6 +24,7 @@ from patchwise.patch_review.decorators import register_llm_review, register_long
23
24
 
24
25
  from patchwise.patch_review.ai_review.ai_review import AiReview
25
26
  from patchwise.ui import events
27
+ from patchwise.utils.config import ai_output_format
26
28
  from patchwise.utils.repo_workspace import (
27
29
  project_layout_note,
28
30
  repo_project_note,
@@ -296,7 +298,6 @@ name the concern, do not write the analysis.
296
298
  ```
297
299
  """
298
300
 
299
-
300
301
  # Phase 2 (EXECUTION) prompt
301
302
 
302
303
  EXECUTION_INSTRUCTIONS = """
@@ -1567,12 +1568,89 @@ finding with record_verdict as you work through them.
1567
1568
  ),
1568
1569
  )
1569
1570
 
1571
+ if ai_output_format() == "gerrit":
1572
+ if findings is None:
1573
+ self.logger.warning(
1574
+ "[cleanup] JSON parse failed; posting the review patchset-level."
1575
+ )
1576
+ findings = [{"finding": text, "end_line": 0}]
1577
+ return json.dumps(self._gerrit_comments(findings), indent=2)
1578
+
1570
1579
  if findings is None:
1571
1580
  self.logger.warning("[cleanup] JSON parse failed; falling back to raw text.")
1572
1581
  return text.strip()
1573
1582
 
1574
1583
  return super().format_chat_response(self._render_inline_review(findings).strip())
1575
1584
 
1585
+ @property
1586
+ def output_suffix(self) -> str:
1587
+ return "json" if ai_output_format() == "gerrit" else "txt"
1588
+
1589
+ @staticmethod
1590
+ def _diff_path(header: str) -> str:
1591
+ """The new path from `diff --git a/<old> b/<new>`. Git C-quotes paths
1592
+ with unusual characters (`"b/\\303\\251.txt"`)."""
1593
+ if header.endswith('"'):
1594
+ quoted = header[header.rindex(' "b/') + 1 :]
1595
+ return ast.literal_eval("b" + quoted).decode()[2:]
1596
+ return header.rsplit(" b/", 1)[-1]
1597
+
1598
+ def _gerrit_anchors(self) -> list[tuple[str, dict]]:
1599
+ """Map each numbered-source line (0-based) to a Gerrit (path,
1600
+ CommentInput) anchor, per the REST API's CommentInput entity.
1601
+
1602
+ Message lines go to the /COMMIT_MSG magic file, below the header Gerrit
1603
+ generates above the message (MagicFile.createCommitMessageHeader: one
1604
+ line per parent, Author, AuthorDate, Commit, CommitDate, blank). File
1605
+ and hunk headers get a file comment; anything else is patchset-level."""
1606
+ raw_lines = self._numbered_source.split("\n")
1607
+ anchors: list[tuple[str, dict]] = [("/PATCHSET_LEVEL", {})] * len(raw_lines)
1608
+ header = len(self.commit.parents) + 5
1609
+ diff_start = self._diff_start_line(self.commit_message) - 1
1610
+ for i in range(diff_start - 1):
1611
+ anchors[i] = ("/COMMIT_MSG", {"line": header + i + 1})
1612
+ path, in_hunk, old, new = None, False, 0, 0
1613
+ for i in range(diff_start, len(raw_lines)):
1614
+ line = raw_lines[i]
1615
+ hunk = re.match(r"@@ -(\d+)(?:,\d+)? \+(\d+)", line)
1616
+ if line.startswith("diff --git"):
1617
+ path, in_hunk = self._diff_path(line), False
1618
+ elif hunk:
1619
+ in_hunk, old, new = True, int(hunk.group(1)), int(hunk.group(2))
1620
+ if path is None:
1621
+ continue
1622
+ anchors[i] = (path, {})
1623
+ if not in_hunk or hunk:
1624
+ continue
1625
+ if line.startswith("+"):
1626
+ anchors[i] = (path, {"line": new})
1627
+ new += 1
1628
+ elif line.startswith("-"):
1629
+ anchors[i] = (path, {"line": old, "side": "PARENT"})
1630
+ old += 1
1631
+ elif line.startswith(" "):
1632
+ anchors[i] = (path, {"line": new})
1633
+ old, new = old + 1, new + 1
1634
+ return anchors
1635
+
1636
+ def _gerrit_comments(self, findings: list) -> dict[str, list[dict]]:
1637
+ """Findings as a Gerrit ReviewInput `comments` map (path -> list of
1638
+ CommentInput), each anchored at its end line as the inline review
1639
+ places it. An out-of-range line becomes a patchset-level comment."""
1640
+ anchors = self._gerrit_anchors()
1641
+ comments: dict[str, list[dict]] = defaultdict(list)
1642
+ for e in findings:
1643
+ end = e["end_line"]
1644
+ path, anchor = (
1645
+ anchors[end - 1]
1646
+ if 1 <= end <= len(anchors)
1647
+ else ("/PATCHSET_LEVEL", {})
1648
+ )
1649
+ comments[path].append(
1650
+ dict(anchor, message=str(e["finding"]).strip(), unresolved=True)
1651
+ )
1652
+ return comments
1653
+
1576
1654
  _SUBDIR = "ai_code_review"
1577
1655
 
1578
1656
  def _dump(self, name: str, content: str) -> None:
@@ -85,6 +85,9 @@ class PatchReview(abc.ABC):
85
85
  return specific_dockerfile
86
86
  return DOCKERFILES_PATH / "base.Dockerfile"
87
87
 
88
+ # Extension of the file main.py saves this review's result to
89
+ output_suffix = "txt"
90
+
88
91
  @abc.abstractmethod
89
92
  def setup(self) -> None:
90
93
  """
@@ -61,6 +61,14 @@ def redis_address() -> Tuple[str, int]:
61
61
  return cache["host"], int(cache["port"])
62
62
 
63
63
 
64
+ def ai_output_format() -> str:
65
+ """Return `ai.output_format`: "inline" or "gerrit"."""
66
+ fmt = parse_config()["ai"].get("output_format", "inline")
67
+ if fmt not in ("inline", "gerrit"):
68
+ raise ValueError(f'ai.output_format must be "inline" or "gerrit", not {fmt!r}')
69
+ return fmt
70
+
71
+
64
72
  def update_user_config(dict: Dict[str, Any]) -> None:
65
73
  if not USER_CONFIG_PATH.exists():
66
74
  CONFIG_DIR.mkdir(parents=True, exist_ok=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patchwise
3
- Version: 0.9.2
3
+ Version: 0.9.3
4
4
  Summary: AI Code Review, Root Cause Analysis and Static Analysis for the Linux kernel
5
5
  Author-email: "Qualcomm Technologies, Inc." <qc.opensource@qti.qualcomm.com>
6
6
  Maintainer-email: Aditya Chillara <achillar@qti.qualcomm.com>
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "patchwise"
7
- version = "0.9.2"
7
+ version = "0.9.3"
8
8
  description = "AI Code Review, Root Cause Analysis and Static Analysis for the Linux kernel"
9
9
  authors = [
10
10
  { name = "Qualcomm Technologies, Inc.", email = "qc.opensource@qti.qualcomm.com" }
File without changes
File without changes
File without changes
File without changes