codrspot-processor-mcp 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.
- codrspot_processor_mcp-0.1.0/LICENSE +23 -0
- codrspot_processor_mcp-0.1.0/PKG-INFO +396 -0
- codrspot_processor_mcp-0.1.0/README.md +339 -0
- codrspot_processor_mcp-0.1.0/pyproject.toml +52 -0
- codrspot_processor_mcp-0.1.0/setup.cfg +4 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/__init__.py +14 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/__main__.py +9 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/allowed_scope_cache.py +62 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/api_client/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/api_client/lease_client.py +34 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/api_client/net_guard.py +98 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/api_client/promote_client.py +59 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/api_client/reasoning_client.py +163 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/api_client/registry_client.py +119 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/api_client/superkg_client.py +327 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/cli/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/cli/init.py +578 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/cli/main.py +78 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/config.py +104 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/git_utils.py +67 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/license/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/license/fingerprint.py +61 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/license/jwt_client.py +60 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/license/project_lock.py +44 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/local_registry.py +40 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/manifest/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/manifest/credentials.py +35 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/mcp/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/mcp/action_monitor.py +246 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/mcp/lifecycle.py +649 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/mcp/server.py +656 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/mcp/tools.py +1665 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer1_business/project_registry.py +99 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/ast_graph.py +426 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/bm25_store.py +132 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/chunking/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/chunking/ast_chunker.py +313 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/chunking/languages.py +238 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/embed_worker.py +128 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/embeddings.py +452 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/extract/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/extract/compactor.py +103 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/extract/providers/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/extract/providers/base.py +38 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/indexer.py +945 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/ppl/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/ppl/emitter.py +162 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/ppl/parser.py +352 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/qdrant_store.py +387 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/scanning/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/scanning/manifest_scanner.py +72 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/scanning/md_scanner.py +97 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/scanning/repo_mapper.py +495 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/condensation/session_vector_store.py +69 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/coupling/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/coupling/domain.py +263 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/coupling/graph.py +255 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/coupling/layer2_gate.py +189 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/coupling/projector.py +139 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/coupling/resolver.py +150 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/pipeline/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/pipeline/execute_semantic.py +1249 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/pipeline/filesystem_reorg.py +575 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/pipeline/patch_generator.py +127 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/pipeline/patch_validator.py +101 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/__init__.py +19 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/anchors.py +61 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/applicability.py +75 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/edit_planner.py +264 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/materializer.py +121 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/merger.py +73 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/add_import.py +36 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/append_argument.py +37 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/insert_literal.py +24 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/remove_import.py +33 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/remove_statement_unique.py +14 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/rename_symbol_local.py +16 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/region_resolver.py +229 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/synthesizer.py +186 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/target_locator.py +94 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/semantic/validator.py +322 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/snippet/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/snippet/assembler.py +503 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/materialization/snippet/loader.py +187 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/retrieval/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/retrieval/graph_walk.py +47 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/retrieval/hybrid.py +95 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/retrieval/rerank_worker.py +86 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/retrieval/reranker.py +213 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/watcher/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/codepreproc_client/layer2_tooling/watcher/fs_watcher.py +3 -0
- codrspot_processor_mcp-0.1.0/src/codrspot_processor_mcp.egg-info/PKG-INFO +396 -0
- codrspot_processor_mcp-0.1.0/src/codrspot_processor_mcp.egg-info/SOURCES.txt +103 -0
- codrspot_processor_mcp-0.1.0/src/codrspot_processor_mcp.egg-info/dependency_links.txt +1 -0
- codrspot_processor_mcp-0.1.0/src/codrspot_processor_mcp.egg-info/entry_points.txt +3 -0
- codrspot_processor_mcp-0.1.0/src/codrspot_processor_mcp.egg-info/requires.txt +20 -0
- codrspot_processor_mcp-0.1.0/src/codrspot_processor_mcp.egg-info/top_level.txt +2 -0
- codrspot_processor_mcp-0.1.0/src/contracts/__init__.py +0 -0
- codrspot_processor_mcp-0.1.0/src/contracts/dtos.py +1239 -0
- codrspot_processor_mcp-0.1.0/src/contracts/ir.py +102 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Copyright (c) 2026 alexlqi (alexlqi@gmail.com)
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use of this software, in source or binary form, with or
|
|
6
|
+
without accompanying documentation, is permitted provided that:
|
|
7
|
+
|
|
8
|
+
1. The software is redistributed unmodified and in its entirety (as-is),
|
|
9
|
+
retaining this license and all copyright notices.
|
|
10
|
+
2. No person or entity may modify, create derivative works from, decompile,
|
|
11
|
+
reverse-engineer, or otherwise alter the functionality of this software,
|
|
12
|
+
in whole or in part, without prior written consent from the copyright
|
|
13
|
+
holder.
|
|
14
|
+
3. This license text is included, unaltered, with every copy or substantial
|
|
15
|
+
portion of the software that is redistributed.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
23
|
+
IN THE SOFTWARE.
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codrspot-processor-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local MCP server exposing codepreproc's code-context tools to Claude Code
|
|
5
|
+
Author-email: alexlqi <alexlqi@gmail.com>
|
|
6
|
+
License: Copyright (c) 2026 alexlqi (alexlqi@gmail.com)
|
|
7
|
+
|
|
8
|
+
All rights reserved.
|
|
9
|
+
|
|
10
|
+
Redistribution and use of this software, in source or binary form, with or
|
|
11
|
+
without accompanying documentation, is permitted provided that:
|
|
12
|
+
|
|
13
|
+
1. The software is redistributed unmodified and in its entirety (as-is),
|
|
14
|
+
retaining this license and all copyright notices.
|
|
15
|
+
2. No person or entity may modify, create derivative works from, decompile,
|
|
16
|
+
reverse-engineer, or otherwise alter the functionality of this software,
|
|
17
|
+
in whole or in part, without prior written consent from the copyright
|
|
18
|
+
holder.
|
|
19
|
+
3. This license text is included, unaltered, with every copy or substantial
|
|
20
|
+
portion of the software that is redistributed.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
27
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
28
|
+
IN THE SOFTWARE.
|
|
29
|
+
|
|
30
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
31
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
32
|
+
Classifier: License :: Other/Proprietary License
|
|
33
|
+
Requires-Python: <3.13,>=3.12
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
License-File: LICENSE
|
|
36
|
+
Requires-Dist: anyio
|
|
37
|
+
Requires-Dist: python-dotenv
|
|
38
|
+
Requires-Dist: bm25s
|
|
39
|
+
Requires-Dist: filelock
|
|
40
|
+
Requires-Dist: gitpython
|
|
41
|
+
Requires-Dist: httpx
|
|
42
|
+
Requires-Dist: mcp
|
|
43
|
+
Requires-Dist: numpy
|
|
44
|
+
Requires-Dist: openai
|
|
45
|
+
Requires-Dist: pydantic>=2
|
|
46
|
+
Requires-Dist: pyyaml
|
|
47
|
+
Requires-Dist: qdrant-client[fastembed]>=1.10.0
|
|
48
|
+
Requires-Dist: sentence-transformers
|
|
49
|
+
Requires-Dist: torch
|
|
50
|
+
Requires-Dist: tree-sitter
|
|
51
|
+
Requires-Dist: tree-sitter-languages
|
|
52
|
+
Requires-Dist: watchdog
|
|
53
|
+
Requires-Dist: xxhash
|
|
54
|
+
Requires-Dist: pyahocorasick
|
|
55
|
+
Requires-Dist: zstandard
|
|
56
|
+
Dynamic: license-file
|
|
57
|
+
|
|
58
|
+
# codepreproc
|
|
59
|
+
|
|
60
|
+
Servidor MCP local en Python para preprocesar contexto de repos de codigo antes de enviarlo a un agente como Claude Code.
|
|
61
|
+
|
|
62
|
+
## Que hace
|
|
63
|
+
|
|
64
|
+
`codepreproc` indexa uno o mas repositorios locales, resuelve el proyecto activo a partir del registro o de los roots enviados por el cliente MCP, y expone tools para:
|
|
65
|
+
|
|
66
|
+
### Gestion de proyectos e indice
|
|
67
|
+
|
|
68
|
+
- `list_projects` — lista proyectos configurados y estado del indice
|
|
69
|
+
- `switch_project` — fija el proyecto activo para la sesion
|
|
70
|
+
- `reindex` — corre reindex full o incremental
|
|
71
|
+
- `project_status` — devuelve estado git + indice
|
|
72
|
+
|
|
73
|
+
### Semantic patch pipeline
|
|
74
|
+
|
|
75
|
+
- `analyze_request` — ejecuta el pipeline completo: intent → retrieval → rerank → graph walk → target locator → planner → synthesizer → merger → materializer → validator → `SemanticExecutionPack`
|
|
76
|
+
- `preview_semantic_plan` — recupera el `SemanticEditPlan` cacheado por `task_id`
|
|
77
|
+
- `preview_patch` — devuelve los patches materializados como unified diffs
|
|
78
|
+
- `validate_patch` — resume el resultado de validacion estructural
|
|
79
|
+
- `disambiguate_region` — reanuda un task ambiguo eligiendo un `region_id` concreto
|
|
80
|
+
- `apply_patch` — aplica los patches con `git apply` y restaura CRLF si el archivo original lo usaba
|
|
81
|
+
|
|
82
|
+
### Filesystem reorg pipeline
|
|
83
|
+
|
|
84
|
+
- `analyze_filesystem_reorg` — genera un plan de moves/renames del arbol del repo
|
|
85
|
+
- `preview_filesystem_plan` — recupera el plan de filesystem cacheado
|
|
86
|
+
- `apply_filesystem_plan` — ejecuta los moves/renames del plan cacheado
|
|
87
|
+
|
|
88
|
+
### Busqueda de contexto y generacion de documentos
|
|
89
|
+
|
|
90
|
+
- `search_context` — semantic search hibrido (dense + BM25 + reranking): devuelve chunks con file_path, symbol, signature, score y body
|
|
91
|
+
- `generate_document` — recupera contexto, expande el grafo de dependencias, formatea invariantes y sintetiza un archivo Markdown con LLM; escribe el resultado en `output_path`
|
|
92
|
+
|
|
93
|
+
### Politica LLM y costos
|
|
94
|
+
|
|
95
|
+
- `usage_report` — resume costo/uso LLM acumulado por proveedor
|
|
96
|
+
- `set_llm_policy` — override por sesion de la politica de routing LLM del proyecto
|
|
97
|
+
|
|
98
|
+
### Snippet assembly (Fase 4)
|
|
99
|
+
|
|
100
|
+
- `list_snippets` — lista los snippets disponibles en la biblioteca, filtrables por framework, language o layer
|
|
101
|
+
- `assemble_from_snippets` — pipeline de dos fases: (1) modelo ligero resuelve intent → selecciona snippets → instancia variables → define scope; (2) modelo de capacidad alta integra los snippets en los archivos target respetando constraints DDD
|
|
102
|
+
|
|
103
|
+
## Requisitos
|
|
104
|
+
|
|
105
|
+
- Python 3.12
|
|
106
|
+
- Qdrant disponible en `http://127.0.0.1:6333`
|
|
107
|
+
- Un endpoint LLM compatible con OpenAI disponible en `http://127.0.0.1:8080/v1`
|
|
108
|
+
|
|
109
|
+
Los valores por defecto se toman de `registry.yaml` y pueden sobreescribirse con variables de entorno.
|
|
110
|
+
|
|
111
|
+
## Creacion e instalacion
|
|
112
|
+
|
|
113
|
+
Desde la raiz del proyecto:
|
|
114
|
+
|
|
115
|
+
```powershell
|
|
116
|
+
python -m venv .venv
|
|
117
|
+
.\.venv\Scripts\Activate.ps1
|
|
118
|
+
python -m pip install --upgrade pip
|
|
119
|
+
python -m pip install -e .
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Tambien queda disponible el entrypoint `codepreproc-mcp`.
|
|
123
|
+
|
|
124
|
+
## Puesta en marcha
|
|
125
|
+
|
|
126
|
+
Puedes iniciar el servidor MCP por stdio de cualquiera de estas dos formas:
|
|
127
|
+
|
|
128
|
+
```powershell
|
|
129
|
+
.\.venv\Scripts\python.exe -m codepreproc
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
```powershell
|
|
133
|
+
.\.venv\Scripts\codepreproc-mcp.exe
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Precarga manual de embeddings
|
|
137
|
+
|
|
138
|
+
Si quieres descargar un modelo de embeddings antes de arrancar el MCP, puedes usar este script:
|
|
139
|
+
|
|
140
|
+
```powershell
|
|
141
|
+
powershell -ExecutionPolicy Bypass -File .\scripts\preload_embedding.ps1
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Por defecto precarga `Qwen/Qwen3-Embedding-0.6B` en `cuda:0` para dejarlo en cache con la misma GPU que usa el MCP durante `reindex`.
|
|
145
|
+
|
|
146
|
+
Si quieres precargar otro modelo:
|
|
147
|
+
|
|
148
|
+
```powershell
|
|
149
|
+
powershell -ExecutionPolicy Bypass -File .\scripts\preload_embedding.ps1 -Model "sentence-transformers/all-MiniLM-L6-v2"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Si quieres forzar otro device:
|
|
153
|
+
|
|
154
|
+
```powershell
|
|
155
|
+
powershell -ExecutionPolicy Bypass -File .\scripts\preload_embedding.ps1 -Device "cuda:0"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Configuracion del registro de proyectos
|
|
159
|
+
|
|
160
|
+
Por defecto el servidor carga el registro desde:
|
|
161
|
+
|
|
162
|
+
```text
|
|
163
|
+
%USERPROFILE%\.codepreproc\registry.yaml
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Ejemplo:
|
|
167
|
+
|
|
168
|
+
```yaml
|
|
169
|
+
defaults:
|
|
170
|
+
embedding_model: sentence-transformers/all-MiniLM-L6-v2
|
|
171
|
+
reranker_model: BAAI/bge-reranker-v2-m3
|
|
172
|
+
llm_endpoint: http://127.0.0.1:8080/v1
|
|
173
|
+
llm_model: qwen2.5-coder-7b
|
|
174
|
+
qdrant_url: http://127.0.0.1:6333
|
|
175
|
+
qdrant_grpc: 127.0.0.1:6334
|
|
176
|
+
mcp_action_timeout_seconds: 300
|
|
177
|
+
mcp_action_heartbeat_seconds: 15
|
|
178
|
+
chunking:
|
|
179
|
+
max_chunk_chars: 2000
|
|
180
|
+
overlap_lines: 0
|
|
181
|
+
max_file_size_kb: 50
|
|
182
|
+
|
|
183
|
+
projects:
|
|
184
|
+
wallmart:
|
|
185
|
+
root: D:\repos\challenge_one\wallmart
|
|
186
|
+
languages: [typescript, tsx, javascript]
|
|
187
|
+
qdrant_collection: wallmart_code
|
|
188
|
+
branch_aware: false
|
|
189
|
+
project_context: |
|
|
190
|
+
Proyecto wallmart.
|
|
191
|
+
App web orientada a e-commerce.
|
|
192
|
+
ignore:
|
|
193
|
+
- node_modules
|
|
194
|
+
- dist
|
|
195
|
+
- build
|
|
196
|
+
- .git
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Notas:
|
|
200
|
+
|
|
201
|
+
- El `project_id` es la clave del proyecto, por ejemplo `wallmart`.
|
|
202
|
+
- `root` debe ser una ruta absoluta al repo local.
|
|
203
|
+
- Las `languages` soportadas actualmente son: `python`, `typescript`, `tsx`, `javascript`, `go`, `rust`, `yaml`, `markdown`.
|
|
204
|
+
- `mcp_action_timeout_seconds` define el timeout por falta de avance relevante por tool.
|
|
205
|
+
- `mcp_action_heartbeat_seconds` define cada cuánto se emite heartbeat mientras una tool larga sigue viva.
|
|
206
|
+
- `CODEPREPROC_MCP_CONNECTION_VERBOSITY` controla el logging de ciclo de vida MCP: `off`, `basic`, `verbose`. Por defecto usa `basic`.
|
|
207
|
+
- Si tienes mas de un proyecto configurado, conviene pasar `project` explicito en las llamadas MCP.
|
|
208
|
+
|
|
209
|
+
## Configuracion del MCP en Claude Code
|
|
210
|
+
|
|
211
|
+
Una vez instalado el paquete, registra este servidor en la configuracion MCP de Claude Code:
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"mcpServers": {
|
|
216
|
+
"codepreproc": {
|
|
217
|
+
"command": "C:\\Users\\<usuario>\\.codepreproc\\.venv\\Scripts\\python.exe",
|
|
218
|
+
"args": ["-m", "codepreproc"]
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Si prefieres usar el ejecutable del entrypoint:
|
|
225
|
+
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"mcpServers": {
|
|
229
|
+
"codepreproc": {
|
|
230
|
+
"command": "C:\\Users\\<usuario>\\.codepreproc\\.venv\\Scripts\\codepreproc-mcp.exe"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Reemplaza la ruta por la ubicacion real de tu entorno virtual.
|
|
237
|
+
|
|
238
|
+
## Logging de conexion MCP
|
|
239
|
+
|
|
240
|
+
- El servidor escribe eventos de ciclo de vida MCP en `%USERPROFILE%\.codepreproc\logs\mcp_server.log` con prefijo `mcp_lifecycle`.
|
|
241
|
+
- `CODEPREPROC_MCP_CONNECTION_VERBOSITY=basic` registra transiciones principales: apertura, inicializacion, cierre y fallos relevantes.
|
|
242
|
+
- `CODEPREPROC_MCP_CONNECTION_VERBOSITY=verbose` agrega metadatos extra como capabilities, soporte de roots, tiempos de inicializacion y conteos de requests al cerrar.
|
|
243
|
+
- En transporte `stdio`, una "reconexion" significa una nueva sesion/proceso que vuelve a ejecutar `initialize`; no hay reanudacion de socket.
|
|
244
|
+
- Los eventos posteriores a `initialize` tambien intentan reflejarse al cliente mediante `codepreproc.mcp.lifecycle`, pero ese espejo es best-effort.
|
|
245
|
+
- Si la conexion falla antes de completar `initialize` o el transporte se cae abruptamente, revisa `mcp_server.log`: esa es la fuente de verdad.
|
|
246
|
+
|
|
247
|
+
## Flujo recomendado de uso en Claude Code
|
|
248
|
+
|
|
249
|
+
1. Registra el repo en `%USERPROFILE%\.codepreproc\registry.yaml`.
|
|
250
|
+
2. Inicia o deja configurado el servidor MCP en Claude Code.
|
|
251
|
+
3. Ejecuta `list_projects` para confirmar que Claude Code ve el proyecto.
|
|
252
|
+
4. Ejecuta `reindex` con `{"project":"wallmart","full":true}` la primera vez.
|
|
253
|
+
5. Ejecuta `project_status` para validar `last_indexed_sha` y revisar si hay drift.
|
|
254
|
+
6. Ejecuta `analyze_request` con un prompt concreto y, si aplica, consulta `preview_patch` con el `task_id` devuelto.
|
|
255
|
+
7. Si el cambio es mover o renombrar archivos o directorios, usa `analyze_filesystem_reorg`, revisa `preview_filesystem_plan` y luego aplica con `apply_filesystem_plan`.
|
|
256
|
+
8. Para explorar el repo o generar documentacion, usa `search_context` o `generate_document` directamente — no requieren un region objetivo y producen su resultado en una sola llamada.
|
|
257
|
+
9. Para generar codigo DDD nuevo a partir de plantillas (NestJS, Flutter, FastAPI), usa `assemble_from_snippets` con un prompt y el framework objetivo.
|
|
258
|
+
|
|
259
|
+
## Flujo de generate_document
|
|
260
|
+
|
|
261
|
+
`generate_document` sigue este pipeline (`VERIFICADO` en codigo):
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
prompt + output_path
|
|
265
|
+
→ HybridRetriever (dense + BM25)
|
|
266
|
+
→ Reranker (cross-encoder, top_k ≤ 30)
|
|
267
|
+
→ GraphWalker (expande dependencias a depth configurable)
|
|
268
|
+
→ _format_doc_context (agrupa por paquete, extrae invariantes: UPPERCASE_CONSTANTS, thresholds, exports)
|
|
269
|
+
→ router.chat(task_type="document_generation", schema=None)
|
|
270
|
+
→ write_text(output_path)
|
|
271
|
+
→ { success, file_path, bytes_written, chunks_used, llm_usage }
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Notas:
|
|
275
|
+
- `output_path` puede ser absoluto o relativo al `root` del proyecto.
|
|
276
|
+
- El directorio padre se crea automaticamente si no existe.
|
|
277
|
+
- El LLM recibe un system prompt que exige secciones estructuradas: vision general, tabla de componentes, flujo ASCII, secciones por componente, contratos, dependencias y entry/exit points.
|
|
278
|
+
- Usar cuando no existe una region de codigo objetivo. Para modificar codigo existente, preferir `analyze_request`.
|
|
279
|
+
|
|
280
|
+
## Progreso y timeout
|
|
281
|
+
|
|
282
|
+
- Las tools ahora emiten progreso por `notifications/progress` cuando el cliente envía `progressToken`, y duplican el estado con `notifications/message`.
|
|
283
|
+
- `reindex` y `analyze_request` reportan etapas visibles como `health_check`, `git_sync`, `chunk_files`, `embed_batches`, `qdrant_upsert`, `planner` y `validate`.
|
|
284
|
+
- Si una acción pasa mas de `mcp_action_timeout_seconds` sin cambio relevante, falla con `error=action_timed_out` y devuelve la etapa donde se quedó.
|
|
285
|
+
- Los heartbeats no reinician el timeout; solo sirven para indicar que la acción sigue viva.
|
|
286
|
+
|
|
287
|
+
## Estado del índice
|
|
288
|
+
|
|
289
|
+
- `project_status` ahora devuelve `index_state` con uno de estos valores: `ready`, `building`, `invalid`.
|
|
290
|
+
- Cuando un incremental falla después de tocar el índice activo, el estado pasa a `invalid` y el siguiente flujo semántico fuerza `full reindex` antes de recuperar contexto.
|
|
291
|
+
- `last_index_error` incluye `code`, `stage` y `message` cuando el índice quedó inválido.
|
|
292
|
+
|
|
293
|
+
Ejemplos:
|
|
294
|
+
|
|
295
|
+
```json
|
|
296
|
+
{
|
|
297
|
+
"project": "wallmart",
|
|
298
|
+
"full": true
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
```json
|
|
303
|
+
{
|
|
304
|
+
"project": "wallmart",
|
|
305
|
+
"prompt": "Explicame la arquitectura del proyecto y los puntos de entrada principales"
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Variables de entorno utiles
|
|
310
|
+
|
|
311
|
+
- `CODEPREPROC_HOME`
|
|
312
|
+
- `CODEPREPROC_REGISTRY_PATH`
|
|
313
|
+
- `CODEPREPROC_INDEXES_DIR`
|
|
314
|
+
- `CODEPREPROC_LOGS_DIR`
|
|
315
|
+
- `CODEPREPROC_LLM_ENDPOINT`
|
|
316
|
+
- `CODEPREPROC_LLM_MODEL`
|
|
317
|
+
- `CODEPREPROC_MCP_CONNECTION_VERBOSITY`
|
|
318
|
+
- `CODEPREPROC_DEBUG`
|
|
319
|
+
|
|
320
|
+
## Preflight del servidor standalone y Docker
|
|
321
|
+
|
|
322
|
+
Este flujo verifica la frontera HTTP que ya existe entre `codepreproc_client`
|
|
323
|
+
y `codepreproc_server`: `/health`, `/v1/mint`, `/v1/promote` y
|
|
324
|
+
`/v1/lease_world_model`. Los modulos temporales que todavia importan codigo
|
|
325
|
+
del servidor desde `codepreproc_client.layer1_business.api_client` quedan fuera
|
|
326
|
+
de este preflight hasta que se cambien por llamadas HTTP reales.
|
|
327
|
+
|
|
328
|
+
### Local standalone
|
|
329
|
+
|
|
330
|
+
1. Configura PostgreSQL y exporta `CODEPREPROC_PG_DSN`.
|
|
331
|
+
2. Crea el schema:
|
|
332
|
+
|
|
333
|
+
```powershell
|
|
334
|
+
.\.venv\Scripts\codepreproc.exe db-init
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
3. Inserta una licencia de prueba:
|
|
338
|
+
|
|
339
|
+
```powershell
|
|
340
|
+
.\.venv\Scripts\codepreproc.exe license-add --license-id preflight-license --api-key preflight-api-key --tier pro --max-seats 5 --max-projects 20 --scope promote --scope lease
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
4. Arranca el servidor:
|
|
344
|
+
|
|
345
|
+
```powershell
|
|
346
|
+
$env:CODEPREPROC_JWT_SIGNING_KEY = "replace-with-a-long-stable-secret"
|
|
347
|
+
$env:CODEPREPROC_SERVER_PORT = "8443"
|
|
348
|
+
.\.venv\Scripts\codepreproc-server.exe
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
5. En otra terminal, ejecuta el preflight:
|
|
352
|
+
|
|
353
|
+
```powershell
|
|
354
|
+
.\.venv\Scripts\python.exe scripts\preflight_server_api.py --base-url http://127.0.0.1:8443
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Docker
|
|
358
|
+
|
|
359
|
+
1. Arranca solo PostgreSQL:
|
|
360
|
+
|
|
361
|
+
```powershell
|
|
362
|
+
docker compose up -d postgres
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
2. Crea schema y licencia desde la imagen del servidor:
|
|
366
|
+
|
|
367
|
+
```powershell
|
|
368
|
+
docker compose run --rm server codepreproc db-init
|
|
369
|
+
docker compose run --rm server codepreproc license-add --license-id preflight-license --api-key preflight-api-key --tier pro --max-seats 5 --max-projects 20 --scope promote --scope lease
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
3. Arranca el API:
|
|
373
|
+
|
|
374
|
+
```powershell
|
|
375
|
+
docker compose up -d server
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
4. Ejecuta el preflight contra Docker:
|
|
379
|
+
|
|
380
|
+
```powershell
|
|
381
|
+
.\.venv\Scripts\python.exe scripts\preflight_server_api.py --base-url http://127.0.0.1:8443
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
Para remoto, copia la imagen/compose/env al host Docker, cambia
|
|
385
|
+
`CODEPREPROC_JWT_SIGNING_KEY` por un secreto real, repite el seed de licencia
|
|
386
|
+
en el Postgres remoto y ejecuta el mismo preflight apuntando a la URL remota
|
|
387
|
+
antes de cambiar clientes reales.
|
|
388
|
+
|
|
389
|
+
## Observaciones
|
|
390
|
+
|
|
391
|
+
- El proyecto debe existir en `registry.yaml`; la implementacion actual no acepta un `path` arbitrario como argumento de tool.
|
|
392
|
+
- Si el cliente MCP envia `roots`, el servidor puede resolver el proyecto automaticamente cuando ese root cae dentro de un `root` registrado.
|
|
393
|
+
- `analyze_request` no solo recupera contexto: con la implementacion actual tambien intenta construir un execution pack y generar un patch validable.
|
|
394
|
+
- `analyze_request` solo cubre cambios dentro de archivos existentes. Si el prompt implica mover o renombrar archivos o directorios, o reorganizar el arbol del repo, el servidor devuelve `failure.code=OUT_OF_SCOPE` y recomienda usar `analyze_filesystem_reorg`. `target_locator` opera sobre regiones de codigo dentro de archivos, no sobre el filesystem.
|
|
395
|
+
- `analyze_filesystem_reorg` genera un plan de moves/renames, lo guarda en memoria de sesion con snapshot del arbol actual y valida consistencia antes de permitir `apply_filesystem_plan`.
|
|
396
|
+
- El flujo de filesystem solo mueve o renombra paths. No reescribe imports ni divide contenido entre archivos; si el cambio requiere eso, hay que combinarlo despues con el flujo semantico normal.
|