memcrumbs 0.2.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.
- memcrumbs-0.2.0/LICENSE +202 -0
- memcrumbs-0.2.0/PKG-INFO +153 -0
- memcrumbs-0.2.0/README.md +133 -0
- memcrumbs-0.2.0/memcrumbs/__init__.py +6 -0
- memcrumbs-0.2.0/memcrumbs/__main__.py +3 -0
- memcrumbs-0.2.0/memcrumbs/bench.py +138 -0
- memcrumbs-0.2.0/memcrumbs/cites.py +136 -0
- memcrumbs-0.2.0/memcrumbs/claude_settings.py +148 -0
- memcrumbs-0.2.0/memcrumbs/cli.py +300 -0
- memcrumbs-0.2.0/memcrumbs/cli_args.py +140 -0
- memcrumbs-0.2.0/memcrumbs/cmd_read.py +271 -0
- memcrumbs-0.2.0/memcrumbs/cmd_setup.py +49 -0
- memcrumbs-0.2.0/memcrumbs/cmd_write.py +114 -0
- memcrumbs-0.2.0/memcrumbs/curate.py +120 -0
- memcrumbs-0.2.0/memcrumbs/dashboard.py +204 -0
- memcrumbs-0.2.0/memcrumbs/doctor.py +258 -0
- memcrumbs-0.2.0/memcrumbs/dupes.py +85 -0
- memcrumbs-0.2.0/memcrumbs/facts.py +256 -0
- memcrumbs-0.2.0/memcrumbs/freshness.py +231 -0
- memcrumbs-0.2.0/memcrumbs/guard.py +30 -0
- memcrumbs-0.2.0/memcrumbs/header.py +182 -0
- memcrumbs-0.2.0/memcrumbs/indexer.py +87 -0
- memcrumbs-0.2.0/memcrumbs/jsonedit.py +87 -0
- memcrumbs-0.2.0/memcrumbs/lint.py +161 -0
- memcrumbs-0.2.0/memcrumbs/lint_records.py +57 -0
- memcrumbs-0.2.0/memcrumbs/markdown.py +262 -0
- memcrumbs-0.2.0/memcrumbs/outline/__init__.py +56 -0
- memcrumbs-0.2.0/memcrumbs/outline/braces.py +33 -0
- memcrumbs-0.2.0/memcrumbs/outline/md.py +21 -0
- memcrumbs-0.2.0/memcrumbs/outline/mql.py +59 -0
- memcrumbs-0.2.0/memcrumbs/outline/ps.py +44 -0
- memcrumbs-0.2.0/memcrumbs/outline/py.py +69 -0
- memcrumbs-0.2.0/memcrumbs/output.py +95 -0
- memcrumbs-0.2.0/memcrumbs/packs/__init__.py +1 -0
- memcrumbs-0.2.0/memcrumbs/plan.py +202 -0
- memcrumbs-0.2.0/memcrumbs/plugins.py +105 -0
- memcrumbs-0.2.0/memcrumbs/project.py +167 -0
- memcrumbs-0.2.0/memcrumbs/query.py +112 -0
- memcrumbs-0.2.0/memcrumbs/rank.py +152 -0
- memcrumbs-0.2.0/memcrumbs/redact.py +226 -0
- memcrumbs-0.2.0/memcrumbs/review.py +206 -0
- memcrumbs-0.2.0/memcrumbs/sources.py +154 -0
- memcrumbs-0.2.0/memcrumbs/store.py +359 -0
- memcrumbs-0.2.0/memcrumbs/suggest.py +233 -0
- memcrumbs-0.2.0/memcrumbs/suggest_gaps.py +222 -0
- memcrumbs-0.2.0/memcrumbs/suggest_guard.py +405 -0
- memcrumbs-0.2.0/memcrumbs/suggest_memory.py +176 -0
- memcrumbs-0.2.0/memcrumbs/suggest_skill.py +339 -0
- memcrumbs-0.2.0/memcrumbs/suggest_state.py +201 -0
- memcrumbs-0.2.0/memcrumbs/suggest_wiki.py +123 -0
- memcrumbs-0.2.0/memcrumbs/synonyms.py +104 -0
- memcrumbs-0.2.0/memcrumbs/templates/agents_block.md +11 -0
- memcrumbs-0.2.0/memcrumbs/templates/claude_block.md +11 -0
- memcrumbs-0.2.0/memcrumbs/templates/dashboard.html +279 -0
- memcrumbs-0.2.0/memcrumbs/templates/dashboard.js +708 -0
- memcrumbs-0.2.0/memcrumbs/templates/gotchas.md +12 -0
- memcrumbs-0.2.0/memcrumbs/templates/index.md +15 -0
- memcrumbs-0.2.0/memcrumbs/templates/markdown.js +146 -0
- memcrumbs-0.2.0/memcrumbs/templates/memcrumbs.toml +31 -0
- memcrumbs-0.2.0/memcrumbs/templates/page.md +14 -0
- memcrumbs-0.2.0/memcrumbs/templates/rules.md +12 -0
- memcrumbs-0.2.0/memcrumbs/templates/skill.md +59 -0
- memcrumbs-0.2.0/memcrumbs/transcripts.py +174 -0
- memcrumbs-0.2.0/memcrumbs/usage.py +108 -0
- memcrumbs-0.2.0/memcrumbs/util.py +178 -0
- memcrumbs-0.2.0/memcrumbs/verdicts.py +79 -0
- memcrumbs-0.2.0/memcrumbs/wire.py +191 -0
- memcrumbs-0.2.0/memcrumbs/writeset.py +108 -0
- memcrumbs-0.2.0/memcrumbs.egg-info/PKG-INFO +153 -0
- memcrumbs-0.2.0/memcrumbs.egg-info/SOURCES.txt +90 -0
- memcrumbs-0.2.0/memcrumbs.egg-info/dependency_links.txt +1 -0
- memcrumbs-0.2.0/memcrumbs.egg-info/entry_points.txt +3 -0
- memcrumbs-0.2.0/memcrumbs.egg-info/top_level.txt +1 -0
- memcrumbs-0.2.0/pyproject.toml +34 -0
- memcrumbs-0.2.0/setup.cfg +4 -0
- memcrumbs-0.2.0/tests/test_bench.py +140 -0
- memcrumbs-0.2.0/tests/test_cli.py +160 -0
- memcrumbs-0.2.0/tests/test_compat.py +87 -0
- memcrumbs-0.2.0/tests/test_core.py +149 -0
- memcrumbs-0.2.0/tests/test_edge_cases.py +182 -0
- memcrumbs-0.2.0/tests/test_genblocks.py +82 -0
- memcrumbs-0.2.0/tests/test_hygiene.py +40 -0
- memcrumbs-0.2.0/tests/test_index.py +124 -0
- memcrumbs-0.2.0/tests/test_plan.py +118 -0
- memcrumbs-0.2.0/tests/test_ranking.py +91 -0
- memcrumbs-0.2.0/tests/test_records.py +177 -0
- memcrumbs-0.2.0/tests/test_redact.py +138 -0
- memcrumbs-0.2.0/tests/test_review.py +113 -0
- memcrumbs-0.2.0/tests/test_safety.py +193 -0
- memcrumbs-0.2.0/tests/test_suggest.py +535 -0
- memcrumbs-0.2.0/tests/test_verdicts.py +111 -0
- memcrumbs-0.2.0/tests/test_wire.py +130 -0
memcrumbs-0.2.0/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.
|
memcrumbs-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: memcrumbs
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Breadcrumbs of project memory for coding agents: a markdown wiki + token-efficient index (stdlib only)
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Keywords: agents,claude-code,wiki,memory,search,sqlite,fts5
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Environment :: Console
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# memcrumbs
|
|
22
|
+
|
|
23
|
+
**Project memory for Claude Code and other coding agents: a small markdown wiki your agent reads before it
|
|
24
|
+
reads your code, and a local index that answers in a few hundred tokens.**
|
|
25
|
+
|
|
26
|
+
Every new session, a coding agent starts from zero. It greps, it reads whole files, it rediscovers the same
|
|
27
|
+
facts, and it repeats mistakes your team already made. Notes kept by hand drift until they contradict the
|
|
28
|
+
system, and sometimes they leak a secret.
|
|
29
|
+
|
|
30
|
+
memcrumbs gives each project a memory that stays small, current and safe.
|
|
31
|
+
|
|
32
|
+
## What it does for you
|
|
33
|
+
|
|
34
|
+
- **Your agent starts every session knowing the rules.** A short header (under 1,000 tokens) brings your
|
|
35
|
+
standing rules, the project map, the top gotchas and recent journal lines, so "never deploy on Friday" is
|
|
36
|
+
read before anything else.
|
|
37
|
+
- **Answers instead of file dumps.** `memcrumbs find "how do I roll back a bad deploy"` returns a few ranked hits
|
|
38
|
+
with `path:line`, how old each one is and whether it is still current. The agent then opens one section or
|
|
39
|
+
one function, not a 4,000-line file.
|
|
40
|
+
- **It remembers what happened and why.** Decisions (including the ones you rejected), incidents with the
|
|
41
|
+
symptom someone will see next time, runbooks, and a dated journal. Asking "did we ever try Postgres?" finds
|
|
42
|
+
the rejected decision instead of a fresh attempt.
|
|
43
|
+
- **It knows when it may be wrong.** Every hit says how long ago it was verified, flags `STALE` pages, and says
|
|
44
|
+
`SRC-CHANGED` when the code a page describes changed after the page was checked.
|
|
45
|
+
- **It tells the agent what the wiki says about a file before it edits it.** `memcrumbs about deploy.ps1` lists
|
|
46
|
+
the decisions, incidents and gotchas that mention it.
|
|
47
|
+
- **It keeps one current value per fact.** Versions, ports and hosts live in one table, optionally read straight
|
|
48
|
+
from the source file, and `check` flags pages that still state an old value.
|
|
49
|
+
- **It notices things for you, and asks first.** `memcrumbs suggest` offers near-duplicate pages to merge,
|
|
50
|
+
questions the wiki could not answer, gotchas that can become permission prompts, repeated command sequences
|
|
51
|
+
that could become a skill, and auto-memory notes the wiki already holds. Nothing changes until you say yes,
|
|
52
|
+
and every change can be undone byte for byte.
|
|
53
|
+
- **Your secrets stay out.** Everything indexed, printed or written is redacted; `.env` files and keys are never
|
|
54
|
+
indexed; `memcrumbs scan` checks a folder or a package before you publish it.
|
|
55
|
+
- **You stay in control of token spend.** Re-indexing is free and local. Rewriting stale pages is agent work, so
|
|
56
|
+
`memcrumbs plan` and the dashboard let you pick the pages and the budget.
|
|
57
|
+
|
|
58
|
+
Standard library only: no model calls, no network, no background service, no per-tool-call hooks. Your wiki is
|
|
59
|
+
plain markdown in your own folder.
|
|
60
|
+
|
|
61
|
+
## What it looks like
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
$ memcrumbs find "how do I roll back a bad deploy" -n 3
|
|
65
|
+
[run ] Roll back booking app — wiki/runbooks/rollback-booking.md:1 · v8d
|
|
66
|
+
…booking [release] in under two minutes by repointing the current junction [Roll back] booking…
|
|
67
|
+
[run ] Deploy booking app — wiki/runbooks/deploy-booking.md:1 · v8d
|
|
68
|
+
Numbered steps to [ship] a new booking app [release] to web-srv, with the…
|
|
69
|
+
[wiki] Booking web app › Behaviour notes — wiki/components/booking-app.md:23 · v8d
|
|
70
|
+
…[Deploy] with [[deploy-booking]]; [undo] with [[rollback-booking]].
|
|
71
|
+
read: memcrumbs page rollback-booking · more: -n 6
|
|
72
|
+
|
|
73
|
+
$ memcrumbs about repo/ops/EmberOps.psm1
|
|
74
|
+
EmberOps.psm1 — cited by 1 decision (ACCEPTED), 2 incidents, 1 runbook
|
|
75
|
+
[dec ] Unlimited execution time for daemon tasks — wiki/decisions/2026-08-12-execution-time-limit-zero.md:1 · ACCEPTED
|
|
76
|
+
[inc ] BOM in a PowerShell script silently broke a scheduled task — wiki/incidents/2026-07-29-bom-breaks-scheduled-task.md:1
|
|
77
|
+
…
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
(From the invented sample project in `bench/kiln`.)
|
|
81
|
+
|
|
82
|
+
## Install
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install git+https://github.com/mikedconcepcion/memcrumbs # Python 3.11+; puts `memcrumbs` on PATH
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Your wikis live outside the package, in `~/.memcrumbs/projects` by default. To keep them somewhere else (for
|
|
89
|
+
example a private git repo), set `projects_dir` in `~/.memcrumbs/config.toml` or the `MEMCRUMBS_PROJECTS`
|
|
90
|
+
environment variable.
|
|
91
|
+
|
|
92
|
+
## Quick start
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
memcrumbs init myapp --repo /code/myapp --title "My App" # creates the project and a starter wiki
|
|
96
|
+
memcrumbs -p myapp index # builds the index (seconds; incremental afterwards)
|
|
97
|
+
memcrumbs -p myapp wire --repo /code/myapp --apply --allow # CLAUDE.md block, session header hook, skill
|
|
98
|
+
memcrumbs -p myapp doctor # checks the install, the index and the hook
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
From then on, every Claude Code session in that repo starts with the header, and the agent looks things up with
|
|
102
|
+
`memcrumbs find`. Inside the repo (or the project folder) `-p` can be left out. Write the wiki as you go:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
memcrumbs log "rotated the API key" --tag ops # a dated journal line
|
|
106
|
+
memcrumbs decision "Move bookings to Postgres" --status rejected --why "too much to run for our size"
|
|
107
|
+
memcrumbs incident "Nightly task died after 72 h" --symptom "no reports since Tuesday" --cause "task time limit"
|
|
108
|
+
memcrumbs check # lint: secrets, links, stale pages, …
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`wire --remove --apply` takes everything out again, byte for byte. A step-by-step setup that your agent can
|
|
112
|
+
follow is in [docs/adopting.md](docs/adopting.md).
|
|
113
|
+
|
|
114
|
+
## Everyday commands
|
|
115
|
+
|
|
116
|
+
| Command | What you get |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `find <words>` | Ranked hits with `path:line`, age and status. Filters: `kind:decision status:rejected path:booking` |
|
|
119
|
+
| `page <name> [section]` | A page, or one section of it |
|
|
120
|
+
| `outline <file>` · `sym <name> [--body]` | Functions and classes with line ranges · where a symbol is defined |
|
|
121
|
+
| `about <file>` · `fact [key]` | What the wiki says about a file · a current value with its source |
|
|
122
|
+
| `log` · `decision` · `incident` · `rule` | Write the journal, a decision, an incident, a standing rule |
|
|
123
|
+
| `verify <page>` · `supersede <page> --by <new>` | Mark a page re-checked today · replaced by a newer one |
|
|
124
|
+
| `suggest` · `suggest apply ID` · `suggest undo ID` | Offers to improve the wiki and the agent setup, applied only on your yes |
|
|
125
|
+
| `check` · `scan [path]` | Lint the wiki · secret-scan a folder, an sdist or a wheel |
|
|
126
|
+
| `plan` · `dashboard --open` | What needs a refresh and what it would cost · an HTML overview |
|
|
127
|
+
| `doctor` · `stats --usage` · `bench` | Health check · output size per command · lookup quality on your own questions |
|
|
128
|
+
|
|
129
|
+
Every command takes `--json`. Full reference: [docs/cli.md](docs/cli.md).
|
|
130
|
+
|
|
131
|
+
## Documentation
|
|
132
|
+
|
|
133
|
+
- [Setting up a project](docs/adopting.md), step by step
|
|
134
|
+
- [Writing good crumbs](docs/writing-crumbs.md): pages, rules, gotchas, decisions, incidents, facts
|
|
135
|
+
- [Configuration](docs/config.md) · [Command reference](docs/cli.md)
|
|
136
|
+
- [Plugins and packs](docs/plugins.md): add a source, a check, a header section or a language
|
|
137
|
+
- [Security](SECURITY.md): what redaction promises and what it does not
|
|
138
|
+
|
|
139
|
+
## Contributing and reporting bugs
|
|
140
|
+
|
|
141
|
+
- **Found a bug?** [Open an issue](https://github.com/mikedconcepcion/memcrumbs/issues/new/choose) with the bug
|
|
142
|
+
template. Paste the output of `memcrumbs doctor --share`: it holds versions, counts and timings only, never
|
|
143
|
+
your paths, page text or secrets.
|
|
144
|
+
- **An idea or a missing feature?** Use the feature request template. Say what you were trying to do.
|
|
145
|
+
- **A security problem?** Please report it privately, as described in [SECURITY.md](SECURITY.md), not in a
|
|
146
|
+
public issue.
|
|
147
|
+
- **Want to contribute code or docs?** See [CONTRIBUTING.md](CONTRIBUTING.md): how to run the tests, the few
|
|
148
|
+
rules the code follows, and what a good pull request looks like.
|
|
149
|
+
|
|
150
|
+
## Status
|
|
151
|
+
|
|
152
|
+
Alpha: usable day to day, with the command line and config still allowed to change before 1.0. Changes are
|
|
153
|
+
listed in [CHANGELOG.md](CHANGELOG.md). License: [Apache-2.0](LICENSE).
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# memcrumbs
|
|
2
|
+
|
|
3
|
+
**Project memory for Claude Code and other coding agents: a small markdown wiki your agent reads before it
|
|
4
|
+
reads your code, and a local index that answers in a few hundred tokens.**
|
|
5
|
+
|
|
6
|
+
Every new session, a coding agent starts from zero. It greps, it reads whole files, it rediscovers the same
|
|
7
|
+
facts, and it repeats mistakes your team already made. Notes kept by hand drift until they contradict the
|
|
8
|
+
system, and sometimes they leak a secret.
|
|
9
|
+
|
|
10
|
+
memcrumbs gives each project a memory that stays small, current and safe.
|
|
11
|
+
|
|
12
|
+
## What it does for you
|
|
13
|
+
|
|
14
|
+
- **Your agent starts every session knowing the rules.** A short header (under 1,000 tokens) brings your
|
|
15
|
+
standing rules, the project map, the top gotchas and recent journal lines, so "never deploy on Friday" is
|
|
16
|
+
read before anything else.
|
|
17
|
+
- **Answers instead of file dumps.** `memcrumbs find "how do I roll back a bad deploy"` returns a few ranked hits
|
|
18
|
+
with `path:line`, how old each one is and whether it is still current. The agent then opens one section or
|
|
19
|
+
one function, not a 4,000-line file.
|
|
20
|
+
- **It remembers what happened and why.** Decisions (including the ones you rejected), incidents with the
|
|
21
|
+
symptom someone will see next time, runbooks, and a dated journal. Asking "did we ever try Postgres?" finds
|
|
22
|
+
the rejected decision instead of a fresh attempt.
|
|
23
|
+
- **It knows when it may be wrong.** Every hit says how long ago it was verified, flags `STALE` pages, and says
|
|
24
|
+
`SRC-CHANGED` when the code a page describes changed after the page was checked.
|
|
25
|
+
- **It tells the agent what the wiki says about a file before it edits it.** `memcrumbs about deploy.ps1` lists
|
|
26
|
+
the decisions, incidents and gotchas that mention it.
|
|
27
|
+
- **It keeps one current value per fact.** Versions, ports and hosts live in one table, optionally read straight
|
|
28
|
+
from the source file, and `check` flags pages that still state an old value.
|
|
29
|
+
- **It notices things for you, and asks first.** `memcrumbs suggest` offers near-duplicate pages to merge,
|
|
30
|
+
questions the wiki could not answer, gotchas that can become permission prompts, repeated command sequences
|
|
31
|
+
that could become a skill, and auto-memory notes the wiki already holds. Nothing changes until you say yes,
|
|
32
|
+
and every change can be undone byte for byte.
|
|
33
|
+
- **Your secrets stay out.** Everything indexed, printed or written is redacted; `.env` files and keys are never
|
|
34
|
+
indexed; `memcrumbs scan` checks a folder or a package before you publish it.
|
|
35
|
+
- **You stay in control of token spend.** Re-indexing is free and local. Rewriting stale pages is agent work, so
|
|
36
|
+
`memcrumbs plan` and the dashboard let you pick the pages and the budget.
|
|
37
|
+
|
|
38
|
+
Standard library only: no model calls, no network, no background service, no per-tool-call hooks. Your wiki is
|
|
39
|
+
plain markdown in your own folder.
|
|
40
|
+
|
|
41
|
+
## What it looks like
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
$ memcrumbs find "how do I roll back a bad deploy" -n 3
|
|
45
|
+
[run ] Roll back booking app — wiki/runbooks/rollback-booking.md:1 · v8d
|
|
46
|
+
…booking [release] in under two minutes by repointing the current junction [Roll back] booking…
|
|
47
|
+
[run ] Deploy booking app — wiki/runbooks/deploy-booking.md:1 · v8d
|
|
48
|
+
Numbered steps to [ship] a new booking app [release] to web-srv, with the…
|
|
49
|
+
[wiki] Booking web app › Behaviour notes — wiki/components/booking-app.md:23 · v8d
|
|
50
|
+
…[Deploy] with [[deploy-booking]]; [undo] with [[rollback-booking]].
|
|
51
|
+
read: memcrumbs page rollback-booking · more: -n 6
|
|
52
|
+
|
|
53
|
+
$ memcrumbs about repo/ops/EmberOps.psm1
|
|
54
|
+
EmberOps.psm1 — cited by 1 decision (ACCEPTED), 2 incidents, 1 runbook
|
|
55
|
+
[dec ] Unlimited execution time for daemon tasks — wiki/decisions/2026-08-12-execution-time-limit-zero.md:1 · ACCEPTED
|
|
56
|
+
[inc ] BOM in a PowerShell script silently broke a scheduled task — wiki/incidents/2026-07-29-bom-breaks-scheduled-task.md:1
|
|
57
|
+
…
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
(From the invented sample project in `bench/kiln`.)
|
|
61
|
+
|
|
62
|
+
## Install
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install git+https://github.com/mikedconcepcion/memcrumbs # Python 3.11+; puts `memcrumbs` on PATH
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Your wikis live outside the package, in `~/.memcrumbs/projects` by default. To keep them somewhere else (for
|
|
69
|
+
example a private git repo), set `projects_dir` in `~/.memcrumbs/config.toml` or the `MEMCRUMBS_PROJECTS`
|
|
70
|
+
environment variable.
|
|
71
|
+
|
|
72
|
+
## Quick start
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
memcrumbs init myapp --repo /code/myapp --title "My App" # creates the project and a starter wiki
|
|
76
|
+
memcrumbs -p myapp index # builds the index (seconds; incremental afterwards)
|
|
77
|
+
memcrumbs -p myapp wire --repo /code/myapp --apply --allow # CLAUDE.md block, session header hook, skill
|
|
78
|
+
memcrumbs -p myapp doctor # checks the install, the index and the hook
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
From then on, every Claude Code session in that repo starts with the header, and the agent looks things up with
|
|
82
|
+
`memcrumbs find`. Inside the repo (or the project folder) `-p` can be left out. Write the wiki as you go:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
memcrumbs log "rotated the API key" --tag ops # a dated journal line
|
|
86
|
+
memcrumbs decision "Move bookings to Postgres" --status rejected --why "too much to run for our size"
|
|
87
|
+
memcrumbs incident "Nightly task died after 72 h" --symptom "no reports since Tuesday" --cause "task time limit"
|
|
88
|
+
memcrumbs check # lint: secrets, links, stale pages, …
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`wire --remove --apply` takes everything out again, byte for byte. A step-by-step setup that your agent can
|
|
92
|
+
follow is in [docs/adopting.md](docs/adopting.md).
|
|
93
|
+
|
|
94
|
+
## Everyday commands
|
|
95
|
+
|
|
96
|
+
| Command | What you get |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `find <words>` | Ranked hits with `path:line`, age and status. Filters: `kind:decision status:rejected path:booking` |
|
|
99
|
+
| `page <name> [section]` | A page, or one section of it |
|
|
100
|
+
| `outline <file>` · `sym <name> [--body]` | Functions and classes with line ranges · where a symbol is defined |
|
|
101
|
+
| `about <file>` · `fact [key]` | What the wiki says about a file · a current value with its source |
|
|
102
|
+
| `log` · `decision` · `incident` · `rule` | Write the journal, a decision, an incident, a standing rule |
|
|
103
|
+
| `verify <page>` · `supersede <page> --by <new>` | Mark a page re-checked today · replaced by a newer one |
|
|
104
|
+
| `suggest` · `suggest apply ID` · `suggest undo ID` | Offers to improve the wiki and the agent setup, applied only on your yes |
|
|
105
|
+
| `check` · `scan [path]` | Lint the wiki · secret-scan a folder, an sdist or a wheel |
|
|
106
|
+
| `plan` · `dashboard --open` | What needs a refresh and what it would cost · an HTML overview |
|
|
107
|
+
| `doctor` · `stats --usage` · `bench` | Health check · output size per command · lookup quality on your own questions |
|
|
108
|
+
|
|
109
|
+
Every command takes `--json`. Full reference: [docs/cli.md](docs/cli.md).
|
|
110
|
+
|
|
111
|
+
## Documentation
|
|
112
|
+
|
|
113
|
+
- [Setting up a project](docs/adopting.md), step by step
|
|
114
|
+
- [Writing good crumbs](docs/writing-crumbs.md): pages, rules, gotchas, decisions, incidents, facts
|
|
115
|
+
- [Configuration](docs/config.md) · [Command reference](docs/cli.md)
|
|
116
|
+
- [Plugins and packs](docs/plugins.md): add a source, a check, a header section or a language
|
|
117
|
+
- [Security](SECURITY.md): what redaction promises and what it does not
|
|
118
|
+
|
|
119
|
+
## Contributing and reporting bugs
|
|
120
|
+
|
|
121
|
+
- **Found a bug?** [Open an issue](https://github.com/mikedconcepcion/memcrumbs/issues/new/choose) with the bug
|
|
122
|
+
template. Paste the output of `memcrumbs doctor --share`: it holds versions, counts and timings only, never
|
|
123
|
+
your paths, page text or secrets.
|
|
124
|
+
- **An idea or a missing feature?** Use the feature request template. Say what you were trying to do.
|
|
125
|
+
- **A security problem?** Please report it privately, as described in [SECURITY.md](SECURITY.md), not in a
|
|
126
|
+
public issue.
|
|
127
|
+
- **Want to contribute code or docs?** See [CONTRIBUTING.md](CONTRIBUTING.md): how to run the tests, the few
|
|
128
|
+
rules the code follows, and what a good pull request looks like.
|
|
129
|
+
|
|
130
|
+
## Status
|
|
131
|
+
|
|
132
|
+
Alpha: usable day to day, with the command line and config still allowed to change before 1.0. Changes are
|
|
133
|
+
listed in [CHANGELOG.md](CHANGELOG.md). License: [Apache-2.0](LICENSE).
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""memcrumbs - breadcrumbs of project memory for coding agents: a wiki plus a token-efficient index.
|
|
2
|
+
|
|
3
|
+
Layers: core (this package: wiki, index, outline, checks) -> packs (memcrumbs.packs.*: reusable domain add-ons)
|
|
4
|
+
-> project (<projects_dir>/<name>/: memcrumbs.toml, wiki/, plugins/ tailored to one project).
|
|
5
|
+
"""
|
|
6
|
+
__version__ = "0.2.0"
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"""`memcrumbs bench QUESTIONS.toml`: recall@1 / recall@3 / MRR, tokens per answer and latency, against any
|
|
2
|
+
project (public or private) with no code changes.
|
|
3
|
+
|
|
4
|
+
[[q]]
|
|
5
|
+
id = "rb-01"
|
|
6
|
+
q = "how do I roll back a bad deploy?"
|
|
7
|
+
expect = ["wiki/runbooks/rollback.md"] # path suffixes; any one in the top k counts
|
|
8
|
+
category = "runbook" # optional; results are also broken down by category
|
|
9
|
+
|
|
10
|
+
A hit matches an expected path when its file path ends with it (`wiki/x.md`, `repo/app.py`); `path#Section`
|
|
11
|
+
also requires the hit's section to contain that text. Tokens are the `find` output's chars/4 (estimate)."""
|
|
12
|
+
import io
|
|
13
|
+
import json
|
|
14
|
+
import time
|
|
15
|
+
import tomllib
|
|
16
|
+
from contextlib import redirect_stdout
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
from memcrumbs import cmd_read, writeset
|
|
20
|
+
from memcrumbs.output import Out, est_tokens
|
|
21
|
+
from memcrumbs.util import posix
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def load(path):
|
|
25
|
+
with open(path, "rb") as f:
|
|
26
|
+
qs = tomllib.load(f).get("q", [])
|
|
27
|
+
for i, q in enumerate(qs):
|
|
28
|
+
if not q.get("q") or not q.get("expect"):
|
|
29
|
+
raise SystemExit("bench: question %d needs q and expect" % (i + 1))
|
|
30
|
+
q.setdefault("id", "q%d" % (i + 1))
|
|
31
|
+
return qs
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _match(hit, expect):
|
|
35
|
+
path = "/" + posix(hit["path"]).lstrip("/")
|
|
36
|
+
for e in expect:
|
|
37
|
+
target, _, section = e.partition("#")
|
|
38
|
+
if path.lower().endswith("/" + target.strip("/").lower()) and \
|
|
39
|
+
(not section or section.lower() in (hit.get("section") or "").lower()):
|
|
40
|
+
return True
|
|
41
|
+
return False
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def run(project, store, questions, k=8):
|
|
45
|
+
rows = []
|
|
46
|
+
for q in questions:
|
|
47
|
+
t0 = time.perf_counter()
|
|
48
|
+
hits = store.search(q["q"], kinds=q.get("kinds"), limit=k)
|
|
49
|
+
ms = (time.perf_counter() - t0) * 1000
|
|
50
|
+
buf = io.StringIO()
|
|
51
|
+
with redirect_stdout(buf): # the exact text an agent would read
|
|
52
|
+
out = Out("find", None, project.redact)
|
|
53
|
+
cmd_read.find(out, project, store, q["q"], q.get("kinds"), k, track=False)
|
|
54
|
+
out.close()
|
|
55
|
+
rank = next((i + 1 for i, h in enumerate(hits) if _match(h, q["expect"])), None)
|
|
56
|
+
followed = next((i + 1 for i, h in enumerate(hits) if _match(h, q["expect"]) or
|
|
57
|
+
(h.get("see") and _match(h["see"], q["expect"]))), None)
|
|
58
|
+
rows.append(dict(id=q["id"], q=q["q"], category=q.get("category", ""), paraphrase=bool(q.get("paraphrase")),
|
|
59
|
+
rank=rank, followed=followed, ms=round(ms, 1), tokens=est_tokens(len(buf.getvalue())),
|
|
60
|
+
top3=[project.rel(h["path"]) for h in hits[:3]]))
|
|
61
|
+
return rows
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _agg(rows):
|
|
65
|
+
n = len(rows) or 1
|
|
66
|
+
ms, toks = sorted(r["ms"] for r in rows), sorted(r["tokens"] for r in rows)
|
|
67
|
+
pct = (lambda xs, p: xs[min(len(xs) - 1, int(p * len(xs)))] if xs else 0)
|
|
68
|
+
return dict(n=len(rows), recall_at_1=round(sum(1 for r in rows if r["rank"] == 1) / n, 3),
|
|
69
|
+
recall_at_3=round(sum(1 for r in rows if r["rank"] and r["rank"] <= 3) / n, 3),
|
|
70
|
+
recall_at_3_with_pointers=round(sum(1 for r in rows if r.get("followed") and r["followed"] <= 3) / n, 3),
|
|
71
|
+
mrr=round(sum(1 / r["rank"] for r in rows if r["rank"]) / n, 3),
|
|
72
|
+
tokens_mean=round(sum(toks) / n), tokens_p95=pct(toks, 0.95),
|
|
73
|
+
ms_mean=round(sum(ms) / n, 1), ms_p95=pct(ms, 0.95))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def default_path(project):
|
|
77
|
+
"""The project's own bench, grown from real use with `memcrumbs bench --add` (kept with the wiki)."""
|
|
78
|
+
return project.wiki / "bench.toml"
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def add(out, project, question, expects, category=""):
|
|
82
|
+
"""Record a question the wiki should answer, with the file(s) that do. Run it when a lookup missed."""
|
|
83
|
+
from memcrumbs.curate import exact_page
|
|
84
|
+
if not expects:
|
|
85
|
+
raise SystemExit("memcrumbs: --add needs --expect <page or file>")
|
|
86
|
+
targets = []
|
|
87
|
+
for e in expects:
|
|
88
|
+
try:
|
|
89
|
+
targets.append(project.rel(exact_page(project, e)))
|
|
90
|
+
except SystemExit:
|
|
91
|
+
p = Path(e).expanduser().resolve()
|
|
92
|
+
if not p.exists():
|
|
93
|
+
raise SystemExit("memcrumbs: no page or file %r" % e)
|
|
94
|
+
try:
|
|
95
|
+
targets.append(posix(p.relative_to(project.dir)))
|
|
96
|
+
except ValueError:
|
|
97
|
+
targets.append(posix(p))
|
|
98
|
+
path = default_path(project)
|
|
99
|
+
head = "" if path.exists() else ("# Questions this wiki must answer (memcrumbs bench). Added with "
|
|
100
|
+
"`memcrumbs bench --add`.\n")
|
|
101
|
+
n = len(load(path)) + 1 if path.exists() else 1
|
|
102
|
+
entry = '%s\n[[q]]\nid = "real-%03d"\nq = %s\nexpect = [%s]\n%s' % (
|
|
103
|
+
head, n, json.dumps(project.redact(question), ensure_ascii=False), ", ".join(json.dumps(t) for t in targets),
|
|
104
|
+
("category = %s\n" % json.dumps(category)) if category else "")
|
|
105
|
+
writeset.append_text(project, path, entry)
|
|
106
|
+
out.set(path=project.rel(path), id="real-%03d" % n, expect=targets)
|
|
107
|
+
out("added real-%03d to %s (%d questions) — memcrumbs bench to measure" % (n, project.rel(path), n))
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def report(out, project, store, path, min_recall3=None, k=8):
|
|
111
|
+
path = path or default_path(project)
|
|
112
|
+
if not Path(path).exists():
|
|
113
|
+
raise SystemExit("memcrumbs: no questions at %s — record real ones with: memcrumbs bench --add \"<question>\" "
|
|
114
|
+
"--expect <page>" % posix(path))
|
|
115
|
+
rows = run(project, store, load(path), k)
|
|
116
|
+
total = _agg(rows)
|
|
117
|
+
cats = {c: _agg([r for r in rows if r["category"] == c]) for c in sorted({r["category"] for r in rows if r["category"]})}
|
|
118
|
+
para = _agg([r for r in rows if r["paraphrase"]])
|
|
119
|
+
misses = [r for r in rows if not r["rank"] or r["rank"] > 3]
|
|
120
|
+
out.list_key = "questions"
|
|
121
|
+
out.set(project=project.name, questions_file=posix(path), total=total, by_category=cats, paraphrase=para,
|
|
122
|
+
questions=rows)
|
|
123
|
+
out.hint("memcrumbs bench %s --json --full" % posix(path))
|
|
124
|
+
out("bench %s · %d questions · recall@1 %.3f · recall@3 %.3f · MRR %.3f" % (
|
|
125
|
+
project.name, total["n"], total["recall_at_1"], total["recall_at_3"], total["mrr"]))
|
|
126
|
+
out("recall@3 counting '→ see' pointers under a hit: %.3f" % total["recall_at_3_with_pointers"])
|
|
127
|
+
out("tokens/answer mean %d p95 %d (est.) · search latency mean %.1f ms p95 %.1f ms" % (
|
|
128
|
+
total["tokens_mean"], total["tokens_p95"], total["ms_mean"], total["ms_p95"]))
|
|
129
|
+
if para["n"]:
|
|
130
|
+
out("paraphrased questions: %d · recall@3 %.3f" % (para["n"], para["recall_at_3"]))
|
|
131
|
+
for c, a in cats.items():
|
|
132
|
+
out(" %-12s n=%-3d r@1 %.2f r@3 %.2f" % (c, a["n"], a["recall_at_1"], a["recall_at_3"]))
|
|
133
|
+
for r in misses:
|
|
134
|
+
out("miss %s (rank %s): %s → %s" % (r["id"], r["rank"] or "-", r["q"], ", ".join(r["top3"]) or "no hits"))
|
|
135
|
+
if min_recall3 is not None and total["recall_at_3"] < min_recall3:
|
|
136
|
+
out("FAIL: recall@3 %.3f < %.3f" % (total["recall_at_3"], min_recall3))
|
|
137
|
+
return 1
|
|
138
|
+
return 0
|