Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
cdba77c
WIP(cli): database abstraction layer
Davidyz Sep 1, 2025
dac5f75
WIP(cli): Add wip chromadb connector
Davidyz Sep 1, 2025
8bda33f
feat(db): Improve database abstraction and vectorisation process
Davidyz Sep 4, 2025
6f42c52
feat(db): Implement delete and drop methods for database connectors
Davidyz Sep 5, 2025
9028981
refactor(cli): `drop` now use the DB adapter layer.
Davidyz Sep 5, 2025
416d7c8
fix(cli): default db_url for chroma0
Davidyz Sep 5, 2025
8cb0e2d
fix(cli): minor fixes.
Davidyz Sep 5, 2025
1f457f7
feat(cli): implement database builder with lazy import
Davidyz Sep 5, 2025
40b6d97
refactor(cli): `ls` in CLI mode now use the DB adapter layer.
Davidyz Sep 5, 2025
129ebd4
docs about database connectors.
Davidyz Sep 7, 2025
fdc6e27
feat(cli): support excluding files in queries.
Davidyz Sep 7, 2025
984cf15
fix query filter
Davidyz Sep 11, 2025
b082fa6
feat(db): Implement config update and replace methods for database co…
Davidyz Sep 12, 2025
9494a76
remove some parameters.
Davidyz Sep 12, 2025
6263c1b
update `chroma0` connector to adopt the new API definition.
Davidyz Sep 12, 2025
fd3dd3c
fix(cli): fix default value of `excluded_files`
Davidyz Sep 12, 2025
79e540e
fix(cli): improve assertions for `metadatas`, `documents` and `ids`
Davidyz Sep 12, 2025
1bea28a
refactor(cli): Use DB adapter layer for `ls` and `rm` commands
Davidyz Sep 12, 2025
4dd184e
docs(db): Improve docstrings for database connectors
Davidyz Sep 13, 2025
b5e3d79
docs(db): Add documentation for database connectors
Davidyz Sep 13, 2025
a34d84e
feat(db): Implement orphan removal functionality in the database conn…
Davidyz Sep 13, 2025
5f8b65f
feat(db): Refactor database connectors to use embeddings and improve …
Davidyz Sep 13, 2025
b578328
refactor(db): Implement `get_chunks` method in the database connectors
Davidyz Sep 13, 2025
a5546ee
wip(db): port `vectorise` command to the new db layer
Davidyz Sep 13, 2025
46b52c0
fix(db): Refactor `list_collection_content` to accept keyword arguments
Davidyz Sep 13, 2025
29f53d3
feat(cli): Refactor vectorise command to use DB adapter layer
Davidyz Sep 14, 2025
35db49f
feat(cli): Refactor `update` command to use DB adapter layer
Davidyz Sep 14, 2025
dcf8309
refactor(cli): Refactor query command to use DB adapter layer
Davidyz Sep 14, 2025
3f7b591
feat(db): Enforce Chroma v0 client version
Davidyz Sep 14, 2025
beb1d8b
feat(deps): Update chromadb dependency to latest and add `chromadb==0…
Davidyz Sep 14, 2025
c3ec51f
fix(cli): Fix query command by removing deprecated code and chunking …
Davidyz Sep 14, 2025
92cdc9d
refactor(cli): Refactor mcp_main to use DB adapter layer
Davidyz Sep 14, 2025
265a213
refactor(cli): Refactor query command to use `preprocess_query_keywor…
Davidyz Sep 15, 2025
5e3a0cc
fix(cli): Remove all references to chromadb-related APIs.
Davidyz Sep 15, 2025
80a8893
fix(chroma0): fix import origin for `get_uuid`
Davidyz Sep 15, 2025
7facf78
refactor(lsp): Refactor LSP server to use DB adapter layer
Davidyz Sep 15, 2025
7281c45
refactor(cli): Refactor `clean` command to use DB adapter layer
Davidyz Sep 15, 2025
236d57f
refactor(cli)!: remove `common.py`
Davidyz Sep 15, 2025
f064fa3
docs(database): Clarify terminology in database README
Davidyz Sep 15, 2025
07d8c53
feat(chroma0): add graceful shutdown for bundled chroma server
Davidyz Sep 16, 2025
5fdb3d1
test(chroma0): Add unittests.
Davidyz Sep 16, 2025
aed9e6d
remove unnecessary test
Davidyz Sep 16, 2025
bce3e28
tests(mcp): fix tests.
Davidyz Sep 16, 2025
a335964
fix(mcp): Improve error handling and test coverage
Davidyz Sep 17, 2025
8c29871
fix(lsp): use correct file lists
Davidyz Sep 17, 2025
3478ac7
tests(chroma0): make sure database is mocked.
Davidyz Sep 17, 2025
61628eb
fix(lsp): remove collection-related code and improved test coverage.
Davidyz Sep 18, 2025
3949592
tests(cli): Improve test coverage for `ls` subcommand and handle `Col…
Davidyz Sep 19, 2025
301525b
tests(cli): refactor tests and coverage for `files rm`
Davidyz Sep 19, 2025
341fc24
tests(cli): Refactor query subcommand and add tests
Davidyz Sep 19, 2025
03432d4
fix(lsp): Validate include parameters in query command
Davidyz Sep 19, 2025
7b9a633
tests(cli): Refactor drop subcommand and add exception handling
Davidyz Sep 19, 2025
333d663
feat(cli): Improve test coverage for `vectorise`
Davidyz Sep 19, 2025
c46118e
tests(cli): Improve test coverage and refactor update subcommand
Davidyz Sep 19, 2025
b6d23d5
tests(cli): Refactor tests and improve coverage for `main`
Davidyz Sep 19, 2025
e3518bf
tests: Refactor database types and improve test coverage
Davidyz Sep 19, 2025
a6a2d72
tests(cli): Refactor config and cleanup path handling
Davidyz Sep 19, 2025
c7e27d6
chore(cli): mark some code as nocover
Davidyz Sep 19, 2025
2ef9349
pin to chroma 0.6.3 for now.
Davidyz Sep 19, 2025
7edec0c
fix: use `os.path.samefile` for accurate directory comparison
Davidyz Sep 19, 2025
108b195
fix error message
Davidyz Sep 19, 2025
c15051f
docs(database): Document the database connector API
Davidyz Sep 20, 2025
778d84e
tests(chroma0): Add more tests to chroma0
Davidyz Sep 20, 2025
b05701b
tests(cli): Improve test coverage for SpecResolver
Davidyz Sep 20, 2025
e64d297
tests: Add tests for database types
Davidyz Sep 20, 2025
5894d7a
tests(chroma0): improve test coverages.
Davidyz Sep 20, 2025
734e330
docs(database): update database configuration documentation
Davidyz Sep 20, 2025
3abc848
Auto generate docs
Davidyz Sep 20, 2025
3c4f759
docs(database): Document helper methods and error handling in the dat…
Davidyz Sep 21, 2025
35c554f
docs: Document database configuration and connector development
Davidyz Sep 21, 2025
ff775cb
Auto generate docs
Davidyz Sep 21, 2025
4aa138d
docs: clarify default chroma version
Davidyz Sep 22, 2025
424ccb4
Auto generate docs
Davidyz Sep 22, 2025
1df845e
feat(cli): Report skipped files in vectorise stats
Davidyz Sep 25, 2025
34421db
build(cli): add `chroma0` dep group.
Davidyz Oct 3, 2025
7baa033
Auto generate docs
Davidyz Oct 3, 2025
11aecc4
chore(cli): Use chroma0 for CI in test workflow
Davidyz Oct 3, 2025
4f12fd5
chore(cli): Document how to install extra dependencies
Davidyz Oct 3, 2025
dc44ba9
docs(cli): reflect packaging changes.
Davidyz Oct 3, 2025
d064d99
Auto generate docs
Davidyz Oct 3, 2025
dad1eb9
tests(db): Add database connector initialization test
Davidyz Oct 3, 2025
78495a9
tests(db): skip tests when dependency's not met
Davidyz Oct 4, 2025
1684d14
chore: extra coverage args via env var.
Davidyz Oct 4, 2025
5c13bea
feat(db): Check ChromaDB version on startup
Davidyz Oct 4, 2025
ff1c3da
refactor(cli): remove obsolete opts
Davidyz Oct 5, 2025
d84fa81
fix(cli): Fixes db_url config retrieval
Davidyz Oct 5, 2025
db10d56
refactor(chroma0): extract some stuff that can be reused by chromadb …
Davidyz Oct 5, 2025
6a20a0e
fix(db): Upgrade chromadb version check and include enums
Davidyz Oct 5, 2025
5ea7d74
feat(chroma): a WIP chromadb connector for chroma 1.x
Davidyz Oct 5, 2025
19db7dd
feat(chroma0): Raise CollectionNotFoundError on missing collection
Davidyz Oct 6, 2025
f3dfdae
feat(db): Implemented all methods in the ChromaDB 1.x connector
Davidyz Oct 6, 2025
be217d6
coverage(cli): Remove static analysis and improve coverage pipeline
Davidyz Oct 6, 2025
29cb6aa
feat(db): Add inter-process and inter-thread locks for ChromaDB conne…
Davidyz Oct 8, 2025
9021967
feat(cli): Refactor lock manager and implement inter-thread locks for…
Davidyz Oct 10, 2025
c59136b
ci(cli): Run coverage via shell script and enable coredumpy
Davidyz Oct 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/test_and_cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: pdm config use_uv true

- name: install pdm and dependencies
run: make deps
run: EXTRA_LOCK_ARGS="--group chroma0" make deps

- name: Set custom HF cache directory
run: |
Expand All @@ -47,18 +47,12 @@ jobs:
mkdir -p "$HF_HOME"
[ -z "$(ls "$HF_HOME")" ] || rm "${HF_HOME:?}/*" -rf && true

- name: run tests
run: pdm run pytest --enable-coredumpy --coredumpy-dir ${{ env.COREDUMPY_DUMP_DIR }}

- name: run coverage
run: |
pdm run coverage run -m pytest
sh ./scripts/coverage.sh
pdm run coverage report -m
pdm run coverage xml -i

- name: static analysis by basedpyright
run: pdm run basedpyright

- name: upload coverage reports to codecov
uses: codecov/codecov-action@v5
with:
Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
.PHONY: multitest
EXTRA_LOCK_ARGS?=
EXTRA_DEPS?=
EXTRA_COVERAGEPY_ARGS?=

LOADED_DOT_ENV=@if [ -f .env ] ; then source .env; fi;

DEFAULT_GROUPS=--group dev --group lsp --group mcp --group debug
DEFAULT_GROUPS=--group dev --group lsp --group mcp --group debug $(EXTRA_LOCK_ARGS)

.PHONY: multitest

deps:
pdm lock $(DEFAULT_GROUPS) || pdm lock $(DEFAULT_GROUPS) --group legacy; \
pdm install
[ -z "$(EXTRA_DEPS)" ] || (pdm run python -m ensurepip && pdm run python -m pip install $(EXTRA_DEPS))

test:
make deps; \
Expand All @@ -18,7 +25,7 @@ multitest:

coverage:
make deps; \
pdm run coverage run -m pytest; \
pdm run coverage run $(EXTRA_COVERAGEPY_ARGS) -m pytest --enable-coredumpy --coredumpy-dir dumps; \
pdm run coverage html; \
pdm run coverage report -m

Expand Down
69 changes: 35 additions & 34 deletions doc/VectorCode-API.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ This function queries VectorCode and returns an array of results.
})
<

- `query_message`string or a list of strings, the query messages;
- `opts`The following are the available options for this function (see |VectorCode-API-`setup(opts?)`| for details):
- `query_message`: string or a list of strings, the query messages;
- `opts`: The following are the available options for this function (see |VectorCode-API-`setup(opts?)`| for details):

>lua
{
Expand All @@ -71,7 +71,7 @@ This function queries VectorCode and returns an array of results.
}
<

- `callback`a callback function that takes the result of the retrieval as the
- `callback`: a callback function that takes the result of the retrieval as the
only parameter. If this is set, the `query` function will be non-blocking and
runs in an async manner. In this case, it doesn’t return any value and
retrieval results can only be accessed by this callback function.
Expand Down Expand Up @@ -118,7 +118,7 @@ project. See the CLI manual for details <./cli.md>.
require("vectorcode").check()
<

The following are the available options for this function: - `check_item`Only
The following are the available options for this function: - `check_item`: Only
supports `"config"` at the moment. Checks if a project-local config is present.
Return value: `true` if passed, `false` if failed.

Expand Down Expand Up @@ -201,25 +201,25 @@ This function registers a buffer to be cached by VectorCode.
})
<

The following are the available options for this function: - `bufnr`buffer
number. Default: `0` (current buffer); - `opts`accepts a lua table with the
following keys: - `project_root`a string of the path that overrides the
The following are the available options for this function: - `bufnr`: buffer
number. Default: `0` (current buffer); - `opts`: accepts a lua table with the
following keys: - `project_root`: a string of the path that overrides the
detected project root. Default: `nil`. This is mostly intended to use with the
|VectorCode-API-user-command|, and you probably should not use this directly in
your config. **If you’re using the LSP backend and did not specify this
value, it will be automatically detected based on .vectorcode or .git. If this
fails, LSP backend will not work**; - `exclude_this`whether to exclude the file
you’re editing. Default: `true`; - `n_query`number of retrieved documents.
Default: `1`; - `debounce`debounce time in milliseconds. Default: `10`; -
`notify`whether to show notifications when a query is completed. Default:
`false`; - `query_cb``fun(bufnr: integer):string|string[]`, a callback function
that accepts the buffer ID and returns the query message(s). Default:
`require("vectorcode.utils").make_surrounding_lines_cb(-1)`. See
fails, LSP backend will not work**; - `exclude_this`: whether to exclude the
file you’re editing. Default: `true`; - `n_query`: number of retrieved
documents. Default: `1`; - `debounce`: debounce time in milliseconds. Default:
`10`; - `notify`: whether to show notifications when a query is completed.
Default: `false`; - `query_cb`: `fun(bufnr: integer):string|string[]`, a
callback function that accepts the buffer ID and returns the query message(s).
Default: `require("vectorcode.utils").make_surrounding_lines_cb(-1)`. See
|VectorCode-API-this-section| for a list of built-in query callbacks; -
`events`list of autocommand events that triggers the query. Default:
`{"BufWritePost", "InsertEnter", "BufReadPost"}`; - `run_on_register`whether to
run the query when the buffer is registered. Default: `false`; -
`single_job`boolean. If this is set to `true`, there will only be one running
`events`: list of autocommand events that triggers the query. Default:
`{"BufWritePost", "InsertEnter", "BufReadPost"}`; - `run_on_register`: whether
to run the query when the buffer is registered. Default: `false`; -
`single_job`: boolean. If this is set to `true`, there will only be one running
job for each buffer, and when a new job is triggered, the last-running job will
be cancelled. Default: `false`.

Expand All @@ -232,10 +232,10 @@ This function queries VectorCode from cache.
local query_results = cacher_backend.query_from_cache(0, {notify=false})
<

The following are the available options for this function: - `bufnr`buffer
number. Default: current buffer; - `opts`accepts a lua table with the following
keys: - `notify`boolean, whether to show notifications when a query is
completed. Default: `false`;
The following are the available options for this function: - `bufnr`: buffer
number. Default: current buffer; - `opts`: accepts a lua table with the
following keys: - `notify`: boolean, whether to show notifications when a query
is completed. Default: `false`;

Return value: an array of results. Each item of the array is in the format of
`{path="path/to/your/code.lua", document="document content"}`.
Expand All @@ -254,17 +254,18 @@ project.
)
<

The following are the available options for this function: - `check_item`any
The following are the available options for this function: - `check_item`: any
check that works with `vectorcode check` command. If not set, it defaults to
`"config"`; - `on_success`a callback function that is called when the check
passes; - `on_failure`a callback function that is called when the check fails.
`"config"`; - `on_success`: a callback function that is called when the check
passes; - `on_failure`: a callback function that is called when the check
fails.


CACHER_BACKEND.BUF_IS_REGISTERED(BUFNR?) ~

This function checks if a buffer has been registered with VectorCode.

The following are the available options for this function: - `bufnr`buffer
The following are the available options for this function: - `bufnr`: buffer
number. Default: current buffer. Return value: `true` if registered, `false`
otherwise.

Expand All @@ -276,7 +277,7 @@ slightly different from `buf_is_registered`, because it does not guarantee
VectorCode is actively caching the content of the buffer. It is the same as
`buf_is_registered && not is_paused`.

The following are the available options for this function: - `bufnr`buffer
The following are the available options for this function: - `bufnr`: buffer
number. Default: current buffer. Return value: `true` if enabled, `false`
otherwise.

Expand All @@ -288,8 +289,8 @@ Returns the number of running jobs in the background.

CACHER_BACKEND.MAKE_PROMPT_COMPONENT(BUFNR?, COMPONENT_CB?) ~

Compile the retrieval results into a string. Parameters: - `bufnr`buffer
number. Default: current buffer; - `component_cb`a callback function that
Compile the retrieval results into a string. Parameters: - `bufnr`: buffer
number. Default: current buffer; - `component_cb`: a callback function that
formats each retrieval result, so that you can customise the control token,
etc. for the component. The default is the following:

Expand All @@ -299,8 +300,8 @@ etc. for the component. The default is the following:
end
<

`make_prompt_component` returns a table with 2 keys: - `count`number of
retrieved documents; - `content`The retrieval results concatenated together
`make_prompt_component` returns a table with 2 keys: - `count`: number of
retrieved documents; - `content`: The retrieval results concatenated together
into a string. Each result is formatted by `component_cb`.


Expand All @@ -311,15 +312,15 @@ takes the buffer ID as the only parameter, and return a string or a list of
strings. The `vectorcode.utils` module provides the following callback
constructor for you to play around with it, but you can easily build your own!

- `require("vectorcode.utils").make_surrounding_lines_cb(line_count)`returns a
- `require("vectorcode.utils").make_surrounding_lines_cb(line_count)`: returns a
callback that uses `line_count` lines around the cursor as the query. When
`line_count` is negative, it uses the full buffer;
- `require("vectorcode.utils").make_lsp_document_symbol_cb()`returns a
- `require("vectorcode.utils").make_lsp_document_symbol_cb()`: returns a
callback which uses the `textDocument/documentSymbol` method to retrieve a
list of symbols in the current document. This will fallback to
`make_surrounding_lines_cb(-1)` when there’s no LSP that supports the
`documentSymbol` method;
- `require("vectorcode.utils").make_changes_cb(max_num)`returns a callback
- `require("vectorcode.utils").make_changes_cb(max_num)`: returns a callback
that fetches `max_num` unique items from the `:changes` list. This will also
fallback to `make_surrounding_lines_cb(-1)`. The default value for `max_num`
is 50.
Expand Down
Loading
Loading