patchwise 0.2.1__py3-none-any.whl → 0.9.2__py3-none-any.whl

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 (134) hide show
  1. patchwise/__init__.py +17 -2
  2. patchwise/default_config.yaml +54 -0
  3. patchwise/docker.py +978 -0
  4. patchwise/dockerfiles/AiCodeReview.Dockerfile +13 -0
  5. patchwise/dockerfiles/Checkpatch.Dockerfile +10 -0
  6. patchwise/dockerfiles/Coccicheck.Dockerfile +13 -0
  7. patchwise/dockerfiles/CrashdumpAgent.Dockerfile +12 -0
  8. patchwise/dockerfiles/DtCheck.Dockerfile +26 -0
  9. patchwise/dockerfiles/DtbsCheck.Dockerfile +37 -0
  10. patchwise/dockerfiles/LLMCommitAudit.Dockerfile +9 -0
  11. patchwise/dockerfiles/Sparse.Dockerfile +39 -0
  12. patchwise/dockerfiles/base.Dockerfile +72 -0
  13. patchwise/logger_setup.py +3 -2
  14. patchwise/mail_handler/__init__.py +2 -0
  15. patchwise/mail_handler/ai_models.py +10 -0
  16. patchwise/mail_handler/cli.py +115 -0
  17. patchwise/mail_handler/config.py +65 -0
  18. patchwise/mail_handler/handler.py +498 -0
  19. patchwise/mail_handler/mail_client.py +291 -0
  20. patchwise/mail_handler/utils.py +55 -0
  21. patchwise/main.py +248 -35
  22. patchwise/patch_review/__init__.py +146 -51
  23. patchwise/patch_review/ai_agent/__init__.py +47 -0
  24. patchwise/patch_review/ai_agent/agent.py +1792 -0
  25. patchwise/patch_review/ai_agent/crashdump_agent.py +368 -0
  26. patchwise/patch_review/ai_agent/tool_definitions.py +583 -0
  27. patchwise/patch_review/ai_fix/__init__.py +6 -0
  28. patchwise/patch_review/ai_fix/ai_fix.py +109 -0
  29. patchwise/patch_review/ai_fix/ai_patch_fix.py +111 -0
  30. patchwise/patch_review/ai_fix/checkpatch_fixer.py +688 -0
  31. patchwise/patch_review/ai_fix/kernel_docs_rag.py +469 -0
  32. patchwise/patch_review/ai_fix/sparse_fixer.py +309 -0
  33. patchwise/patch_review/ai_review/ai_code_review.py +1563 -959
  34. patchwise/patch_review/ai_review/ai_review.py +93 -82
  35. patchwise/patch_review/ai_review/fetch_reviewer_comment.py +375 -0
  36. patchwise/patch_review/ai_review/llm_commit_audit.py +2 -6
  37. patchwise/patch_review/ai_review/root_cause_analysis.py +1314 -0
  38. patchwise/patch_review/ai_review/ts_cache.py +92 -0
  39. patchwise/patch_review/ai_review/ts_indexer.py +360 -0
  40. patchwise/patch_review/decorators.py +17 -1
  41. patchwise/patch_review/kernel_tree.py +38 -2
  42. patchwise/patch_review/patch_review.py +54 -276
  43. patchwise/patch_review/static_analysis/checkpatch.py +3 -5
  44. patchwise/patch_review/static_analysis/coccicheck.py +47 -7
  45. patchwise/patch_review/static_analysis/dt_check.py +65 -38
  46. patchwise/patch_review/static_analysis/dtbs_check.py +63 -39
  47. patchwise/patch_review/static_analysis/sparse.py +122 -116
  48. patchwise/patch_review/static_analysis/static_analysis.py +85 -5
  49. patchwise/stats/__init__.py +4 -0
  50. patchwise/stats/dashboard.py +957 -0
  51. patchwise/ui/__init__.py +11 -0
  52. patchwise/ui/dashboard.py +680 -0
  53. patchwise/ui/events.py +72 -0
  54. patchwise/ui/screen.py +320 -0
  55. patchwise/utils/config.py +70 -0
  56. patchwise/utils/decorators.py +102 -0
  57. patchwise/utils/lru_cache.py +25 -0
  58. patchwise/utils/repo_workspace.py +123 -0
  59. patchwise/utils/tui.py +81 -0
  60. patchwise-0.9.2.dist-info/METADATA +412 -0
  61. patchwise-0.9.2.dist-info/RECORD +134 -0
  62. {patchwise-0.2.1.dist-info → patchwise-0.9.2.dist-info}/WHEEL +1 -1
  63. thirdparty/review-prompts/kernel/false-positive-guide.md +478 -0
  64. thirdparty/review-prompts/kernel/subsystem/alignment.md +68 -0
  65. thirdparty/review-prompts/kernel/subsystem/arm64.md +529 -0
  66. thirdparty/review-prompts/kernel/subsystem/ata.md +75 -0
  67. thirdparty/review-prompts/kernel/subsystem/block.md +102 -0
  68. thirdparty/review-prompts/kernel/subsystem/bluetooth.md +138 -0
  69. thirdparty/review-prompts/kernel/subsystem/boot-params.md +45 -0
  70. thirdparty/review-prompts/kernel/subsystem/bpf.md +239 -0
  71. thirdparty/review-prompts/kernel/subsystem/btf.md +60 -0
  72. thirdparty/review-prompts/kernel/subsystem/btrfs.md +126 -0
  73. thirdparty/review-prompts/kernel/subsystem/build.md +29 -0
  74. thirdparty/review-prompts/kernel/subsystem/cleanup.md +166 -0
  75. thirdparty/review-prompts/kernel/subsystem/cxl.md +37 -0
  76. thirdparty/review-prompts/kernel/subsystem/dax.md +25 -0
  77. thirdparty/review-prompts/kernel/subsystem/drm.md +889 -0
  78. thirdparty/review-prompts/kernel/subsystem/dt-bindings.md +107 -0
  79. thirdparty/review-prompts/kernel/subsystem/fscrypt.md +25 -0
  80. thirdparty/review-prompts/kernel/subsystem/gic-v3.md +1225 -0
  81. thirdparty/review-prompts/kernel/subsystem/gic-v5.md +1027 -0
  82. thirdparty/review-prompts/kernel/subsystem/hid.md +395 -0
  83. thirdparty/review-prompts/kernel/subsystem/hyp-arm64.md +742 -0
  84. thirdparty/review-prompts/kernel/subsystem/i2c.md +99 -0
  85. thirdparty/review-prompts/kernel/subsystem/input.md +235 -0
  86. thirdparty/review-prompts/kernel/subsystem/io-accessors.md +91 -0
  87. thirdparty/review-prompts/kernel/subsystem/io_uring.md +341 -0
  88. thirdparty/review-prompts/kernel/subsystem/kconfig.md +104 -0
  89. thirdparty/review-prompts/kernel/subsystem/kho.md +121 -0
  90. thirdparty/review-prompts/kernel/subsystem/kvm-arm64.md +246 -0
  91. thirdparty/review-prompts/kernel/subsystem/kvm.md +304 -0
  92. thirdparty/review-prompts/kernel/subsystem/libbpf.md +80 -0
  93. thirdparty/review-prompts/kernel/subsystem/locking.md +520 -0
  94. thirdparty/review-prompts/kernel/subsystem/mips.md +80 -0
  95. thirdparty/review-prompts/kernel/subsystem/mm-alloc.md +319 -0
  96. thirdparty/review-prompts/kernel/subsystem/mm-folio.md +349 -0
  97. thirdparty/review-prompts/kernel/subsystem/mm-largepage.md +348 -0
  98. thirdparty/review-prompts/kernel/subsystem/mm-pagetable.md +444 -0
  99. thirdparty/review-prompts/kernel/subsystem/mm-reclaim.md +245 -0
  100. thirdparty/review-prompts/kernel/subsystem/mm-vma.md +246 -0
  101. thirdparty/review-prompts/kernel/subsystem/netlink.md +109 -0
  102. thirdparty/review-prompts/kernel/subsystem/networking-core.md +310 -0
  103. thirdparty/review-prompts/kernel/subsystem/networking-drivers.md +147 -0
  104. thirdparty/review-prompts/kernel/subsystem/nfsd.md +532 -0
  105. thirdparty/review-prompts/kernel/subsystem/objtool.md +57 -0
  106. thirdparty/review-prompts/kernel/subsystem/of.md +138 -0
  107. thirdparty/review-prompts/kernel/subsystem/pci.md +114 -0
  108. thirdparty/review-prompts/kernel/subsystem/perf.md +111 -0
  109. thirdparty/review-prompts/kernel/subsystem/pm.md +222 -0
  110. thirdparty/review-prompts/kernel/subsystem/pmdomain.md +119 -0
  111. thirdparty/review-prompts/kernel/subsystem/rcu.md +94 -0
  112. thirdparty/review-prompts/kernel/subsystem/rust.md +54 -0
  113. thirdparty/review-prompts/kernel/subsystem/scheduler.md +212 -0
  114. thirdparty/review-prompts/kernel/subsystem/selftests.md +314 -0
  115. thirdparty/review-prompts/kernel/subsystem/smb-ksmbd.md +67 -0
  116. thirdparty/review-prompts/kernel/subsystem/subjective-review.md +44 -0
  117. thirdparty/review-prompts/kernel/subsystem/subsystem-template.md +184 -0
  118. thirdparty/review-prompts/kernel/subsystem/subsystem.md +95 -0
  119. thirdparty/review-prompts/kernel/subsystem/sunrpc.md +344 -0
  120. thirdparty/review-prompts/kernel/subsystem/syscall.md +12 -0
  121. thirdparty/review-prompts/kernel/subsystem/sysfs.md +130 -0
  122. thirdparty/review-prompts/kernel/subsystem/timers.md +105 -0
  123. thirdparty/review-prompts/kernel/subsystem/tracing.md +97 -0
  124. thirdparty/review-prompts/kernel/subsystem/tty.md +90 -0
  125. thirdparty/review-prompts/kernel/subsystem/usb-storage.md +83 -0
  126. thirdparty/review-prompts/kernel/subsystem/vfs.md +233 -0
  127. thirdparty/review-prompts/kernel/subsystem/wireless.md +73 -0
  128. thirdparty/review-prompts/kernel/subsystem/workqueue.md +3 -0
  129. thirdparty/review-prompts/kernel/technical-patterns.md +161 -0
  130. patchwise-0.2.1.dist-info/METADATA +0 -18
  131. patchwise-0.2.1.dist-info/RECORD +0 -24
  132. {patchwise-0.2.1.dist-info → patchwise-0.9.2.dist-info}/entry_points.txt +0 -0
  133. {patchwise-0.2.1.dist-info → patchwise-0.9.2.dist-info}/licenses/LICENSE.txt +0 -0
  134. {patchwise-0.2.1.dist-info → patchwise-0.9.2.dist-info}/top_level.txt +0 -0
patchwise/__init__.py CHANGED
@@ -1,6 +1,8 @@
1
1
  # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2
2
  # SPDX-License-Identifier: BSD-3-Clause
3
3
 
4
+ import os
5
+ from importlib.metadata import PackageNotFoundError, version
4
6
  from pathlib import Path
5
7
 
6
8
  # Get the path of the patchwise package
@@ -8,11 +10,24 @@ PACKAGE_PATH = Path(__file__).resolve().parent
8
10
 
9
11
  PACKAGE_NAME = __name__.split(".")[0]
10
12
 
11
- # Define the sandbox/workspace path in tmp directory
12
- SANDBOX_PATH = Path("/tmp") / PACKAGE_NAME / "sandbox"
13
+ try:
14
+ __version__ = version(PACKAGE_NAME)
15
+ except PackageNotFoundError:
16
+ __version__ = "unknown"
17
+
18
+ # Define the sandbox/workspace path.
19
+ # Honor PATCHWISE_SANDBOX_PATH so operators can locate the sandbox to a
20
+ # filesystem with enough free space (/tmp may be a small tmpfs).
21
+ _default_sandbox = Path("/tmp") / PACKAGE_NAME / "sandbox"
22
+ SANDBOX_PATH = Path(os.environ.get("PATCHWISE_SANDBOX_PATH", str(_default_sandbox)))
13
23
  SANDBOX_BIN = SANDBOX_PATH / "bin"
14
24
  # Define the kernel workspace path
15
25
  KERNEL_PATH = SANDBOX_PATH / "kernel"
16
26
 
27
+ # Define the output directory path
28
+ _default_output = Path("/tmp") / PACKAGE_NAME / "output"
29
+ OUTPUT_PATH = Path(os.environ.get("PATCHWISE_OUTPUT_PATH", str(_default_output)))
30
+
17
31
  # Ensure the sandbox directory exists
18
32
  SANDBOX_PATH.mkdir(parents=True, exist_ok=True)
33
+ OUTPUT_PATH.mkdir(parents=True, exist_ok=True)
@@ -0,0 +1,54 @@
1
+ log_level: "INFO"
2
+ # Workspace-relative directory path patterns pruned when building the
3
+ # tree-sitter code index. Patterns are gitignore-style.
4
+ # Override this with your own list in ~/.config/patchwise_config.yaml.
5
+ indexing:
6
+ cache:
7
+ host: "127.0.0.1" # published loopback of the patchwise-ts-cache container
8
+ port: 6379
9
+ # schema_version: # optional override of the module constant
10
+ blocklist:
11
+ - "**/out/"
12
+ - "**/prebuilts/"
13
+ - "**/external/"
14
+ - "**/bazel-*/"
15
+ # Placeholder identity used inside the patchwise container for git commits.
16
+ git_committer:
17
+ name: "Patchwise"
18
+ email: "patchwise@qualcomm.com"
19
+ ai:
20
+ model: "openai/Pro"
21
+ provider: "https://api.openai.com/v1"
22
+ # API key for the AI model API. Leave empty to fall back to the provider's
23
+ # usual environment variable (e.g. OPENAI_API_KEY). Override in
24
+ # ~/.config/patchwise_config.yaml.
25
+ api_key: ""
26
+ # Maps LiteLLM model strings to human-friendly display names shown in
27
+ # mail replies (see get_model_name()). Override in
28
+ # ~/.config/patchwise_config.yaml, e.g.:
29
+ # ai:
30
+ # models:
31
+ # openai/Pro: "GPT-5"
32
+ models: {}
33
+ api_key_disclaimer:
34
+ 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
+ options: ["Yes", "No", "Yes. Don't show again"]
36
+ no_reprompt: false
37
+ mail:
38
+ email: "patchwise@qualcomm.com"
39
+ password: ""
40
+ from_email: "Patchwise <patchwise@qualcomm.com>"
41
+ accepted_sender_domains: []
42
+ accepted_lists: []
43
+ deprecated_lists: {}
44
+ always_cc: []
45
+ additional_cc: []
46
+ send_mode: 2
47
+ imap:
48
+ server: "imap.gmail.com"
49
+ port: 993
50
+ ssl: true
51
+ smtp:
52
+ server: "smtp.gmail.com"
53
+ port: 465
54
+ ssl: true