budgetdex 0.0.1__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.
- budgetdex-0.0.1/.gitignore +36 -0
- budgetdex-0.0.1/CHANGELOG.md +26 -0
- budgetdex-0.0.1/CONTRIBUTING.md +24 -0
- budgetdex-0.0.1/LICENSE +202 -0
- budgetdex-0.0.1/NOTICE +16 -0
- budgetdex-0.0.1/PKG-INFO +192 -0
- budgetdex-0.0.1/README.md +154 -0
- budgetdex-0.0.1/README_JA.md +172 -0
- budgetdex-0.0.1/SECURITY.md +41 -0
- budgetdex-0.0.1/eval/sample/bench_result.json +23202 -0
- budgetdex-0.0.1/eval/sample/corpus/contracts.md +15 -0
- budgetdex-0.0.1/eval/sample/corpus/handbook_en.md +13 -0
- budgetdex-0.0.1/eval/sample/corpus/inventory.csv +5 -0
- budgetdex-0.0.1/eval/sample/corpus/notes/meeting_2026_10.md +13 -0
- budgetdex-0.0.1/eval/sample/corpus/notes/security.txt +7 -0
- budgetdex-0.0.1/eval/sample/corpus/onboarding.md +13 -0
- budgetdex-0.0.1/eval/sample/corpus/pricing.md +13 -0
- budgetdex-0.0.1/eval/sample/corpus/sales_2026.csv +7 -0
- budgetdex-0.0.1/eval/sample/questions.jsonl +12 -0
- budgetdex-0.0.1/plugin/.claude-plugin/plugin.json +16 -0
- budgetdex-0.0.1/plugin/.mcp.json +8 -0
- budgetdex-0.0.1/plugin/README.md +5 -0
- budgetdex-0.0.1/plugin/skills/knowledge-search/SKILL.md +16 -0
- budgetdex-0.0.1/pyproject.toml +74 -0
- budgetdex-0.0.1/src/budgetdex/__init__.py +21 -0
- budgetdex-0.0.1/src/budgetdex/_name.py +16 -0
- budgetdex-0.0.1/src/budgetdex/api.py +257 -0
- budgetdex-0.0.1/src/budgetdex/bench.py +437 -0
- budgetdex-0.0.1/src/budgetdex/cards.py +303 -0
- budgetdex-0.0.1/src/budgetdex/cli.py +317 -0
- budgetdex-0.0.1/src/budgetdex/configs.py +434 -0
- budgetdex-0.0.1/src/budgetdex/excerpt.py +184 -0
- budgetdex-0.0.1/src/budgetdex/ingest/__init__.py +320 -0
- budgetdex-0.0.1/src/budgetdex/ingest/formats.py +226 -0
- budgetdex-0.0.1/src/budgetdex/ingest/glossary.py +139 -0
- budgetdex-0.0.1/src/budgetdex/ingest/notion_api.py +438 -0
- budgetdex-0.0.1/src/budgetdex/ingest/notion_zip.py +385 -0
- budgetdex-0.0.1/src/budgetdex/ingest/postgres.py +674 -0
- budgetdex-0.0.1/src/budgetdex/ingest/secrets.py +44 -0
- budgetdex-0.0.1/src/budgetdex/ingest/table.py +785 -0
- budgetdex-0.0.1/src/budgetdex/ingest/text.py +264 -0
- budgetdex-0.0.1/src/budgetdex/ingest/walk.py +304 -0
- budgetdex-0.0.1/src/budgetdex/mcp_server.py +100 -0
- budgetdex-0.0.1/src/budgetdex/pack.py +341 -0
- budgetdex-0.0.1/src/budgetdex/rank.py +176 -0
- budgetdex-0.0.1/src/budgetdex/render.py +283 -0
- budgetdex-0.0.1/src/budgetdex/rerank.py +249 -0
- budgetdex-0.0.1/src/budgetdex/search.py +191 -0
- budgetdex-0.0.1/src/budgetdex/secretstore.py +60 -0
- budgetdex-0.0.1/src/budgetdex/spm.py +247 -0
- budgetdex-0.0.1/src/budgetdex/sqltool.py +445 -0
- budgetdex-0.0.1/src/budgetdex/store.py +191 -0
- budgetdex-0.0.1/src/budgetdex/textindex.py +276 -0
- budgetdex-0.0.1/src/budgetdex/tokens.py +91 -0
- budgetdex-0.0.1/src/budgetdex/vec.py +467 -0
- budgetdex-0.0.1/src/budgetdex/weak.py +567 -0
- budgetdex-0.0.1/tests/conftest.py +13 -0
- budgetdex-0.0.1/tests/data/token_samples.json +10 -0
- budgetdex-0.0.1/tests/p2_fixtures.py +127 -0
- budgetdex-0.0.1/tests/test_01_scaffold.py +30 -0
- budgetdex-0.0.1/tests/test_02_tokens.py +47 -0
- budgetdex-0.0.1/tests/test_03_store.py +54 -0
- budgetdex-0.0.1/tests/test_04_textindex.py +81 -0
- budgetdex-0.0.1/tests/test_05_walk.py +103 -0
- budgetdex-0.0.1/tests/test_06_text.py +81 -0
- budgetdex-0.0.1/tests/test_07_search.py +88 -0
- budgetdex-0.0.1/tests/test_08_pack.py +170 -0
- budgetdex-0.0.1/tests/test_09_render.py +88 -0
- budgetdex-0.0.1/tests/test_10_api_cli.py +63 -0
- budgetdex-0.0.1/tests/test_11_mcp.py +57 -0
- budgetdex-0.0.1/tests/test_12_table.py +99 -0
- budgetdex-0.0.1/tests/test_13_audit.py +269 -0
- budgetdex-0.0.1/tests/test_14_p1.py +326 -0
- budgetdex-0.0.1/tests/test_15_p1b.py +338 -0
- budgetdex-0.0.1/tests/test_16_p2_sql.py +341 -0
- budgetdex-0.0.1/tests/test_17_p2_formats.py +151 -0
- budgetdex-0.0.1/tests/test_18_p2_notion_zip.py +162 -0
- budgetdex-0.0.1/tests/test_19_p2_postgres.py +599 -0
- budgetdex-0.0.1/tests/test_20_p2_notion_api.py +222 -0
- budgetdex-0.0.1/tests/test_21_final.py +251 -0
- budgetdex-0.0.1/tests/test_22_p3.py +331 -0
- budgetdex-0.0.1/tests/test_23_p3_audit.py +207 -0
- budgetdex-0.0.1/tests/test_24_p4.py +102 -0
- budgetdex-0.0.1/tests/test_25_p4_audit.py +124 -0
- budgetdex-0.0.1/tests/test_26_lab_notion.py +90 -0
- budgetdex-0.0.1/tests/test_27_lab_search.py +167 -0
- budgetdex-0.0.1/tests/test_28_lab2.py +406 -0
- budgetdex-0.0.1/tests/test_29_lab3.py +167 -0
- budgetdex-0.0.1/tests/test_30_lab4.py +227 -0
- budgetdex-0.0.1/tests/test_31_p6_audit.py +283 -0
- budgetdex-0.0.1/tests/test_32_typed_tables.py +166 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.venv/
|
|
2
|
+
__pycache__/
|
|
3
|
+
.pytest_cache/
|
|
4
|
+
.hypothesis/
|
|
5
|
+
.ruff_cache/
|
|
6
|
+
.mypy_cache/
|
|
7
|
+
*.db
|
|
8
|
+
*.db-wal
|
|
9
|
+
*.db-shm
|
|
10
|
+
eval/private/
|
|
11
|
+
.cache/
|
|
12
|
+
dist/
|
|
13
|
+
build/
|
|
14
|
+
*.egg-info/
|
|
15
|
+
*.whl
|
|
16
|
+
.DS_Store
|
|
17
|
+
.env
|
|
18
|
+
.env.*
|
|
19
|
+
.uv-cache/
|
|
20
|
+
.uv/
|
|
21
|
+
|
|
22
|
+
# ---- internal working material: kept locally, never published ----
|
|
23
|
+
# Phase reports, audits, design notes and status (they quote local paths and
|
|
24
|
+
# private evaluation files). README.md / README_JA.md stand alone without them.
|
|
25
|
+
/AUDIT_P*_JA.md
|
|
26
|
+
/P*_REPORT_JA.md
|
|
27
|
+
/DESIGN_JA.md
|
|
28
|
+
/IMPLEMENTATION_PLAN_JA.md
|
|
29
|
+
/COMPETITORS_JA.md
|
|
30
|
+
/STATUS_JA.md
|
|
31
|
+
/RELEASE_CHECKLIST_JA.md
|
|
32
|
+
# P0 measurement script (its queries are tied to the owner's private corpus)
|
|
33
|
+
/eval/measure_p0.py
|
|
34
|
+
# live-lab outputs (contain local paths and run logs); the lab code itself is public
|
|
35
|
+
/lab/results/
|
|
36
|
+
.ci-home/
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are recorded here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
|
|
5
|
+
[Semantic Versioning](https://semver.org/) (0.x: anything may still change).
|
|
6
|
+
|
|
7
|
+
## [0.0.1] - Unreleased
|
|
8
|
+
|
|
9
|
+
First public release (alpha).
|
|
10
|
+
|
|
11
|
+
- Local SQLite index over folders and files (md, txt, csv, tsv; xlsx, pdf, docx
|
|
12
|
+
with extras) and Notion "Markdown & CSV" export zips.
|
|
13
|
+
- Search that packs results into a token budget chosen by the caller
|
|
14
|
+
(profiles `light`, `standard`, `max`).
|
|
15
|
+
- MCP server over stdio with three tools: `search`, `get`, `sql`; the same
|
|
16
|
+
as CLI and Python SDK (`budgetdex.open()`).
|
|
17
|
+
- Read-only `sql` over indexed tables.
|
|
18
|
+
- Local table columns whose non-empty cells are all clean numbers are stored as
|
|
19
|
+
INTEGER / REAL (empty cells NULL), so `sql` compares, orders and aggregates them as
|
|
20
|
+
numbers; leading zeros, long digit strings and formatted values stay text
|
|
21
|
+
(card type 数字の文字列). Older indexes are converted once on open.
|
|
22
|
+
- Opt-in connectors: Postgres / Supabase (schema and planner statistics
|
|
23
|
+
only; queries run read-only) and the Notion API (read-only use).
|
|
24
|
+
- Optional pinned, sha256-checked models: multilingual-e5-small (vectors)
|
|
25
|
+
and an mMiniLMv2 cross-encoder (profile `max`).
|
|
26
|
+
- `bench`: retrieval-level comparison of search configurations on an eval set.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping. Keep changes small and include a test.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
uv sync --all-extras # dev tools (pytest, hypothesis) and all optional extras
|
|
7
|
+
uv run pytest -q # the whole suite; needs no network and no model
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
- Tests that need the real embedding model, `tokenizers` or a local Postgres
|
|
11
|
+
(`initdb` / `pg_ctl` on PATH) skip themselves when those are missing.
|
|
12
|
+
- Search output must not change by accident: the bench configurations
|
|
13
|
+
(`cc_deep`, `rrf_rank`, `tok_snip_deep`, ...) are checked for byte-identical
|
|
14
|
+
output by the test suite. If you change ranking or packing on purpose, say so
|
|
15
|
+
in the pull request and show the bench numbers before and after:
|
|
16
|
+
`uv run budgetdex bench eval/sample/questions.jsonl --corpus eval/sample/corpus`.
|
|
17
|
+
- `lab/` is an optional live harness against Notion and Supabase. It is not
|
|
18
|
+
needed for development or CI, and it needs your **own** test accounts:
|
|
19
|
+
a throwaway Notion page and a throwaway Postgres schema, with secrets in the
|
|
20
|
+
macOS keychain (see `lab/README_JA.md`). Never point it at real data.
|
|
21
|
+
- Do not commit indexes (`*.db`), models, `.cache/`, or anything with personal
|
|
22
|
+
data or secrets.
|
|
23
|
+
- By contributing you agree that your contribution is licensed under the
|
|
24
|
+
Apache License 2.0.
|
budgetdex-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
budgetdex-0.0.1/NOTICE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
budgetdex
|
|
2
|
+
Copyright 2026 The budgetdex authors
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
src/budgetdex/spm.py contains a Python re-implementation of the SentencePiece
|
|
7
|
+
Unigram segmentation rules as implemented in the Hugging Face `tokenizers`
|
|
8
|
+
library (Unigram "encode_optimized"), and uses `tokenizers` at run time for
|
|
9
|
+
normalisation and pre-tokenisation.
|
|
10
|
+
- tokenizers: Copyright Hugging Face, Inc. Licensed under the Apache License 2.0.
|
|
11
|
+
- SentencePiece (the Unigram algorithm): Copyright Google LLC.
|
|
12
|
+
Licensed under the Apache License 2.0.
|
|
13
|
+
|
|
14
|
+
No model weights or vocabularies are distributed with this package. The
|
|
15
|
+
optional models are downloaded by the user with `budgetdex embed --download`
|
|
16
|
+
and remain under their own licences (see README.md, "Models and licences").
|
budgetdex-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: budgetdex
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Local, LLM-free index over personal documents that returns search results packed into a token budget.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Keywords: bm25,japanese,local-first,mcp,notion,postgres,rag,search,sqlite,token-budget
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: Natural Language :: Japanese
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Database
|
|
22
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Requires-Dist: mcp<3,>=2.3.0
|
|
25
|
+
Provides-Extra: docx
|
|
26
|
+
Requires-Dist: python-docx>=1.1; extra == 'docx'
|
|
27
|
+
Provides-Extra: pdf
|
|
28
|
+
Requires-Dist: pypdf>=5; extra == 'pdf'
|
|
29
|
+
Provides-Extra: postgres
|
|
30
|
+
Requires-Dist: psycopg[binary]>=3.2; extra == 'postgres'
|
|
31
|
+
Provides-Extra: vec
|
|
32
|
+
Requires-Dist: numpy>=2.4.6; extra == 'vec'
|
|
33
|
+
Requires-Dist: onnxruntime>=1.32.0; extra == 'vec'
|
|
34
|
+
Requires-Dist: tokenizers>=0.23.3; extra == 'vec'
|
|
35
|
+
Provides-Extra: xlsx
|
|
36
|
+
Requires-Dist: openpyxl>=3.1; extra == 'xlsx'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# budgetdex
|
|
40
|
+
|
|
41
|
+
A local index over your own documents and tables, for AI agents.
|
|
42
|
+
The agent says how many tokens it can spend; budgetdex returns the most useful hits packed into that budget (top hits in full, the rest as snippets or title lines).
|
|
43
|
+
No LLM is called to build or query the index, no account is needed, and nothing leaves your machine unless you add a connector or download the optional model.
|
|
44
|
+
|
|
45
|
+
Status: **alpha (0.0.1)**. Tested on macOS (Apple silicon). Linux runs in CI; Windows is not tested.
|
|
46
|
+
Search headers and CLI messages are currently in **Japanese** (the tool works on English and Japanese text alike).
|
|
47
|
+
日本語の説明は [README_JA.md](README_JA.md)。
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uv tool install "budgetdex[vec]" # or: pipx install "budgetdex[vec]"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Extras: `vec` (vector search: numpy, onnxruntime, tokenizers; no PyTorch), `xlsx` (openpyxl), `pdf` (pypdf), `docx` (python-docx), `postgres` (psycopg). Combine them as `budgetdex[vec,xlsx,pdf,docx]`. The core depends only on `mcp`. Without an extra, the affected files are listed by `budgetdex status` with an install hint, and search uses BM25 alone. Python 3.11+.
|
|
56
|
+
|
|
57
|
+
## 60-second quickstart
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
budgetdex add ~/notes # index a folder (md, txt, csv, tsv; xlsx/pdf/docx with extras)
|
|
61
|
+
budgetdex search "refund deadline" -b 500 # results packed into 500 tokens
|
|
62
|
+
budgetdex get <id> -b 800 # full text of one hit
|
|
63
|
+
budgetdex sql "select count(*) from my_table" # read-only SQL over indexed CSV/xlsx tables
|
|
64
|
+
budgetdex status # what is indexed, what was skipped and why
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Later runs of `budgetdex sync` re-read changed files only. The index lives in `~/.budgetdex/default.db` (set `BUDGETDEX_HOME` to move it).
|
|
68
|
+
|
|
69
|
+
Vectors are optional (better for paraphrases and English/Japanese mixes):
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
budgetdex embed --download # one-time ~135 MB model download, then embeds all chunks
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
After later CLI syncs, run `budgetdex embed` again for new chunks; the MCP server does this by itself in the background.
|
|
76
|
+
|
|
77
|
+
## Connect an agent (MCP over stdio)
|
|
78
|
+
|
|
79
|
+
Claude Code:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
claude mcp add budgetdex -- budgetdex mcp
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Any other MCP client (JSON config):
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"mcpServers": {
|
|
90
|
+
"budgetdex": { "command": "budgetdex", "args": ["mcp"] }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The server re-syncs all sources in the background when it starts. A Claude Code plugin (server definition plus a usage skill) is in `plugin/`.
|
|
96
|
+
|
|
97
|
+
| Tool | What it does |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `search(query, budget, where)` | Ranked hits within `budget` tokens, one `[id] title|source date` line each. `where` narrows to a path glob. Items already returned in the session come back as a title line marked `※既出`. A header ending in `一致弱め` means the matches are weak (the answer may not be in the index). |
|
|
100
|
+
| `get(id, budget, start)` | Full text of one hit within `budget`; a cut text ends with the `start` to continue from. |
|
|
101
|
+
| `sql(query, budget)` | Read-only SQL over the tables that search shows as `表` (CSV/TSV, xlsx, Notion databases, Postgres). Tab-separated, within `budget`. |
|
|
102
|
+
|
|
103
|
+
The same is available from Python: `budgetdex.open().search("...", budget=800)`.
|
|
104
|
+
|
|
105
|
+
## Profiles and resources
|
|
106
|
+
|
|
107
|
+
Chosen per index with `budgetdex profile NAME`.
|
|
108
|
+
|
|
109
|
+
| Profile | What it does | Memory (one CLI process) | Search p50 | Extra disk |
|
|
110
|
+
|---|---|---|---|---|
|
|
111
|
+
| `light` | BM25 only, no model | ~19–23 MB | ~35–45 ms | — |
|
|
112
|
+
| `standard` (default) | BM25 + vectors (multilingual-e5-small) | ~205 MB (peaks ~390–470 MB while loading / embedding) | ~50–70 ms | model ~143 MB |
|
|
113
|
+
| `max` | + cross-encoder re-ranking | ~466 MB | ~0.3 s | + ~144 MB |
|
|
114
|
+
|
|
115
|
+
Without the model, `standard` behaves like `light`-style BM25 search. As an MCP server, idle memory is ~51–54 MB (no model is loaded until a search needs it); after 100 searches ~61 MB (`light`) and ~240–260 MB (`standard`). The index file is about 3x the size of the indexed text.
|
|
116
|
+
Measured on one machine (Apple M2 Pro, a 1.5 MB / 1,525-chunk folder, macOS `phys_footprint`). Your numbers will differ.
|
|
117
|
+
|
|
118
|
+
## Connectors (opt-in)
|
|
119
|
+
|
|
120
|
+
Nothing is contacted unless you add it explicitly. Secrets come from an environment variable (`--env VAR`, default `BUDGETDEX_POSTGRES_URL` / `NOTION_TOKEN`) or, on macOS only, the keychain (`--keychain SERVICE`; on Linux/Windows `add --keychain` stops with an error, use `--env`). Secrets are read when needed and never stored in the index, printed or returned to the agent.
|
|
121
|
+
|
|
122
|
+
**Postgres / Supabase** — `budgetdex add postgres [--schema NAME]` (extra `postgres`).
|
|
123
|
+
- At sync, only the schema and planner statistics are read (table and column names, types, comments, approximate counts). No rows are copied into the index.
|
|
124
|
+
- `sql` queries go to the database in a `READ ONLY` transaction with a statement timeout, a server-side cursor, a row cap and one 5 s deadline. A textual pre-check refuses writes first.
|
|
125
|
+
- Limits: these checks are a second line of defence. **Use a database role that can only `SELECT`** — a function with side effects can still run inside a read-only transaction. Joins between local tables and Postgres tables are refused. Tables with row-level security and no policy for your role return 0 rows (the card shows `RLS有効` and `budgetdex status` prints a policy example).
|
|
126
|
+
- Supabase: use the Session pooler connection string with a dedicated read-only role. Step-by-step guide (Japanese) in [README_JA.md](README_JA.md), section “Supabase:手順”.
|
|
127
|
+
|
|
128
|
+
**Notion API** — `budgetdex add notion`.
|
|
129
|
+
- Create an internal integration with only the "Read content" capability and share the pages you want indexed with it. The connector issues only `GET` requests and `POST /search` to `api.notion.com`.
|
|
130
|
+
- Limits: nested blocks up to 8 levels and at most 150 block requests per page; pages cut by a limit or with unreadable blocks are indexed partially and listed in `budgetdex status`. System properties (created by, etc.) are not indexed; people properties only by the display name the API already returns.
|
|
131
|
+
|
|
132
|
+
Notion "Markdown & CSV" export zips can also be added as files (`budgetdex add export.zip`), without any network access.
|
|
133
|
+
|
|
134
|
+
## Privacy and security
|
|
135
|
+
|
|
136
|
+
- **What leaves the machine:** nothing, except (1) the connectors you add (your Postgres host, `api.notion.com`), and (2) the explicit `budgetdex embed --download`. No telemetry.
|
|
137
|
+
- **The model download** fetches exactly two files per model from `https://huggingface.co/<repo>/resolve/<pinned revision>/<file>`, following Hugging Face's redirect to its file CDN (User-Agent `budgetdex`):
|
|
138
|
+
- `Xenova/multilingual-e5-small` @ `761b726d…`: `onnx/model_quantized.onnx` (118,308,185 bytes) and `tokenizer.json` (17,082,730 bytes) — ~135 MB.
|
|
139
|
+
- With `--reranker`: `cross-encoder/mmarco-mMiniLMv2-L12-H384-v1` @ `1427fd65…`: `onnx/model_qint8_arm64.onnx` (118,620,017 bytes, plain int8 ops, runs on any CPU) and `tokenizer.json` (17,082,660 bytes) — ~136 MB.
|
|
140
|
+
- The announced size is checked before reading; size and sha256 are checked before a file is put in place and again when the model is loaded. An interrupted download leaves no partial file. Files go to `$BUDGETDEX_HOME/models/`.
|
|
141
|
+
- **The index is a plaintext copy** of what you indexed (`default.db`, mode 0600, not encrypted). Deleting a source file removes it at the next sync.
|
|
142
|
+
- **Ignored by default:** `.env*`, key files (`*.pem`, `id_rsa*`, ...), names that look like passwords / tokens / API keys, `.git`, `.ssh`, `.aws`, `.gnupg`, `.config`, `node_modules`, `.venv`, ... and `.gitignore`d paths. `--allow GLOB` overrides only `.gitignore`. Obvious secrets (PEM keys, known key prefixes, `password=...`) are masked in output.
|
|
143
|
+
- **Table rows are not in the search index.** Table cards show column names, types and counts, but no cell values unless you opt in per source (`--table-values`). Rows are reachable through `sql`. One exception: when a question word (3+ characters) appears in no document but as a whole word in a text cell of a local table, the search header names the table, column and row count (never the value); personal- and secret-looking columns are never read for this.
|
|
144
|
+
- **Local `sql`** runs on a separate read-only SQLite connection with an authorizer (SELECT on user tables only; no writes, ATTACH, PRAGMA or extensions), a 5 s timeout and a row cap.
|
|
145
|
+
- **Prompt injection cannot be fully prevented.** Results are returned as data with their source, but a document can still contain instructions an agent may follow. Index only what you would let the agent read.
|
|
146
|
+
|
|
147
|
+
See [SECURITY.md](SECURITY.md) to report a problem.
|
|
148
|
+
|
|
149
|
+
## Models and licences
|
|
150
|
+
|
|
151
|
+
No model is bundled; the optional ones are downloaded by you and keep their own licences:
|
|
152
|
+
- `intfloat/multilingual-e5-small` (ONNX build `Xenova/multilingual-e5-small`): MIT. <!-- TODO(owner): confirm on both model cards before release -->
|
|
153
|
+
- `cross-encoder/mmarco-mMiniLMv2-L12-H384-v1`: Apache-2.0 per its model card; it was trained on mMARCO, a translation of MS MARCO, whose terms restrict use to non-commercial research. Check whether that matters for your use before enabling `max`. <!-- TODO(owner): verify -->
|
|
154
|
+
|
|
155
|
+
`src/budgetdex/spm.py` re-implements the SentencePiece-Unigram segmentation of Hugging Face `tokenizers` (Apache-2.0) to save memory; see [NOTICE](NOTICE).
|
|
156
|
+
|
|
157
|
+
## Evaluation (honest version)
|
|
158
|
+
|
|
159
|
+
Measured at retrieval level: a question counts as answered when the answer string appears in the returned text. This is not an end-to-end agent measurement. **Token counts are this package's own estimate, not calibrated against a real tokenizer.**
|
|
160
|
+
|
|
161
|
+
- **Synthetic lab** (generated fictional Notion pages, Postgres tables and files; two unseen seeds, ~90 search questions each): profile `standard` at budget 1,000 answered **92% and 96%** using **~885 tokens** on average; returning the top 10 hits in full answered 93% and 96% using ~2,100–2,200 tokens. The data is synthetic and written by the same project, so real documents may behave differently.
|
|
162
|
+
- **Private set** (60 questions over a real personal folder, not used for tuning, scored once): plain hybrid top-10 RAG 0.73 at 3,802 tokens; `standard` 0.68–0.75 at budgets 1,000–1,900 (~880–1,690 tokens). Roughly the same answer rate at a quarter to a half of the tokens; the difference is within noise. An earlier independent 50-question set did *not* reach parity (0.52 vs 0.62).
|
|
163
|
+
- **Weak spots:** questions in another language than the document (e.g. English question, Japanese column names), paraphrases that share no words with the text, and detecting that the answer is not in the index at all.
|
|
164
|
+
|
|
165
|
+
## Limitations
|
|
166
|
+
|
|
167
|
+
- Alpha: the index format and output may change between 0.0.x versions.
|
|
168
|
+
- Output headers and messages are in Japanese.
|
|
169
|
+
- Cross-language and paraphrase questions are clearly weaker than same-language keyword questions (see above).
|
|
170
|
+
- Local table columns (CSV, TSV, xlsx, Notion databases) are stored as INTEGER or REAL in `sql` only when every non-empty cell is a clean number (no leading zeros, at most 15 digits, thousands separators like `1,234` allowed, decimals that a double keeps exactly); empty cells of those columns are NULL. Everything else stays text: codes with leading zeros (`007`, postal codes), longer digit strings, full-width digits, currency / units / percentages (`¥1,200`, `30%`), `(5)`, dates and mixed columns. The table card says 整数 / 数値 for numeric columns and 数字の文字列 for numeric-looking text, which compares as text (cast it yourself if you need numbers). Indexes from before this change are converted once when opened writable (`budgetdex status` shows tables still waiting).
|
|
171
|
+
- Token counts are estimates; leave some margin in a hard context limit.
|
|
172
|
+
- One index per `BUDGETDEX_HOME`; no multi-user or server mode.
|
|
173
|
+
- macOS keychain support only on macOS; Windows is untested.
|
|
174
|
+
|
|
175
|
+
## Uninstall
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
claude mcp remove budgetdex # if you registered it with Claude Code
|
|
179
|
+
uv tool uninstall budgetdex # or: pipx uninstall budgetdex
|
|
180
|
+
rm -rf ~/.budgetdex # the index and downloaded models ($BUDGETDEX_HOME if you set it)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Keychain items you created for connectors are not touched; delete them with `security delete-generic-password -s SERVICE`.
|
|
184
|
+
|
|
185
|
+
## Development
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
uv sync --all-extras && uv run pytest -q
|
|
189
|
+
uv run budgetdex bench eval/sample/questions.jsonl --corpus eval/sample/corpus
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) and [CHANGELOG.md](CHANGELOG.md). Licensed under the [Apache License 2.0](LICENSE).
|