codrspot-processor-mcp 0.1.2__tar.gz → 0.1.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.
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/PKG-INFO +1 -1
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/README.md +205 -205
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/pyproject.toml +52 -52
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/api_client/reasoning_client.py +31 -2
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/api_client/superkg_client.py +9 -1
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/mcp/server.py +21 -4
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/mcp/tools.py +35 -21
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/indexer.py +11 -2
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/scanning/repo_mapper.py +24 -11
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/region_resolver.py +1 -1
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/target_locator.py +109 -94
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codrspot_processor_mcp.egg-info/PKG-INFO +1 -1
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/LICENSE +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/setup.cfg +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/__main__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/allowed_scope_cache.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/api_client/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/api_client/lease_client.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/api_client/net_guard.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/api_client/promote_client.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/api_client/registry_client.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/cli/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/cli/init.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/cli/main.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/cli/setup.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/config.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/git_utils.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/license/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/license/fingerprint.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/license/jwt_client.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/license/project_lock.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/local_registry.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/manifest/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/manifest/credentials.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/mcp/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/mcp/action_monitor.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/mcp/lifecycle.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer1_business/project_registry.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/ast_graph.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/bm25_store.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/chunking/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/chunking/ast_chunker.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/chunking/languages.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/embed_worker.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/embeddings.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/extract/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/extract/compactor.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/extract/providers/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/extract/providers/base.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/ppl/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/ppl/emitter.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/ppl/parser.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/qdrant_store.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/scanning/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/scanning/manifest_scanner.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/scanning/md_scanner.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/condensation/session_vector_store.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/coupling/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/coupling/domain.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/coupling/graph.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/coupling/layer2_gate.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/coupling/projector.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/coupling/resolver.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/pipeline/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/pipeline/execute_semantic.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/pipeline/filesystem_reorg.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/pipeline/patch_generator.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/pipeline/patch_validator.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/anchors.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/applicability.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/edit_planner.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/materializer.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/merger.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/add_import.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/append_argument.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/insert_literal.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/remove_import.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/remove_statement_unique.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/ops/rename_symbol_local.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/synthesizer.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/semantic/validator.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/snippet/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/snippet/assembler.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/materialization/snippet/loader.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/retrieval/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/retrieval/graph_walk.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/retrieval/hybrid.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/retrieval/rerank_worker.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/retrieval/reranker.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/watcher/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codepreproc_client/layer2_tooling/watcher/fs_watcher.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codrspot_processor_mcp.egg-info/SOURCES.txt +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codrspot_processor_mcp.egg-info/dependency_links.txt +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codrspot_processor_mcp.egg-info/entry_points.txt +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codrspot_processor_mcp.egg-info/requires.txt +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/codrspot_processor_mcp.egg-info/top_level.txt +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/contracts/__init__.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/contracts/dtos.py +0 -0
- {codrspot_processor_mcp-0.1.2 → codrspot_processor_mcp-0.1.3}/src/contracts/ir.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codrspot-processor-mcp
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: Local MCP server exposing codepreproc's code-context tools to Claude Code
|
|
5
5
|
Author-email: alexlqi <alexlqi@gmail.com>
|
|
6
6
|
License: Copyright (c) 2026 alexlqi (alexlqi@gmail.com)
|
|
@@ -1,205 +1,205 @@
|
|
|
1
|
-
# codrspot-processor-mcp
|
|
2
|
-
|
|
3
|
-
A local MCP (Model Context Protocol) client that connects Claude Code to your
|
|
4
|
-
indexed repositories, giving it code-context retrieval and patch-generation
|
|
5
|
-
tools for a project registered with a codrspot-processor server.
|
|
6
|
-
|
|
7
|
-
This package is the **client** only. It talks to a codrspot-processor server
|
|
8
|
-
over its HTTP API; it does not include or require running the server itself.
|
|
9
|
-
|
|
10
|
-
## Requirements
|
|
11
|
-
|
|
12
|
-
- Python 3.12 (3.13 is not supported)
|
|
13
|
-
- A reachable codrspot-processor server instance and its base URL
|
|
14
|
-
- A `credentials.yaml` manifest issued by your server operator (used to mint
|
|
15
|
-
a JWT for each project you register)
|
|
16
|
-
- An OpenAI-compatible LLM endpoint (a local server or `OPENAI_API_KEY` for a
|
|
17
|
-
remote provider)
|
|
18
|
-
|
|
19
|
-
No local Qdrant install is needed — the client keeps its own embedded,
|
|
20
|
-
file-backed vector store for source chunks.
|
|
21
|
-
|
|
22
|
-
## 1. Install
|
|
23
|
-
|
|
24
|
-
Pick a permanent install location — this becomes `CODEPREPROC_HOME`. Claude
|
|
25
|
-
Code's default expectation is `%USERPROFILE%\.codepreproc` on Windows, or
|
|
26
|
-
`$HOME/.codepreproc` on macOS/Linux:
|
|
27
|
-
|
|
28
|
-
**Windows (PowerShell)**
|
|
29
|
-
|
|
30
|
-
```powershell
|
|
31
|
-
mkdir "$env:USERPROFILE\.codepreproc"
|
|
32
|
-
cd "$env:USERPROFILE\.codepreproc"
|
|
33
|
-
python -m venv .venv
|
|
34
|
-
.\.venv\Scripts\Activate.ps1
|
|
35
|
-
python -m pip install --upgrade pip
|
|
36
|
-
python -m pip install codrspot-processor-mcp
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
This installs the `codepreproc` and `codepreproc-mcp` console scripts into
|
|
40
|
-
`.venv\Scripts\`. To upgrade later:
|
|
41
|
-
|
|
42
|
-
```powershell
|
|
43
|
-
python -m pip install --upgrade codrspot-processor-mcp
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
**macOS/Linux (bash/zsh)**
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
mkdir -p "$HOME/.codepreproc"
|
|
50
|
-
cd "$HOME/.codepreproc"
|
|
51
|
-
python3 -m venv .venv
|
|
52
|
-
source .venv/bin/activate
|
|
53
|
-
python -m pip install --upgrade pip
|
|
54
|
-
python -m pip install codrspot-processor-mcp
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
This installs the `codepreproc` and `codepreproc-mcp` console scripts into
|
|
58
|
-
`.venv/bin/`. To upgrade later:
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
python -m pip install --upgrade codrspot-processor-mcp
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Then run `codepreproc setup` to scaffold `CODEPREPROC_HOME` (`indexes/`,
|
|
65
|
-
`logs/`, a starter `.env`) and print the Claude Code `mcp.json` snippet with
|
|
66
|
-
the exe path already resolved. Safe to re-run — it never overwrites an
|
|
67
|
-
existing `.env`.
|
|
68
|
-
|
|
69
|
-
## 2. Configure the environment
|
|
70
|
-
|
|
71
|
-
Create a `.env` file in `%CODEPREPROC_HOME%` (`$CODEPREPROC_HOME` on
|
|
72
|
-
macOS/Linux) with at least:
|
|
73
|
-
|
|
74
|
-
```dotenv
|
|
75
|
-
CODEPREPROC_SERVER_URL=https://your-codrspot-processor-server-host:8443
|
|
76
|
-
OPENAI_API_KEY=sk-... # if using a remote LLM policy
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Also place the `credentials.yaml` your server operator gave you at
|
|
80
|
-
`%CODEPREPROC_HOME%\credentials.yaml` (`$CODEPREPROC_HOME/credentials.yaml`
|
|
81
|
-
on macOS/Linux), or point `CODEPREPROC_CREDENTIALS` at a different path.
|
|
82
|
-
|
|
83
|
-
`.env` is loaded automatically from `%CODEPREPROC_HOME%` (defaults to
|
|
84
|
-
`%USERPROFILE%\.codepreproc` on Windows, `$HOME/.codepreproc` on
|
|
85
|
-
macOS/Linux, if unset).
|
|
86
|
-
|
|
87
|
-
## 3. Register your project(s)
|
|
88
|
-
|
|
89
|
-
From inside each repo you want indexed:
|
|
90
|
-
|
|
91
|
-
**Windows (PowerShell)**
|
|
92
|
-
|
|
93
|
-
```powershell
|
|
94
|
-
cd D:\path\to\your\repo
|
|
95
|
-
& "$env:USERPROFILE\.codepreproc\.venv\Scripts\codepreproc.exe" init
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
**macOS/Linux (bash/zsh)**
|
|
99
|
-
|
|
100
|
-
```bash
|
|
101
|
-
cd /path/to/your/repo
|
|
102
|
-
"$HOME/.codepreproc/.venv/bin/codepreproc" init
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
This scans the repo, mints a JWT for it from `credentials.yaml`, and
|
|
106
|
-
registers it with your server over the API. Running it again on an
|
|
107
|
-
already-registered project is a no-op.
|
|
108
|
-
|
|
109
|
-
## 4. Register the MCP server in Claude Code
|
|
110
|
-
|
|
111
|
-
Add this to your Claude Code MCP configuration (project `.mcp.json` or
|
|
112
|
-
global settings).
|
|
113
|
-
|
|
114
|
-
**Windows**
|
|
115
|
-
|
|
116
|
-
```json
|
|
117
|
-
{
|
|
118
|
-
"mcpServers": {
|
|
119
|
-
"codepreproc": {
|
|
120
|
-
"command": "C:\\Users\\<username>\\.codepreproc\\.venv\\Scripts\\codepreproc-mcp.exe"
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
Replace `<username>` with your actual Windows username, and adjust the path
|
|
127
|
-
if you installed into a folder other than `%USERPROFILE%\.codepreproc`.
|
|
128
|
-
|
|
129
|
-
**macOS/Linux**
|
|
130
|
-
|
|
131
|
-
```json
|
|
132
|
-
{
|
|
133
|
-
"mcpServers": {
|
|
134
|
-
"codepreproc": {
|
|
135
|
-
"command": "/home/<username>/.codepreproc/.venv/bin/codepreproc-mcp"
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Replace `<username>` with your actual username (on macOS this is typically
|
|
142
|
-
under `/Users/<username>`), and adjust the path if you installed into a
|
|
143
|
-
folder other than `$HOME/.codepreproc`.
|
|
144
|
-
|
|
145
|
-
## 5. Restart Claude Code and verify
|
|
146
|
-
|
|
147
|
-
Restart Claude Code (or reload the MCP connection), then run:
|
|
148
|
-
|
|
149
|
-
- `list_projects` — should show the project(s) registered in step 3
|
|
150
|
-
- `reindex` with `{"project": "<your-project>", "full": true}` — builds the
|
|
151
|
-
index the first time
|
|
152
|
-
- `project_status` — confirms the index is healthy and up to date
|
|
153
|
-
|
|
154
|
-
If the connection fails before it finishes initializing, check
|
|
155
|
-
`%USERPROFILE%\.codepreproc\logs\mcp_server.log` (`$HOME/.codepreproc/logs/mcp_server.log`
|
|
156
|
-
on macOS/Linux) — set `CODEPREPROC_MCP_CONNECTION_VERBOSITY=verbose` in
|
|
157
|
-
`.env` for more detail.
|
|
158
|
-
|
|
159
|
-
## Available tools
|
|
160
|
-
|
|
161
|
-
Once connected, Claude Code gets access to these MCP tools:
|
|
162
|
-
|
|
163
|
-
**Projects and index**
|
|
164
|
-
- `list_projects` — list registered projects and index status
|
|
165
|
-
- `switch_project` — set the active project for the session
|
|
166
|
-
- `reindex` — run a full or incremental reindex
|
|
167
|
-
- `project_status` — report index health and git sync state
|
|
168
|
-
|
|
169
|
-
**Code changes**
|
|
170
|
-
- `analyze_request` — turn a natural-language prompt into a validated patch
|
|
171
|
-
- `preview_semantic_plan` — inspect the cached edit plan for a task
|
|
172
|
-
- `preview_patch` — view the generated patch as a unified diff
|
|
173
|
-
- `validate_patch` — check a patch's structural validity
|
|
174
|
-
- `disambiguate_region` — resolve an ambiguous edit target
|
|
175
|
-
- `apply_patch` — apply a validated patch to the repo
|
|
176
|
-
|
|
177
|
-
**Filesystem reorganization**
|
|
178
|
-
- `analyze_filesystem_reorg` — plan file/directory moves and renames
|
|
179
|
-
- `preview_filesystem_plan` — inspect a cached reorg plan
|
|
180
|
-
- `apply_filesystem_plan` — apply a reorg plan
|
|
181
|
-
|
|
182
|
-
**Search and documentation**
|
|
183
|
-
- `search_context` — hybrid semantic search over the indexed repo
|
|
184
|
-
- `generate_document` — generate a Markdown document from retrieved context
|
|
185
|
-
|
|
186
|
-
**Snippets**
|
|
187
|
-
- `list_snippets` — list available code snippets/templates
|
|
188
|
-
- `assemble_from_snippets` — generate new code from templates for a target
|
|
189
|
-
framework
|
|
190
|
-
|
|
191
|
-
**LLM usage**
|
|
192
|
-
- `usage_report` — summarize accumulated LLM cost/usage
|
|
193
|
-
- `set_llm_policy` — override the LLM routing policy for the session
|
|
194
|
-
|
|
195
|
-
## Useful environment variables
|
|
196
|
-
|
|
197
|
-
- `CODEPREPROC_HOME`
|
|
198
|
-
- `CODEPREPROC_SERVER_URL`
|
|
199
|
-
- `CODEPREPROC_CREDENTIALS`
|
|
200
|
-
- `CODEPREPROC_MCP_CONNECTION_VERBOSITY` (`off`, `basic`, `verbose`)
|
|
201
|
-
- `CODEPREPROC_DEBUG`
|
|
202
|
-
|
|
203
|
-
## License
|
|
204
|
-
|
|
205
|
-
See [LICENSE](LICENSE).
|
|
1
|
+
# codrspot-processor-mcp
|
|
2
|
+
|
|
3
|
+
A local MCP (Model Context Protocol) client that connects Claude Code to your
|
|
4
|
+
indexed repositories, giving it code-context retrieval and patch-generation
|
|
5
|
+
tools for a project registered with a codrspot-processor server.
|
|
6
|
+
|
|
7
|
+
This package is the **client** only. It talks to a codrspot-processor server
|
|
8
|
+
over its HTTP API; it does not include or require running the server itself.
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
|
|
12
|
+
- Python 3.12 (3.13 is not supported)
|
|
13
|
+
- A reachable codrspot-processor server instance and its base URL
|
|
14
|
+
- A `credentials.yaml` manifest issued by your server operator (used to mint
|
|
15
|
+
a JWT for each project you register)
|
|
16
|
+
- An OpenAI-compatible LLM endpoint (a local server or `OPENAI_API_KEY` for a
|
|
17
|
+
remote provider)
|
|
18
|
+
|
|
19
|
+
No local Qdrant install is needed — the client keeps its own embedded,
|
|
20
|
+
file-backed vector store for source chunks.
|
|
21
|
+
|
|
22
|
+
## 1. Install
|
|
23
|
+
|
|
24
|
+
Pick a permanent install location — this becomes `CODEPREPROC_HOME`. Claude
|
|
25
|
+
Code's default expectation is `%USERPROFILE%\.codepreproc` on Windows, or
|
|
26
|
+
`$HOME/.codepreproc` on macOS/Linux:
|
|
27
|
+
|
|
28
|
+
**Windows (PowerShell)**
|
|
29
|
+
|
|
30
|
+
```powershell
|
|
31
|
+
mkdir "$env:USERPROFILE\.codepreproc"
|
|
32
|
+
cd "$env:USERPROFILE\.codepreproc"
|
|
33
|
+
python -m venv .venv
|
|
34
|
+
.\.venv\Scripts\Activate.ps1
|
|
35
|
+
python -m pip install --upgrade pip
|
|
36
|
+
python -m pip install codrspot-processor-mcp
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This installs the `codepreproc` and `codepreproc-mcp` console scripts into
|
|
40
|
+
`.venv\Scripts\`. To upgrade later:
|
|
41
|
+
|
|
42
|
+
```powershell
|
|
43
|
+
python -m pip install --upgrade codrspot-processor-mcp
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**macOS/Linux (bash/zsh)**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
mkdir -p "$HOME/.codepreproc"
|
|
50
|
+
cd "$HOME/.codepreproc"
|
|
51
|
+
python3 -m venv .venv
|
|
52
|
+
source .venv/bin/activate
|
|
53
|
+
python -m pip install --upgrade pip
|
|
54
|
+
python -m pip install codrspot-processor-mcp
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This installs the `codepreproc` and `codepreproc-mcp` console scripts into
|
|
58
|
+
`.venv/bin/`. To upgrade later:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
python -m pip install --upgrade codrspot-processor-mcp
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Then run `codepreproc setup` to scaffold `CODEPREPROC_HOME` (`indexes/`,
|
|
65
|
+
`logs/`, a starter `.env`) and print the Claude Code `mcp.json` snippet with
|
|
66
|
+
the exe path already resolved. Safe to re-run — it never overwrites an
|
|
67
|
+
existing `.env`.
|
|
68
|
+
|
|
69
|
+
## 2. Configure the environment
|
|
70
|
+
|
|
71
|
+
Create a `.env` file in `%CODEPREPROC_HOME%` (`$CODEPREPROC_HOME` on
|
|
72
|
+
macOS/Linux) with at least:
|
|
73
|
+
|
|
74
|
+
```dotenv
|
|
75
|
+
CODEPREPROC_SERVER_URL=https://your-codrspot-processor-server-host:8443
|
|
76
|
+
OPENAI_API_KEY=sk-... # if using a remote LLM policy
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Also place the `credentials.yaml` your server operator gave you at
|
|
80
|
+
`%CODEPREPROC_HOME%\credentials.yaml` (`$CODEPREPROC_HOME/credentials.yaml`
|
|
81
|
+
on macOS/Linux), or point `CODEPREPROC_CREDENTIALS` at a different path.
|
|
82
|
+
|
|
83
|
+
`.env` is loaded automatically from `%CODEPREPROC_HOME%` (defaults to
|
|
84
|
+
`%USERPROFILE%\.codepreproc` on Windows, `$HOME/.codepreproc` on
|
|
85
|
+
macOS/Linux, if unset).
|
|
86
|
+
|
|
87
|
+
## 3. Register your project(s)
|
|
88
|
+
|
|
89
|
+
From inside each repo you want indexed:
|
|
90
|
+
|
|
91
|
+
**Windows (PowerShell)**
|
|
92
|
+
|
|
93
|
+
```powershell
|
|
94
|
+
cd D:\path\to\your\repo
|
|
95
|
+
& "$env:USERPROFILE\.codepreproc\.venv\Scripts\codepreproc.exe" init
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**macOS/Linux (bash/zsh)**
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
cd /path/to/your/repo
|
|
102
|
+
"$HOME/.codepreproc/.venv/bin/codepreproc" init
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
This scans the repo, mints a JWT for it from `credentials.yaml`, and
|
|
106
|
+
registers it with your server over the API. Running it again on an
|
|
107
|
+
already-registered project is a no-op.
|
|
108
|
+
|
|
109
|
+
## 4. Register the MCP server in Claude Code
|
|
110
|
+
|
|
111
|
+
Add this to your Claude Code MCP configuration (project `.mcp.json` or
|
|
112
|
+
global settings).
|
|
113
|
+
|
|
114
|
+
**Windows**
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"mcpServers": {
|
|
119
|
+
"codepreproc": {
|
|
120
|
+
"command": "C:\\Users\\<username>\\.codepreproc\\.venv\\Scripts\\codepreproc-mcp.exe"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Replace `<username>` with your actual Windows username, and adjust the path
|
|
127
|
+
if you installed into a folder other than `%USERPROFILE%\.codepreproc`.
|
|
128
|
+
|
|
129
|
+
**macOS/Linux**
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"mcpServers": {
|
|
134
|
+
"codepreproc": {
|
|
135
|
+
"command": "/home/<username>/.codepreproc/.venv/bin/codepreproc-mcp"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Replace `<username>` with your actual username (on macOS this is typically
|
|
142
|
+
under `/Users/<username>`), and adjust the path if you installed into a
|
|
143
|
+
folder other than `$HOME/.codepreproc`.
|
|
144
|
+
|
|
145
|
+
## 5. Restart Claude Code and verify
|
|
146
|
+
|
|
147
|
+
Restart Claude Code (or reload the MCP connection), then run:
|
|
148
|
+
|
|
149
|
+
- `list_projects` — should show the project(s) registered in step 3
|
|
150
|
+
- `reindex` with `{"project": "<your-project>", "full": true}` — builds the
|
|
151
|
+
index the first time
|
|
152
|
+
- `project_status` — confirms the index is healthy and up to date
|
|
153
|
+
|
|
154
|
+
If the connection fails before it finishes initializing, check
|
|
155
|
+
`%USERPROFILE%\.codepreproc\logs\mcp_server.log` (`$HOME/.codepreproc/logs/mcp_server.log`
|
|
156
|
+
on macOS/Linux) — set `CODEPREPROC_MCP_CONNECTION_VERBOSITY=verbose` in
|
|
157
|
+
`.env` for more detail.
|
|
158
|
+
|
|
159
|
+
## Available tools
|
|
160
|
+
|
|
161
|
+
Once connected, Claude Code gets access to these MCP tools:
|
|
162
|
+
|
|
163
|
+
**Projects and index**
|
|
164
|
+
- `list_projects` — list registered projects and index status
|
|
165
|
+
- `switch_project` — set the active project for the session
|
|
166
|
+
- `reindex` — run a full or incremental reindex
|
|
167
|
+
- `project_status` — report index health and git sync state
|
|
168
|
+
|
|
169
|
+
**Code changes**
|
|
170
|
+
- `analyze_request` — turn a natural-language prompt into a validated patch
|
|
171
|
+
- `preview_semantic_plan` — inspect the cached edit plan for a task
|
|
172
|
+
- `preview_patch` — view the generated patch as a unified diff
|
|
173
|
+
- `validate_patch` — check a patch's structural validity
|
|
174
|
+
- `disambiguate_region` — resolve an ambiguous edit target
|
|
175
|
+
- `apply_patch` — apply a validated patch to the repo
|
|
176
|
+
|
|
177
|
+
**Filesystem reorganization**
|
|
178
|
+
- `analyze_filesystem_reorg` — plan file/directory moves and renames
|
|
179
|
+
- `preview_filesystem_plan` — inspect a cached reorg plan
|
|
180
|
+
- `apply_filesystem_plan` — apply a reorg plan
|
|
181
|
+
|
|
182
|
+
**Search and documentation**
|
|
183
|
+
- `search_context` — hybrid semantic search over the indexed repo
|
|
184
|
+
- `generate_document` — generate a Markdown document from retrieved context
|
|
185
|
+
|
|
186
|
+
**Snippets**
|
|
187
|
+
- `list_snippets` — list available code snippets/templates
|
|
188
|
+
- `assemble_from_snippets` — generate new code from templates for a target
|
|
189
|
+
framework
|
|
190
|
+
|
|
191
|
+
**LLM usage**
|
|
192
|
+
- `usage_report` — summarize accumulated LLM cost/usage
|
|
193
|
+
- `set_llm_policy` — override the LLM routing policy for the session
|
|
194
|
+
|
|
195
|
+
## Useful environment variables
|
|
196
|
+
|
|
197
|
+
- `CODEPREPROC_HOME`
|
|
198
|
+
- `CODEPREPROC_SERVER_URL`
|
|
199
|
+
- `CODEPREPROC_CREDENTIALS`
|
|
200
|
+
- `CODEPREPROC_MCP_CONNECTION_VERBOSITY` (`off`, `basic`, `verbose`)
|
|
201
|
+
- `CODEPREPROC_DEBUG`
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
See [LICENSE](LICENSE).
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=69", "wheel"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "codrspot-processor-mcp"
|
|
7
|
-
version = "0.1.
|
|
8
|
-
description = "Local MCP server exposing codepreproc's code-context tools to Claude Code"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.12,<3.13"
|
|
11
|
-
license = { file = "LICENSE" }
|
|
12
|
-
authors = [
|
|
13
|
-
{ name = "alexlqi", email = "alexlqi@gmail.com" },
|
|
14
|
-
]
|
|
15
|
-
classifiers = [
|
|
16
|
-
"Programming Language :: Python :: 3.12",
|
|
17
|
-
"Operating System :: Microsoft :: Windows",
|
|
18
|
-
"License :: Other/Proprietary License",
|
|
19
|
-
]
|
|
20
|
-
dependencies = [
|
|
21
|
-
"anyio",
|
|
22
|
-
"python-dotenv",
|
|
23
|
-
"bm25s",
|
|
24
|
-
"filelock",
|
|
25
|
-
"gitpython",
|
|
26
|
-
"httpx",
|
|
27
|
-
"mcp",
|
|
28
|
-
"numpy",
|
|
29
|
-
"openai",
|
|
30
|
-
"pydantic>=2",
|
|
31
|
-
"pyyaml",
|
|
32
|
-
"qdrant-client[fastembed]>=1.10.0",
|
|
33
|
-
"sentence-transformers",
|
|
34
|
-
"torch",
|
|
35
|
-
"tree-sitter",
|
|
36
|
-
"tree-sitter-languages",
|
|
37
|
-
"watchdog",
|
|
38
|
-
"xxhash",
|
|
39
|
-
"pyahocorasick",
|
|
40
|
-
"zstandard",
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
[project.scripts]
|
|
44
|
-
codepreproc-mcp = "codepreproc_client.layer1_business.mcp.server:run"
|
|
45
|
-
codepreproc = "codepreproc_client.layer1_business.cli.main:run"
|
|
46
|
-
|
|
47
|
-
[tool.setuptools]
|
|
48
|
-
package-dir = {"" = "src"}
|
|
49
|
-
|
|
50
|
-
[tool.setuptools.packages.find]
|
|
51
|
-
where = ["src"]
|
|
52
|
-
include = ["codepreproc_client*", "contracts*"]
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=69", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "codrspot-processor-mcp"
|
|
7
|
+
version = "0.1.3"
|
|
8
|
+
description = "Local MCP server exposing codepreproc's code-context tools to Claude Code"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12,<3.13"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "alexlqi", email = "alexlqi@gmail.com" },
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Operating System :: Microsoft :: Windows",
|
|
18
|
+
"License :: Other/Proprietary License",
|
|
19
|
+
]
|
|
20
|
+
dependencies = [
|
|
21
|
+
"anyio",
|
|
22
|
+
"python-dotenv",
|
|
23
|
+
"bm25s",
|
|
24
|
+
"filelock",
|
|
25
|
+
"gitpython",
|
|
26
|
+
"httpx",
|
|
27
|
+
"mcp",
|
|
28
|
+
"numpy",
|
|
29
|
+
"openai",
|
|
30
|
+
"pydantic>=2",
|
|
31
|
+
"pyyaml",
|
|
32
|
+
"qdrant-client[fastembed]>=1.10.0",
|
|
33
|
+
"sentence-transformers",
|
|
34
|
+
"torch",
|
|
35
|
+
"tree-sitter",
|
|
36
|
+
"tree-sitter-languages",
|
|
37
|
+
"watchdog",
|
|
38
|
+
"xxhash",
|
|
39
|
+
"pyahocorasick",
|
|
40
|
+
"zstandard",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.scripts]
|
|
44
|
+
codepreproc-mcp = "codepreproc_client.layer1_business.mcp.server:run"
|
|
45
|
+
codepreproc = "codepreproc_client.layer1_business.cli.main:run"
|
|
46
|
+
|
|
47
|
+
[tool.setuptools]
|
|
48
|
+
package-dir = {"" = "src"}
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.packages.find]
|
|
51
|
+
where = ["src"]
|
|
52
|
+
include = ["codepreproc_client*", "contracts*"]
|
|
@@ -9,12 +9,15 @@ this module only builds requests and validates typed responses.
|
|
|
9
9
|
|
|
10
10
|
from __future__ import annotations
|
|
11
11
|
|
|
12
|
+
import logging
|
|
12
13
|
from collections.abc import Awaitable, Callable
|
|
13
14
|
from typing import Any
|
|
14
15
|
|
|
15
16
|
import httpx
|
|
16
17
|
from pydantic import BaseModel
|
|
17
18
|
|
|
19
|
+
_logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
18
21
|
from contracts.dtos import (
|
|
19
22
|
ROUTING_MATRIX,
|
|
20
23
|
IntentSpec,
|
|
@@ -100,10 +103,32 @@ class LLMRuntime:
|
|
|
100
103
|
|
|
101
104
|
def __init__(self, base_url: str, jwt_provider: Callable[[], Awaitable[str]]) -> None:
|
|
102
105
|
self.router = LLMRouter(base_url, jwt_provider)
|
|
106
|
+
self._base_url = base_url
|
|
107
|
+
self._jwt_provider = jwt_provider
|
|
103
108
|
|
|
104
109
|
async def close(self) -> None:
|
|
105
110
|
pass # no local provider connections to release
|
|
106
111
|
|
|
112
|
+
async def usage_report(self, *, project: str | None, since_days: int) -> dict[str, object]:
|
|
113
|
+
"""Cost/usage accounting lives entirely server-side (CostTracker); this
|
|
114
|
+
calls the GET /usage_report proxy instead of a local cost_tracker
|
|
115
|
+
attribute, which the client never has."""
|
|
116
|
+
jwt = await self._jwt_provider()
|
|
117
|
+
params: dict[str, Any] = {"since_days": since_days}
|
|
118
|
+
if project:
|
|
119
|
+
params["project"] = project
|
|
120
|
+
try:
|
|
121
|
+
async with httpx.AsyncClient(base_url=self._base_url, timeout=DEFAULT_TIMEOUT_S) as client:
|
|
122
|
+
response = await client.get(
|
|
123
|
+
"/v1/usage_report",
|
|
124
|
+
params=params,
|
|
125
|
+
headers={"Authorization": f"Bearer {jwt}"},
|
|
126
|
+
)
|
|
127
|
+
response.raise_for_status()
|
|
128
|
+
except httpx.HTTPError as exc:
|
|
129
|
+
raise ProviderUnavailableError(str(exc)) from exc
|
|
130
|
+
return response.json()
|
|
131
|
+
|
|
107
132
|
|
|
108
133
|
class IntentExtractor:
|
|
109
134
|
"""Extract structured intent from a user prompt (ported from the server's
|
|
@@ -147,8 +172,12 @@ class IntentExtractor:
|
|
|
147
172
|
task_id=task_id,
|
|
148
173
|
)
|
|
149
174
|
return IntentSpec.model_validate(result) if not isinstance(result, IntentSpec) else result, usage
|
|
150
|
-
except Exception:
|
|
151
|
-
|
|
175
|
+
except Exception as exc:
|
|
176
|
+
_logger.warning("intent extraction failed, falling back to raw prompt: %s", exc)
|
|
177
|
+
return (
|
|
178
|
+
IntentSpec(change_summary=user_prompt, constraints=[]),
|
|
179
|
+
LLMUsageStats(provider="fallback", task_type="intent_extraction", fallback_from=f"{type(exc).__name__}: {exc}"),
|
|
180
|
+
)
|
|
152
181
|
|
|
153
182
|
|
|
154
183
|
__all__ = [
|
|
@@ -74,6 +74,11 @@ class SuperKGClient:
|
|
|
74
74
|
self._jwt_provider = jwt_provider
|
|
75
75
|
self._timeout = timeout
|
|
76
76
|
self._enrich_timeout = enrich_timeout
|
|
77
|
+
# Reason the most recent _post() call returned None, so callers that
|
|
78
|
+
# care about *why* registration/bootstrap failed (e.g. _ensure_superkg_system)
|
|
79
|
+
# can surface something more actionable than a bare None. All the
|
|
80
|
+
# fire-and-forget callers below can keep ignoring this.
|
|
81
|
+
self.last_error: str | None = None
|
|
77
82
|
|
|
78
83
|
# ------------------------------------------------------------------
|
|
79
84
|
# Internal helpers
|
|
@@ -87,6 +92,7 @@ class SuperKGClient:
|
|
|
87
92
|
self, path: str, project_id: str, request, *, kind: str | None = None, timeout: float | None = None
|
|
88
93
|
) -> dict | None:
|
|
89
94
|
if not self.enabled:
|
|
95
|
+
self.last_error = "superkg_disabled"
|
|
90
96
|
return None
|
|
91
97
|
assert_safe_to_send(request)
|
|
92
98
|
payload = request.model_dump(mode="json")
|
|
@@ -97,9 +103,11 @@ class SuperKGClient:
|
|
|
97
103
|
async with httpx.AsyncClient(base_url=self._base, timeout=timeout or self._timeout) as client:
|
|
98
104
|
resp = await client.post(f"/v1/superkg{path}", json=payload, headers=headers)
|
|
99
105
|
resp.raise_for_status()
|
|
106
|
+
self.last_error = None
|
|
100
107
|
return resp.json()
|
|
101
108
|
except Exception as exc:
|
|
102
|
-
|
|
109
|
+
self.last_error = str(exc)
|
|
110
|
+
_log.warning("SuperKG proxy POST %s failed: %s", path, exc)
|
|
103
111
|
return None
|
|
104
112
|
|
|
105
113
|
async def _delete(self, path: str, project_id: str, request) -> None:
|
|
@@ -164,13 +164,30 @@ async def main() -> None:
|
|
|
164
164
|
qdrant_store = SessionVectorStore(path=settings.indexes_dir / "session_vectors")
|
|
165
165
|
logger.info("session_vector_store_init path=%s", settings.indexes_dir / "session_vectors")
|
|
166
166
|
|
|
167
|
+
project_registry = ProjectRegistry(registry_data)
|
|
168
|
+
|
|
169
|
+
# bootstrap_jwt_client above was minted from a startup-time snapshot of
|
|
170
|
+
# local_projects - if the server started with zero registered projects,
|
|
171
|
+
# it stays None forever even after init_project registers one later in
|
|
172
|
+
# the same session. Cache it in a mutable holder and lazily re-mint from
|
|
173
|
+
# the *live* registry (mirroring _project_jwt_provider below) so
|
|
174
|
+
# reasoning calls succeed as soon as any project is registered, whenever
|
|
175
|
+
# that happens relative to server startup.
|
|
176
|
+
_bootstrap_jwt_holder: dict[str, object] = {"client": bootstrap_jwt_client}
|
|
177
|
+
|
|
167
178
|
async def _reasoning_jwt_provider() -> str:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
179
|
+
client = _bootstrap_jwt_holder["client"]
|
|
180
|
+
if client is None:
|
|
181
|
+
live_projects = project_registry.registry.projects
|
|
182
|
+
if not live_projects:
|
|
183
|
+
raise RuntimeError("no project registered yet - cannot mint a JWT for LLM reasoning calls")
|
|
184
|
+
_, client = await _mint_bootstrap_jwt(live_projects)
|
|
185
|
+
if client is None:
|
|
186
|
+
raise RuntimeError("no project registered yet - cannot mint a JWT for LLM reasoning calls")
|
|
187
|
+
_bootstrap_jwt_holder["client"] = client
|
|
188
|
+
return await client.get_bearer_token()
|
|
171
189
|
|
|
172
190
|
llm_runtime = LLMRuntime(get_server_url(), _reasoning_jwt_provider)
|
|
173
|
-
project_registry = ProjectRegistry(registry_data)
|
|
174
191
|
|
|
175
192
|
# Any /v1/superkg/* (or other project-scoped) call must present a JWT
|
|
176
193
|
# naming that specific project_id in claims["project_ids"] (see
|