filesonar 0.1.0__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.
- filesonar-0.1.0/.github/workflows/ci.yml +32 -0
- filesonar-0.1.0/.github/workflows/release.yml +55 -0
- filesonar-0.1.0/.gitignore +10 -0
- filesonar-0.1.0/CHANGELOG.md +53 -0
- filesonar-0.1.0/CONTRIBUTING.md +71 -0
- filesonar-0.1.0/LICENSE +21 -0
- filesonar-0.1.0/PKG-INFO +326 -0
- filesonar-0.1.0/PRIVACY.md +55 -0
- filesonar-0.1.0/README.md +290 -0
- filesonar-0.1.0/SECURITY.md +44 -0
- filesonar-0.1.0/pyproject.toml +67 -0
- filesonar-0.1.0/scripts/eval_search.py +167 -0
- filesonar-0.1.0/src/filesonar/__init__.py +3 -0
- filesonar-0.1.0/src/filesonar/chunking.py +43 -0
- filesonar-0.1.0/src/filesonar/cli.py +459 -0
- filesonar-0.1.0/src/filesonar/config.py +471 -0
- filesonar-0.1.0/src/filesonar/db.py +412 -0
- filesonar-0.1.0/src/filesonar/drive.py +535 -0
- filesonar-0.1.0/src/filesonar/drive_index.py +391 -0
- filesonar-0.1.0/src/filesonar/extract.py +351 -0
- filesonar-0.1.0/src/filesonar/indexer.py +427 -0
- filesonar-0.1.0/src/filesonar/models.py +257 -0
- filesonar-0.1.0/src/filesonar/outbox.py +111 -0
- filesonar-0.1.0/src/filesonar/pathrules.py +68 -0
- filesonar-0.1.0/src/filesonar/search.py +262 -0
- filesonar-0.1.0/src/filesonar/server.py +360 -0
- filesonar-0.1.0/src/filesonar/skill/SKILL.md +77 -0
- filesonar-0.1.0/src/filesonar/watcher.py +104 -0
- filesonar-0.1.0/src/filesonar/wizard.py +520 -0
- filesonar-0.1.0/tests/conftest.py +149 -0
- filesonar-0.1.0/tests/fakedrive.py +236 -0
- filesonar-0.1.0/tests/samples.py +98 -0
- filesonar-0.1.0/tests/test_cli_watcher.py +137 -0
- filesonar-0.1.0/tests/test_config.py +119 -0
- filesonar-0.1.0/tests/test_drive.py +669 -0
- filesonar-0.1.0/tests/test_extract.py +284 -0
- filesonar-0.1.0/tests/test_indexer.py +371 -0
- filesonar-0.1.0/tests/test_integration.py +138 -0
- filesonar-0.1.0/tests/test_models.py +207 -0
- filesonar-0.1.0/tests/test_outbox.py +118 -0
- filesonar-0.1.0/tests/test_pathrules_chunking.py +96 -0
- filesonar-0.1.0/tests/test_search.py +227 -0
- filesonar-0.1.0/tests/test_server.py +135 -0
- filesonar-0.1.0/tests/test_wizard.py +388 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
python: ["3.11", "3.12", "3.13"]
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python }}
|
|
23
|
+
- name: Install system packages
|
|
24
|
+
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends tesseract-ocr fonts-dejavu-core
|
|
25
|
+
- name: Install
|
|
26
|
+
run: pip install -e ".[dev]"
|
|
27
|
+
- name: Lint
|
|
28
|
+
run: |
|
|
29
|
+
ruff check .
|
|
30
|
+
ruff format --check .
|
|
31
|
+
- name: Test
|
|
32
|
+
run: pytest --cov=filesonar --cov-report=term-missing
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Publishes to PyPI when a version tag (v0.1.0, ...) is pushed. Uses PyPI trusted
|
|
4
|
+
# publishing: PyPI checks that the upload comes from this workflow in this repository,
|
|
5
|
+
# so no API token is stored anywhere.
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
tags: ["v*"]
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
- name: Tag matches the package version
|
|
22
|
+
run: |
|
|
23
|
+
version=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
|
|
24
|
+
test "v$version" = "$GITHUB_REF_NAME" || { echo "tag $GITHUB_REF_NAME != v$version"; exit 1; }
|
|
25
|
+
- name: Install system packages
|
|
26
|
+
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends tesseract-ocr fonts-dejavu-core
|
|
27
|
+
- name: Test
|
|
28
|
+
run: |
|
|
29
|
+
pip install -e ".[dev]"
|
|
30
|
+
ruff check .
|
|
31
|
+
pytest
|
|
32
|
+
- name: Build
|
|
33
|
+
run: |
|
|
34
|
+
pip install build twine
|
|
35
|
+
python -m build
|
|
36
|
+
twine check --strict dist/*
|
|
37
|
+
- uses: actions/upload-artifact@v4
|
|
38
|
+
with:
|
|
39
|
+
name: dist
|
|
40
|
+
path: dist/
|
|
41
|
+
|
|
42
|
+
publish:
|
|
43
|
+
needs: build
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
environment:
|
|
46
|
+
name: pypi
|
|
47
|
+
url: https://pypi.org/project/filesonar/
|
|
48
|
+
permissions:
|
|
49
|
+
id-token: write # for trusted publishing only
|
|
50
|
+
steps:
|
|
51
|
+
- uses: actions/download-artifact@v4
|
|
52
|
+
with:
|
|
53
|
+
name: dist
|
|
54
|
+
path: dist/
|
|
55
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes are listed here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
|
|
5
|
+
[semantic versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-11-27
|
|
10
|
+
|
|
11
|
+
First release.
|
|
12
|
+
|
|
13
|
+
- `filesonar setup` takes a fresh install to a working one: checks Ollama and downloads
|
|
14
|
+
the models, checks Tesseract, writes the config with the folders you choose, connects
|
|
15
|
+
Google Drive if you want, registers with OpenClaw (and installs its skill) and Claude
|
|
16
|
+
Code, installs a systemd user service and starts the first index. Safe to run again;
|
|
17
|
+
it only changes what is missing.
|
|
18
|
+
- Index PDFs (text per page, OCR for scanned pages), Word documents, images (vision-model
|
|
19
|
+
captions, OCR, EXIF date and camera) and text files.
|
|
20
|
+
- Hybrid search: SQLite FTS5 keywords plus sqlite-vec embeddings, merged with
|
|
21
|
+
reciprocal rank fusion and a relevance cutoff.
|
|
22
|
+
- Filters by kind, folder and modification date.
|
|
23
|
+
- Incremental indexing with move detection by content hash.
|
|
24
|
+
- `filesonar watch` keeps the index current using inotify, with a daily full scan.
|
|
25
|
+
- MCP server (`filesonar serve`) with read-only `search_files`, `file_info` and
|
|
26
|
+
`index_status` tools, plus `prepare_file`, which copies an indexed file into an outbox
|
|
27
|
+
folder (OpenClaw's media folder by default) so a chat agent can send it without
|
|
28
|
+
running shell commands. Copies are private and removed after 24 hours.
|
|
29
|
+
- Built-in, non-overridable exclusion of keys, credentials and browser data; loopback-only
|
|
30
|
+
model host by default; private index permissions.
|
|
31
|
+
- Identical copies of a file (`report (1).pdf`) reuse the existing index entry and are
|
|
32
|
+
shown as one search result with `other_copies`.
|
|
33
|
+
- Typing a file name ranks that file first.
|
|
34
|
+
- Default exclusions for version control, dependencies, build output and caches apply on
|
|
35
|
+
top of your own patterns; folders where Python packages were installed are skipped.
|
|
36
|
+
- Long books and data exports are capped (`max_chunks_per_file`) so they cannot crowd
|
|
37
|
+
out other results; PDF reading stops once that budget is full.
|
|
38
|
+
- Robust against real-world files: runaway captions are capped and cleaned, OCR has a
|
|
39
|
+
per-image time limit, truncated images and unusual PNG transparency are handled.
|
|
40
|
+
- Files are read once without following symlinks, closing a check-then-read race.
|
|
41
|
+
- Google Drive support (opt-in): `filesonar drive login` signs in with your own OAuth
|
|
42
|
+
client; Drive files, Google Docs, Sheets and Slides are indexed locally and kept up to
|
|
43
|
+
date through the Drive change feed (`filesonar watch` polls every `poll_minutes`).
|
|
44
|
+
Files that also exist on this computer are matched by MD5 and never downloaded;
|
|
45
|
+
photos are described from Drive's preview image.
|
|
46
|
+
- Search results from Drive carry their Drive folder and a private link; `--source`
|
|
47
|
+
/ `source` limits results to `local` or `drive`.
|
|
48
|
+
- `share_file` MCP tool: a private Drive link for a laptop file, uploading it to a
|
|
49
|
+
`filesonar` folder only if Drive does not already have it.
|
|
50
|
+
- Signing in to Drive again needs no client_secret file: the saved OAuth client is reused.
|
|
51
|
+
- `filesonar doctor` warns when Ollama has a model only partly in GPU memory.
|
|
52
|
+
- `scripts/eval_search.py` measures search quality on your own index; the fusion
|
|
53
|
+
constant (5) was chosen with it on a real 16,000-file index.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Contributing to filesonar
|
|
2
|
+
|
|
3
|
+
Thanks for taking the time. Bug reports, ideas, documentation fixes and code are all
|
|
4
|
+
welcome.
|
|
5
|
+
|
|
6
|
+
## Getting set up
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
git clone https://github.com/yacbln/filesonar && cd filesonar
|
|
10
|
+
python -m venv .venv && . .venv/bin/activate
|
|
11
|
+
pip install -e ".[dev]"
|
|
12
|
+
sudo apt install tesseract-ocr # some tests need it; they are skipped otherwise
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Running the tests
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pytest # fast suite: fake models, real files, real SQLite
|
|
19
|
+
pytest -m ollama # end-to-end: real Ollama models and a real MCP stdio session
|
|
20
|
+
pytest --cov=filesonar --cov-report=term-missing
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The fast suite needs no network and no models. Sample PDFs, Word files and images are
|
|
24
|
+
generated by `tests/samples.py` at test time, so the repository holds no binary fixtures.
|
|
25
|
+
|
|
26
|
+
## Changing how results are ranked
|
|
27
|
+
|
|
28
|
+
Unit tests cannot tell whether search got better. Measure it on a real index first:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
python scripts/eval_search.py --mode rare # distinctive words from each file
|
|
32
|
+
python scripts/eval_search.py --mode random # ordinary words
|
|
33
|
+
python scripts/eval_search.py --mode paraphrase # the local model's own wording
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Run each with two or three `--seed` values before and after your change and include
|
|
37
|
+
the numbers in the pull request. The script only reads the index.
|
|
38
|
+
|
|
39
|
+
## Before opening a pull request
|
|
40
|
+
|
|
41
|
+
- `ruff check . && ruff format --check .` passes
|
|
42
|
+
- new behaviour has tests, bug fixes have a test that failed before the fix
|
|
43
|
+
- user-visible changes are described in `CHANGELOG.md` under "Unreleased"
|
|
44
|
+
- the README is updated if options, commands or tools changed
|
|
45
|
+
|
|
46
|
+
## Ground rules for changes
|
|
47
|
+
|
|
48
|
+
filesonar handles private files, so a few things are not negotiable:
|
|
49
|
+
|
|
50
|
+
- no new network destinations, telemetry or "phone home" of any kind (the only ones are
|
|
51
|
+
the configured Ollama server and, when the user enables it, Google's Drive API)
|
|
52
|
+
- the built-in exclusion list (`ALWAYS_EXCLUDED` in `config.py`) can grow but never shrink
|
|
53
|
+
- MCP tools never modify or delete the user's files; a tool that writes anything at all
|
|
54
|
+
(like `prepare_file`, which only writes to its outbox) is discussed in an issue first
|
|
55
|
+
- anything parsed from a file is untrusted input: bound it, and never execute it
|
|
56
|
+
|
|
57
|
+
## Adding a file format
|
|
58
|
+
|
|
59
|
+
1. Add the extension and an `extract_<format>` function in `src/filesonar/extract.py`
|
|
60
|
+
returning an `Extraction`.
|
|
61
|
+
2. Generate a sample in `tests/samples.py` and add tests in `tests/test_extract.py`,
|
|
62
|
+
including a corrupt file.
|
|
63
|
+
3. Mention it in the README table.
|
|
64
|
+
|
|
65
|
+
## Releasing (maintainers)
|
|
66
|
+
|
|
67
|
+
1. Move the "Unreleased" entries in `CHANGELOG.md` under a new version heading and set
|
|
68
|
+
the same `version` in `pyproject.toml`.
|
|
69
|
+
2. Commit, then tag and push: `git tag v0.2.0 && git push origin v0.2.0`.
|
|
70
|
+
3. The `Release` workflow tests, builds and publishes to PyPI through trusted publishing
|
|
71
|
+
(no API token exists to leak). It refuses a tag that does not match the version.
|
filesonar-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 filesonar contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
filesonar-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: filesonar
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local, private search over what your files contain (documents, PDFs, images), exposed to AI agents over MCP.
|
|
5
|
+
Project-URL: Homepage, https://github.com/yacbln/filesonar
|
|
6
|
+
Project-URL: Issues, https://github.com/yacbln/filesonar/issues
|
|
7
|
+
Author: filesonar contributors
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: local-first,mcp,ocr,ollama,openclaw,rag,search,semantic-search
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Desktop Environment :: File Managers
|
|
21
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: httpx>=0.27
|
|
24
|
+
Requires-Dist: mcp<3,>=2.0
|
|
25
|
+
Requires-Dist: pillow>=10.0
|
|
26
|
+
Requires-Dist: pymupdf>=1.24
|
|
27
|
+
Requires-Dist: pytesseract>=0.3.10
|
|
28
|
+
Requires-Dist: python-docx>=1.1
|
|
29
|
+
Requires-Dist: sqlite-vec>=0.1.6
|
|
30
|
+
Requires-Dist: watchdog>=4.0
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# filesonar
|
|
38
|
+
|
|
39
|
+
[](https://github.com/yacbln/filesonar/actions/workflows/ci.yml)
|
|
40
|
+
[](https://github.com/yacbln/filesonar/blob/main/LICENSE)
|
|
41
|
+
|
|
42
|
+
**Search your files by what is inside them — privately, on your own machine — and let your AI agent do it for you.**
|
|
43
|
+
|
|
44
|
+
Your file manager searches by file name. That is fine until you need "the PDF with the car insurance renewal" or "that photo of the red bike by the lake" and have no idea what either file is called. filesonar reads your documents, PDFs, scans, screenshots and photos once, remembers what they contain, and answers questions in plain language:
|
|
45
|
+
|
|
46
|
+
```console
|
|
47
|
+
$ filesonar search "automobile coverage"
|
|
48
|
+
1. /home/sam/Documents/insurance/auto-policy.pdf p.1
|
|
49
|
+
pdf, 2024-03-02, matched in text
|
|
50
|
+
Car insurance policy. Vehicle: 2019 Toyota Corolla. Premium 640 EUR per year.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Notice the query shares no words with the file. filesonar combines classic keyword search with meaning-based search, so both "invoice 4471" and "that bill from the hardware store" work.
|
|
54
|
+
|
|
55
|
+
It also runs as an [MCP](https://modelcontextprotocol.io) server, so an agent such as [OpenClaw](https://openclaw.ai), Claude Code or Cursor can search your files when you ask it to — from your phone, if your agent lives in Telegram or WhatsApp.
|
|
56
|
+
|
|
57
|
+
Everything runs locally through [Ollama](https://ollama.com). No file, no snippet and no query ever leaves your computer, unless you point filesonar at a model server elsewhere or turn on Google Drive.
|
|
58
|
+
|
|
59
|
+
Optionally, it can also index your [Google Drive](#google-drive) — the files are downloaded and understood on your machine, just like local ones — and hand out a private Drive link to a file on your laptop.
|
|
60
|
+
|
|
61
|
+
## What it understands
|
|
62
|
+
|
|
63
|
+
| Files | How |
|
|
64
|
+
|---|---|
|
|
65
|
+
| PDF | Text per page; pages that are scans are read with OCR |
|
|
66
|
+
| Word (`.docx`) | Paragraphs, tables, title and author |
|
|
67
|
+
| Images (`.jpg`, `.png`, `.webp`, `.gif`, `.bmp`, `.tiff`) | A local vision model describes what the picture shows; OCR reads any text (receipts, screenshots, slides); date and camera from EXIF |
|
|
68
|
+
| Text (`.txt`, `.md`, `.csv`, `.json`, `.html`, …) | As is |
|
|
69
|
+
|
|
70
|
+
With [Google Drive](#google-drive) enabled, the same goes for files in your Drive, plus Google Docs, Sheets and Slides. Coming next: audio and video. See the [roadmap](#roadmap).
|
|
71
|
+
|
|
72
|
+
## Install
|
|
73
|
+
|
|
74
|
+
You need Linux, Python 3.11 or newer, and [Ollama](https://ollama.com/download), which runs the models on your computer. Then:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pipx install filesonar
|
|
78
|
+
filesonar setup
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`setup` asks a few questions and does the rest. Each step checks first and only changes what is missing, so it is safe to run again — and running it after `pipx upgrade filesonar` is how an upgrade takes effect. It:
|
|
82
|
+
|
|
83
|
+
1. checks that Ollama runs, and downloads the text model `nomic-embed-text` (274 MB). It offers the vision model `qwen2.5vl:7b` that describes photos (about 6 GB, best with a GPU);
|
|
84
|
+
2. checks for [Tesseract](https://github.com/tesseract-ocr/tesseract), which reads text in scans and screenshots, and prints the install command if it is missing (`sudo apt install tesseract-ocr`; add `tesseract-ocr-fra`, `-ara`, … for other languages). Setup never runs `sudo` itself;
|
|
85
|
+
3. writes `~/.config/filesonar/config.toml` with the folders you choose (by default Documents, Pictures, Downloads and Desktop, if they exist);
|
|
86
|
+
4. optionally connects [Google Drive](#google-drive);
|
|
87
|
+
5. registers filesonar with OpenClaw and installs its skill, and with Claude Code if you have it;
|
|
88
|
+
6. installs a systemd user service that keeps the index up to date;
|
|
89
|
+
7. starts the first index.
|
|
90
|
+
|
|
91
|
+
For a setup without questions: `filesonar setup --yes`, optionally with `--folder ~/Papers` (repeatable), `--no-vision`, `--no-service`. See `filesonar setup --help`.
|
|
92
|
+
|
|
93
|
+
A GPU makes photo descriptions fast. Text, PDFs and OCR are fine on a CPU.
|
|
94
|
+
|
|
95
|
+
To install the latest code from GitHub instead: `pipx install git+https://github.com/yacbln/filesonar`.
|
|
96
|
+
|
|
97
|
+
## Quick start
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
filesonar search "lease agreement for the apartment"
|
|
101
|
+
filesonar status # how much is indexed
|
|
102
|
+
filesonar doctor # checks Ollama, the models, Tesseract and Drive
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Useful search options: `--kind pdf|document|image|text`, `--folder ~/Documents/taxes`, `--after 2024-01-01`, `--before 2024-12-31`, `--source local|drive`, `--json`.
|
|
106
|
+
|
|
107
|
+
### Keep the index up to date
|
|
108
|
+
|
|
109
|
+
`filesonar watch` re-indexes files as soon as they are added, edited, moved or deleted (it waits for a few quiet seconds, so copying 500 photos results in one pass, not 500). It also does a full scan once a day as a safety net. Moving or renaming a file is recognised by its content and costs nothing.
|
|
110
|
+
|
|
111
|
+
`filesonar setup` runs it in the background as the systemd user service `filesonar-watch`:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
systemctl --user status filesonar-watch
|
|
115
|
+
journalctl --user -u filesonar-watch -f # see what it is doing
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Use it from an AI agent
|
|
119
|
+
|
|
120
|
+
`filesonar serve` speaks MCP over stdio. Three tools are read-only; `prepare_file` writes, but only copies into its own outbox folder; `share_file` exists only when Google Drive is enabled:
|
|
121
|
+
|
|
122
|
+
| Tool | What it does |
|
|
123
|
+
|---|---|
|
|
124
|
+
| `search_files` | Ranked results with path, kind, date, the passage that matched and why it matched (text, OCR, caption or metadata). Identical copies of a file are one result, with the other locations listed. Filters for kind, folder, date range and source (`local` or `drive`). Drive results include their Drive folder and a private link. |
|
|
125
|
+
| `file_info` | Details and a short text preview for a file **that is already in the index**. It cannot be used to open arbitrary paths. |
|
|
126
|
+
| `prepare_file` | Copies a file **that is already in the index** into the outbox folder (by default OpenClaw's media folder, `~/.openclaw/media/filesonar`) and returns the copy's path, so a chat agent can attach it to a message. Copies are private and deleted after 24 hours. Works for Drive files too (downloaded, or taken from the identical local copy); Google Docs and Slides arrive as PDF, Sheets as `.xlsx`. |
|
|
127
|
+
| `share_file` | Returns a Google Drive link for an indexed laptop file. If the same file (same MD5) is already in your Drive, that link is returned and nothing is uploaded; otherwise a copy is uploaded to a `filesonar` folder in your Drive. Links are private: only you can open them. Handy for files too large to attach. |
|
|
128
|
+
| `index_status` | How many files are indexed and when the index last changed. |
|
|
129
|
+
|
|
130
|
+
Why `prepare_file`? Chat agents usually may only view or send files inside their own folders. Without it, an agent asked to "send me that photo" will try to run `cp`, a shell command that could write anywhere and so needs your approval each time. `prepare_file` does the one safe copy itself, and because it is marked as non-destructive and local, OpenClaw runs it without a prompt.
|
|
131
|
+
|
|
132
|
+
### OpenClaw
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
openclaw mcp add filesonar --command filesonar --arg serve
|
|
136
|
+
openclaw mcp probe filesonar
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`filesonar setup` does this for you, and also installs a [skill](https://github.com/yacbln/filesonar/blob/main/src/filesonar/skill/SKILL.md) that teaches OpenClaw when to use these tools (into `~/.openclaw/workspace/skills/filesonar/`). If your gateway runs elsewhere or hot reload is off, reload or restart it afterwards. If `openclaw` on your `PATH` is not the one your gateway runs, point setup at the right one: `filesonar setup --openclaw /path/to/openclaw`.
|
|
140
|
+
|
|
141
|
+
### Claude Code
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
claude mcp add filesonar -- filesonar serve
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Any other MCP client
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"mcpServers": {
|
|
152
|
+
"filesonar": { "command": "filesonar", "args": ["serve"] }
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Add `"--config", "/path/to/config.toml"` before `"serve"` if your config is not in the default place.
|
|
158
|
+
|
|
159
|
+
## Google Drive
|
|
160
|
+
|
|
161
|
+
filesonar can index the files in your Google Drive and keep up with changes, so "find the lease" also finds the copy you only have in Drive. File contents are downloaded to your computer and processed there by the same local models; only Drive's own API is contacted. Photos are described from Drive's preview image (no need to download a 6 MB original), and files that are already on your computer — say, photos synced to Drive — are recognised by their checksum and never downloaded at all.
|
|
162
|
+
|
|
163
|
+
After the first sync, filesonar uses Drive's [change feed](https://developers.google.com/drive/api/guides/manage-changes): `filesonar watch` asks "what changed?" every few minutes, which is one cheap request when nothing did. The Drive API is free for this kind of personal use.
|
|
164
|
+
|
|
165
|
+
### One-time setup (about 5 minutes)
|
|
166
|
+
|
|
167
|
+
filesonar does not ship a shared Google app; you create your own, so your access is yours alone and does not depend on anyone else's project.
|
|
168
|
+
|
|
169
|
+
1. Open [Google Cloud Console](https://console.cloud.google.com/) and create a project (any name, e.g. "filesonar").
|
|
170
|
+
2. **APIs & Services → Library**: search for **Google Drive API** and enable it.
|
|
171
|
+
3. **Google Auth Platform** (formerly *OAuth consent screen*): click **Get started**, enter an app name (e.g. "filesonar") and your email, and choose **External**.
|
|
172
|
+
4. **Audience**: add your own Google account under **Test users**. Apps in *Testing* get sign-ins that expire after 7 days (filesonar then asks you to run `filesonar drive login` again). To avoid that, fill in **Branding** — app name, support email, a homepage and a privacy policy URL; this repository and its [`PRIVACY.md`](https://github.com/yacbln/filesonar/blob/main/PRIVACY.md) are fine — and click **Publish app** so the app is *In production*. You do not need Google's verification for your own use.
|
|
173
|
+
5. **Clients → Create client**, application type **Desktop app** (not *Web application*, and leave *"Use this client for an AI-powered agent"* unticked). Download the JSON file and keep it private.
|
|
174
|
+
6. Sign in and turn Drive on:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
filesonar setup --drive-client-secret ~/Downloads/client_secret_XXXX.json
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Your browser opens Google's consent page. Because the app is yours and unverified, Google shows *"Google hasn't verified this app"*: choose **Advanced → Go to filesonar**. Allow both permissions (read your Drive, and create files filesonar makes). Setup then turns Drive on in your config, and the background service indexes it. (By hand: `filesonar drive login --client-secret FILE`, set `enabled = true` under `[drive]`, run `filesonar index`.) You can delete the downloaded JSON afterwards; filesonar keeps what it needs in its own private file, and to sign in again later (for example after publishing the app) plain `filesonar drive login` is enough.
|
|
181
|
+
|
|
182
|
+
The sign-in is saved to `~/.local/share/filesonar/drive-token.json` (permissions `0600`). `filesonar drive logout` revokes it and removes Drive files from the index.
|
|
183
|
+
|
|
184
|
+
### Commands and options
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
filesonar drive status # who is signed in, how many Drive files are indexed
|
|
188
|
+
filesonar drive sync # fetch changes now (`--full` re-lists everything)
|
|
189
|
+
filesonar search "visa appointment" --source drive
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
```toml
|
|
193
|
+
[drive]
|
|
194
|
+
enabled = true
|
|
195
|
+
folders = ["Taxes", "Photos/2024"] # only these folders in My Drive; empty = all of it
|
|
196
|
+
exclude = ["/Archive/**"] # patterns, matched against the path inside My Drive
|
|
197
|
+
include_shared = false # also index files others shared with you
|
|
198
|
+
share_folder = "filesonar" # where share_file uploads to
|
|
199
|
+
poll_minutes = 5
|
|
200
|
+
image_previews = true # describe photos from Drive's preview image
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The built-in exclusions (keys, `.env` files, password stores, …) apply to Drive too.
|
|
204
|
+
|
|
205
|
+
## Configuration
|
|
206
|
+
|
|
207
|
+
All options with their defaults (the `[drive]` section is described under [Google Drive](#google-drive)):
|
|
208
|
+
|
|
209
|
+
```toml
|
|
210
|
+
roots = ["~/Documents", "~/Pictures", "~/Downloads"] # folders to index
|
|
211
|
+
|
|
212
|
+
# Extra patterns to skip, matched against the path inside each folder.
|
|
213
|
+
# "*" stays within one folder, "**/" spans any number of folders,
|
|
214
|
+
# a leading "/" anchors to the indexed folder itself.
|
|
215
|
+
exclude = [] # e.g. ["**/old-backups/**", "*.log"]
|
|
216
|
+
|
|
217
|
+
# data_dir = "~/.local/share/filesonar" # where the index is stored
|
|
218
|
+
# outbox_dir = "~/.openclaw/media/filesonar" # where prepare_file puts copies
|
|
219
|
+
|
|
220
|
+
[models]
|
|
221
|
+
host = "http://127.0.0.1:11434"
|
|
222
|
+
embedding_model = "nomic-embed-text"
|
|
223
|
+
vision_model = "qwen2.5vl:7b"
|
|
224
|
+
caption_images = true
|
|
225
|
+
allow_remote_host = false # see "Privacy and security"
|
|
226
|
+
timeout_seconds = 120
|
|
227
|
+
|
|
228
|
+
[index]
|
|
229
|
+
max_file_size_mb = 50
|
|
230
|
+
max_pdf_pages = 300
|
|
231
|
+
max_chunks_per_file = 300 # very long books and data exports: only the start is indexed
|
|
232
|
+
ocr = true
|
|
233
|
+
ocr_languages = "eng" # Tesseract codes joined by "+", e.g. "eng+fra+ara"
|
|
234
|
+
include_hidden = false # dot-files and dot-folders
|
|
235
|
+
default_excludes = true # .git, node_modules, venvs, build output, caches, trash, ...
|
|
236
|
+
skip_dependency_folders = true # folders where software packages were installed
|
|
237
|
+
chunk_chars = 1200
|
|
238
|
+
chunk_overlap = 200
|
|
239
|
+
|
|
240
|
+
[search]
|
|
241
|
+
max_distance = 0.44 # how close a meaning-only match must be (lower = stricter)
|
|
242
|
+
relative_margin = 0.12
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Your `exclude` patterns are added to the defaults rather than replacing them. Folders where Python packages were installed (they contain `*.dist-info` entries, e.g. a bundled AWS Lambda) are skipped too, so a code project inside `~/Documents` does not bury your own files under thousands of library files.
|
|
246
|
+
|
|
247
|
+
Unknown options are rejected instead of silently ignored, so a typo never turns a setting off.
|
|
248
|
+
|
|
249
|
+
If you switch `embedding_model`, rebuild the index with `filesonar index --rebuild`; filesonar refuses to mix vectors from different models. `max_distance` is tuned for `nomic-embed-text` — other embedding models may need a different value.
|
|
250
|
+
|
|
251
|
+
## Privacy and security
|
|
252
|
+
|
|
253
|
+
filesonar reads your personal files, so it is built to be boring and predictable:
|
|
254
|
+
|
|
255
|
+
- **Local only by default.** It talks to one server: the Ollama address in your config, which must be on this machine unless you set `allow_remote_host = true`. It ignores `HTTP_PROXY`-style variables for that, has no telemetry and makes no other network requests.
|
|
256
|
+
- **Google Drive is opt-in and contacts only Google.** With `[drive] enabled = true`, filesonar talks to `googleapis.com` (the Drive API and sign-in) and to the `googleusercontent.com` preview links the Drive API hands out — nothing else. Drive files are processed on your machine, never sent anywhere. Sign-in uses Google's flow for installed apps (PKCE, random `state`, a one-shot listener on `127.0.0.1`); the refresh token lives in a `0600` file and is never logged. Uploads happen only through `share_file`, only for indexed files, only into one folder that filesonar created, and the Drive permission filesonar asks for (`drive.file`) cannot change or delete files it did not create.
|
|
257
|
+
- **Secrets are never indexed.** SSH and GPG keys, password stores, cloud credentials, browser profiles, crypto wallets, `.env` files, `*.pem`/`*.key` files and similar are always skipped. This list is built in and cannot be switched off by the config.
|
|
258
|
+
- **No symlink surprises.** Symbolic links are never followed, and a file whose real location is outside your indexed folders is skipped.
|
|
259
|
+
- **The agent only sees the index.** The MCP server never opens a path that is not in the index, returns short snippets (and at most a 2,000-character preview), and tells the agent to treat file contents as data rather than instructions — a defence against documents that try to give orders to AI assistants.
|
|
260
|
+
- **`prepare_file` can only copy, and only into its outbox.** It copies files that are in the index and still allowed by your config, reads them without following symlinks, writes `0600` copies into `0700` folders inside `outbox_dir`, never writes through a symlink, and only ever deletes its own copies older than 24 hours. Your original files are never modified. The outbox is never indexed.
|
|
261
|
+
- **GPS coordinates are not stored.** Photo dates and camera models are, locations are not.
|
|
262
|
+
- **The index is private.** It is a single SQLite file created with `0600` permissions inside a `0700` folder. Delete it at any time; it can be rebuilt from your files.
|
|
263
|
+
- **Defensive parsing.** Images that would decode to more than ~90 megapixels, password-protected PDFs, oversized files and binary files with text extensions are skipped rather than processed.
|
|
264
|
+
|
|
265
|
+
Found a problem? Please see [SECURITY.md](https://github.com/yacbln/filesonar/blob/main/SECURITY.md). The full privacy policy is in [PRIVACY.md](https://github.com/yacbln/filesonar/blob/main/PRIVACY.md).
|
|
266
|
+
|
|
267
|
+
## How it works
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
files ──► extract ──────────────► chunk ──► embed (Ollama) ──► SQLite
|
|
271
|
+
PDF/DOCX text ├─ FTS5 keyword index
|
|
272
|
+
OCR (Tesseract) └─ sqlite-vec vectors
|
|
273
|
+
photo captions (vision model)
|
|
274
|
+
EXIF / document metadata
|
|
275
|
+
query ──► keyword hits ─┐
|
|
276
|
+
└─► nearest by meaning ─┴─► fused ranking ──► results
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
- Changes are detected by size and modification time first and confirmed with a SHA-256 of the content, so unchanged files are never read twice and a moved file keeps its index entry.
|
|
280
|
+
- Keyword and meaning results are merged with reciprocal rank fusion. Matches by meaning only count if they are genuinely close; otherwise unrelated searches would always "find" something.
|
|
281
|
+
- If Ollama is not running, search keeps working with keywords only and says so.
|
|
282
|
+
|
|
283
|
+
## Performance
|
|
284
|
+
|
|
285
|
+
Embedding text is near-instant (well under 0.1 s per chunk on a desktop GPU). Describing a photo is the slow step, and it is much faster when the vision model fits entirely in video memory. If your GPU is busy with other models — for example the model your agent runs on — Ollama splits the vision model between GPU and CPU and captions slow down to several seconds per photo. Options:
|
|
286
|
+
|
|
287
|
+
- run the first big index when the GPU is free (overnight), or
|
|
288
|
+
- use a smaller vision model such as `qwen2.5vl:3b`, or
|
|
289
|
+
- set `caption_images = false`; photos stay searchable by any text in them, their date and name.
|
|
290
|
+
|
|
291
|
+
Images that could not be captioned are retried automatically the next time the vision model is available.
|
|
292
|
+
|
|
293
|
+
## Troubleshooting
|
|
294
|
+
|
|
295
|
+
- **`filesonar doctor`** shows what is missing.
|
|
296
|
+
- **"meaning-based search unavailable"** — Ollama is not running or the embedding model is not pulled.
|
|
297
|
+
- **Photos suddenly take 10+ seconds each** — Ollama loaded the vision model while video memory was short and split it between GPU and CPU; it stays split until reloaded. `filesonar doctor` warns about this. Free some GPU memory and run `ollama stop qwen2.5vl:7b`; the next photo loads it fully onto the GPU.
|
|
298
|
+
- **A file is not found** — check that its folder is in `roots`, that it is not excluded or hidden, and `filesonar status` for errors. `filesonar -v index` prints every file it reads.
|
|
299
|
+
|
|
300
|
+
## Roadmap
|
|
301
|
+
|
|
302
|
+
- [x] Documents, PDFs (with OCR), images (captions + OCR), text
|
|
303
|
+
- [x] Hybrid keyword + meaning search, MCP server, folder watcher
|
|
304
|
+
- [x] Google Drive: index files in Drive and keep them in sync (Drive Changes API)
|
|
305
|
+
- [x] `share_file`: a private Drive link to a laptop file, uploading only if it is not in Drive yet
|
|
306
|
+
- [ ] Audio and video (transcripts and key frames)
|
|
307
|
+
- [ ] More formats: `.odt`, `.pptx`, `.xlsx`, `.epub`
|
|
308
|
+
- [ ] macOS support
|
|
309
|
+
|
|
310
|
+
Ideas and pull requests are welcome.
|
|
311
|
+
|
|
312
|
+
## Contributing
|
|
313
|
+
|
|
314
|
+
See [CONTRIBUTING.md](https://github.com/yacbln/filesonar/blob/main/CONTRIBUTING.md). The short version:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
python -m venv .venv && . .venv/bin/activate
|
|
318
|
+
pip install -e ".[dev]"
|
|
319
|
+
pytest # fast suite, no models needed
|
|
320
|
+
pytest -m ollama # end-to-end against your local Ollama
|
|
321
|
+
ruff check . && ruff format --check .
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## License
|
|
325
|
+
|
|
326
|
+
[MIT](https://github.com/yacbln/filesonar/blob/main/LICENSE)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Privacy policy
|
|
2
|
+
|
|
3
|
+
filesonar is software you run on your own computer. There is no filesonar service,
|
|
4
|
+
account or server, and the people who write filesonar never receive any of your data.
|
|
5
|
+
|
|
6
|
+
## What filesonar reads
|
|
7
|
+
|
|
8
|
+
- Files in the folders you list in its configuration.
|
|
9
|
+
- If you turn on Google Drive and sign in: the files in your Google Drive (or the Drive
|
|
10
|
+
folders you choose), their names, folders, dates, sizes and checksums.
|
|
11
|
+
|
|
12
|
+
## What it does with it
|
|
13
|
+
|
|
14
|
+
Everything is processed on your computer, by the AI models you run there (Ollama). The
|
|
15
|
+
result — extracted text, descriptions of photos, and metadata — is stored in a private
|
|
16
|
+
index file in your own data folder (`~/.local/share/filesonar/` by default), readable
|
|
17
|
+
only by your user account. You can delete it at any time.
|
|
18
|
+
|
|
19
|
+
filesonar does not:
|
|
20
|
+
|
|
21
|
+
- send your files, the index or your searches to its authors or to any third party;
|
|
22
|
+
- include analytics, telemetry or crash reporting;
|
|
23
|
+
- store GPS locations from photos;
|
|
24
|
+
- index secrets such as SSH keys, password stores, browser profiles or `.env` files.
|
|
25
|
+
|
|
26
|
+
## Google Drive
|
|
27
|
+
|
|
28
|
+
When you enable Google Drive, filesonar uses an OAuth client that **you** create in your
|
|
29
|
+
own Google Cloud project, and asks Google for two permissions:
|
|
30
|
+
|
|
31
|
+
- `drive.readonly` — to list and read your Drive files so they can be indexed locally;
|
|
32
|
+
- `drive.file` — to create the one folder and the files that `share_file` uploads when
|
|
33
|
+
you ask for a link. This permission cannot change or delete files filesonar did not
|
|
34
|
+
create.
|
|
35
|
+
|
|
36
|
+
Your sign-in (a refresh token) is stored only on your computer, in a file readable only
|
|
37
|
+
by you. filesonar talks only to Google's own servers for this. Running
|
|
38
|
+
`filesonar drive logout` revokes the access and removes Drive data from the index; you
|
|
39
|
+
can also revoke it at <https://myaccount.google.com/permissions>.
|
|
40
|
+
|
|
41
|
+
filesonar's use and transfer of information received from Google APIs adheres to the
|
|
42
|
+
[Google API Services User Data Policy](https://developers.google.com/terms/api-services-user-data-policy),
|
|
43
|
+
including the Limited Use requirements.
|
|
44
|
+
|
|
45
|
+
## AI agents
|
|
46
|
+
|
|
47
|
+
If you connect filesonar to an AI agent (OpenClaw, Claude Code, Cursor, ...), that
|
|
48
|
+
agent receives search results and short excerpts from your files when it asks for them.
|
|
49
|
+
What the agent then does with them — including sending them to the AI model provider
|
|
50
|
+
it uses — is governed by that agent's and that provider's privacy policies, not this
|
|
51
|
+
one.
|
|
52
|
+
|
|
53
|
+
## Contact
|
|
54
|
+
|
|
55
|
+
Questions or concerns: open an issue in the project's repository.
|