kodit 0.1.2__py3-none-any.whl → 0.1.4__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.
Potentially problematic release.
This version of kodit might be problematic. Click here for more details.
- kodit/_version.py +2 -2
- kodit/cli.py +0 -2
- kodit/database.py +5 -1
- kodit/indexing/service.py +0 -1
- kodit/mcp.py +63 -4
- {kodit-0.1.2.dist-info → kodit-0.1.4.dist-info}/METADATA +1 -1
- {kodit-0.1.2.dist-info → kodit-0.1.4.dist-info}/RECORD +10 -10
- {kodit-0.1.2.dist-info → kodit-0.1.4.dist-info}/WHEEL +0 -0
- {kodit-0.1.2.dist-info → kodit-0.1.4.dist-info}/entry_points.txt +0 -0
- {kodit-0.1.2.dist-info → kodit-0.1.4.dist-info}/licenses/LICENSE +0 -0
kodit/_version.py
CHANGED
kodit/cli.py
CHANGED
|
@@ -104,7 +104,6 @@ async def list_indexes(session: AsyncSession) -> None:
|
|
|
104
104
|
"ID",
|
|
105
105
|
"Created At",
|
|
106
106
|
"Updated At",
|
|
107
|
-
"Source URI",
|
|
108
107
|
"Num Snippets",
|
|
109
108
|
]
|
|
110
109
|
data = [
|
|
@@ -112,7 +111,6 @@ async def list_indexes(session: AsyncSession) -> None:
|
|
|
112
111
|
index.id,
|
|
113
112
|
index.created_at,
|
|
114
113
|
index.updated_at,
|
|
115
|
-
index.source_uri,
|
|
116
114
|
index.num_snippets,
|
|
117
115
|
]
|
|
118
116
|
for index in indexes
|
kodit/database.py
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import asyncio
|
|
4
4
|
from collections.abc import AsyncGenerator, Callable
|
|
5
|
+
from contextlib import asynccontextmanager
|
|
5
6
|
from datetime import UTC, datetime
|
|
6
7
|
from functools import wraps
|
|
8
|
+
from pathlib import Path
|
|
7
9
|
from typing import Any, TypeVar
|
|
8
10
|
|
|
9
11
|
from alembic import command
|
|
@@ -17,6 +19,7 @@ from sqlalchemy.ext.asyncio import (
|
|
|
17
19
|
)
|
|
18
20
|
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
|
19
21
|
|
|
22
|
+
from kodit import alembic
|
|
20
23
|
from kodit.config import DATA_DIR
|
|
21
24
|
|
|
22
25
|
# Constants
|
|
@@ -52,6 +55,7 @@ class CommonMixin:
|
|
|
52
55
|
)
|
|
53
56
|
|
|
54
57
|
|
|
58
|
+
@asynccontextmanager
|
|
55
59
|
async def get_session() -> AsyncGenerator[AsyncSession, None]:
|
|
56
60
|
"""Get a database session."""
|
|
57
61
|
async with async_session_factory() as session:
|
|
@@ -82,6 +86,6 @@ def configure_database() -> None:
|
|
|
82
86
|
"""Configure the database by initializing it and running any pending migrations."""
|
|
83
87
|
# Create Alembic configuration and run migrations
|
|
84
88
|
alembic_cfg = Config()
|
|
85
|
-
alembic_cfg.set_main_option("script_location",
|
|
89
|
+
alembic_cfg.set_main_option("script_location", str(Path(alembic.__file__).parent))
|
|
86
90
|
alembic_cfg.set_main_option("sqlalchemy.url", DB_URL)
|
|
87
91
|
command.upgrade(alembic_cfg, "head")
|
kodit/indexing/service.py
CHANGED
kodit/mcp.py
CHANGED
|
@@ -7,14 +7,21 @@ import structlog
|
|
|
7
7
|
from mcp.server.fastmcp import FastMCP
|
|
8
8
|
from pydantic import Field
|
|
9
9
|
|
|
10
|
+
from kodit.database import get_session
|
|
11
|
+
from kodit.retreival.repository import RetrievalRepository, RetrievalResult
|
|
12
|
+
from kodit.retreival.service import RetrievalRequest, RetrievalService
|
|
13
|
+
|
|
10
14
|
mcp = FastMCP("kodit MCP Server")
|
|
11
15
|
|
|
12
16
|
|
|
13
17
|
@mcp.tool()
|
|
14
18
|
async def retrieve_relevant_snippets(
|
|
15
|
-
|
|
19
|
+
user_intent: Annotated[
|
|
16
20
|
str,
|
|
17
|
-
Field(
|
|
21
|
+
Field(
|
|
22
|
+
description="Think about what the user wants to achieve. Describe the "
|
|
23
|
+
"user's intent in one sentence."
|
|
24
|
+
),
|
|
18
25
|
],
|
|
19
26
|
related_file_paths: Annotated[
|
|
20
27
|
list[Path],
|
|
@@ -30,6 +37,12 @@ async def retrieve_relevant_snippets(
|
|
|
30
37
|
"user's intent."
|
|
31
38
|
),
|
|
32
39
|
],
|
|
40
|
+
keywords: Annotated[
|
|
41
|
+
list[str],
|
|
42
|
+
Field(
|
|
43
|
+
description="A list of keywords that are relevant to the desired outcome."
|
|
44
|
+
),
|
|
45
|
+
],
|
|
33
46
|
) -> str:
|
|
34
47
|
"""Retrieve relevant snippets from various sources.
|
|
35
48
|
|
|
@@ -42,10 +55,56 @@ async def retrieve_relevant_snippets(
|
|
|
42
55
|
log = structlog.get_logger(__name__)
|
|
43
56
|
log.debug(
|
|
44
57
|
"Retrieving relevant snippets",
|
|
45
|
-
|
|
58
|
+
user_intent=user_intent,
|
|
59
|
+
keywords=keywords,
|
|
46
60
|
file_count=len(related_file_paths),
|
|
47
61
|
file_paths=related_file_paths,
|
|
48
62
|
file_contents=related_file_contents,
|
|
49
63
|
)
|
|
50
64
|
|
|
51
|
-
|
|
65
|
+
async with get_session() as session:
|
|
66
|
+
log.debug("Creating retrieval repository")
|
|
67
|
+
retrieval_repository = RetrievalRepository(
|
|
68
|
+
session=session,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
log.debug("Creating retrieval service")
|
|
72
|
+
retrieval_service = RetrievalService(
|
|
73
|
+
repository=retrieval_repository,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
log.debug("Fusing input")
|
|
77
|
+
input_query = input_fusion(
|
|
78
|
+
user_intent=user_intent,
|
|
79
|
+
related_file_paths=related_file_paths,
|
|
80
|
+
related_file_contents=related_file_contents,
|
|
81
|
+
keywords=keywords,
|
|
82
|
+
)
|
|
83
|
+
log.debug("Input", input_query=input_query)
|
|
84
|
+
retrieval_request = RetrievalRequest(
|
|
85
|
+
query=input_query,
|
|
86
|
+
)
|
|
87
|
+
log.debug("Retrieving snippets")
|
|
88
|
+
snippets = await retrieval_service.retrieve(request=retrieval_request)
|
|
89
|
+
|
|
90
|
+
log.debug("Fusing output")
|
|
91
|
+
output = output_fusion(snippets=snippets)
|
|
92
|
+
|
|
93
|
+
log.debug("Output", output=output)
|
|
94
|
+
return output
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def input_fusion(
|
|
98
|
+
user_intent: str, # noqa: ARG001
|
|
99
|
+
related_file_paths: list[Path], # noqa: ARG001
|
|
100
|
+
related_file_contents: list[str], # noqa: ARG001
|
|
101
|
+
keywords: list[str],
|
|
102
|
+
) -> str:
|
|
103
|
+
"""Fuse the search query and related file contents into a single query."""
|
|
104
|
+
# Since this is a dummy implementation, we just return the first keyword
|
|
105
|
+
return keywords[0] if len(keywords) > 0 else ""
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def output_fusion(snippets: list[RetrievalResult]) -> str:
|
|
109
|
+
"""Fuse the snippets into a single output."""
|
|
110
|
+
return "\n\n".join(f"{snippet.uri}\n{snippet.content}" for snippet in snippets)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
kodit/.gitignore,sha256=ztkjgRwL9Uud1OEi36hGQeDGk3OLK1NfDEO8YqGYy8o,11
|
|
2
2
|
kodit/__init__.py,sha256=aEKHYninUq1yh6jaNfvJBYg-6fenpN132nJt1UU6Jxs,59
|
|
3
|
-
kodit/_version.py,sha256=
|
|
3
|
+
kodit/_version.py,sha256=hcPkC9vIGgfrKK6ft7ysLT7iOCjpFmCBmyKLmXiaZ1g,511
|
|
4
4
|
kodit/app.py,sha256=FBAeeOz2CICvVN_27iMq9wEF9y8d1IDl0WmkEnM_M_U,699
|
|
5
|
-
kodit/cli.py,sha256=
|
|
5
|
+
kodit/cli.py,sha256=C8fos0wkUH3AJAf_yVBDEYKAgqNfGbKQiVBCGRqZITQ,5644
|
|
6
6
|
kodit/config.py,sha256=Wq9MlxOnOA3p9mgIzsq-s7N57_GFVIOMML-4GFINmqE,104
|
|
7
|
-
kodit/database.py,sha256=
|
|
7
|
+
kodit/database.py,sha256=4gkgf3d8ZBrW5ZXQ6yO16f3jFXSbqa6UiPBz1g_teJE,2521
|
|
8
8
|
kodit/logging.py,sha256=dQr4YXVH8_B52V0wXbBrn_HvH4QpO-fsi0C3JPWzn0Y,5022
|
|
9
|
-
kodit/mcp.py,sha256=
|
|
9
|
+
kodit/mcp.py,sha256=Fi5e8r-6Ec3sHSe7jlIHpnUPsG0-t-Cw7_rwbKtcRAk,3521
|
|
10
10
|
kodit/middleware.py,sha256=NHLrqq20ZtPTE9esX9HD3z7EKi56_QTFxBlkdq0JDzQ,2138
|
|
11
11
|
kodit/sse.py,sha256=UgwXJUeFq5D5S9KYKVVg4m6P0-_QHnJOCRRQB8XNR-M,2259
|
|
12
12
|
kodit/alembic/README,sha256=ISVtAOvqvKk_5ThM5ioJE-lMkvf9IbknFUFVU_vPma4,58
|
|
@@ -18,7 +18,7 @@ kodit/alembic/versions/__init__.py,sha256=9-lHzptItTzq_fomdIRBegQNm4Znx6pVjwD4Mi
|
|
|
18
18
|
kodit/indexing/__init__.py,sha256=cPyi2Iej3G1JFWlWr7X80_UrsMaTu5W5rBwgif1B3xo,75
|
|
19
19
|
kodit/indexing/models.py,sha256=sZIhGwvL4Dw0QTWFxrjfWctSLkAoDT6fv5DlGz8-Fr8,1258
|
|
20
20
|
kodit/indexing/repository.py,sha256=GeRpgRNOZunEKtzkkqkJWlOaR8cpGMX4rI_puDdB8WY,4006
|
|
21
|
-
kodit/indexing/service.py,sha256=
|
|
21
|
+
kodit/indexing/service.py,sha256=jdQMOsm8kYTlNybxSs2xisRxZRQISlmRQDfLtoqkpjg,4951
|
|
22
22
|
kodit/retreival/__init__.py,sha256=33PhJU-3gtsqYq6A1UkaLNKbev_Zee9Lq6dYC59-CsA,69
|
|
23
23
|
kodit/retreival/repository.py,sha256=WJQiePfeuwnj8Vy6dqF4bhNhsWqH9VspjN2zlvYQWvY,2273
|
|
24
24
|
kodit/retreival/service.py,sha256=Iy9IBLhohQmypeOs0hDEjgr1hsr0xtaiMqjIzykFWrY,727
|
|
@@ -26,8 +26,8 @@ kodit/sources/__init__.py,sha256=1NTZyPdjThVQpZO1Mp1ColVsS7sqYanOVLqnoqV9Ipo,83
|
|
|
26
26
|
kodit/sources/models.py,sha256=xb42CaNDO1CUB8SIW-xXMrB6Ji8cFw-yeJ550xBEg9Q,2398
|
|
27
27
|
kodit/sources/repository.py,sha256=mGJrHWH6Uo8YABdoojHFbzaf_jW-2ywJpAHIa1gnc3U,3401
|
|
28
28
|
kodit/sources/service.py,sha256=khrz3UH6hNTYwXMFosGc46trcb8Sm0dTPwvptbgRgwM,6722
|
|
29
|
-
kodit-0.1.
|
|
30
|
-
kodit-0.1.
|
|
31
|
-
kodit-0.1.
|
|
32
|
-
kodit-0.1.
|
|
33
|
-
kodit-0.1.
|
|
29
|
+
kodit-0.1.4.dist-info/METADATA,sha256=QOoPAs68hrp4m_RYvCamYIrznlMIl79faJeq2Rzn-zw,2019
|
|
30
|
+
kodit-0.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
31
|
+
kodit-0.1.4.dist-info/entry_points.txt,sha256=hoTn-1aKyTItjnY91fnO-rV5uaWQLQ-Vi7V5et2IbHY,40
|
|
32
|
+
kodit-0.1.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
33
|
+
kodit-0.1.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|