kodit 0.1.0__tar.gz → 0.1.2__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.
Potentially problematic release.
This version of kodit might be problematic. Click here for more details.
- {kodit-0.1.0 → kodit-0.1.2}/.github/workflows/pypi.yaml +10 -3
- kodit-0.1.2/.github/workflows/test.yaml +71 -0
- {kodit-0.1.0 → kodit-0.1.2}/.gitignore +2 -0
- kodit-0.1.2/.vscode/settings.json +28 -0
- {kodit-0.1.0 → kodit-0.1.2}/PKG-INFO +8 -1
- kodit-0.1.2/alembic.ini +119 -0
- kodit-0.1.2/docs/developer/index.md +17 -0
- {kodit-0.1.0 → kodit-0.1.2}/pyproject.toml +27 -1
- {kodit-0.1.0 → kodit-0.1.2}/src/kodit/_version.py +2 -2
- kodit-0.1.2/src/kodit/alembic/README +1 -0
- kodit-0.1.2/src/kodit/alembic/__init__.py +1 -0
- kodit-0.1.2/src/kodit/alembic/env.py +86 -0
- kodit-0.1.2/src/kodit/alembic/script.py.mako +30 -0
- kodit-0.1.2/src/kodit/alembic/versions/85155663351e_initial.py +82 -0
- kodit-0.1.2/src/kodit/alembic/versions/__init__.py +1 -0
- kodit-0.1.2/src/kodit/cli.py +188 -0
- kodit-0.1.2/src/kodit/config.py +5 -0
- kodit-0.1.2/src/kodit/database.py +87 -0
- kodit-0.1.2/src/kodit/indexing/__init__.py +1 -0
- kodit-0.1.2/src/kodit/indexing/models.py +43 -0
- kodit-0.1.2/src/kodit/indexing/repository.py +132 -0
- kodit-0.1.2/src/kodit/indexing/service.py +153 -0
- {kodit-0.1.0 → kodit-0.1.2}/src/kodit/logging.py +9 -0
- kodit-0.1.2/src/kodit/retreival/__init__.py +1 -0
- kodit-0.1.2/src/kodit/retreival/repository.py +76 -0
- kodit-0.1.2/src/kodit/retreival/service.py +30 -0
- kodit-0.1.2/src/kodit/sources/__init__.py +1 -0
- kodit-0.1.2/src/kodit/sources/models.py +71 -0
- kodit-0.1.2/src/kodit/sources/repository.py +110 -0
- kodit-0.1.2/src/kodit/sources/service.py +209 -0
- kodit-0.1.2/tests/__init__.py +1 -0
- kodit-0.1.2/tests/conftest.py +42 -0
- kodit-0.1.2/tests/kodit/__init__.py +1 -0
- kodit-0.1.2/tests/kodit/cli_test.py +19 -0
- kodit-0.1.2/tests/kodit/indexing/__init__.py +1 -0
- kodit-0.1.2/tests/kodit/indexing/test_service.py +145 -0
- kodit-0.1.2/tests/kodit/retreival/__init__.py +1 -0
- kodit-0.1.2/tests/kodit/retreival/test_service.py +85 -0
- kodit-0.1.2/tests/kodit/sources/__init__.py +1 -0
- kodit-0.1.2/tests/kodit/sources/test_service.py +110 -0
- kodit-0.1.2/tests/smoke.sh +20 -0
- {kodit-0.1.0 → kodit-0.1.2}/uv.lock +168 -0
- kodit-0.1.0/.github/workflows/test.yaml +0 -44
- kodit-0.1.0/.vscode/settings.json +0 -14
- kodit-0.1.0/src/kodit/cli.py +0 -66
- {kodit-0.1.0 → kodit-0.1.2}/.github/CODE_OF_CONDUCT.md +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/.github/CONTRIBUTING.md +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/.github/workflows/docker.yaml +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/.github/workflows/docs.yaml +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/.github/workflows/pypi-test.yaml +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/.python-version +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/Dockerfile +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/LICENSE +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/README.md +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/docs/_index.md +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/src/kodit/.gitignore +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/src/kodit/__init__.py +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/src/kodit/app.py +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/src/kodit/mcp.py +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/src/kodit/middleware.py +0 -0
- {kodit-0.1.0 → kodit-0.1.2}/src/kodit/sse.py +0 -0
- {kodit-0.1.0/src → kodit-0.1.2/tests}/kodit/mcp_test.py +0 -0
|
@@ -21,19 +21,26 @@ jobs:
|
|
|
21
21
|
name: Bump Homebrew formula
|
|
22
22
|
needs: pypi
|
|
23
23
|
runs-on: ubuntu-latest
|
|
24
|
+
environment:
|
|
25
|
+
name: pypi
|
|
24
26
|
permissions:
|
|
25
27
|
contents: read
|
|
26
28
|
steps:
|
|
29
|
+
- name: Wait for PyPI release to be available
|
|
30
|
+
run: |
|
|
31
|
+
while true; do
|
|
32
|
+
if curl -s https://pypi.io/packages/source/k/${{ github.event.repository.name }}/${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.tar.gz; then
|
|
33
|
+
break
|
|
34
|
+
fi
|
|
35
|
+
done
|
|
27
36
|
- uses: mislav/bump-homebrew-formula-action@v3
|
|
28
37
|
with:
|
|
29
38
|
formula-name: ${{ github.event.repository.name }}
|
|
30
39
|
formula-path: Formula/${{ github.event.repository.name }}.rb
|
|
31
40
|
homebrew-tap: ${{ github.repository_owner }}/homebrew-${{ github.event.repository.name }}
|
|
32
41
|
tag-name: "${{ github.event.release.tag_name }}"
|
|
33
|
-
push-to: ${{ github.repository_owner }}/homebrew-${{ github.event.repository.name }}
|
|
34
|
-
base-branch: "main"
|
|
35
42
|
download-url: "https://pypi.io/packages/source/k/${{ github.event.repository.name }}/${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.tar.gz"
|
|
36
43
|
commit-message: |
|
|
37
44
|
{{formulaName}} {{version}}
|
|
38
45
|
env:
|
|
39
|
-
COMMITTER_TOKEN: ${{ secrets.
|
|
46
|
+
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
push:
|
|
6
|
+
workflow_call:
|
|
7
|
+
|
|
8
|
+
# Set default permissions for all jobs
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read # Needed to check out code
|
|
11
|
+
checks: write # Needed to report test results
|
|
12
|
+
pull-requests: write # Needed to add comments/annotations to PRs
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
test:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout code
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
# Use the official Python action to set up Python because it is faster
|
|
22
|
+
- name: "Set up Python"
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version-file: ".python-version"
|
|
26
|
+
|
|
27
|
+
- name: Install uv
|
|
28
|
+
uses: astral-sh/setup-uv@v5
|
|
29
|
+
|
|
30
|
+
- name: Install the project
|
|
31
|
+
run: uv sync --locked --all-extras --dev
|
|
32
|
+
|
|
33
|
+
- name: Lint
|
|
34
|
+
run: uv run ruff check
|
|
35
|
+
|
|
36
|
+
- name: Run tests
|
|
37
|
+
run: uv run pytest -s --cov=src --cov-report=xml
|
|
38
|
+
|
|
39
|
+
- name: Pytest coverage comment
|
|
40
|
+
if: github.event_name == 'pull_request'
|
|
41
|
+
uses: MishaKav/pytest-coverage-comment@v1.1.54
|
|
42
|
+
with:
|
|
43
|
+
pytest-xml-coverage-path: ./coverage.xml
|
|
44
|
+
build-test:
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
steps:
|
|
47
|
+
- name: Checkout code
|
|
48
|
+
uses: actions/checkout@v4
|
|
49
|
+
|
|
50
|
+
# Use the official Python action to set up Python because it is faster
|
|
51
|
+
- name: "Set up Python"
|
|
52
|
+
uses: actions/setup-python@v5
|
|
53
|
+
with:
|
|
54
|
+
python-version-file: ".python-version"
|
|
55
|
+
|
|
56
|
+
- name: Install uv
|
|
57
|
+
uses: astral-sh/setup-uv@v5
|
|
58
|
+
|
|
59
|
+
- run: uv build --sdist --out-dir test-build
|
|
60
|
+
- run: uv tool run twine check test-build/*.tar.gz
|
|
61
|
+
- name: Find the path of the sdist
|
|
62
|
+
id: sdist-path
|
|
63
|
+
run: echo "::set-output name=path::$(ls test-build/*.tar.gz)"
|
|
64
|
+
- name: Install sdist
|
|
65
|
+
uses: threeal/pipx-install-action@v1.0.0
|
|
66
|
+
with:
|
|
67
|
+
packages: ${{ steps.sdist-path.outputs.path }}
|
|
68
|
+
- name: Run simple version command test
|
|
69
|
+
run: kodit version
|
|
70
|
+
- name: Run smoke test
|
|
71
|
+
run: ./tests/smoke.sh
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.formatOnSave": true,
|
|
3
|
+
"editor.codeActionsOnSave": {
|
|
4
|
+
"source.organizeImports": "explicit",
|
|
5
|
+
"source.fixAll": "explicit",
|
|
6
|
+
},
|
|
7
|
+
"ruff.enable": true,
|
|
8
|
+
"ruff.fixAll": true,
|
|
9
|
+
"ruff.lint.enable": true,
|
|
10
|
+
"rewrap.autoWrap.enabled": true,
|
|
11
|
+
"editor.wordWrap": "off",
|
|
12
|
+
"editor.wordWrapColumn": 88,
|
|
13
|
+
"python.testing.pytestEnabled": true,
|
|
14
|
+
"python.testing.unittestEnabled": false,
|
|
15
|
+
"python.testing.cwd": "",
|
|
16
|
+
"python.testing.pytestArgs": [
|
|
17
|
+
".",
|
|
18
|
+
"--cov=src",
|
|
19
|
+
"--cov-report=term-missing",
|
|
20
|
+
"--cov-report=html",
|
|
21
|
+
"--cov-report=xml"
|
|
22
|
+
],
|
|
23
|
+
"python.analysis.autoFormatStrings": true,
|
|
24
|
+
"python.analysis.autoImportCompletions": true,
|
|
25
|
+
"python.analysis.completeFunctionParens": true,
|
|
26
|
+
"python.analysis.inlayHints.functionReturnTypes": true,
|
|
27
|
+
"python.analysis.typeCheckingMode": "strict",
|
|
28
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kodit
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
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/
|
|
@@ -17,6 +17,9 @@ Classifier: Intended Audience :: Developers
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Classifier: Topic :: Software Development :: Code Generators
|
|
19
19
|
Requires-Python: >=3.12
|
|
20
|
+
Requires-Dist: aiofiles>=24.1.0
|
|
21
|
+
Requires-Dist: aiosqlite>=0.20.0
|
|
22
|
+
Requires-Dist: alembic>=1.15.2
|
|
20
23
|
Requires-Dist: asgi-correlation-id>=4.3.4
|
|
21
24
|
Requires-Dist: better-exceptions>=0.3.3
|
|
22
25
|
Requires-Dist: click>=8.1.8
|
|
@@ -27,7 +30,11 @@ Requires-Dist: httpx-retries>=0.3.2
|
|
|
27
30
|
Requires-Dist: httpx>=0.28.1
|
|
28
31
|
Requires-Dist: mcp>=1.6.0
|
|
29
32
|
Requires-Dist: posthog>=4.0.1
|
|
33
|
+
Requires-Dist: pytable-formatter>=0.1.1
|
|
34
|
+
Requires-Dist: sqlalchemy[asyncio]>=2.0.40
|
|
30
35
|
Requires-Dist: structlog>=25.3.0
|
|
36
|
+
Requires-Dist: tdqm>=0.0.1
|
|
37
|
+
Requires-Dist: uritools>=5.0.0
|
|
31
38
|
Description-Content-Type: text/markdown
|
|
32
39
|
|
|
33
40
|
# kodit
|
kodit-0.1.2/alembic.ini
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# A generic, single database configuration.
|
|
2
|
+
|
|
3
|
+
[alembic]
|
|
4
|
+
# path to migration scripts
|
|
5
|
+
# Use forward slashes (/) also on windows to provide an os agnostic path
|
|
6
|
+
script_location = src/kodit/alembic
|
|
7
|
+
|
|
8
|
+
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
|
|
9
|
+
# Uncomment the line below if you want the files to be prepended with date and time
|
|
10
|
+
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
|
|
11
|
+
# for all available tokens
|
|
12
|
+
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
|
|
13
|
+
|
|
14
|
+
# sys.path path, will be prepended to sys.path if present.
|
|
15
|
+
# defaults to the current working directory.
|
|
16
|
+
prepend_sys_path = .
|
|
17
|
+
|
|
18
|
+
# timezone to use when rendering the date within the migration file
|
|
19
|
+
# as well as the filename.
|
|
20
|
+
# If specified, requires the python>=3.9 or backports.zoneinfo library and tzdata library.
|
|
21
|
+
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
|
|
22
|
+
# string value is passed to ZoneInfo()
|
|
23
|
+
# leave blank for localtime
|
|
24
|
+
# timezone =
|
|
25
|
+
|
|
26
|
+
# max length of characters to apply to the "slug" field
|
|
27
|
+
# truncate_slug_length = 40
|
|
28
|
+
|
|
29
|
+
# set to 'true' to run the environment during
|
|
30
|
+
# the 'revision' command, regardless of autogenerate
|
|
31
|
+
# revision_environment = false
|
|
32
|
+
|
|
33
|
+
# set to 'true' to allow .pyc and .pyo files without
|
|
34
|
+
# a source .py file to be detected as revisions in the
|
|
35
|
+
# versions/ directory
|
|
36
|
+
# sourceless = false
|
|
37
|
+
|
|
38
|
+
# version location specification; This defaults
|
|
39
|
+
# to alembic/versions. When using multiple version
|
|
40
|
+
# directories, initial revisions must be specified with --version-path.
|
|
41
|
+
# The path separator used here should be the separator specified by "version_path_separator" below.
|
|
42
|
+
# version_locations = %(here)s/bar:%(here)s/bat:alembic/versions
|
|
43
|
+
|
|
44
|
+
# version path separator; As mentioned above, this is the character used to split
|
|
45
|
+
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
|
|
46
|
+
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
|
|
47
|
+
# Valid values for version_path_separator are:
|
|
48
|
+
#
|
|
49
|
+
# version_path_separator = :
|
|
50
|
+
# version_path_separator = ;
|
|
51
|
+
# version_path_separator = space
|
|
52
|
+
# version_path_separator = newline
|
|
53
|
+
#
|
|
54
|
+
# Use os.pathsep. Default configuration used for new projects.
|
|
55
|
+
version_path_separator = os
|
|
56
|
+
|
|
57
|
+
# set to 'true' to search source files recursively
|
|
58
|
+
# in each "version_locations" directory
|
|
59
|
+
# new in Alembic version 1.10
|
|
60
|
+
# recursive_version_locations = false
|
|
61
|
+
|
|
62
|
+
# the output encoding used when revision files
|
|
63
|
+
# are written from script.py.mako
|
|
64
|
+
# output_encoding = utf-8
|
|
65
|
+
|
|
66
|
+
sqlalchemy.url = sqlite+aiosqlite:///%(here)s/.kodit/kodit.db
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
[post_write_hooks]
|
|
70
|
+
# post_write_hooks defines scripts or Python functions that are run
|
|
71
|
+
# on newly generated revision scripts. See the documentation for further
|
|
72
|
+
# detail and examples
|
|
73
|
+
|
|
74
|
+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
|
|
75
|
+
# hooks = black
|
|
76
|
+
# black.type = console_scripts
|
|
77
|
+
# black.entrypoint = black
|
|
78
|
+
# black.options = -l 79 REVISION_SCRIPT_FILENAME
|
|
79
|
+
|
|
80
|
+
# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
|
|
81
|
+
# hooks = ruff
|
|
82
|
+
# ruff.type = exec
|
|
83
|
+
# ruff.executable = %(here)s/.venv/bin/ruff
|
|
84
|
+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
|
|
85
|
+
|
|
86
|
+
# Logging configuration
|
|
87
|
+
[loggers]
|
|
88
|
+
keys = root,sqlalchemy,alembic
|
|
89
|
+
|
|
90
|
+
[handlers]
|
|
91
|
+
keys = console
|
|
92
|
+
|
|
93
|
+
[formatters]
|
|
94
|
+
keys = generic
|
|
95
|
+
|
|
96
|
+
[logger_root]
|
|
97
|
+
level = WARNING
|
|
98
|
+
handlers = console
|
|
99
|
+
qualname =
|
|
100
|
+
|
|
101
|
+
[logger_sqlalchemy]
|
|
102
|
+
level = WARNING
|
|
103
|
+
handlers =
|
|
104
|
+
qualname = sqlalchemy.engine
|
|
105
|
+
|
|
106
|
+
[logger_alembic]
|
|
107
|
+
level = WARNING
|
|
108
|
+
handlers =
|
|
109
|
+
qualname = alembic
|
|
110
|
+
|
|
111
|
+
[handler_console]
|
|
112
|
+
class = StreamHandler
|
|
113
|
+
args = (sys.stderr,)
|
|
114
|
+
level = NOTSET
|
|
115
|
+
formatter = generic
|
|
116
|
+
|
|
117
|
+
[formatter_generic]
|
|
118
|
+
format = %(levelname)-5.5s [%(name)s] %(message)s
|
|
119
|
+
datefmt = %H:%M:%S
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Kodit Developer Documentation"
|
|
3
|
+
linkTitle: Developer Docs
|
|
4
|
+
# next: /helix/getting-started
|
|
5
|
+
weight: 99
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Database
|
|
9
|
+
|
|
10
|
+
All database operations are handled by SQLAlchemy and Alembic.
|
|
11
|
+
|
|
12
|
+
### Creating a Database Migration
|
|
13
|
+
|
|
14
|
+
1. Make changes to your models
|
|
15
|
+
2. Ensure the model is referenced in [alembic's env.py](src/kodit/alembic/env.py)
|
|
16
|
+
3. Run `alembic revision --autogenerate -m "your message"`
|
|
17
|
+
4. The new migration will be applied when you next run a kodit command
|
|
@@ -32,6 +32,13 @@ dependencies = [
|
|
|
32
32
|
"mcp>=1.6.0",
|
|
33
33
|
"structlog>=25.3.0",
|
|
34
34
|
"posthog>=4.0.1",
|
|
35
|
+
"sqlalchemy[asyncio]>=2.0.40",
|
|
36
|
+
"alembic>=1.15.2",
|
|
37
|
+
"aiosqlite>=0.20.0",
|
|
38
|
+
"pytable-formatter>=0.1.1",
|
|
39
|
+
"aiofiles>=24.1.0",
|
|
40
|
+
"tdqm>=0.0.1",
|
|
41
|
+
"uritools>=5.0.0",
|
|
35
42
|
]
|
|
36
43
|
|
|
37
44
|
[dependency-groups]
|
|
@@ -68,12 +75,14 @@ source = "vcs"
|
|
|
68
75
|
version-file = "src/kodit/_version.py"
|
|
69
76
|
|
|
70
77
|
[tool.pytest.ini_options]
|
|
78
|
+
pythonpath = ["."]
|
|
71
79
|
norecursedirs = ".git"
|
|
72
80
|
asyncio_mode = "auto"
|
|
73
81
|
asyncio_default_fixture_loop_scope = "function"
|
|
74
82
|
filterwarnings = [
|
|
75
83
|
"ignore:.*websockets.*:DeprecationWarning",
|
|
76
84
|
]
|
|
85
|
+
addopts = ["--cov=src", "--cov-report=term-missing", "--cov-report=html", "--cov-report=xml"]
|
|
77
86
|
|
|
78
87
|
[tool.coverage.run]
|
|
79
88
|
source = ["src"]
|
|
@@ -92,6 +101,7 @@ ignore = [
|
|
|
92
101
|
"PLR2004", # Just annoying, not really useful
|
|
93
102
|
"TRY003", # Long exception messages in custom exception classes
|
|
94
103
|
"S101", # Allow assert statements in test files
|
|
104
|
+
"PGH004", # If I've disabled all, I mean disable all
|
|
95
105
|
]
|
|
96
106
|
select = ["ALL"]
|
|
97
107
|
exclude = []
|
|
@@ -107,4 +117,20 @@ url = "https://test.pypi.org/simple/"
|
|
|
107
117
|
publish-url = "https://test.pypi.org/legacy/"
|
|
108
118
|
|
|
109
119
|
[tool.uv]
|
|
110
|
-
package = true
|
|
120
|
+
package = true
|
|
121
|
+
|
|
122
|
+
[tool.mypy]
|
|
123
|
+
plugins = ["sqlalchemy.ext.mypy.plugin"]
|
|
124
|
+
warn_return_any = true
|
|
125
|
+
warn_unused_configs = true
|
|
126
|
+
disallow_untyped_defs = true
|
|
127
|
+
disallow_incomplete_defs = true
|
|
128
|
+
check_untyped_defs = true
|
|
129
|
+
disallow_untyped_decorators = true
|
|
130
|
+
no_implicit_optional = true
|
|
131
|
+
warn_redundant_casts = true
|
|
132
|
+
warn_unused_ignores = true
|
|
133
|
+
warn_no_return = true
|
|
134
|
+
warn_unreachable = true
|
|
135
|
+
strict_optional = true
|
|
136
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Generic single-database configuration with an async dbapi.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Database configuration for kodit."""
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# ruff: noqa: F401
|
|
2
|
+
"""Alembic environment file for kodit."""
|
|
3
|
+
|
|
4
|
+
import asyncio
|
|
5
|
+
|
|
6
|
+
import structlog
|
|
7
|
+
from alembic import context
|
|
8
|
+
from sqlalchemy import pool
|
|
9
|
+
from sqlalchemy.engine import Connection
|
|
10
|
+
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
11
|
+
|
|
12
|
+
import kodit.indexing.models
|
|
13
|
+
import kodit.sources.models
|
|
14
|
+
from kodit.database import Base
|
|
15
|
+
|
|
16
|
+
# this is the Alembic Config object, which provides
|
|
17
|
+
# access to the values within the .ini file in use.
|
|
18
|
+
config = context.config
|
|
19
|
+
|
|
20
|
+
# Interpret the config file for Python logging.
|
|
21
|
+
# This line sets up loggers basically.
|
|
22
|
+
# We skip this to preserve the existing logging configuration
|
|
23
|
+
# if config.config_file_name is not None:
|
|
24
|
+
|
|
25
|
+
# add your model's MetaData object here
|
|
26
|
+
# for 'autogenerate' support
|
|
27
|
+
target_metadata = Base.metadata
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def run_migrations_offline() -> None:
|
|
31
|
+
"""Run migrations in 'offline' mode.
|
|
32
|
+
|
|
33
|
+
This configures the context with just a URL
|
|
34
|
+
and not an Engine, though an Engine is acceptable
|
|
35
|
+
here as well. By skipping the Engine creation
|
|
36
|
+
we don't even need a DBAPI to be available.
|
|
37
|
+
|
|
38
|
+
Calls to context.execute() here emit the given string to the
|
|
39
|
+
script output.
|
|
40
|
+
|
|
41
|
+
"""
|
|
42
|
+
url = config.get_main_option("sqlalchemy.url")
|
|
43
|
+
context.configure(
|
|
44
|
+
url=url,
|
|
45
|
+
target_metadata=target_metadata,
|
|
46
|
+
literal_binds=True,
|
|
47
|
+
dialect_opts={"paramstyle": "named"},
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
with context.begin_transaction():
|
|
51
|
+
context.run_migrations()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def do_run_migrations(connection: Connection) -> None:
|
|
55
|
+
"""Run migrations in 'online' mode."""
|
|
56
|
+
context.configure(connection=connection, target_metadata=target_metadata)
|
|
57
|
+
|
|
58
|
+
with context.begin_transaction():
|
|
59
|
+
context.run_migrations()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
async def run_async_migrations() -> None:
|
|
63
|
+
"""Run migrations in 'async' mode."""
|
|
64
|
+
connectable = async_engine_from_config(
|
|
65
|
+
config.get_section(config.config_ini_section, {}),
|
|
66
|
+
prefix="sqlalchemy.",
|
|
67
|
+
poolclass=pool.NullPool,
|
|
68
|
+
)
|
|
69
|
+
log = structlog.get_logger(__name__)
|
|
70
|
+
log.debug("Running migrations on %s", connectable.url)
|
|
71
|
+
|
|
72
|
+
async with connectable.connect() as connection:
|
|
73
|
+
await connection.run_sync(do_run_migrations)
|
|
74
|
+
|
|
75
|
+
await connectable.dispose()
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def run_migrations_online() -> None:
|
|
79
|
+
"""Run migrations in 'online' mode."""
|
|
80
|
+
asyncio.run(run_async_migrations())
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if context.is_offline_mode():
|
|
84
|
+
run_migrations_offline()
|
|
85
|
+
else:
|
|
86
|
+
run_migrations_online()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# ruff: noqa
|
|
2
|
+
"""${message}
|
|
3
|
+
|
|
4
|
+
Revision ID: ${up_revision}
|
|
5
|
+
Revises: ${down_revision | comma,n}
|
|
6
|
+
Create Date: ${create_date}
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from typing import Sequence, Union
|
|
11
|
+
|
|
12
|
+
from alembic import op
|
|
13
|
+
import sqlalchemy as sa
|
|
14
|
+
${imports if imports else ""}
|
|
15
|
+
|
|
16
|
+
# revision identifiers, used by Alembic.
|
|
17
|
+
revision: str = ${repr(up_revision)}
|
|
18
|
+
down_revision: Union[str, None] = ${repr(down_revision)}
|
|
19
|
+
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
|
20
|
+
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def upgrade() -> None:
|
|
24
|
+
"""Upgrade schema."""
|
|
25
|
+
${upgrades if upgrades else "pass"}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def downgrade() -> None:
|
|
29
|
+
"""Downgrade schema."""
|
|
30
|
+
${downgrades if downgrades else "pass"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# ruff: noqa
|
|
2
|
+
"""initial
|
|
3
|
+
|
|
4
|
+
Revision ID: 85155663351e
|
|
5
|
+
Revises:
|
|
6
|
+
Create Date: 2025-05-08 13:45:16.687162
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from typing import Sequence, Union
|
|
11
|
+
|
|
12
|
+
from alembic import op
|
|
13
|
+
import sqlalchemy as sa
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# revision identifiers, used by Alembic.
|
|
17
|
+
revision: str = '85155663351e'
|
|
18
|
+
down_revision: Union[str, None] = None
|
|
19
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
20
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def upgrade() -> None:
|
|
24
|
+
"""Upgrade schema."""
|
|
25
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
|
26
|
+
op.create_table('sources',
|
|
27
|
+
sa.Column('uri', sa.String(length=1024), nullable=False),
|
|
28
|
+
sa.Column('cloned_path', sa.String(length=1024), nullable=False),
|
|
29
|
+
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
30
|
+
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
31
|
+
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
|
32
|
+
sa.PrimaryKeyConstraint('id')
|
|
33
|
+
)
|
|
34
|
+
op.create_index(op.f('ix_sources_uri'), 'sources', ['uri'], unique=True)
|
|
35
|
+
op.create_table('files',
|
|
36
|
+
sa.Column('source_id', sa.Integer(), nullable=False),
|
|
37
|
+
sa.Column('mime_type', sa.String(length=255), nullable=False),
|
|
38
|
+
sa.Column('uri', sa.String(length=1024), nullable=False),
|
|
39
|
+
sa.Column('cloned_path', sa.String(length=1024), nullable=False),
|
|
40
|
+
sa.Column('sha256', sa.String(length=64), nullable=False),
|
|
41
|
+
sa.Column('size_bytes', sa.Integer(), nullable=False),
|
|
42
|
+
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
43
|
+
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
44
|
+
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
|
45
|
+
sa.ForeignKeyConstraint(['source_id'], ['sources.id'], ),
|
|
46
|
+
sa.PrimaryKeyConstraint('id')
|
|
47
|
+
)
|
|
48
|
+
op.create_index(op.f('ix_files_sha256'), 'files', ['sha256'], unique=False)
|
|
49
|
+
op.create_table('indexes',
|
|
50
|
+
sa.Column('source_id', sa.Integer(), nullable=False),
|
|
51
|
+
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
52
|
+
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
53
|
+
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
|
54
|
+
sa.ForeignKeyConstraint(['source_id'], ['sources.id'], ),
|
|
55
|
+
sa.PrimaryKeyConstraint('id')
|
|
56
|
+
)
|
|
57
|
+
op.create_index(op.f('ix_indexes_source_id'), 'indexes', ['source_id'], unique=True)
|
|
58
|
+
op.create_table('snippets',
|
|
59
|
+
sa.Column('file_id', sa.Integer(), nullable=False),
|
|
60
|
+
sa.Column('index_id', sa.Integer(), nullable=False),
|
|
61
|
+
sa.Column('content', sa.UnicodeText(), nullable=False),
|
|
62
|
+
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
63
|
+
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
64
|
+
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
|
65
|
+
sa.ForeignKeyConstraint(['file_id'], ['files.id'], ),
|
|
66
|
+
sa.ForeignKeyConstraint(['index_id'], ['indexes.id'], ),
|
|
67
|
+
sa.PrimaryKeyConstraint('id')
|
|
68
|
+
)
|
|
69
|
+
# ### end Alembic commands ###
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def downgrade() -> None:
|
|
73
|
+
"""Downgrade schema."""
|
|
74
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
|
75
|
+
op.drop_table('snippets')
|
|
76
|
+
op.drop_index(op.f('ix_indexes_source_id'), table_name='indexes')
|
|
77
|
+
op.drop_table('indexes')
|
|
78
|
+
op.drop_index(op.f('ix_files_sha256'), table_name='files')
|
|
79
|
+
op.drop_table('files')
|
|
80
|
+
op.drop_index(op.f('ix_sources_uri'), table_name='sources')
|
|
81
|
+
op.drop_table('sources')
|
|
82
|
+
# ### end Alembic commands ###
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Alembic migrations for kodit."""
|