pycodesage 0.1.0__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 (38) hide show
  1. pycodesage-0.1.0/LICENSE +21 -0
  2. pycodesage-0.1.0/PKG-INFO +242 -0
  3. pycodesage-0.1.0/README.md +200 -0
  4. pycodesage-0.1.0/codesage/__init__.py +4 -0
  5. pycodesage-0.1.0/codesage/__main__.py +6 -0
  6. pycodesage-0.1.0/codesage/cli/__init__.py +5 -0
  7. pycodesage-0.1.0/codesage/cli/main.py +461 -0
  8. pycodesage-0.1.0/codesage/core/__init__.py +6 -0
  9. pycodesage-0.1.0/codesage/core/indexer.py +229 -0
  10. pycodesage-0.1.0/codesage/core/suggester.py +182 -0
  11. pycodesage-0.1.0/codesage/llm/__init__.py +11 -0
  12. pycodesage-0.1.0/codesage/llm/embeddings.py +264 -0
  13. pycodesage-0.1.0/codesage/llm/prompts.py +71 -0
  14. pycodesage-0.1.0/codesage/llm/provider.py +257 -0
  15. pycodesage-0.1.0/codesage/models/__init__.py +6 -0
  16. pycodesage-0.1.0/codesage/models/code_element.py +106 -0
  17. pycodesage-0.1.0/codesage/models/suggestion.py +57 -0
  18. pycodesage-0.1.0/codesage/parsers/__init__.py +11 -0
  19. pycodesage-0.1.0/codesage/parsers/base.py +72 -0
  20. pycodesage-0.1.0/codesage/parsers/python_parser.py +220 -0
  21. pycodesage-0.1.0/codesage/parsers/registry.py +92 -0
  22. pycodesage-0.1.0/codesage/storage/__init__.py +6 -0
  23. pycodesage-0.1.0/codesage/storage/database.py +350 -0
  24. pycodesage-0.1.0/codesage/storage/vector_store.py +210 -0
  25. pycodesage-0.1.0/codesage/utils/__init__.py +5 -0
  26. pycodesage-0.1.0/codesage/utils/config.py +189 -0
  27. pycodesage-0.1.0/codesage/utils/health.py +247 -0
  28. pycodesage-0.1.0/codesage/utils/logging.py +227 -0
  29. pycodesage-0.1.0/codesage/utils/rate_limiter.py +129 -0
  30. pycodesage-0.1.0/codesage/utils/retry.py +204 -0
  31. pycodesage-0.1.0/pycodesage.egg-info/PKG-INFO +242 -0
  32. pycodesage-0.1.0/pycodesage.egg-info/SOURCES.txt +36 -0
  33. pycodesage-0.1.0/pycodesage.egg-info/dependency_links.txt +1 -0
  34. pycodesage-0.1.0/pycodesage.egg-info/entry_points.txt +2 -0
  35. pycodesage-0.1.0/pycodesage.egg-info/requires.txt +30 -0
  36. pycodesage-0.1.0/pycodesage.egg-info/top_level.txt +1 -0
  37. pycodesage-0.1.0/pyproject.toml +89 -0
  38. pycodesage-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Keshav Ashiya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,242 @@
1
+ Metadata-Version: 2.4
2
+ Name: pycodesage
3
+ Version: 0.1.0
4
+ Summary: Local-first CLI code intelligence tool with LangChain-powered RAG
5
+ Author: Keshav Ashiya
6
+ License: MIT
7
+ Keywords: code,ai,cli,devtools,rag,langchain
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: typer[all]>=0.9.0
17
+ Requires-Dist: rich>=13.7.0
18
+ Requires-Dist: langchain>=0.3.0
19
+ Requires-Dist: langchain-community>=0.3.0
20
+ Requires-Dist: langchain-ollama>=0.2.0
21
+ Requires-Dist: langchain-chroma>=0.1.0
22
+ Requires-Dist: chromadb>=0.4.0
23
+ Requires-Dist: pyyaml>=6.0.0
24
+ Requires-Dist: gitpython>=3.1.0
25
+ Requires-Dist: numpy>=1.26.0
26
+ Provides-Extra: openai
27
+ Requires-Dist: langchain-openai>=0.1.0; extra == "openai"
28
+ Provides-Extra: anthropic
29
+ Requires-Dist: langchain-anthropic>=0.1.0; extra == "anthropic"
30
+ Provides-Extra: multi-language
31
+ Requires-Dist: tree-sitter>=0.20.0; extra == "multi-language"
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
34
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
35
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
36
+ Requires-Dist: black>=23.12.0; extra == "dev"
37
+ Requires-Dist: ruff>=0.1.8; extra == "dev"
38
+ Requires-Dist: mypy>=1.7.0; extra == "dev"
39
+ Provides-Extra: all
40
+ Requires-Dist: codesage[anthropic,dev,multi-language,openai]; extra == "all"
41
+ Dynamic: license-file
42
+
43
+ # CodeSage
44
+
45
+ **Local-first CLI code intelligence tool with LangChain-powered RAG**
46
+
47
+ CodeSage indexes your codebase and enables semantic code search using AI. Everything runs locally on your machine with Ollama.
48
+
49
+ ## Features
50
+
51
+ - **Semantic Code Search** - Find code using natural language queries
52
+ - **AI-Powered Suggestions** - Get intelligent code recommendations from your codebase
53
+ - **100% Local** - Everything runs on your machine with Ollama, no cloud required
54
+ - **Fast Indexing** - Incremental updates only re-index changed files
55
+ - **Python Support** - Full Python AST parsing
56
+
57
+ ## Requirements
58
+
59
+ - **Python 3.9+**
60
+ - **Ollama** - Local LLM runtime ([Install Ollama](https://ollama.ai))
61
+
62
+ ### Setting Up Ollama
63
+
64
+ ```bash
65
+ # Install Ollama from https://ollama.ai, then pull required models:
66
+ ollama pull qwen2.5-coder:7b # For code analysis (~4.4GB)
67
+ ollama pull mxbai-embed-large # For embeddings (~670MB)
68
+ ```
69
+
70
+ ## Installation
71
+
72
+ ### From PyPI
73
+
74
+ ```bash
75
+ pip install codesage
76
+ ```
77
+
78
+ ### From Source (Development)
79
+
80
+ ```bash
81
+ # Clone the repository
82
+ git clone https://github.com/keshavashiya/codesage.git
83
+ cd codesage
84
+
85
+ # Create virtual environment
86
+ python -m venv venv
87
+ source venv/bin/activate # On Windows: venv\Scripts\activate
88
+
89
+ # Install in development mode
90
+ pip install -e ".[dev]"
91
+ ```
92
+
93
+ ### Optional: OpenAI/Anthropic Support
94
+
95
+ ```bash
96
+ pip install codesage[openai] # For OpenAI
97
+ pip install codesage[anthropic] # For Anthropic Claude
98
+ ```
99
+
100
+ ## Quick Start
101
+
102
+ ```bash
103
+ # Navigate to your project
104
+ cd your-project
105
+
106
+ # Initialize CodeSage
107
+ codesage init
108
+
109
+ # Index the codebase
110
+ codesage index
111
+
112
+ # Search for code
113
+ codesage suggest "function to validate email"
114
+ ```
115
+
116
+ ## Commands
117
+
118
+ ### `codesage init [PATH]`
119
+
120
+ Initialize CodeSage in a project directory.
121
+
122
+ ```bash
123
+ codesage init # Initialize in current directory
124
+ codesage init /path/to/project # Initialize in specific directory
125
+ codesage init --model qwen2.5-coder:7b # Specify LLM model
126
+ codesage init --embedding-model mxbai-embed-large # Specify embedding model
127
+ ```
128
+
129
+ ### `codesage index [PATH]`
130
+
131
+ Index the codebase for semantic search.
132
+
133
+ ```bash
134
+ codesage index # Incremental index (only changed files)
135
+ codesage index --full # Force full reindex
136
+ codesage index --clear # Clear existing index before indexing
137
+ ```
138
+
139
+ ### `codesage suggest QUERY`
140
+
141
+ Search for code using natural language.
142
+
143
+ ```bash
144
+ codesage suggest "error handling" # Search with default settings
145
+ codesage suggest "database query" -n 10 # Return 10 results (default: 5)
146
+ codesage suggest "auth logic" -s 0.5 # Set minimum similarity threshold
147
+ codesage suggest "config" --no-explain # Skip AI explanations (faster)
148
+ codesage suggest "utils" -p /path/to/proj # Search in specific project
149
+ ```
150
+
151
+ ### `codesage stats`
152
+
153
+ Show index statistics.
154
+
155
+ ```bash
156
+ codesage stats # Show stats for current directory
157
+ codesage stats /path/to/proj # Show stats for specific project
158
+ ```
159
+
160
+ ### `codesage health`
161
+
162
+ Check system health and dependencies.
163
+
164
+ ```bash
165
+ codesage health # Check Ollama, database, disk space
166
+ ```
167
+
168
+ ### `codesage version`
169
+
170
+ Show CodeSage version.
171
+
172
+ ```bash
173
+ codesage version
174
+ ```
175
+
176
+ ## Configuration
177
+
178
+ Configuration is stored in `.codesage/config.yaml`:
179
+
180
+ ```yaml
181
+ project_name: my-project
182
+ language: python
183
+
184
+ llm:
185
+ provider: ollama
186
+ model: qwen2.5-coder:7b
187
+ embedding_model: mxbai-embed-large
188
+ base_url: http://localhost:11434
189
+ temperature: 0.3
190
+ max_tokens: 500
191
+ request_timeout: 30.0
192
+ max_retries: 3
193
+
194
+ storage:
195
+ vector_store: chromadb
196
+
197
+ exclude_dirs:
198
+ - venv
199
+ - node_modules
200
+ - .git
201
+ - __pycache__
202
+ ```
203
+
204
+ ### Using OpenAI or Anthropic
205
+
206
+ ```bash
207
+ export CODESAGE_API_KEY="your-api-key"
208
+ ```
209
+
210
+ ```yaml
211
+ llm:
212
+ provider: openai # or anthropic
213
+ model: gpt-4o-mini # or claude-3-haiku-20240307
214
+ ```
215
+
216
+ ## Development
217
+
218
+ ```bash
219
+ # Run tests
220
+ pytest tests/ -v
221
+
222
+ # Format code
223
+ black codesage tests
224
+
225
+ # Lint
226
+ ruff check codesage
227
+ ```
228
+
229
+ ## Troubleshooting
230
+
231
+ ### "Ollama connection failed"
232
+
233
+ ```bash
234
+ ollama serve # Make sure Ollama is running
235
+ ```
236
+
237
+ ### "Model not found"
238
+
239
+ ```bash
240
+ ollama pull qwen2.5-coder:7b
241
+ ollama pull mxbai-embed-large
242
+ ```
@@ -0,0 +1,200 @@
1
+ # CodeSage
2
+
3
+ **Local-first CLI code intelligence tool with LangChain-powered RAG**
4
+
5
+ CodeSage indexes your codebase and enables semantic code search using AI. Everything runs locally on your machine with Ollama.
6
+
7
+ ## Features
8
+
9
+ - **Semantic Code Search** - Find code using natural language queries
10
+ - **AI-Powered Suggestions** - Get intelligent code recommendations from your codebase
11
+ - **100% Local** - Everything runs on your machine with Ollama, no cloud required
12
+ - **Fast Indexing** - Incremental updates only re-index changed files
13
+ - **Python Support** - Full Python AST parsing
14
+
15
+ ## Requirements
16
+
17
+ - **Python 3.9+**
18
+ - **Ollama** - Local LLM runtime ([Install Ollama](https://ollama.ai))
19
+
20
+ ### Setting Up Ollama
21
+
22
+ ```bash
23
+ # Install Ollama from https://ollama.ai, then pull required models:
24
+ ollama pull qwen2.5-coder:7b # For code analysis (~4.4GB)
25
+ ollama pull mxbai-embed-large # For embeddings (~670MB)
26
+ ```
27
+
28
+ ## Installation
29
+
30
+ ### From PyPI
31
+
32
+ ```bash
33
+ pip install codesage
34
+ ```
35
+
36
+ ### From Source (Development)
37
+
38
+ ```bash
39
+ # Clone the repository
40
+ git clone https://github.com/keshavashiya/codesage.git
41
+ cd codesage
42
+
43
+ # Create virtual environment
44
+ python -m venv venv
45
+ source venv/bin/activate # On Windows: venv\Scripts\activate
46
+
47
+ # Install in development mode
48
+ pip install -e ".[dev]"
49
+ ```
50
+
51
+ ### Optional: OpenAI/Anthropic Support
52
+
53
+ ```bash
54
+ pip install codesage[openai] # For OpenAI
55
+ pip install codesage[anthropic] # For Anthropic Claude
56
+ ```
57
+
58
+ ## Quick Start
59
+
60
+ ```bash
61
+ # Navigate to your project
62
+ cd your-project
63
+
64
+ # Initialize CodeSage
65
+ codesage init
66
+
67
+ # Index the codebase
68
+ codesage index
69
+
70
+ # Search for code
71
+ codesage suggest "function to validate email"
72
+ ```
73
+
74
+ ## Commands
75
+
76
+ ### `codesage init [PATH]`
77
+
78
+ Initialize CodeSage in a project directory.
79
+
80
+ ```bash
81
+ codesage init # Initialize in current directory
82
+ codesage init /path/to/project # Initialize in specific directory
83
+ codesage init --model qwen2.5-coder:7b # Specify LLM model
84
+ codesage init --embedding-model mxbai-embed-large # Specify embedding model
85
+ ```
86
+
87
+ ### `codesage index [PATH]`
88
+
89
+ Index the codebase for semantic search.
90
+
91
+ ```bash
92
+ codesage index # Incremental index (only changed files)
93
+ codesage index --full # Force full reindex
94
+ codesage index --clear # Clear existing index before indexing
95
+ ```
96
+
97
+ ### `codesage suggest QUERY`
98
+
99
+ Search for code using natural language.
100
+
101
+ ```bash
102
+ codesage suggest "error handling" # Search with default settings
103
+ codesage suggest "database query" -n 10 # Return 10 results (default: 5)
104
+ codesage suggest "auth logic" -s 0.5 # Set minimum similarity threshold
105
+ codesage suggest "config" --no-explain # Skip AI explanations (faster)
106
+ codesage suggest "utils" -p /path/to/proj # Search in specific project
107
+ ```
108
+
109
+ ### `codesage stats`
110
+
111
+ Show index statistics.
112
+
113
+ ```bash
114
+ codesage stats # Show stats for current directory
115
+ codesage stats /path/to/proj # Show stats for specific project
116
+ ```
117
+
118
+ ### `codesage health`
119
+
120
+ Check system health and dependencies.
121
+
122
+ ```bash
123
+ codesage health # Check Ollama, database, disk space
124
+ ```
125
+
126
+ ### `codesage version`
127
+
128
+ Show CodeSage version.
129
+
130
+ ```bash
131
+ codesage version
132
+ ```
133
+
134
+ ## Configuration
135
+
136
+ Configuration is stored in `.codesage/config.yaml`:
137
+
138
+ ```yaml
139
+ project_name: my-project
140
+ language: python
141
+
142
+ llm:
143
+ provider: ollama
144
+ model: qwen2.5-coder:7b
145
+ embedding_model: mxbai-embed-large
146
+ base_url: http://localhost:11434
147
+ temperature: 0.3
148
+ max_tokens: 500
149
+ request_timeout: 30.0
150
+ max_retries: 3
151
+
152
+ storage:
153
+ vector_store: chromadb
154
+
155
+ exclude_dirs:
156
+ - venv
157
+ - node_modules
158
+ - .git
159
+ - __pycache__
160
+ ```
161
+
162
+ ### Using OpenAI or Anthropic
163
+
164
+ ```bash
165
+ export CODESAGE_API_KEY="your-api-key"
166
+ ```
167
+
168
+ ```yaml
169
+ llm:
170
+ provider: openai # or anthropic
171
+ model: gpt-4o-mini # or claude-3-haiku-20240307
172
+ ```
173
+
174
+ ## Development
175
+
176
+ ```bash
177
+ # Run tests
178
+ pytest tests/ -v
179
+
180
+ # Format code
181
+ black codesage tests
182
+
183
+ # Lint
184
+ ruff check codesage
185
+ ```
186
+
187
+ ## Troubleshooting
188
+
189
+ ### "Ollama connection failed"
190
+
191
+ ```bash
192
+ ollama serve # Make sure Ollama is running
193
+ ```
194
+
195
+ ### "Model not found"
196
+
197
+ ```bash
198
+ ollama pull qwen2.5-coder:7b
199
+ ollama pull mxbai-embed-large
200
+ ```
@@ -0,0 +1,4 @@
1
+ """CodeSage: Local-first CLI code intelligence tool."""
2
+
3
+ __version__ = "0.1.0"
4
+ __author__ = "Keshav Ashiya"
@@ -0,0 +1,6 @@
1
+ """Allow running as python -m codesage."""
2
+
3
+ from codesage.cli.main import app
4
+
5
+ if __name__ == "__main__":
6
+ app()
@@ -0,0 +1,5 @@
1
+ """CLI package exports."""
2
+
3
+ from codesage.cli.main import app
4
+
5
+ __all__ = ["app"]