kodit 0.1.6__py3-none-any.whl → 0.1.7__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 +45 -96
- kodit/indexing/repository.py +5 -3
- kodit/indexing/service.py +3 -1
- {kodit-0.1.6.dist-info → kodit-0.1.7.dist-info}/METADATA +1 -1
- {kodit-0.1.6.dist-info → kodit-0.1.7.dist-info}/RECORD +9 -9
- {kodit-0.1.6.dist-info → kodit-0.1.7.dist-info}/WHEEL +0 -0
- {kodit-0.1.6.dist-info → kodit-0.1.7.dist-info}/entry_points.txt +0 -0
- {kodit-0.1.6.dist-info → kodit-0.1.7.dist-info}/licenses/LICENSE +0 -0
kodit/_version.py
CHANGED
kodit/cli.py
CHANGED
|
@@ -8,7 +8,7 @@ from typing import Any
|
|
|
8
8
|
import click
|
|
9
9
|
import structlog
|
|
10
10
|
import uvicorn
|
|
11
|
-
from pytable_formatter import Table
|
|
11
|
+
from pytable_formatter import Cell, Table
|
|
12
12
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
13
13
|
|
|
14
14
|
from kodit.config import (
|
|
@@ -84,110 +84,59 @@ def cli( # noqa: PLR0913
|
|
|
84
84
|
ctx.obj = config
|
|
85
85
|
|
|
86
86
|
|
|
87
|
-
@cli.
|
|
88
|
-
|
|
89
|
-
"""Manage code sources."""
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
@sources.command(name="list")
|
|
93
|
-
@with_app_context
|
|
94
|
-
@with_session
|
|
95
|
-
async def list_sources(session: AsyncSession, app_context: AppContext) -> None:
|
|
96
|
-
"""List all code sources."""
|
|
97
|
-
repository = SourceRepository(session)
|
|
98
|
-
service = SourceService(app_context.get_clone_dir(), repository)
|
|
99
|
-
sources = await service.list_sources()
|
|
100
|
-
|
|
101
|
-
# Define headers and data
|
|
102
|
-
headers = ["ID", "Created At", "URI"]
|
|
103
|
-
data = [[source.id, source.created_at, source.uri] for source in sources]
|
|
104
|
-
|
|
105
|
-
# Create and display the table
|
|
106
|
-
table = Table(headers=headers, data=data)
|
|
107
|
-
click.echo(table)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
@sources.command(name="create")
|
|
111
|
-
@click.argument("uri")
|
|
112
|
-
@with_app_context
|
|
113
|
-
@with_session
|
|
114
|
-
async def create_source(
|
|
115
|
-
session: AsyncSession, app_context: AppContext, uri: str
|
|
116
|
-
) -> None:
|
|
117
|
-
"""Add a new code source."""
|
|
118
|
-
repository = SourceRepository(session)
|
|
119
|
-
service = SourceService(app_context.get_clone_dir(), repository)
|
|
120
|
-
source = await service.create(uri)
|
|
121
|
-
click.echo(f"Source created: {source.id}")
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
@cli.group()
|
|
125
|
-
def indexes() -> None:
|
|
126
|
-
"""Manage indexes."""
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
@indexes.command(name="create")
|
|
130
|
-
@click.argument("source_id")
|
|
87
|
+
@cli.command()
|
|
88
|
+
@click.argument("sources", nargs=-1)
|
|
131
89
|
@with_app_context
|
|
132
90
|
@with_session
|
|
133
|
-
async def
|
|
134
|
-
session: AsyncSession,
|
|
91
|
+
async def index(
|
|
92
|
+
session: AsyncSession,
|
|
93
|
+
app_context: AppContext,
|
|
94
|
+
sources: list[str],
|
|
135
95
|
) -> None:
|
|
136
|
-
"""
|
|
96
|
+
"""List indexes, or index data sources."""
|
|
137
97
|
source_repository = SourceRepository(session)
|
|
138
98
|
source_service = SourceService(app_context.get_clone_dir(), source_repository)
|
|
139
99
|
repository = IndexRepository(session)
|
|
140
100
|
service = IndexService(repository, source_service, app_context.get_data_dir())
|
|
141
|
-
index = await service.create(source_id)
|
|
142
|
-
click.echo(f"Index created: {index.id}")
|
|
143
101
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
service = IndexService(repository, source_service, app_context.get_data_dir())
|
|
154
|
-
indexes = await service.list_indexes()
|
|
155
|
-
|
|
156
|
-
# Define headers and data
|
|
157
|
-
headers = [
|
|
158
|
-
"ID",
|
|
159
|
-
"Created At",
|
|
160
|
-
"Updated At",
|
|
161
|
-
"Num Snippets",
|
|
162
|
-
]
|
|
163
|
-
data = [
|
|
164
|
-
[
|
|
165
|
-
index.id,
|
|
166
|
-
index.created_at,
|
|
167
|
-
index.updated_at,
|
|
168
|
-
index.num_snippets,
|
|
102
|
+
if not sources:
|
|
103
|
+
# No source specified, list all indexes
|
|
104
|
+
indexes = await service.list_indexes()
|
|
105
|
+
headers: list[str | Cell] = [
|
|
106
|
+
"ID",
|
|
107
|
+
"Created At",
|
|
108
|
+
"Updated At",
|
|
109
|
+
"Source",
|
|
110
|
+
"Num Snippets",
|
|
169
111
|
]
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
112
|
+
data = [
|
|
113
|
+
[
|
|
114
|
+
index.id,
|
|
115
|
+
index.created_at,
|
|
116
|
+
index.updated_at,
|
|
117
|
+
index.source,
|
|
118
|
+
index.num_snippets,
|
|
119
|
+
]
|
|
120
|
+
for index in indexes
|
|
121
|
+
]
|
|
122
|
+
click.echo(Table(headers=headers, data=data))
|
|
123
|
+
return
|
|
124
|
+
# Handle source indexing
|
|
125
|
+
for source in sources:
|
|
126
|
+
if source.startswith("https://"):
|
|
127
|
+
msg = "Web or git indexing is not implemented yet"
|
|
128
|
+
raise click.UsageError(msg)
|
|
129
|
+
if source.startswith("git"):
|
|
130
|
+
msg = "Git indexing is not implemented yet"
|
|
131
|
+
raise click.UsageError(msg)
|
|
132
|
+
if Path(source).is_file():
|
|
133
|
+
msg = "File indexing is not implemented yet"
|
|
134
|
+
raise click.UsageError(msg)
|
|
135
|
+
|
|
136
|
+
# Index directory
|
|
137
|
+
s = await source_service.create(source)
|
|
138
|
+
index = await service.create(s.id)
|
|
139
|
+
await service.run(index.id)
|
|
191
140
|
|
|
192
141
|
|
|
193
142
|
@cli.command()
|
kodit/indexing/repository.py
CHANGED
|
@@ -82,7 +82,7 @@ class IndexRepository:
|
|
|
82
82
|
result = await self.session.execute(query)
|
|
83
83
|
return list(result.scalars())
|
|
84
84
|
|
|
85
|
-
async def list_indexes(self) -> list[Index]:
|
|
85
|
+
async def list_indexes(self) -> list[tuple[Index, Source]]:
|
|
86
86
|
"""List all indexes.
|
|
87
87
|
|
|
88
88
|
Returns:
|
|
@@ -90,9 +90,11 @@ class IndexRepository:
|
|
|
90
90
|
and counts of files and snippets.
|
|
91
91
|
|
|
92
92
|
"""
|
|
93
|
-
query = select(Index).
|
|
93
|
+
query = select(Index, Source).join(
|
|
94
|
+
Source, Index.source_id == Source.id, full=True
|
|
95
|
+
)
|
|
94
96
|
result = await self.session.execute(query)
|
|
95
|
-
return list(result.
|
|
97
|
+
return list(result.tuples())
|
|
96
98
|
|
|
97
99
|
async def num_snippets_for_index(self, index_id: int) -> int:
|
|
98
100
|
"""Get the number of snippets for an index."""
|
kodit/indexing/service.py
CHANGED
|
@@ -33,6 +33,7 @@ class IndexView(pydantic.BaseModel):
|
|
|
33
33
|
id: int
|
|
34
34
|
created_at: datetime
|
|
35
35
|
updated_at: datetime | None = None
|
|
36
|
+
source: str | None = None
|
|
36
37
|
num_snippets: int | None = None
|
|
37
38
|
|
|
38
39
|
|
|
@@ -105,8 +106,9 @@ class IndexService:
|
|
|
105
106
|
created_at=index.created_at,
|
|
106
107
|
updated_at=index.updated_at,
|
|
107
108
|
num_snippets=await self.repository.num_snippets_for_index(index.id),
|
|
109
|
+
source=source.uri,
|
|
108
110
|
)
|
|
109
|
-
for index in indexes
|
|
111
|
+
for index, source in indexes
|
|
110
112
|
]
|
|
111
113
|
|
|
112
114
|
async def run(self, index_id: int) -> None:
|
|
@@ -1,8 +1,8 @@
|
|
|
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=W_EoL8cAL4KhujvbYWEpb9NqRLbbrH0T024lJvRRWHI,511
|
|
4
4
|
kodit/app.py,sha256=Mr5BFHOHx5zppwjC4XPWVvHjwgl1yrKbUjTWXKubJQM,891
|
|
5
|
-
kodit/cli.py,sha256=
|
|
5
|
+
kodit/cli.py,sha256=x1zw2zOlGhhU6D3E-GU3cMw3l9CqKC76geQREAQKweY,6915
|
|
6
6
|
kodit/config.py,sha256=nlm9U-nVx5riH2SrU1XY4XcCMhQK4DrwO_1H8bPOBjA,2927
|
|
7
7
|
kodit/database.py,sha256=vtTlmrXHyHJH3Ek-twZTCqEjB0jun-NncALFze2fqhA,2350
|
|
8
8
|
kodit/logging.py,sha256=cFEQXWI27LzWScSxly9ApwkbBDamUG17pA-jEfVakXQ,5316
|
|
@@ -18,8 +18,8 @@ kodit/bm25/__init__.py,sha256=j8zyriNWhbwE5Lbybzg1hQAhANlU9mKHWw4beeUR6og,19
|
|
|
18
18
|
kodit/bm25/bm25.py,sha256=3wyNRSrTaYqV7s4R1D6X0NpCf22PuFK2_uc8YapzYLE,2263
|
|
19
19
|
kodit/indexing/__init__.py,sha256=cPyi2Iej3G1JFWlWr7X80_UrsMaTu5W5rBwgif1B3xo,75
|
|
20
20
|
kodit/indexing/models.py,sha256=sZIhGwvL4Dw0QTWFxrjfWctSLkAoDT6fv5DlGz8-Fr8,1258
|
|
21
|
-
kodit/indexing/repository.py,sha256=
|
|
22
|
-
kodit/indexing/service.py,sha256=
|
|
21
|
+
kodit/indexing/repository.py,sha256=C020FGpIfTZmVZg7NH04kVuffWv7r7m-82Pdex8CItg,4388
|
|
22
|
+
kodit/indexing/service.py,sha256=7vHqevve-PnKHP2pDfyrW5n3AXVOghABWNsNTw588KY,5499
|
|
23
23
|
kodit/retreival/__init__.py,sha256=33PhJU-3gtsqYq6A1UkaLNKbev_Zee9Lq6dYC59-CsA,69
|
|
24
24
|
kodit/retreival/repository.py,sha256=1lqGgJHsBmvMGMzEYa-hrdXg2q7rqtYPl1cvBb7jMRE,3119
|
|
25
25
|
kodit/retreival/service.py,sha256=9wvURtPPJVvPUWNIC2waIrJMxcm1Ka1J_xDEOEedAFU,2007
|
|
@@ -33,8 +33,8 @@ kodit/sources/__init__.py,sha256=1NTZyPdjThVQpZO1Mp1ColVsS7sqYanOVLqnoqV9Ipo,83
|
|
|
33
33
|
kodit/sources/models.py,sha256=xb42CaNDO1CUB8SIW-xXMrB6Ji8cFw-yeJ550xBEg9Q,2398
|
|
34
34
|
kodit/sources/repository.py,sha256=mGJrHWH6Uo8YABdoojHFbzaf_jW-2ywJpAHIa1gnc3U,3401
|
|
35
35
|
kodit/sources/service.py,sha256=cBCxnOQKwGNi2e13_3Vue8MylAaUxb9XG4IgM636la0,6712
|
|
36
|
-
kodit-0.1.
|
|
37
|
-
kodit-0.1.
|
|
38
|
-
kodit-0.1.
|
|
39
|
-
kodit-0.1.
|
|
40
|
-
kodit-0.1.
|
|
36
|
+
kodit-0.1.7.dist-info/METADATA,sha256=8doJ6TfmVkn-OTLSbgRlDut6YxFbmBKs1L0rgZUlxUQ,2181
|
|
37
|
+
kodit-0.1.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
38
|
+
kodit-0.1.7.dist-info/entry_points.txt,sha256=hoTn-1aKyTItjnY91fnO-rV5uaWQLQ-Vi7V5et2IbHY,40
|
|
39
|
+
kodit-0.1.7.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
40
|
+
kodit-0.1.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|