ai-coding-assistant 0.5.0__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 (89) hide show
  1. ai_coding_assistant-0.5.0.dist-info/METADATA +226 -0
  2. ai_coding_assistant-0.5.0.dist-info/RECORD +89 -0
  3. ai_coding_assistant-0.5.0.dist-info/WHEEL +4 -0
  4. ai_coding_assistant-0.5.0.dist-info/entry_points.txt +3 -0
  5. ai_coding_assistant-0.5.0.dist-info/licenses/LICENSE +21 -0
  6. coding_assistant/__init__.py +3 -0
  7. coding_assistant/__main__.py +19 -0
  8. coding_assistant/cli/__init__.py +1 -0
  9. coding_assistant/cli/app.py +158 -0
  10. coding_assistant/cli/commands/__init__.py +19 -0
  11. coding_assistant/cli/commands/ask.py +178 -0
  12. coding_assistant/cli/commands/config.py +438 -0
  13. coding_assistant/cli/commands/diagram.py +267 -0
  14. coding_assistant/cli/commands/document.py +410 -0
  15. coding_assistant/cli/commands/explain.py +192 -0
  16. coding_assistant/cli/commands/fix.py +249 -0
  17. coding_assistant/cli/commands/index.py +162 -0
  18. coding_assistant/cli/commands/refactor.py +245 -0
  19. coding_assistant/cli/commands/search.py +182 -0
  20. coding_assistant/cli/commands/serve_docs.py +128 -0
  21. coding_assistant/cli/repl.py +381 -0
  22. coding_assistant/cli/theme.py +90 -0
  23. coding_assistant/codebase/__init__.py +1 -0
  24. coding_assistant/codebase/crawler.py +93 -0
  25. coding_assistant/codebase/parser.py +266 -0
  26. coding_assistant/config/__init__.py +25 -0
  27. coding_assistant/config/config_manager.py +615 -0
  28. coding_assistant/config/settings.py +82 -0
  29. coding_assistant/context/__init__.py +19 -0
  30. coding_assistant/context/chunker.py +443 -0
  31. coding_assistant/context/enhanced_retriever.py +322 -0
  32. coding_assistant/context/hybrid_search.py +311 -0
  33. coding_assistant/context/ranker.py +355 -0
  34. coding_assistant/context/retriever.py +119 -0
  35. coding_assistant/context/window.py +362 -0
  36. coding_assistant/documentation/__init__.py +23 -0
  37. coding_assistant/documentation/agents/__init__.py +27 -0
  38. coding_assistant/documentation/agents/coordinator.py +510 -0
  39. coding_assistant/documentation/agents/module_documenter.py +111 -0
  40. coding_assistant/documentation/agents/synthesizer.py +139 -0
  41. coding_assistant/documentation/agents/task_delegator.py +100 -0
  42. coding_assistant/documentation/decomposition/__init__.py +21 -0
  43. coding_assistant/documentation/decomposition/context_preserver.py +477 -0
  44. coding_assistant/documentation/decomposition/module_detector.py +302 -0
  45. coding_assistant/documentation/decomposition/partitioner.py +621 -0
  46. coding_assistant/documentation/generators/__init__.py +14 -0
  47. coding_assistant/documentation/generators/dataflow_generator.py +440 -0
  48. coding_assistant/documentation/generators/diagram_generator.py +511 -0
  49. coding_assistant/documentation/graph/__init__.py +13 -0
  50. coding_assistant/documentation/graph/dependency_builder.py +468 -0
  51. coding_assistant/documentation/graph/module_analyzer.py +475 -0
  52. coding_assistant/documentation/writers/__init__.py +11 -0
  53. coding_assistant/documentation/writers/markdown_writer.py +322 -0
  54. coding_assistant/embeddings/__init__.py +0 -0
  55. coding_assistant/embeddings/generator.py +89 -0
  56. coding_assistant/embeddings/store.py +187 -0
  57. coding_assistant/exceptions/__init__.py +50 -0
  58. coding_assistant/exceptions/base.py +110 -0
  59. coding_assistant/exceptions/llm.py +249 -0
  60. coding_assistant/exceptions/recovery.py +263 -0
  61. coding_assistant/exceptions/storage.py +213 -0
  62. coding_assistant/exceptions/validation.py +230 -0
  63. coding_assistant/llm/__init__.py +1 -0
  64. coding_assistant/llm/client.py +277 -0
  65. coding_assistant/llm/gemini_client.py +181 -0
  66. coding_assistant/llm/groq_client.py +160 -0
  67. coding_assistant/llm/prompts.py +98 -0
  68. coding_assistant/llm/together_client.py +160 -0
  69. coding_assistant/operations/__init__.py +13 -0
  70. coding_assistant/operations/differ.py +369 -0
  71. coding_assistant/operations/generator.py +347 -0
  72. coding_assistant/operations/linter.py +430 -0
  73. coding_assistant/operations/validator.py +406 -0
  74. coding_assistant/storage/__init__.py +9 -0
  75. coding_assistant/storage/database.py +363 -0
  76. coding_assistant/storage/session.py +231 -0
  77. coding_assistant/utils/__init__.py +31 -0
  78. coding_assistant/utils/cache.py +477 -0
  79. coding_assistant/utils/hardware.py +132 -0
  80. coding_assistant/utils/keystore.py +206 -0
  81. coding_assistant/utils/logger.py +32 -0
  82. coding_assistant/utils/progress.py +311 -0
  83. coding_assistant/validation/__init__.py +13 -0
  84. coding_assistant/validation/files.py +305 -0
  85. coding_assistant/validation/inputs.py +335 -0
  86. coding_assistant/validation/params.py +280 -0
  87. coding_assistant/validation/sanitizers.py +243 -0
  88. coding_assistant/vcs/__init__.py +5 -0
  89. coding_assistant/vcs/git.py +269 -0
@@ -0,0 +1,139 @@
1
+ """Synthesize module documentation into repository overview.
2
+
3
+ This module combines individual module documentation into a cohesive
4
+ repository-level documentation.
5
+ """
6
+
7
+ from typing import Dict, List
8
+ from pathlib import Path
9
+
10
+ from coding_assistant.documentation.decomposition.partitioner import Partition
11
+ from coding_assistant.utils.logger import get_logger
12
+
13
+ logger = get_logger(__name__)
14
+
15
+
16
+ class DocumentationSynthesizer:
17
+ """
18
+ Synthesize module-level documentation into repository overview.
19
+
20
+ Creates:
21
+ - Repository overview
22
+ - Architecture documentation
23
+ - Module index
24
+ - Cross-module relationships
25
+ """
26
+
27
+ def __init__(self, llm_client=None):
28
+ """
29
+ Initialize synthesizer.
30
+
31
+ Args:
32
+ llm_client: LLM client instance
33
+ """
34
+ from coding_assistant.llm.client import LLMClientFactory
35
+ self.llm_client = llm_client or LLMClientFactory.create_client()
36
+
37
+ async def synthesize_overview(self,
38
+ module_docs: Dict[str, str],
39
+ partitions: List[Partition],
40
+ repo_metadata: Dict) -> str:
41
+ """
42
+ Synthesize repository overview from module documentation.
43
+
44
+ Args:
45
+ module_docs: Module name -> documentation mapping
46
+ partitions: List of partitions
47
+ repo_metadata: Repository metadata
48
+
49
+ Returns:
50
+ Repository overview documentation as markdown
51
+ """
52
+ logger.info(f"Synthesizing overview from {len(module_docs)} module documents")
53
+
54
+ # Extract summaries from each module doc
55
+ summaries = self._extract_summaries(module_docs)
56
+
57
+ # Build synthesis prompt
58
+ prompt = self._build_synthesis_prompt(summaries, partitions, repo_metadata)
59
+
60
+ try:
61
+ # LLM clients use messages format and return generators
62
+ messages = [{"role": "user", "content": prompt}]
63
+
64
+ # Generate and collect response chunks
65
+ response_chunks = []
66
+ for chunk in self.llm_client.generate(messages=messages, stream=True):
67
+ response_chunks.append(chunk)
68
+
69
+ overview = ''.join(response_chunks)
70
+ return overview
71
+
72
+ except Exception as e:
73
+ logger.error(f"Synthesis failed: {e}")
74
+ return self._generate_fallback_overview(summaries, partitions)
75
+
76
+ def _extract_summaries(self, module_docs: Dict[str, str]) -> Dict[str, str]:
77
+ """Extract one-sentence summaries from module docs."""
78
+ summaries = {}
79
+
80
+ for module_name, doc in module_docs.items():
81
+ # Extract first paragraph or first meaningful line
82
+ lines = [l.strip() for l in doc.split('\n') if l.strip() and not l.strip().startswith('#')]
83
+ summary = lines[0] if lines else "No summary available"
84
+ summaries[module_name] = summary[:200] # Limit length
85
+
86
+ return summaries
87
+
88
+ def _build_synthesis_prompt(self,
89
+ summaries: Dict[str, str],
90
+ partitions: List[Partition],
91
+ repo_metadata: Dict) -> str:
92
+ """Build prompt for repository overview."""
93
+ module_list = "\n".join(f"- **{name}**: {summary}" for name, summary in summaries.items())
94
+
95
+ total_files = sum(len(p.files) for p in partitions)
96
+ total_loc = sum(p.size_loc for p in partitions)
97
+
98
+ return f"""Create a comprehensive repository overview from the following module documentation.
99
+
100
+ **Repository**: {repo_metadata.get('name', 'Code Repository')}
101
+ **Modules**: {len(summaries)}
102
+ **Total Files**: {total_files}
103
+ **Total LOC**: {total_loc}
104
+
105
+ **Module Summaries**:
106
+ {module_list}
107
+
108
+ Generate a professional README-style overview that includes:
109
+
110
+ 1. **Executive Summary** - What this repository does (2-3 paragraphs)
111
+ 2. **Architecture Overview** - High-level system design
112
+ 3. **Module Organization** - How modules are organized
113
+ 4. **Key Features** - Main capabilities
114
+ 5. **Technology Stack** - Languages, frameworks, tools
115
+ 6. **Getting Started** - Quick start guide for new developers
116
+
117
+ Format as markdown. Be concise but comprehensive.
118
+ """
119
+
120
+ def _generate_fallback_overview(self,
121
+ summaries: Dict[str, str],
122
+ partitions: List[Partition]) -> str:
123
+ """Generate basic overview without LLM."""
124
+ total_files = sum(len(p.files) for p in partitions)
125
+ total_loc = sum(p.size_loc for p in partitions)
126
+
127
+ doc = f"""# Repository Documentation
128
+
129
+ ## Overview
130
+
131
+ This repository contains {len(partitions)} modules with {total_files} files ({total_loc} lines of code).
132
+
133
+ ## Modules
134
+
135
+ """
136
+ for module_name, summary in summaries.items():
137
+ doc += f"### {module_name}\n\n{summary}\n\n"
138
+
139
+ return doc
@@ -0,0 +1,100 @@
1
+ """Dynamic task delegation for workload optimization.
2
+
3
+ This module optimizes how tasks are assigned to agents based on
4
+ workload, priority, and resource availability.
5
+ """
6
+
7
+ from typing import List, Dict, Optional
8
+ from collections import defaultdict
9
+
10
+ from coding_assistant.documentation.agents.coordinator import DocumentationTask
11
+ from coding_assistant.utils.logger import get_logger
12
+
13
+ logger = get_logger(__name__)
14
+
15
+
16
+ class TaskDelegator:
17
+ """
18
+ Optimize task delegation across agents.
19
+
20
+ Handles:
21
+ - Load balancing
22
+ - Priority scheduling
23
+ - Resource optimization
24
+ - Adaptive scheduling
25
+ """
26
+
27
+ def __init__(self, num_agents: int = 3):
28
+ """
29
+ Initialize task delegator.
30
+
31
+ Args:
32
+ num_agents: Number of available agents
33
+ """
34
+ self.num_agents = num_agents
35
+ self.agent_loads: Dict[int, int] = defaultdict(int) # Agent ID -> current load
36
+
37
+ def delegate_tasks(self, tasks: List[DocumentationTask]) -> Dict[int, List[DocumentationTask]]:
38
+ """
39
+ Delegate tasks to agents optimally.
40
+
41
+ Args:
42
+ tasks: List of tasks to delegate
43
+
44
+ Returns:
45
+ Dictionary mapping agent IDs to their assigned tasks
46
+ """
47
+ logger.info(f"Delegating {len(tasks)} tasks across {self.num_agents} agents")
48
+
49
+ # Sort tasks by priority (lower number = higher priority)
50
+ sorted_tasks = sorted(tasks, key=lambda t: (t.priority, -t.partition.size_loc))
51
+
52
+ # Assign tasks using greedy load balancing
53
+ assignments: Dict[int, List[DocumentationTask]] = defaultdict(list)
54
+
55
+ for task in sorted_tasks:
56
+ # Find agent with lowest current load
57
+ agent_id = min(range(self.num_agents), key=lambda i: self.agent_loads[i])
58
+
59
+ # Assign task
60
+ assignments[agent_id].append(task)
61
+
62
+ # Update load (use partition size as weight)
63
+ self.agent_loads[agent_id] += task.partition.size_loc
64
+
65
+ # Log delegation stats
66
+ for agent_id, agent_tasks in assignments.items():
67
+ logger.debug(f"Agent {agent_id}: {len(agent_tasks)} tasks, "
68
+ f"{self.agent_loads[agent_id]} LOC")
69
+
70
+ return dict(assignments)
71
+
72
+ def get_load_balance_score(self) -> float:
73
+ """
74
+ Compute load balance quality (0-1, higher is better).
75
+
76
+ Returns:
77
+ Balance score
78
+ """
79
+ if not self.agent_loads:
80
+ return 1.0
81
+
82
+ loads = list(self.agent_loads.values())
83
+ if not loads:
84
+ return 1.0
85
+
86
+ avg_load = sum(loads) / len(loads)
87
+ if avg_load == 0:
88
+ return 1.0
89
+
90
+ # Compute coefficient of variation
91
+ variance = sum((load - avg_load) ** 2 for load in loads) / len(loads)
92
+ std_dev = variance ** 0.5
93
+ cv = std_dev / avg_load
94
+
95
+ # Convert to 0-1 score (lower CV = better balance)
96
+ return max(0, 1.0 - cv)
97
+
98
+ def reset_loads(self):
99
+ """Reset agent load tracking."""
100
+ self.agent_loads.clear()
@@ -0,0 +1,21 @@
1
+ """Hierarchical decomposition for scalable repository processing."""
2
+
3
+ from coding_assistant.documentation.decomposition.partitioner import (
4
+ HierarchicalPartitioner,
5
+ Partition,
6
+ )
7
+ from coding_assistant.documentation.decomposition.context_preserver import (
8
+ ContextPreserver,
9
+ ModuleContext,
10
+ )
11
+ from coding_assistant.documentation.decomposition.module_detector import (
12
+ ModuleDetector,
13
+ )
14
+
15
+ __all__ = [
16
+ 'HierarchicalPartitioner',
17
+ 'Partition',
18
+ 'ContextPreserver',
19
+ 'ModuleContext',
20
+ 'ModuleDetector',
21
+ ]