kodit 0.4.1__py3-none-any.whl → 0.4.2__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/app.py +4 -2
- kodit/application/factories/code_indexing_factory.py +54 -7
- kodit/application/factories/reporting_factory.py +27 -0
- kodit/application/services/auto_indexing_service.py +16 -4
- kodit/application/services/code_indexing_application_service.py +115 -133
- kodit/application/services/indexing_worker_service.py +18 -20
- kodit/application/services/queue_service.py +12 -14
- kodit/application/services/reporting.py +86 -0
- kodit/application/services/sync_scheduler.py +21 -20
- kodit/cli.py +14 -18
- kodit/config.py +24 -1
- kodit/database.py +2 -1
- kodit/domain/protocols.py +9 -1
- kodit/domain/services/bm25_service.py +1 -6
- kodit/domain/services/index_service.py +22 -58
- kodit/domain/value_objects.py +57 -9
- kodit/infrastructure/api/v1/dependencies.py +23 -10
- kodit/infrastructure/cloning/git/working_copy.py +36 -7
- kodit/infrastructure/embedding/embedding_factory.py +8 -3
- kodit/infrastructure/embedding/embedding_providers/litellm_embedding_provider.py +48 -55
- kodit/infrastructure/git/git_utils.py +3 -2
- kodit/infrastructure/mappers/index_mapper.py +1 -0
- kodit/infrastructure/reporting/__init__.py +1 -0
- kodit/infrastructure/reporting/log_progress.py +65 -0
- kodit/infrastructure/reporting/tdqm_progress.py +73 -0
- kodit/infrastructure/sqlalchemy/embedding_repository.py +47 -68
- kodit/infrastructure/sqlalchemy/entities.py +28 -2
- kodit/infrastructure/sqlalchemy/index_repository.py +274 -236
- kodit/infrastructure/sqlalchemy/task_repository.py +55 -39
- kodit/infrastructure/sqlalchemy/unit_of_work.py +59 -0
- kodit/mcp.py +10 -2
- {kodit-0.4.1.dist-info → kodit-0.4.2.dist-info}/METADATA +1 -1
- {kodit-0.4.1.dist-info → kodit-0.4.2.dist-info}/RECORD +37 -36
- kodit/domain/interfaces.py +0 -27
- kodit/infrastructure/ui/__init__.py +0 -1
- kodit/infrastructure/ui/progress.py +0 -170
- kodit/infrastructure/ui/spinner.py +0 -74
- kodit/reporting.py +0 -78
- {kodit-0.4.1.dist-info → kodit-0.4.2.dist-info}/WHEEL +0 -0
- {kodit-0.4.1.dist-info → kodit-0.4.2.dist-info}/entry_points.txt +0 -0
- {kodit-0.4.1.dist-info → kodit-0.4.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"""Spinner for long-running tasks in the UI layer."""
|
|
2
|
-
|
|
3
|
-
import itertools
|
|
4
|
-
import sys
|
|
5
|
-
import threading
|
|
6
|
-
import time
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Spinner:
|
|
10
|
-
"""Spinner for long-running tasks.
|
|
11
|
-
|
|
12
|
-
This class provides visual feedback for long-running operations by displaying
|
|
13
|
-
a spinning animation in the terminal. It's designed to be used as a context
|
|
14
|
-
manager for operations that may take some time to complete.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
def __init__(self, delay: float = 0.1) -> None:
|
|
18
|
-
"""Initialize the spinner.
|
|
19
|
-
|
|
20
|
-
Args:
|
|
21
|
-
delay: The delay between spinner updates in seconds.
|
|
22
|
-
|
|
23
|
-
"""
|
|
24
|
-
self.spinner = itertools.cycle(["-", "/", "|", "\\"])
|
|
25
|
-
self.delay = delay
|
|
26
|
-
self.busy = False
|
|
27
|
-
self.spinner_visible = False
|
|
28
|
-
|
|
29
|
-
def write_next(self) -> None:
|
|
30
|
-
"""Write the next character of the spinner."""
|
|
31
|
-
with self._screen_lock:
|
|
32
|
-
if not self.spinner_visible:
|
|
33
|
-
sys.stdout.write(next(self.spinner))
|
|
34
|
-
self.spinner_visible = True
|
|
35
|
-
sys.stdout.flush()
|
|
36
|
-
|
|
37
|
-
def remove_spinner(self, cleanup: bool = False) -> None: # noqa: FBT001, FBT002
|
|
38
|
-
"""Remove the spinner.
|
|
39
|
-
|
|
40
|
-
Args:
|
|
41
|
-
cleanup: Whether to clean up the spinner display.
|
|
42
|
-
|
|
43
|
-
"""
|
|
44
|
-
with self._screen_lock:
|
|
45
|
-
if self.spinner_visible:
|
|
46
|
-
sys.stdout.write("\b")
|
|
47
|
-
self.spinner_visible = False
|
|
48
|
-
if cleanup:
|
|
49
|
-
sys.stdout.write(" ") # overwrite spinner with blank
|
|
50
|
-
sys.stdout.write("\r") # move to next line
|
|
51
|
-
sys.stdout.flush()
|
|
52
|
-
|
|
53
|
-
def spinner_task(self) -> None:
|
|
54
|
-
"""Task that runs the spinner."""
|
|
55
|
-
while self.busy:
|
|
56
|
-
self.write_next()
|
|
57
|
-
time.sleep(self.delay)
|
|
58
|
-
self.remove_spinner()
|
|
59
|
-
|
|
60
|
-
def __enter__(self) -> None:
|
|
61
|
-
"""Enter the context manager."""
|
|
62
|
-
if sys.stdout.isatty():
|
|
63
|
-
self._screen_lock = threading.Lock()
|
|
64
|
-
self.busy = True
|
|
65
|
-
self.thread = threading.Thread(target=self.spinner_task)
|
|
66
|
-
self.thread.start()
|
|
67
|
-
|
|
68
|
-
def __exit__(self, exception: object, value: object, tb: object) -> None:
|
|
69
|
-
"""Exit the context manager."""
|
|
70
|
-
if sys.stdout.isatty():
|
|
71
|
-
self.busy = False
|
|
72
|
-
self.remove_spinner(cleanup=True)
|
|
73
|
-
else:
|
|
74
|
-
sys.stdout.write("\r")
|
kodit/reporting.py
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"""Unified logging and progress-reporting helper.
|
|
2
|
-
|
|
3
|
-
This utility consolidates the repeated pattern where services:
|
|
4
|
-
1. Log a message (usually via structlog) and
|
|
5
|
-
2. Emit a ProgressEvent via a ProgressCallback.
|
|
6
|
-
|
|
7
|
-
Using Reporter removes boiler-plate and guarantees consistent telemetry.
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
import structlog
|
|
11
|
-
|
|
12
|
-
from kodit.domain.interfaces import NullProgressCallback, ProgressCallback
|
|
13
|
-
from kodit.domain.value_objects import ProgressEvent
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class Reporter:
|
|
17
|
-
"""Emit log and progress updates with a single call."""
|
|
18
|
-
|
|
19
|
-
def __init__(
|
|
20
|
-
self,
|
|
21
|
-
logger: structlog.BoundLogger | None = None,
|
|
22
|
-
progress: ProgressCallback | None = None,
|
|
23
|
-
) -> None:
|
|
24
|
-
"""Initialize the reporter."""
|
|
25
|
-
self.log: structlog.BoundLogger = logger or structlog.get_logger(__name__)
|
|
26
|
-
self.progress: ProgressCallback = progress or NullProgressCallback()
|
|
27
|
-
|
|
28
|
-
# ---------------------------------------------------------------------
|
|
29
|
-
# Life-cycle helpers
|
|
30
|
-
# ---------------------------------------------------------------------
|
|
31
|
-
async def start(
|
|
32
|
-
self, operation: str, total: int, message: str | None = None
|
|
33
|
-
) -> None:
|
|
34
|
-
"""Log *operation.start* and emit initial ProgressEvent."""
|
|
35
|
-
self.log.debug(
|
|
36
|
-
"operation.start", operation=operation, total=total, message=message
|
|
37
|
-
)
|
|
38
|
-
await self.progress.on_progress(
|
|
39
|
-
ProgressEvent(operation=operation, current=0, total=total, message=message)
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
async def step(
|
|
43
|
-
self,
|
|
44
|
-
operation: str,
|
|
45
|
-
current: int,
|
|
46
|
-
total: int,
|
|
47
|
-
message: str | None = None,
|
|
48
|
-
) -> None:
|
|
49
|
-
"""Emit an intermediate progress step (no log by default)."""
|
|
50
|
-
await self.progress.on_progress(
|
|
51
|
-
ProgressEvent(
|
|
52
|
-
operation=operation, current=current, total=total, message=message
|
|
53
|
-
)
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
async def done(self, operation: str, message: str | None = None) -> None:
|
|
57
|
-
"""Log *operation.done* and emit completion event."""
|
|
58
|
-
self.log.debug("operation.done", operation=operation, message=message)
|
|
59
|
-
await self.progress.on_complete(operation)
|
|
60
|
-
|
|
61
|
-
async def advance(
|
|
62
|
-
self,
|
|
63
|
-
operation: str,
|
|
64
|
-
current: int,
|
|
65
|
-
total: int,
|
|
66
|
-
message: str | None = None,
|
|
67
|
-
log_every: int | None = None,
|
|
68
|
-
) -> None:
|
|
69
|
-
"""Emit step; optionally log when *current % log_every == 0*."""
|
|
70
|
-
if log_every and current % log_every == 0:
|
|
71
|
-
self.log.debug(
|
|
72
|
-
"operation.progress",
|
|
73
|
-
operation=operation,
|
|
74
|
-
current=current,
|
|
75
|
-
total=total,
|
|
76
|
-
message=message,
|
|
77
|
-
)
|
|
78
|
-
await self.step(operation, current, total, message)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|