cortexcode 0.2.2__py3-none-any.whl → 0.4.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.
cortexcode/indexer.py CHANGED
@@ -73,10 +73,34 @@ class CodeIndexer:
73
73
  self.file_symbols: dict[str, list[dict[str, Any]]] = {}
74
74
  self.gitignore_patterns: list[tuple[str, bool]] = []
75
75
  self.default_ignore_patterns = {
76
- "__pycache__", ".git", ".venv", "venv", "node_modules",
77
- ".pytest_cache", ".mypy_cache", ".ruff_cache", ".cortexcode",
78
- "dist", "build", "target", ".idea", ".vscode", ".next", ".nuxt",
79
- ".svelte-kit", "coverage", ".cache", "*.log", ".env.local"
76
+ # Python
77
+ "__pycache__", ".venv", "venv", "env", ".env", "virtualenv",
78
+ ".pytest_cache", ".mypy_cache", ".ruff_cache", ".tox", ".nox",
79
+ "*.egg-info", ".eggs", "*.pyc", "*.pyo",
80
+ # Node/JS
81
+ "node_modules", ".npm", ".yarn", ".pnpm-store", "bower_components",
82
+ # Build outputs
83
+ "dist", "build", "out", "output", "target", "bin", "obj",
84
+ ".build", "_build", "public/build", "lib",
85
+ # Framework-specific
86
+ ".next", ".nuxt", ".svelte-kit", ".angular", ".turbo",
87
+ ".parcel-cache", ".webpack", ".rollup.cache", ".vite",
88
+ ".expo", ".gradle", "Pods", "DerivedData",
89
+ # IDE/Editor
90
+ ".idea", ".vscode", ".vs", "*.sublime-*",
91
+ # Version control
92
+ ".git", ".svn", ".hg",
93
+ # Cache/temp
94
+ ".cache", ".tmp", "tmp", "temp", ".temp",
95
+ "coverage", ".nyc_output", ".jest",
96
+ # CortexCode
97
+ ".cortexcode",
98
+ # Misc
99
+ "*.log", ".env.local", ".DS_Store", "Thumbs.db",
100
+ "vendor", "third_party", "external", "deps",
101
+ "__tests__", "__mocks__", "test_fixtures",
102
+ ".serverless", ".terraform", ".pulumi",
103
+ "android/app/build", "ios/build", "ios/Pods",
80
104
  }
81
105
 
82
106
  def _get_parser(self, ext: str) -> Parser | None:
cortexcode/mcp_server.py CHANGED
@@ -222,6 +222,74 @@ class CortexCodeMCPServer:
222
222
  },
223
223
  },
224
224
  },
225
+ {
226
+ "name": "cortexcode_fuzzy_search",
227
+ "description": "USE THIS when exact search returns no results, or user has a typo or partial name. Fuzzy search finds approximate matches using similarity scoring.",
228
+ "inputSchema": {
229
+ "type": "object",
230
+ "properties": {
231
+ "query": {"type": "string", "description": "Approximate symbol name to search for"},
232
+ "threshold": {"type": "number", "description": "Minimum similarity score 0-1 (default 0.5)", "default": 0.5},
233
+ "limit": {"type": "integer", "description": "Max results (default 20)", "default": 20},
234
+ },
235
+ "required": ["query"],
236
+ },
237
+ },
238
+ {
239
+ "name": "cortexcode_regex_search",
240
+ "description": "USE THIS when user wants to search with a pattern, like 'find all getters' or 'functions starting with handle'. Supports regex patterns.",
241
+ "inputSchema": {
242
+ "type": "object",
243
+ "properties": {
244
+ "pattern": {"type": "string", "description": "Regex pattern to match symbol names (e.g. '^get.*', 'handle.*Request$')"},
245
+ "type": {"type": "string", "description": "Filter by type: function, class, method, interface", "enum": ["function", "class", "method", "interface"]},
246
+ "limit": {"type": "integer", "description": "Max results (default 20)", "default": 20},
247
+ },
248
+ "required": ["pattern"],
249
+ },
250
+ },
251
+ {
252
+ "name": "cortexcode_duplicates",
253
+ "description": "USE THIS when user asks about code duplication, copy-paste code, or repeated logic. Finds exact and near-duplicate functions.",
254
+ "inputSchema": {
255
+ "type": "object",
256
+ "properties": {
257
+ "min_lines": {"type": "integer", "description": "Minimum function lines to consider (default 5)", "default": 5},
258
+ },
259
+ },
260
+ },
261
+ {
262
+ "name": "cortexcode_security_scan",
263
+ "description": "USE THIS when user asks about security issues, vulnerabilities, hardcoded secrets, SQL injection, or XSS risks. Scans source code for common security problems.",
264
+ "inputSchema": {
265
+ "type": "object",
266
+ "properties": {},
267
+ },
268
+ },
269
+ {
270
+ "name": "cortexcode_circular_deps",
271
+ "description": "USE THIS when user asks about circular dependencies, import cycles, or dependency loops.",
272
+ "inputSchema": {
273
+ "type": "object",
274
+ "properties": {},
275
+ },
276
+ },
277
+ {
278
+ "name": "cortexcode_endpoints",
279
+ "description": "USE THIS when user asks about API endpoints, routes, REST APIs, or wants a list of all URLs/paths in the app. Detects Express, Flask, FastAPI, Django, Next.js, Spring, Go, Rails routes.",
280
+ "inputSchema": {
281
+ "type": "object",
282
+ "properties": {},
283
+ },
284
+ },
285
+ {
286
+ "name": "cortexcode_api_docs",
287
+ "description": "USE THIS when user asks to generate documentation, see doc coverage, or find undocumented functions. Auto-generates API docs from signatures and docstrings.",
288
+ "inputSchema": {
289
+ "type": "object",
290
+ "properties": {},
291
+ },
292
+ },
225
293
  ]
226
294
 
227
295
  def _call_tool(self, req_id: Any, tool_name: str, args: dict) -> dict:
@@ -255,6 +323,20 @@ class CortexCodeMCPServer:
255
323
  result = self._tool_impact(args)
256
324
  elif tool_name == "cortexcode_file_deps":
257
325
  result = self._tool_file_deps(args)
326
+ elif tool_name == "cortexcode_fuzzy_search":
327
+ result = self._tool_fuzzy_search(args)
328
+ elif tool_name == "cortexcode_regex_search":
329
+ result = self._tool_regex_search(args)
330
+ elif tool_name == "cortexcode_duplicates":
331
+ result = self._tool_duplicates(args)
332
+ elif tool_name == "cortexcode_security_scan":
333
+ result = self._tool_security_scan(args)
334
+ elif tool_name == "cortexcode_circular_deps":
335
+ result = self._tool_circular_deps(args)
336
+ elif tool_name == "cortexcode_endpoints":
337
+ result = self._tool_endpoints(args)
338
+ elif tool_name == "cortexcode_api_docs":
339
+ result = self._tool_api_docs(args)
258
340
  else:
259
341
  return create_mcp_error(req_id, -32602, f"Unknown tool: {tool_name}")
260
342
 
@@ -430,6 +512,66 @@ class CortexCodeMCPServer:
430
512
  return {"error": f"No dependencies found for: {file_path}"}
431
513
 
432
514
  return {"file_dependencies": file_deps}
515
+
516
+ def _tool_fuzzy_search(self, args: dict) -> dict:
517
+ """Fuzzy search for symbols."""
518
+ from cortexcode.advanced_analysis import fuzzy_search
519
+
520
+ query = args.get("query", "")
521
+ threshold = args.get("threshold", 0.5)
522
+ limit = args.get("limit", 20)
523
+
524
+ results = fuzzy_search(self.index, query, threshold, limit)
525
+ return {"count": len(results), "results": results}
526
+
527
+ def _tool_regex_search(self, args: dict) -> dict:
528
+ """Regex search for symbols."""
529
+ from cortexcode.advanced_analysis import regex_search
530
+
531
+ pattern = args.get("pattern", "")
532
+ sym_type = args.get("type")
533
+ limit = args.get("limit", 20)
534
+
535
+ results = regex_search(self.index, pattern, sym_type, limit)
536
+ return {"count": len(results), "results": results}
537
+
538
+ def _tool_duplicates(self, args: dict) -> dict:
539
+ """Find duplicate code."""
540
+ from cortexcode.advanced_analysis import detect_duplicates
541
+
542
+ min_lines = args.get("min_lines", 5)
543
+ root = str(self.index_path.parent.parent)
544
+
545
+ dupes = detect_duplicates(self.index, root, min_lines)
546
+ return {"count": len(dupes), "duplicates": dupes}
547
+
548
+ def _tool_security_scan(self, args: dict) -> dict:
549
+ """Scan for security issues."""
550
+ from cortexcode.advanced_analysis import security_scan
551
+
552
+ root = str(self.index_path.parent.parent)
553
+ return security_scan(root, self.index)
554
+
555
+ def _tool_circular_deps(self, args: dict) -> dict:
556
+ """Detect circular dependencies."""
557
+ from cortexcode.advanced_analysis import detect_circular_deps
558
+
559
+ cycles = detect_circular_deps(self.index)
560
+ return {"count": len(cycles), "cycles": cycles}
561
+
562
+ def _tool_endpoints(self, args: dict) -> dict:
563
+ """Extract API endpoints."""
564
+ from cortexcode.advanced_analysis import extract_endpoints
565
+
566
+ root = str(self.index_path.parent.parent)
567
+ return extract_endpoints(self.index, root)
568
+
569
+ def _tool_api_docs(self, args: dict) -> dict:
570
+ """Generate API documentation."""
571
+ from cortexcode.advanced_analysis import generate_api_docs
572
+
573
+ root = str(self.index_path.parent.parent)
574
+ return generate_api_docs(self.index, root)
433
575
 
434
576
 
435
577
  def run_stdio_server(index_path: Path | None = None):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cortexcode
3
- Version: 0.2.2
3
+ Version: 0.4.0
4
4
  Summary: Lightweight code indexing for AI assistants — save 90%+ tokens with structured context
5
5
  Author-email: Naveen <naveen_joshi07@outlook.com>
6
6
  License: MIT
@@ -228,6 +228,42 @@ npm install && npm run compile
228
228
 
229
229
  ## How AI Agents Use This
230
230
 
231
+ ### Windsurf / Cursor Configuration
232
+
233
+ To make AI agents in Windsurf or Cursor automatically use CortexCode:
234
+
235
+ **Option 1: Auto-detect prompt file**
236
+
237
+ Create `.cortexcode/prompt.md` in your project root. AI agents will automatically read this file and use the CortexCode index for code understanding.
238
+
239
+ **Option 2: Add to agent rules**
240
+
241
+ Add to your project's `.windsurf/rules.md` or Cursor rules:
242
+
243
+ ```
244
+ Always use CortexCode index (.cortexcode/index.json) to understand the codebase before making changes. Use:
245
+ - cortexcode search <symbol> to find symbols
246
+ - cortexcode impact <symbol> to see what uses a function
247
+ - cortexcode context <query> to get relevant code context
248
+
249
+ Run 'cortexcode index' first if the index doesn't exist.
250
+ ```
251
+
252
+ **Option 3: Configure MCP in Windsurf**
253
+
254
+ Add to `~/.windsurf/config.json`:
255
+
256
+ ```json
257
+ {
258
+ "mcpServers": {
259
+ "cortexcode": {
260
+ "command": "cortexcode",
261
+ "args": ["mcp"]
262
+ }
263
+ }
264
+ }
265
+ ```
266
+
231
267
  ### 1. Context Command (simplest)
232
268
 
233
269
  ```bash
@@ -296,16 +332,31 @@ cortexcode mcp
296
332
  }
297
333
  ```
298
334
 
299
- Available MCP tools:
335
+ Available MCP tools (17 tools):
336
+
337
+ **Search & Navigation:**
300
338
  - **`cortexcode_search`** — Search symbols by name
339
+ - **`cortexcode_fuzzy_search`** — Fuzzy/approximate search (handles typos)
340
+ - **`cortexcode_regex_search`** — Regex pattern search (e.g. `^get.*`)
301
341
  - **`cortexcode_context`** — Get rich context with callers/callees
302
342
  - **`cortexcode_file_symbols`** — List all symbols in a file
303
343
  - **`cortexcode_call_graph`** — Trace call graph for a symbol
304
- - **`cortexcode_diff`** — Get changed symbols since last commit
305
- - **`cortexcode_stats`** — Get project statistics
344
+
345
+ **Analysis:**
306
346
  - **`cortexcode_deadcode`** — Find potentially unused symbols
307
347
  - **`cortexcode_complexity`** — Find most complex functions
308
348
  - **`cortexcode_impact`** — Analyze change impact of a symbol
349
+ - **`cortexcode_duplicates`** — Detect duplicate/copy-paste code
350
+ - **`cortexcode_circular_deps`** — Find circular dependencies
351
+
352
+ **Security & Quality:**
353
+ - **`cortexcode_security_scan`** — Scan for hardcoded secrets, SQL injection, XSS
354
+ - **`cortexcode_endpoints`** — Extract API endpoints (Express, Flask, Django, Next.js, etc.)
355
+ - **`cortexcode_api_docs`** — Auto-generate API docs from signatures
356
+
357
+ **Project Info:**
358
+ - **`cortexcode_stats`** — Get project statistics
359
+ - **`cortexcode_diff`** — Get changed symbols since last commit
309
360
  - **`cortexcode_file_deps`** — Get file dependency graph
310
361
 
311
362
  ### 4. LSP Server
@@ -431,6 +482,31 @@ CortexCode respects `.gitignore` files (including nested ones) and has built-in
431
482
  - [x] Django / Flask framework detection
432
483
  - [x] VS Code Marketplace publishing
433
484
 
485
+ ### Future Improvements
486
+
487
+ #### Features
488
+ - [ ] More language support (Ruby, PHP, C++)
489
+ - [ ] Cloud index for team sharing
490
+ - [ ] Graph visualization for call chains
491
+ - [ ] Auto-indexing on git push
492
+ - [ ] Index versioning (compare across commits)
493
+ - [ ] Config file (`.cortexcode.yaml`) for project settings
494
+
495
+ #### Integrations
496
+ - [ ] JetBrains IDEs plugin (IntelliJ, PyCharm)
497
+ - [ ] GitHub Copilot native integration
498
+ - [ ] Claude Code integration
499
+
500
+ #### AI/Search
501
+ - [ ] Semantic embeddings for meaning-based search
502
+ - [ ] AI-powered code review
503
+ - [ ] Bug detection (pattern matching)
504
+
505
+ #### Performance
506
+ - [ ] Compressed index format
507
+ - [ ] Faster search with caching
508
+ - [ ] Parallel multi-threaded indexing
509
+
434
510
  ## Contributing
435
511
 
436
512
  See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
@@ -0,0 +1,27 @@
1
+ cortexcode/__init__.py,sha256=6dAo1HGYcfh35uqvPmnci9spfrTgF-OK1vvZ16iwN1I,87
2
+ cortexcode/advanced_analysis.py,sha256=FdBr2VPpx8x0F0BI6lauDvkdodhYOB3Bis4TBEfWOKk,30372
3
+ cortexcode/analysis.py,sha256=25c8UBLNhYqWn2qOVp1wU05be9Pt_AZmp27XMDM3ysU,11503
4
+ cortexcode/cli.py,sha256=uG2e-hIv75q7CbbvaCwXros2qVj5wRYVrnVysmIwjYc,30751
5
+ cortexcode/context.py,sha256=8L4VlXamEYl9rImeGOxW9DhoYBhMuZQi5-mhhSSjOAw,9765
6
+ cortexcode/dashboard.py,sha256=NNK4EhgBo3gBuwwntT5wIi7ZlX1ThHVlbxn6q0c-HdE,5361
7
+ cortexcode/docs.py,sha256=GT6GxWK7r-Zq-9VqxaLFAo9Yzh11kgwUgdaz46H4NmI,912
8
+ cortexcode/git_diff.py,sha256=YEEZM2yKYztE-T7rI5iBf2NluY4G1WIjlp-DprZ-6Rs,5742
9
+ cortexcode/indexer.py,sha256=GhedSeZiqC01XRSfWTS836kcVAgKUAWynX4981_UjMw,82958
10
+ cortexcode/lsp_server.py,sha256=mAPk78OVWQodBjBI3WhqEjrwjXrb0MF630IYDZ8_MLM,11102
11
+ cortexcode/mcp_server.py,sha256=CxbqxmIOyeKudyzwXuvy_rm6XLu1PVAHukNf7pENx-s,25748
12
+ cortexcode/plugins.py,sha256=6WsmnvRT7D_coxD6YgwB-Dpu_iKOS89FNnT-gkgK4-8,6298
13
+ cortexcode/semantic_search.py,sha256=PO1FjbQhKf6EGfwtwHcdqVXL5W_xMr4e7GxuctdrFzM,8745
14
+ cortexcode/vuln_scan.py,sha256=edU6viXXPLxHdlwDons05g9tLrGuLdPvrNDY-QcqPlU,8539
15
+ cortexcode/watcher.py,sha256=PdY54UzzA70Ff3og2Vv6jE-hzppJRZKpxE4tK8iDVNo,3672
16
+ cortexcode/workspace.py,sha256=ewm5UW_9NQJ0EgjPm46zHMIpZft5UMAlBuX7tt8LWbA,6463
17
+ cortexcode/docs/__init__.py,sha256=lSB29ot6_DqoIqPLacbNRWeMGvCaHPwhbRWY-zIdeD0,432
18
+ cortexcode/docs/generator.py,sha256=p4gn9cg0HpTcRaNM0mO3UvYXKtJ_8dDZebZdsTOTFZM,24557
19
+ cortexcode/docs/html_generators.py,sha256=IWNBuXRxAiO-b4gN7KkVh_7fS9N_EL2Ik3UhhMfAJME,4589
20
+ cortexcode/docs/javascript.py,sha256=8hgk55sNiG9JroAqWl5uilKgjTSJd7tHkXuBRqjuz38,19812
21
+ cortexcode/docs/templates.py,sha256=4g7Zov1PU3CRCVF4Tu_zBVVUA6x8pKjXcNSfT_k6-to,12254
22
+ cortexcode-0.4.0.dist-info/licenses/LICENSE,sha256=DWE8vkHgP2ChQTJHFWtrutLbuHQUBsU_InyfesP4neo,1067
23
+ cortexcode-0.4.0.dist-info/METADATA,sha256=88JNNw5Q5rdV7ADyujrnWMVn-ljJsIxzsAzcAhXHm-0,17458
24
+ cortexcode-0.4.0.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
25
+ cortexcode-0.4.0.dist-info/entry_points.txt,sha256=ZqCHJQMwlffLmdD1m6nyemXlk0M4GWntSH2QORXfNJo,51
26
+ cortexcode-0.4.0.dist-info/top_level.txt,sha256=r8FxzjLfKhRXXcORnECtGo7i2zKYXlV7v1XnIJ0SOc0,11
27
+ cortexcode-0.4.0.dist-info/RECORD,,
@@ -1,21 +0,0 @@
1
- cortexcode/__init__.py,sha256=6dAo1HGYcfh35uqvPmnci9spfrTgF-OK1vvZ16iwN1I,87
2
- cortexcode/analysis.py,sha256=25c8UBLNhYqWn2qOVp1wU05be9Pt_AZmp27XMDM3ysU,11503
3
- cortexcode/cli.py,sha256=uG2e-hIv75q7CbbvaCwXros2qVj5wRYVrnVysmIwjYc,30751
4
- cortexcode/context.py,sha256=8L4VlXamEYl9rImeGOxW9DhoYBhMuZQi5-mhhSSjOAw,9765
5
- cortexcode/dashboard.py,sha256=NNK4EhgBo3gBuwwntT5wIi7ZlX1ThHVlbxn6q0c-HdE,5361
6
- cortexcode/docs.py,sha256=OGrHnWE3qh_rgILMALxt2m2RLa3KE8WfYhFALPF1Nn0,65410
7
- cortexcode/git_diff.py,sha256=YEEZM2yKYztE-T7rI5iBf2NluY4G1WIjlp-DprZ-6Rs,5742
8
- cortexcode/indexer.py,sha256=R178y_PKgLjmasyE3ftQjDRA3AxaeI_qyd93pJZLHZQ,81924
9
- cortexcode/lsp_server.py,sha256=mAPk78OVWQodBjBI3WhqEjrwjXrb0MF630IYDZ8_MLM,11102
10
- cortexcode/mcp_server.py,sha256=h18bZQ6_6zZVmQfTnQYiP4XGZmzfKBVZZfJQra12cy4,18866
11
- cortexcode/plugins.py,sha256=6WsmnvRT7D_coxD6YgwB-Dpu_iKOS89FNnT-gkgK4-8,6298
12
- cortexcode/semantic_search.py,sha256=PO1FjbQhKf6EGfwtwHcdqVXL5W_xMr4e7GxuctdrFzM,8745
13
- cortexcode/vuln_scan.py,sha256=edU6viXXPLxHdlwDons05g9tLrGuLdPvrNDY-QcqPlU,8539
14
- cortexcode/watcher.py,sha256=PdY54UzzA70Ff3og2Vv6jE-hzppJRZKpxE4tK8iDVNo,3672
15
- cortexcode/workspace.py,sha256=ewm5UW_9NQJ0EgjPm46zHMIpZft5UMAlBuX7tt8LWbA,6463
16
- cortexcode-0.2.2.dist-info/licenses/LICENSE,sha256=DWE8vkHgP2ChQTJHFWtrutLbuHQUBsU_InyfesP4neo,1067
17
- cortexcode-0.2.2.dist-info/METADATA,sha256=cXcPQVqeo2r2KFUHEoe-juyVWL11iLR_WUxJMuDxOL0,15139
18
- cortexcode-0.2.2.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
19
- cortexcode-0.2.2.dist-info/entry_points.txt,sha256=ZqCHJQMwlffLmdD1m6nyemXlk0M4GWntSH2QORXfNJo,51
20
- cortexcode-0.2.2.dist-info/top_level.txt,sha256=r8FxzjLfKhRXXcORnECtGo7i2zKYXlV7v1XnIJ0SOc0,11
21
- cortexcode-0.2.2.dist-info/RECORD,,