kodit 0.1.3__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 CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.1.3'
21
- __version_tuple__ = version_tuple = (0, 1, 3)
20
+ __version__ = version = '0.1.4'
21
+ __version_tuple__ = version_tuple = (0, 1, 4)
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,6 +2,7 @@
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
7
8
  from pathlib import Path
@@ -54,6 +55,7 @@ class CommonMixin:
54
55
  )
55
56
 
56
57
 
58
+ @asynccontextmanager
57
59
  async def get_session() -> AsyncGenerator[AsyncSession, None]:
58
60
  """Get a database session."""
59
61
  async with async_session_factory() as session:
kodit/indexing/service.py CHANGED
@@ -37,7 +37,6 @@ class IndexView(pydantic.BaseModel):
37
37
  id: int
38
38
  created_at: datetime
39
39
  updated_at: datetime | None = None
40
- source_uri: str | None = None
41
40
  num_snippets: int | None = None
42
41
 
43
42
 
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
- search_query: Annotated[
19
+ user_intent: Annotated[
16
20
  str,
17
- Field(description="Describe the user's intent in a few sentences."),
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
- search_query=search_query,
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
- return "Retrieved"
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kodit
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: Code indexing for better AI code generation
5
5
  Project-URL: Homepage, https://docs.helixml.tech/kodit/
6
6
  Project-URL: Documentation, https://docs.helixml.tech/kodit/
@@ -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=NIzzV8ZM0W-CSLuEs1weG4zPrn_-8yr1AwwI1iuS6yo,511
3
+ kodit/_version.py,sha256=hcPkC9vIGgfrKK6ft7ysLT7iOCjpFmCBmyKLmXiaZ1g,511
4
4
  kodit/app.py,sha256=FBAeeOz2CICvVN_27iMq9wEF9y8d1IDl0WmkEnM_M_U,699
5
- kodit/cli.py,sha256=2hNz05I6vryhkGqwMXlg_GKVAzhMmS_v8H2Nl6oxBZ4,5696
5
+ kodit/cli.py,sha256=C8fos0wkUH3AJAf_yVBDEYKAgqNfGbKQiVBCGRqZITQ,5644
6
6
  kodit/config.py,sha256=Wq9MlxOnOA3p9mgIzsq-s7N57_GFVIOMML-4GFINmqE,104
7
- kodit/database.py,sha256=ndStVWzR5XAiZ1JBu_NE4Nv-KLEZ3GQVLVjPIUmiRA4,2457
7
+ kodit/database.py,sha256=4gkgf3d8ZBrW5ZXQ6yO16f3jFXSbqa6UiPBz1g_teJE,2521
8
8
  kodit/logging.py,sha256=dQr4YXVH8_B52V0wXbBrn_HvH4QpO-fsi0C3JPWzn0Y,5022
9
- kodit/mcp.py,sha256=Sg7Waes9Z7HYzdglspG92dGhTVtb1lEaEKW-vlaUCXg,1488
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=COiOCNmZN0QKgazXB4dEpHnL1pi002td6n7PRo0d17I,4985
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.3.dist-info/METADATA,sha256=1Q0EP_fo9liqZoW_3QGXMphCj05jtgYxfIwMb4o4e5c,2019
30
- kodit-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
- kodit-0.1.3.dist-info/entry_points.txt,sha256=hoTn-1aKyTItjnY91fnO-rV5uaWQLQ-Vi7V5et2IbHY,40
32
- kodit-0.1.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
33
- kodit-0.1.3.dist-info/RECORD,,
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