llama-github 0.3.1__tar.gz → 0.3.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 (40) hide show
  1. {llama_github-0.3.1 → llama_github-0.3.3}/CHANGELOG.md +10 -0
  2. {llama_github-0.3.1/llama_github.egg-info → llama_github-0.3.3}/PKG-INFO +43 -1
  3. {llama_github-0.3.1 → llama_github-0.3.3}/README.md +32 -0
  4. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/data_retrieval/github_entities.py +87 -46
  5. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/utils.py +97 -6
  6. llama_github-0.3.3/llama_github/version.py +1 -0
  7. {llama_github-0.3.1 → llama_github-0.3.3/llama_github.egg-info}/PKG-INFO +43 -1
  8. {llama_github-0.3.1 → llama_github-0.3.3}/setup.cfg +1 -1
  9. llama_github-0.3.1/llama_github/version.py +0 -1
  10. {llama_github-0.3.1 → llama_github-0.3.3}/LICENSE +0 -0
  11. {llama_github-0.3.1 → llama_github-0.3.3}/MANIFEST.in +0 -0
  12. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/__init__.py +0 -0
  13. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/config/__init__.py +0 -0
  14. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/config/config.json +0 -0
  15. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/config/config.py +0 -0
  16. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/data_retrieval/__init__.py +0 -0
  17. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/data_retrieval/github_api.py +0 -0
  18. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/features/__init__.py +0 -0
  19. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/features/feature_flags.py +0 -0
  20. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/features/insider_features.py +0 -0
  21. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/github_integration/__init__.py +0 -0
  22. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/github_integration/github_auth_manager.py +0 -0
  23. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/github_rag.py +0 -0
  24. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/llm_integration/__init__.py +0 -0
  25. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/llm_integration/initial_load.py +0 -0
  26. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/llm_integration/llm_handler.py +0 -0
  27. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/logger.py +0 -0
  28. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/rag_processing/__init__.py +0 -0
  29. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github/rag_processing/rag_processor.py +0 -0
  30. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github.egg-info/SOURCES.txt +0 -0
  31. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github.egg-info/dependency_links.txt +0 -0
  32. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github.egg-info/requires.txt +0 -0
  33. {llama_github-0.3.1 → llama_github-0.3.3}/llama_github.egg-info/top_level.txt +0 -0
  34. {llama_github-0.3.1 → llama_github-0.3.3}/setup.py +0 -0
  35. {llama_github-0.3.1 → llama_github-0.3.3}/tests/test_data_retrieval.py +0 -0
  36. {llama_github-0.3.1 → llama_github-0.3.3}/tests/test_github_auth_manager.py +0 -0
  37. {llama_github-0.3.1 → llama_github-0.3.3}/tests/test_initial_load.py +0 -0
  38. {llama_github-0.3.1 → llama_github-0.3.3}/tests/test_llm_handler.py +0 -0
  39. {llama_github-0.3.1 → llama_github-0.3.3}/tests/test_logger.py +0 -0
  40. {llama_github-0.3.1 → llama_github-0.3.3}/tests/test_rag_processor.py +0 -0
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.3.3] - 2025-08-24
9
+
10
+ ### Optimized
11
+ - Enhance diff hunk header
12
+
13
+ ## [0.3.2] - 2025-06-23
14
+
15
+ ### Optimized
16
+ - Upgrade to extract_related_issues method
17
+
8
18
  ## [0.3.1] - 2025-05-25
9
19
 
10
20
  ### Optimized
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llama-github
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Llama-github is an open-source Python library that empowers LLM Chatbots, AI Agents, and Auto-dev Agents to conduct Retrieval from actively selected GitHub public projects. It Augments through LLMs and Generates context for any coding question, in order to streamline the development of sophisticated AI-driven applications.
5
5
  Home-page: https://github.com/JetXu-LLM/llama-github
6
6
  Author: Jet Xu
@@ -32,6 +32,38 @@ Requires-Dist: flake8; extra == "dev"
32
32
  Dynamic: license-file
33
33
  Dynamic: requires-dist
34
34
 
35
+
36
+ <div align="right">
37
+ <details>
38
+ <summary >🌐 Language</summary>
39
+ <div>
40
+ <div align="center">
41
+ <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=en">English</a>
42
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=zh-CN">简体中文</a>
43
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=zh-TW">繁體中文</a>
44
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=ja">日本語</a>
45
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=ko">한국어</a>
46
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=hi">हिन्दी</a>
47
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=th">ไทย</a>
48
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=fr">Français</a>
49
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=de">Deutsch</a>
50
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=es">Español</a>
51
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=it">Italiano</a>
52
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=ru">Русский</a>
53
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=pt">Português</a>
54
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=nl">Nederlands</a>
55
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=pl">Polski</a>
56
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=ar">العربية</a>
57
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=fa">فارسی</a>
58
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=tr">Türkçe</a>
59
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=vi">Tiếng Việt</a>
60
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=id">Bahasa Indonesia</a>
61
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=as">অসমীয়া</
62
+ </div>
63
+ </div>
64
+ </details>
65
+ </div>
66
+
35
67
  # llama-github
36
68
 
37
69
  [Detail Document] https://deepwiki.com/JetXu-LLM/llama-github
@@ -156,6 +188,16 @@ All notable changes to this project will be documented in this file.
156
188
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
157
189
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
158
190
 
191
+ ## [0.3.3] - 2025-08-24
192
+
193
+ ### Optimized
194
+ - Enhance diff hunk header
195
+
196
+ ## [0.3.2] - 2025-06-23
197
+
198
+ ### Optimized
199
+ - Upgrade to extract_related_issues method
200
+
159
201
  ## [0.3.1] - 2025-05-25
160
202
 
161
203
  ### Optimized
@@ -1,3 +1,35 @@
1
+
2
+ <div align="right">
3
+ <details>
4
+ <summary >🌐 Language</summary>
5
+ <div>
6
+ <div align="center">
7
+ <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=en">English</a>
8
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=zh-CN">简体中文</a>
9
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=zh-TW">繁體中文</a>
10
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=ja">日本語</a>
11
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=ko">한국어</a>
12
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=hi">हिन्दी</a>
13
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=th">ไทย</a>
14
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=fr">Français</a>
15
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=de">Deutsch</a>
16
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=es">Español</a>
17
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=it">Italiano</a>
18
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=ru">Русский</a>
19
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=pt">Português</a>
20
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=nl">Nederlands</a>
21
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=pl">Polski</a>
22
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=ar">العربية</a>
23
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=fa">فارسی</a>
24
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=tr">Türkçe</a>
25
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=vi">Tiếng Việt</a>
26
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=id">Bahasa Indonesia</a>
27
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=as">অসমীয়া</
28
+ </div>
29
+ </div>
30
+ </details>
31
+ </div>
32
+
1
33
  # llama-github
2
34
 
3
35
  [Detail Document] https://deepwiki.com/JetXu-LLM/llama-github
@@ -396,77 +396,118 @@ class Repository:
396
396
 
397
397
  def extract_related_issues(self, pr_data: Dict[str, Any]) -> List[int]:
398
398
  """
399
- Extracts related issue numbers from all PR data following GitHub's reference syntax.
400
-
401
- This function implements GitHub's official autolink reference formats to find:
402
- 1. Full GitHub issue/PR URLs
403
- 2. Numeric references (#123)
404
- 3. Keywords + issue references (fixes #123)
405
- 4. Repository cross-references (owner/repo#123)
406
-
407
- See: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls
408
-
399
+ Extracts related issue numbers from PR data using adaptive strategies based on content length.
400
+
401
+ Uses different matching strategies:
402
+ - Short descriptions (<200 chars): Aggressive patterns for simple references
403
+ - Long descriptions (>=200 chars): Strict patterns to avoid false positives
404
+
409
405
  Args:
410
- pr_data: Dict[str, Any] - The complete pull request data dictionary
406
+ pr_data: Complete pull request data dictionary
411
407
 
412
408
  Returns:
413
- List[int] - A sorted list of unique issue numbers found in the PR data
409
+ List[int] - Sorted list of unique issue numbers
414
410
  """
415
411
  # GitHub's official closing keywords
416
412
  closing_keywords = (
417
- 'close', 'closes', 'closed',
418
- 'fix', 'fixes', 'fixed',
419
- 'resolve', 'resolves', 'resolved'
413
+ 'close', 'closes', 'closed',
414
+ 'fix', 'fixes', 'fixed',
415
+ 'resolve', 'resolves', 'resolved',
416
+ 'address', 'addresses', 'addressing',
417
+ 'relate', 'relates', 'related',
418
+ 'see',
419
+ 'issue', 'bug', 'ticket', 'todo', 'task'
420
420
  )
421
421
 
422
- # Regex patterns for GitHub issue references
423
- patterns = [
424
- # Full GitHub issue/PR URL pattern
425
- rf'(?:https?://)?github\.com/{re.escape(self.full_name)}/(?:issues|pull)/(\d+)',
426
-
427
- # # Standard #123 reference with proper boundaries
428
- # r'(?:^|[^\w/])#(\d+)(?=[^\w/]|$)',
429
-
430
- # Closing keywords (fixes #123)
431
- fr'(?:^|[^\w/])(?:{"|".join(closing_keywords)}):?\s+#(\d+)(?=[^\w/]|$)',
432
-
433
- # Cross-repo reference (owner/repo#123)
434
- rf'{re.escape(self.full_name)}#(\d+)',
422
+ issues = set()
423
+
424
+ def get_description_length(data: Dict[str, Any]) -> int:
425
+ """Get the length of PR description for strategy selection"""
426
+ try:
427
+ description = data.get('pr_metadata', {}).get('description', '')
428
+ return len(description) if isinstance(description, str) else 0
429
+ except:
430
+ return 0
431
+
432
+ def extract_with_aggressive_patterns(text: str) -> None:
433
+ """Aggressive patterns for short, focused descriptions"""
434
+ if not isinstance(text, str):
435
+ return
436
+
437
+ patterns = [
438
+ # Simple #123 reference (most common in short descriptions)
439
+ r'#(\d+)(?!\d)',
440
+
441
+ # Full GitHub URLs
442
+ rf'(?:https?://)?github\.com/{re.escape(self.full_name)}/(?:issues|pull)/(\d+)',
443
+
444
+ # Closing keywords with flexible spacing
445
+ fr'(?:{"|".join(closing_keywords)})\s*:?\s*#?(\d+)(?!\d)',
446
+
447
+ # Action words commonly used in short descriptions
448
+ r'(?:addresses?|references?|relates?\s+to|see)\s+#?(\d+)(?!\d)',
449
+ ]
435
450
 
436
- # Issue keyword reference (issue #123 or issue: #123)
437
- r'(?:^|[^\w/])(?:issue|bug|ticket|todo|task)s?:?\s+#?(\d+)(?=[^\w/]|$)'
438
- ]
451
+ for pattern in patterns:
452
+ matches = re.findall(pattern, text, re.IGNORECASE)
453
+ valid_matches = [
454
+ int(match) for match in matches
455
+ if match.isdigit() and len(match) <= 6 and int(match) > 0
456
+ ]
457
+ issues.update(valid_matches)
439
458
 
440
- issues = set()
441
-
442
- def extract_from_text(text: str) -> None:
443
- """Helper function to extract issue numbers from text"""
459
+ def extract_with_strict_patterns(text: str) -> None:
460
+ """Strict patterns for long descriptions to avoid false positives"""
444
461
  if not isinstance(text, str):
445
462
  return
446
463
 
464
+ patterns = [
465
+ # Full GitHub URLs (always reliable)
466
+ rf'(?:https?://)?github\.com/{re.escape(self.full_name)}/(?:issues|pull)/(\d+)',
467
+
468
+ # Closing keywords with word boundaries
469
+ fr'\b(?:{"|".join(closing_keywords)})\s*:?\s*#(\d+)\b',
470
+
471
+ # Explicit issue references with word boundaries
472
+ r'\b(?:issue|bug|ticket|pr|pull\s+request)\s*:?\s*#?(\d+)\b',
473
+
474
+ # Cross-repo references
475
+ rf'\b{re.escape(self.full_name)}#(\d+)\b',
476
+ ]
477
+
447
478
  for pattern in patterns:
448
- matches = re.findall(pattern, text, re.IGNORECASE | re.MULTILINE)
449
- # Validate issue numbers (reasonable length and positive values)
479
+ matches = re.findall(pattern, text, re.IGNORECASE)
450
480
  valid_matches = [
451
481
  int(match) for match in matches
452
- if match.isdigit() and len(match) <= 7 and int(match) > 0
482
+ if match.isdigit() and len(match) <= 6 and int(match) > 0
453
483
  ]
454
484
  issues.update(valid_matches)
455
485
 
456
- def process_value(value: Any) -> None:
457
- """Recursively process dictionary values and extract issue numbers"""
486
+ def extract_from_text(text: str, use_aggressive: bool = False) -> None:
487
+ """Extract issue numbers using appropriate strategy"""
488
+ if use_aggressive:
489
+ extract_with_aggressive_patterns(text)
490
+ else:
491
+ extract_with_strict_patterns(text)
492
+
493
+ def process_value(value: Any, use_aggressive: bool = False) -> None:
494
+ """Recursively process values and extract issue numbers"""
458
495
  if isinstance(value, dict):
459
496
  for v in value.values():
460
- process_value(v)
497
+ process_value(v, use_aggressive)
461
498
  elif isinstance(value, (list, tuple)):
462
499
  for item in value:
463
- process_value(item)
500
+ process_value(item, use_aggressive)
464
501
  elif isinstance(value, str):
465
- extract_from_text(value)
502
+ extract_from_text(value, use_aggressive)
503
+
504
+ # Determine strategy based on description length
505
+ desc_length = get_description_length(pr_data)
506
+ use_aggressive_strategy = desc_length < 200
507
+
508
+ # Process all PR data
509
+ process_value(pr_data, use_aggressive_strategy)
466
510
 
467
- # Process all data in pr_data recursively
468
- process_value(pr_data)
469
-
470
511
  return sorted(list(issues))
471
512
 
472
513
 
@@ -11,12 +11,49 @@ import ast
11
11
  class DiffGenerator:
12
12
  """
13
13
  A class for generating custom diffs between two pieces of content.
14
+ It enhances the standard unified diff by adding function/class context to hunk headers,
15
+ similar to `git diff`, in a fail-safe manner.
14
16
  """
15
17
 
18
+ # A pre-compiled list of regex patterns to find function/class definitions.
19
+ # This is the core mechanism that mimics Git's `xfuncname` feature.
20
+ # It covers a wide range of common languages to provide broad, out-of-the-box support.
21
+ _FUNC_CONTEXT_PATTERNS = [
22
+ re.compile(r'^\s*(def|class)\s+.*', re.IGNORECASE), # Python
23
+ re.compile(r'^\s*(public|private|protected|static|final|native|synchronized|abstract|transient|volatile|strictfp|async|function|class|interface|enum|@|implements|extends)'), # Java, JS, TS, PHP, C#
24
+ re.compile(r'^\s*(func|fn|impl|trait|struct|enum|mod)\s+.*', re.IGNORECASE), # Go, Rust
25
+ re.compile(r'^\s*(def|class|module)\s+.*', re.IGNORECASE), # Ruby
26
+ re.compile(r'^\s*([a-zA-Z_][a-zA-Z0-9_]*\s+)*[a-zA-Z_][a-zA-Z0-9_]*\s*\(.*\)\s*\{'), # C, C++ style function definitions
27
+ re.compile(r'^sub\s+.*'), # Perl
28
+ ]
29
+
30
+ @staticmethod
31
+ def _find_context(line_index: int, lines: List[str]) -> str:
32
+ """
33
+ Search upwards from a given line index to find the nearest function/class context.
34
+
35
+ Args:
36
+ line_index (int): The 0-based index to start searching upwards from.
37
+ lines (List[str]): The content of the file, as a list of lines.
38
+
39
+ Returns:
40
+ str: The found context line, stripped of whitespace, or an empty string if not found.
41
+ """
42
+ # Search from the target line upwards to the beginning of the file.
43
+ for i in range(line_index, -1, -1):
44
+ line = lines[i]
45
+ # Check the line against all our predefined patterns.
46
+ for pattern in DiffGenerator._FUNC_CONTEXT_PATTERNS:
47
+ if pattern.search(line):
48
+ return line.strip()
49
+ return "" # Return empty string if no context is found.
50
+
16
51
  @staticmethod
17
52
  def generate_custom_diff(base_content: str, head_content: str, context_lines: int) -> str:
18
53
  """
19
- Generate a custom diff between two pieces of content with specified context lines.
54
+ Generate a custom diff between two pieces of content with specified context lines,
55
+ and automatically add function/class context to hunk headers, similar to `git diff`.
56
+ This method is designed to be fail-safe; if context addition fails, it returns the standard diff.
20
57
 
21
58
  Args:
22
59
  base_content (str): The original content.
@@ -24,7 +61,7 @@ class DiffGenerator:
24
61
  context_lines (int): The number of context lines to include in the diff.
25
62
 
26
63
  Returns:
27
- str: A string representation of the unified diff.
64
+ str: A string representation of the unified diff, preferably with hunk headers.
28
65
 
29
66
  Raises:
30
67
  ValueError: If context_lines is negative.
@@ -40,15 +77,69 @@ class DiffGenerator:
40
77
  # File is deleted
41
78
  return "".join(f"- {line}\n" for line in base_content.splitlines())
42
79
 
80
+ # Use empty strings for None content to ensure difflib handles them correctly
81
+ # as file additions or deletions. This is more robust and aligns with difflib's expectations.
82
+ base_content = base_content or ""
83
+ head_content = head_content or ""
84
+
43
85
  base_lines: List[str] = base_content.splitlines()
44
86
  head_lines: List[str] = head_content.splitlines()
45
87
 
88
+ # Generate the standard unified diff. This part is considered stable.
89
+ diff: List[str] = list(difflib.unified_diff(
90
+ base_lines,
91
+ head_lines,
92
+ n=context_lines,
93
+ lineterm=''
94
+ ))
95
+
96
+ if not diff:
97
+ return "" # No differences found, return early.
98
+
99
+ # --- Start of the fail-safe enhancement logic ---
100
+ # This entire block attempts to add context to hunk headers.
101
+ # If any exception occurs here, we catch it and return the original, un-enhanced diff.
102
+ # This ensures the function is always reliable (Pareto improvement).
46
103
  try:
47
- diff: List[str] = list(difflib.unified_diff(base_lines, head_lines, n=context_lines, lineterm=''))
48
- return '\n'.join(diff)
104
+ enhanced_diff = []
105
+ # Regex to parse the original line number from a hunk header.
106
+ # e.g., from "@@ -35,7 +35,7 @@" it captures "35".
107
+ hunk_header_re = re.compile(r'^@@ -(\d+)(?:,\d+)? .*')
108
+
109
+ for line in diff:
110
+ match = hunk_header_re.match(line)
111
+ if match:
112
+ # This is a hunk header line.
113
+ # The line number from the regex is 1-based.
114
+ start_line_num = int(match.group(1))
115
+
116
+ # The index is 0-based, so we subtract 1.
117
+ # We search from the line where the change starts, or the line before it.
118
+ context_line_index = max(0, start_line_num - 1)
119
+ context = DiffGenerator._find_context(context_line_index, base_lines)
120
+
121
+ if context:
122
+ # If context was found, append it to the hunk header.
123
+ enhanced_diff.append(f"{line} {context}")
124
+ else:
125
+ # Otherwise, use the original hunk header.
126
+ enhanced_diff.append(line)
127
+ else:
128
+ # This is not a hunk header, just a regular diff line (+, -, ' ').
129
+ enhanced_diff.append(line)
130
+
131
+ # If the enhancement process completes successfully, return the result.
132
+ return '\n'.join(enhanced_diff)
133
+
49
134
  except Exception as e:
50
- logger.exception(f"Error generating diff: {str(e)}")
51
- return ""
135
+ # If any error occurred during the enhancement, log a warning and fall back.
136
+ logger.warning(
137
+ f"Could not add hunk header context due to an unexpected error: {str(e)}. "
138
+ "Falling back to standard diff output."
139
+ )
140
+ # --- Fallback mechanism ---
141
+ # Return the original, unmodified diff generated by difflib.
142
+ return '\n'.join(diff)
52
143
 
53
144
 
54
145
  class DataAnonymizer:
@@ -0,0 +1 @@
1
+ __version__ = '0.3.3'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: llama-github
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Llama-github is an open-source Python library that empowers LLM Chatbots, AI Agents, and Auto-dev Agents to conduct Retrieval from actively selected GitHub public projects. It Augments through LLMs and Generates context for any coding question, in order to streamline the development of sophisticated AI-driven applications.
5
5
  Home-page: https://github.com/JetXu-LLM/llama-github
6
6
  Author: Jet Xu
@@ -32,6 +32,38 @@ Requires-Dist: flake8; extra == "dev"
32
32
  Dynamic: license-file
33
33
  Dynamic: requires-dist
34
34
 
35
+
36
+ <div align="right">
37
+ <details>
38
+ <summary >🌐 Language</summary>
39
+ <div>
40
+ <div align="center">
41
+ <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=en">English</a>
42
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=zh-CN">简体中文</a>
43
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=zh-TW">繁體中文</a>
44
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=ja">日本語</a>
45
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=ko">한국어</a>
46
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=hi">हिन्दी</a>
47
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=th">ไทย</a>
48
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=fr">Français</a>
49
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=de">Deutsch</a>
50
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=es">Español</a>
51
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=it">Italiano</a>
52
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=ru">Русский</a>
53
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=pt">Português</a>
54
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=nl">Nederlands</a>
55
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=pl">Polski</a>
56
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=ar">العربية</a>
57
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=fa">فارسی</a>
58
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=tr">Türkçe</a>
59
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=vi">Tiếng Việt</a>
60
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=id">Bahasa Indonesia</a>
61
+ | <a href="https://openaitx.github.io/view.html?user=JetXu-LLM&project=llama-github&lang=as">অসমীয়া</
62
+ </div>
63
+ </div>
64
+ </details>
65
+ </div>
66
+
35
67
  # llama-github
36
68
 
37
69
  [Detail Document] https://deepwiki.com/JetXu-LLM/llama-github
@@ -156,6 +188,16 @@ All notable changes to this project will be documented in this file.
156
188
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
157
189
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
158
190
 
191
+ ## [0.3.3] - 2025-08-24
192
+
193
+ ### Optimized
194
+ - Enhance diff hunk header
195
+
196
+ ## [0.3.2] - 2025-06-23
197
+
198
+ ### Optimized
199
+ - Upgrade to extract_related_issues method
200
+
159
201
  ## [0.3.1] - 2025-05-25
160
202
 
161
203
  ### Optimized
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = llama-github
3
- version = 0.3.1
3
+ version = 0.3.3
4
4
  author = Jet Xu
5
5
  author_email = Voldemort.xu@foxmail.com
6
6
  description = Llama-github is an open-source Python library that empowers LLM Chatbots, AI Agents, and Auto-dev Agents to conduct Retrieval from actively selected GitHub public projects. It Augments through LLMs and Generates context for any coding question, in order to streamline the development of sophisticated AI-driven applications.
@@ -1 +0,0 @@
1
- __version__ = '0.3.1'
File without changes
File without changes
File without changes