pyrefman 0.1.0a1__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.
- pyrefman-0.1.0a1/.githooks/pre-commit +18 -0
- pyrefman-0.1.0a1/.github/workflows/ci.yml +36 -0
- pyrefman-0.1.0a1/.gitignore +13 -0
- pyrefman-0.1.0a1/AGENTS.md +31 -0
- pyrefman-0.1.0a1/CHANGELOG.md +42 -0
- pyrefman-0.1.0a1/CODING_STANDARDS.md +38 -0
- pyrefman-0.1.0a1/GLOSSARY.md +81 -0
- pyrefman-0.1.0a1/LICENSE +21 -0
- pyrefman-0.1.0a1/PKG-INFO +57 -0
- pyrefman-0.1.0a1/README.md +42 -0
- pyrefman-0.1.0a1/docs/adr/0001-files-are-the-record.md +15 -0
- pyrefman-0.1.0a1/docs/adr/0002-csl-yaml-as-record-format.md +14 -0
- pyrefman-0.1.0a1/docs/adr/0003-plugins-through-entry-points.md +20 -0
- pyrefman-0.1.0a1/docs/adr/0004-sqlite-is-an-opt-in-store.md +9 -0
- pyrefman-0.1.0a1/docs/adr/index.md +13 -0
- pyrefman-0.1.0a1/docs/agents/domain.md +44 -0
- pyrefman-0.1.0a1/docs/agents/issue-tracker.md +31 -0
- pyrefman-0.1.0a1/docs/agents/triage-labels.md +13 -0
- pyrefman-0.1.0a1/docs/specs/pyrefman-v1.md +255 -0
- pyrefman-0.1.0a1/pyproject.toml +39 -0
- pyrefman-0.1.0a1/pyrefman-crossref/.gitignore +1 -0
- pyrefman-0.1.0a1/pyrefman-crossref/LICENSE +21 -0
- pyrefman-0.1.0a1/pyrefman-crossref/README.md +27 -0
- pyrefman-0.1.0a1/pyrefman-crossref/pyproject.toml +30 -0
- pyrefman-0.1.0a1/pyrefman-crossref/src/pyrefman_crossref/__init__.py +145 -0
- pyrefman-0.1.0a1/pyrefman-crossref/tests/test_crossref.py +194 -0
- pyrefman-0.1.0a1/src/pyrefman/__init__.py +6 -0
- pyrefman-0.1.0a1/src/pyrefman/adapters/__init__.py +191 -0
- pyrefman-0.1.0a1/src/pyrefman/adapters/sqlite.py +122 -0
- pyrefman-0.1.0a1/src/pyrefman/api.py +347 -0
- pyrefman-0.1.0a1/src/pyrefman/core/__init__.py +6 -0
- pyrefman-0.1.0a1/src/pyrefman/core/bibtex.py +138 -0
- pyrefman-0.1.0a1/src/pyrefman/core/citation.py +39 -0
- pyrefman-0.1.0a1/src/pyrefman/core/importing.py +31 -0
- pyrefman-0.1.0a1/src/pyrefman/core/keys.py +45 -0
- pyrefman-0.1.0a1/src/pyrefman/core/matching.py +37 -0
- pyrefman-0.1.0a1/src/pyrefman/core/merge.py +116 -0
- pyrefman-0.1.0a1/src/pyrefman/core/model.py +165 -0
- pyrefman-0.1.0a1/src/pyrefman/core/organize.py +25 -0
- pyrefman-0.1.0a1/src/pyrefman/core/reconcile.py +38 -0
- pyrefman-0.1.0a1/src/pyrefman/core/resolution.py +57 -0
- pyrefman-0.1.0a1/src/pyrefman/plugins/__init__.py +24 -0
- pyrefman-0.1.0a1/src/pyrefman/plugins/bibtex.py +116 -0
- pyrefman-0.1.0a1/src/pyrefman/plugins/registry.py +75 -0
- pyrefman-0.1.0a1/src/pyrefman/ports.py +76 -0
- pyrefman-0.1.0a1/tests/test_attachments.py +155 -0
- pyrefman-0.1.0a1/tests/test_bibtex.py +132 -0
- pyrefman-0.1.0a1/tests/test_bibtex_mapping.py +96 -0
- pyrefman-0.1.0a1/tests/test_first_record.py +119 -0
- pyrefman-0.1.0a1/tests/test_identity.py +138 -0
- pyrefman-0.1.0a1/tests/test_merge.py +216 -0
- pyrefman-0.1.0a1/tests/test_plugins.py +181 -0
- pyrefman-0.1.0a1/tests/test_reconcile.py +145 -0
- pyrefman-0.1.0a1/tests/test_resolver.py +169 -0
- pyrefman-0.1.0a1/tests/test_sqlite.py +184 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Refuses a commit that stages files outside the places this project keeps them.
|
|
3
|
+
# A review sub-agent once wrote a scratch library into the repo and `git add -A`
|
|
4
|
+
# swept it into a commit; this is the deterministic guard against that class.
|
|
5
|
+
set -eu
|
|
6
|
+
|
|
7
|
+
allowed='^(src/|tests/|pyrefman-crossref/|docs/|\.github/|\.githooks/|AGENTS\.md$|CODING_STANDARDS\.md$|GLOSSARY\.md$|README\.md$|pyproject\.toml$|\.gitignore$|LICENSE)'
|
|
8
|
+
|
|
9
|
+
staged=$(git diff --cached --name-only --diff-filter=ACMR)
|
|
10
|
+
[ -z "$staged" ] && exit 0
|
|
11
|
+
|
|
12
|
+
offside=$(printf '%s\n' "$staged" | grep -vE "$allowed" || true)
|
|
13
|
+
if [ -n "$offside" ]; then
|
|
14
|
+
echo "Refusing to commit files outside src/, tests/, pyrefman-crossref/, docs/:" >&2
|
|
15
|
+
printf ' %s\n' $offside >&2
|
|
16
|
+
echo "If the file belongs, add its pattern to .githooks/pre-commit." >&2
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main", "prototype/**"]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
check:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- uses: astral-sh/setup-uv@v5
|
|
15
|
+
with:
|
|
16
|
+
python-version: "3.12"
|
|
17
|
+
|
|
18
|
+
- name: Install
|
|
19
|
+
run: |
|
|
20
|
+
uv sync
|
|
21
|
+
uv pip install -e ./pyrefman-crossref
|
|
22
|
+
|
|
23
|
+
- name: Lint
|
|
24
|
+
run: uv run ruff check .
|
|
25
|
+
|
|
26
|
+
- name: Format
|
|
27
|
+
run: uv run ruff format --check .
|
|
28
|
+
|
|
29
|
+
- name: Types
|
|
30
|
+
run: uv run mypy
|
|
31
|
+
|
|
32
|
+
- name: Tests
|
|
33
|
+
run: uv run pytest -q
|
|
34
|
+
|
|
35
|
+
- name: Plugin tests
|
|
36
|
+
run: uv run pytest -q pyrefman-crossref/tests
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# pyrefman — agent notes
|
|
2
|
+
|
|
3
|
+
`pyrefman` is a Python library that exposes a reference library as an API. Records are
|
|
4
|
+
CSL-JSON serialised as YAML; the index is derived; importers, resolvers, layouts,
|
|
5
|
+
repositories and renderers are plugins.
|
|
6
|
+
|
|
7
|
+
Read `GLOSSARY.md` and the ADRs in `docs/adr/` before touching the domain model.
|
|
8
|
+
|
|
9
|
+
## Working here
|
|
10
|
+
|
|
11
|
+
- Checks: `uv run ruff check .`, `uv run ruff format --check .`, `uv run mypy`,
|
|
12
|
+
`uv run pytest`. CI runs them for both distributions on every push; there is no reason to guess.
|
|
13
|
+
- Long files: write a skeleton under 40 lines, then extend it with `edit` in blocks under
|
|
14
|
+
150. A single `write` carrying a few hundred lines fails at the provider and costs a turn.
|
|
15
|
+
- The pre-commit hook refuses files outside `src/`, `tests/`, `docs/`, `.github/`,
|
|
16
|
+
`.githooks/` and the root documents. If a file genuinely belongs somewhere else, widen the
|
|
17
|
+
pattern in `.githooks/pre-commit` rather than skipping the hook.
|
|
18
|
+
|
|
19
|
+
## Agent skills
|
|
20
|
+
|
|
21
|
+
### Issue tracker
|
|
22
|
+
|
|
23
|
+
Issues and specs live as GitHub issues in `Icntaann/pyrefman`, driven through the `gh` CLI. See `docs/agents/issue-tracker.md`.
|
|
24
|
+
|
|
25
|
+
### Triage labels
|
|
26
|
+
|
|
27
|
+
The five canonical triage roles map one-to-one to label strings of the same name. See `docs/agents/triage-labels.md`.
|
|
28
|
+
|
|
29
|
+
### Domain docs
|
|
30
|
+
|
|
31
|
+
Single-context: one `GLOSSARY.md` at the root, ADRs in `docs/adr/`, specs in `docs/specs/`. See `docs/agents/domain.md`.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `pyrefman` and `pyrefman-crossref`. Both ship together, so one entry
|
|
4
|
+
covers both.
|
|
5
|
+
|
|
6
|
+
## 0.1.0a1 — 2026-12-05
|
|
7
|
+
|
|
8
|
+
First alpha. The API may still change between alpha releases; no migration path is promised.
|
|
9
|
+
|
|
10
|
+
**Added — `pyrefman`**
|
|
11
|
+
|
|
12
|
+
- `ReferenceManager` with eleven methods: `add`, `import_from`, `export_to`, `find`, `merge`,
|
|
13
|
+
`cite`, `attach`, `rename`, `organize`, `reconcile`, and `add(identifier=…)`.
|
|
14
|
+
- Records as CSL-JSON serialised to YAML (`refman.csl.yaml`), with attachments and
|
|
15
|
+
per-field provenance under `custom.refman`.
|
|
16
|
+
- Identity as a UUID inside the record, citation keys as changeable aliases, and unique keys
|
|
17
|
+
across both.
|
|
18
|
+
- Duplicate detection by identifier (DOI, ISBN, arXiv) and by normalised title; merging with
|
|
19
|
+
per-field precedence — manual beats identifier beats BibTeX beats PDF.
|
|
20
|
+
- BibTeX import and export through `bibtexparser`, with type mapping and a report of what was
|
|
21
|
+
skipped.
|
|
22
|
+
- File layouts as a replaceable plugin; `organize()` moves a library onto a new one.
|
|
23
|
+
- `reconcile()` reporting `missing`, `changed`, `adopted` and `orphaned` records without
|
|
24
|
+
deleting anything.
|
|
25
|
+
- Plugin discovery through six entry-point groups, with explicit registration for tests and a
|
|
26
|
+
reported reason whenever a plugin fails to load.
|
|
27
|
+
- Author-year and numeric citations.
|
|
28
|
+
- A SQLite repository as an opt-in alternative to files (see ADR-0004 for what it costs).
|
|
29
|
+
|
|
30
|
+
**Added — `pyrefman-crossref`**
|
|
31
|
+
|
|
32
|
+
- A Crossref resolver: `manager.add(identifier="10.1038/nphys1170")` fills a reference from
|
|
33
|
+
the DOI, registering itself through `pyrefman.resolvers`.
|
|
34
|
+
|
|
35
|
+
**Known limits**
|
|
36
|
+
|
|
37
|
+
- The index is rebuilt from disk at startup, so a record deleted between two runs reads as
|
|
38
|
+
the new truth rather than as `missing`.
|
|
39
|
+
- Layouts govern where records live, not where attachments live.
|
|
40
|
+
- Crossref mapping covers the fields a citation needs; relations, licences, funders and JATS
|
|
41
|
+
abstracts are not mapped.
|
|
42
|
+
- No CLI and no sync between machines — both are out of scope by design.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Coding standards
|
|
2
|
+
|
|
3
|
+
What a reviewer checks that no linter can. `ruff`, `mypy --strict` and the test suite cover
|
|
4
|
+
the mechanical half; this file covers the judgement calls the reviews of the first nine
|
|
5
|
+
tickets kept finding.
|
|
6
|
+
|
|
7
|
+
## Tests
|
|
8
|
+
|
|
9
|
+
- **Assert values, not existence.** `assert manager.find("widgets")` passes for the wrong
|
|
10
|
+
reference, the wrong count, and a library that returned everything. Name what you expect:
|
|
11
|
+
`assert [reference.citation_key for reference in manager.find("widgets")] == ["smith2020"]`.
|
|
12
|
+
- **Go through the façade.** A test drives `ReferenceManager` and reads back return values
|
|
13
|
+
or the state on disk. Reaching into `manager.repository`, a private attribute or the SQL
|
|
14
|
+
schema couples the test to an implementation that is allowed to change. The exception is a
|
|
15
|
+
test whose subject *is* the storage contract — say so in the test's name.
|
|
16
|
+
- **One behaviour per test, named after the behaviour.** A test called `test_renaming_…`
|
|
17
|
+
that also asserts persistence is two tests waiting to fail for each other's reasons.
|
|
18
|
+
- **A failing test must fail for the reason it claims.** If you cannot make the test fail by
|
|
19
|
+
breaking the code, it is not testing that code.
|
|
20
|
+
|
|
21
|
+
## Reports, not exceptions
|
|
22
|
+
|
|
23
|
+
A domain-level failure — an unreadable record, an unresolvable identifier, a plugin that
|
|
24
|
+
will not load — is a `Report` in the result, not an exception. Exceptions are for a caller
|
|
25
|
+
who asked for something impossible: an unknown key, a bad argument, a refused rename.
|
|
26
|
+
|
|
27
|
+
## Public surface
|
|
28
|
+
|
|
29
|
+
- **Changing a method's signature or return type updates `docs/specs/` in the same commit.**
|
|
30
|
+
The spec's API contract is the only place a caller can learn what `add()` accepts; a spec
|
|
31
|
+
that describes last week's signature is worse than none.
|
|
32
|
+
- **A deviation from an ADR gets an ADR.** If the code contradicts a recorded decision, the
|
|
33
|
+
decision is amended or superseded explicitly, never quietly outgrown.
|
|
34
|
+
|
|
35
|
+
## Language
|
|
36
|
+
|
|
37
|
+
Names follow `GLOSSARY.md`. If the concept you need is missing there, that is a signal — add
|
|
38
|
+
the term or reconsider the concept — rather than inventing a synonym in code.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Glossary
|
|
2
|
+
|
|
3
|
+
The words we use when talking about `pyrefman`. Language only, no implementation.
|
|
4
|
+
|
|
5
|
+
## Reference
|
|
6
|
+
|
|
7
|
+
A single bibliographic work — a paper, a book, a software entry. Not to be confused with
|
|
8
|
+
the *file* it lives in, or with an *entry* in an index.
|
|
9
|
+
|
|
10
|
+
## Record
|
|
11
|
+
|
|
12
|
+
The durable form of a Reference on disk: a `refman.csl.yaml` plus the files that belong to
|
|
13
|
+
it. The Record is the source of truth. When Record and Index disagree, the Record wins.
|
|
14
|
+
|
|
15
|
+
## Index
|
|
16
|
+
|
|
17
|
+
A derived, disposable acceleration structure over all Records — for search, filtering and
|
|
18
|
+
merges. The Index may be wrong; it must merely never stay wrong *unnoticed*.
|
|
19
|
+
|
|
20
|
+
## Library
|
|
21
|
+
|
|
22
|
+
The totality of Records under one root directory, plus the rules that decide where they
|
|
23
|
+
sit.
|
|
24
|
+
|
|
25
|
+
## Layout
|
|
26
|
+
|
|
27
|
+
The rule for where a Record lives and what its files are called — which directory pattern,
|
|
28
|
+
which file name, where attachments go. A Layout is replaceable; a Library survives a Layout
|
|
29
|
+
change through `organize`.
|
|
30
|
+
|
|
31
|
+
## Identity
|
|
32
|
+
|
|
33
|
+
What keeps a Reference the same across renames, key changes and re-exports. Not the key,
|
|
34
|
+
not the directory name, not the title.
|
|
35
|
+
|
|
36
|
+
## Citation key
|
|
37
|
+
|
|
38
|
+
The short human-readable name of a Reference (`smith2020a`), as BibTeX and LaTeX use it.
|
|
39
|
+
Changeable. Several keys may point at the same Reference.
|
|
40
|
+
|
|
41
|
+
## Alias
|
|
42
|
+
|
|
43
|
+
A Citation key that used to be a Reference's primary key and still resolves to it after a
|
|
44
|
+
merge or a rename.
|
|
45
|
+
|
|
46
|
+
## Attachment
|
|
47
|
+
|
|
48
|
+
A file belonging to a Reference — PDF, supplementary material, note. The Attachment is not
|
|
49
|
+
the Reference; the same Reference can exist without one.
|
|
50
|
+
|
|
51
|
+
## Provenance
|
|
52
|
+
|
|
53
|
+
The origin of a field value: which source it came from and when it was read there.
|
|
54
|
+
Provenance decides which value wins during a merge.
|
|
55
|
+
|
|
56
|
+
## Merge
|
|
57
|
+
|
|
58
|
+
The act of folding two References that describe the same work into one. The result is a
|
|
59
|
+
Reference with the older Identity, the better fields of both, and the attachments of both.
|
|
60
|
+
|
|
61
|
+
## Key function
|
|
62
|
+
|
|
63
|
+
The rule that turns a Reference into a Citation key. Replaceable by the user, with a default
|
|
64
|
+
built from family name and year.
|
|
65
|
+
|
|
66
|
+
## Reconcile
|
|
67
|
+
|
|
68
|
+
The comparison between Records and Index. Reports what is missing, what is orphaned, what
|
|
69
|
+
changed outside the tool and what was adopted — instead of guessing. Nothing is deleted.
|
|
70
|
+
|
|
71
|
+
## Adopted
|
|
72
|
+
|
|
73
|
+
A Record that was valid and complete but unknown to the Index — left there by another
|
|
74
|
+
machine, a sync tool or a hand copy. `Reconcile` takes it into the Library instead of
|
|
75
|
+
treating it as foreign.
|
|
76
|
+
|
|
77
|
+
## Plugin
|
|
78
|
+
|
|
79
|
+
A replaceable building block at the edge of the system: an Importer, a Resolver, an
|
|
80
|
+
Enricher, a Layout, a Repository or a Renderer. The core knows only the contracts, never the
|
|
81
|
+
blocks.
|
pyrefman-0.1.0a1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Icntaann
|
|
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.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pyrefman
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: Reference management as a Python library
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Science/Research
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Topic :: Text Processing :: Markup :: LaTeX
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Requires-Dist: bibtexparser>=2.1
|
|
13
|
+
Requires-Dist: pyyaml>=6
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# pyrefman
|
|
17
|
+
|
|
18
|
+
Reference management as a Python library.
|
|
19
|
+
|
|
20
|
+
Records are CSL-JSON serialised as YAML, the index is derived and disposable, and everything
|
|
21
|
+
that talks to the outside world — importers, resolvers, enrichers, layouts, repositories,
|
|
22
|
+
renderers — is a plugin.
|
|
23
|
+
|
|
24
|
+
**Status: alpha.** The v1 ticket set is implemented, but the API can still change between
|
|
25
|
+
alpha releases and nothing is promised about data migration. Use it, expect to re-read the
|
|
26
|
+
release notes.
|
|
27
|
+
|
|
28
|
+
**What works today:**
|
|
29
|
+
|
|
30
|
+
- create references and find them again; records land on disk as `refman.csl.yaml`
|
|
31
|
+
- import and export BibTeX, folding duplicates instead of adding them twice
|
|
32
|
+
- merge two references with per-field precedence and a report of every disagreement
|
|
33
|
+
- attach files, change the filing layout, move the library onto it
|
|
34
|
+
- report drift between records and index without deleting anything
|
|
35
|
+
- create a reference from a DOI or arXiv identifier through a resolver plugin
|
|
36
|
+
- render author-year and numeric citations
|
|
37
|
+
- discover plugins through entry points, or register them directly
|
|
38
|
+
- swap the file store for SQLite when the properties of files are not wanted
|
|
39
|
+
|
|
40
|
+
`docs/specs/pyrefman-v1.md` records what was built and where it deliberately stops.
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
|
|
44
|
+
MIT. See [LICENSE](LICENSE).
|
|
45
|
+
|
|
46
|
+
## Where to look
|
|
47
|
+
|
|
48
|
+
- `docs/specs/pyrefman-v1.md` — the specification and its user stories
|
|
49
|
+
- `docs/adr/` — the decisions behind it, with the rejected alternatives
|
|
50
|
+
- `GLOSSARY.md` — the vocabulary the spec and the code use
|
|
51
|
+
- `docs/agents/` — how the engineering skills operate in this repo
|
|
52
|
+
- branch `prototype/refman-proto` — the throwaway prototype that answered the open questions
|
|
53
|
+
|
|
54
|
+
## Issue tracker
|
|
55
|
+
|
|
56
|
+
Work is tracked as GitHub issues: the specification is #1, the implementation tickets hang
|
|
57
|
+
off it as sub-issues with native blocking edges.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# pyrefman
|
|
2
|
+
|
|
3
|
+
Reference management as a Python library.
|
|
4
|
+
|
|
5
|
+
Records are CSL-JSON serialised as YAML, the index is derived and disposable, and everything
|
|
6
|
+
that talks to the outside world — importers, resolvers, enrichers, layouts, repositories,
|
|
7
|
+
renderers — is a plugin.
|
|
8
|
+
|
|
9
|
+
**Status: alpha.** The v1 ticket set is implemented, but the API can still change between
|
|
10
|
+
alpha releases and nothing is promised about data migration. Use it, expect to re-read the
|
|
11
|
+
release notes.
|
|
12
|
+
|
|
13
|
+
**What works today:**
|
|
14
|
+
|
|
15
|
+
- create references and find them again; records land on disk as `refman.csl.yaml`
|
|
16
|
+
- import and export BibTeX, folding duplicates instead of adding them twice
|
|
17
|
+
- merge two references with per-field precedence and a report of every disagreement
|
|
18
|
+
- attach files, change the filing layout, move the library onto it
|
|
19
|
+
- report drift between records and index without deleting anything
|
|
20
|
+
- create a reference from a DOI or arXiv identifier through a resolver plugin
|
|
21
|
+
- render author-year and numeric citations
|
|
22
|
+
- discover plugins through entry points, or register them directly
|
|
23
|
+
- swap the file store for SQLite when the properties of files are not wanted
|
|
24
|
+
|
|
25
|
+
`docs/specs/pyrefman-v1.md` records what was built and where it deliberately stops.
|
|
26
|
+
|
|
27
|
+
## License
|
|
28
|
+
|
|
29
|
+
MIT. See [LICENSE](LICENSE).
|
|
30
|
+
|
|
31
|
+
## Where to look
|
|
32
|
+
|
|
33
|
+
- `docs/specs/pyrefman-v1.md` — the specification and its user stories
|
|
34
|
+
- `docs/adr/` — the decisions behind it, with the rejected alternatives
|
|
35
|
+
- `GLOSSARY.md` — the vocabulary the spec and the code use
|
|
36
|
+
- `docs/agents/` — how the engineering skills operate in this repo
|
|
37
|
+
- branch `prototype/refman-proto` — the throwaway prototype that answered the open questions
|
|
38
|
+
|
|
39
|
+
## Issue tracker
|
|
40
|
+
|
|
41
|
+
Work is tracked as GitHub issues: the specification is #1, the implementation tickets hang
|
|
42
|
+
off it as sub-issues with native blocking edges.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Files are the Record, the Index is derived
|
|
2
|
+
|
|
3
|
+
A Library has to stay readable without the tool: survive a lost database, be versionable in
|
|
4
|
+
git, be shareable through a synced folder. So every Reference lives as a file on disk, and
|
|
5
|
+
the SQLite index is a disposable acceleration structure that `reconcile` rebuilds. Identity
|
|
6
|
+
is stored *inside* the Record as a UUID, not in the directory name — unlike Papis, where
|
|
7
|
+
directory name and `ref` carry identity and a rename breaks it.
|
|
8
|
+
|
|
9
|
+
**Considered options:** database only (fast, but the Library becomes a binary artefact —
|
|
10
|
+
not diffable, not readable without the tool); filesystem only, as Papis does (readable, but
|
|
11
|
+
no remote operation and no transactional merge).
|
|
12
|
+
|
|
13
|
+
**Consequences:** every write touches two places — Record first, Index second. An abort in
|
|
14
|
+
between leaves the Index stale, never the Record. Conflicts are reported, not silently
|
|
15
|
+
resolved: a missing file is `missing`, an orphaned file is `orphaned`.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# The Record is CSL-JSON as YAML
|
|
2
|
+
|
|
3
|
+
`refman.csl.yaml` follows the CSL data schema: `id` carries the UUID, `citation-key` the
|
|
4
|
+
BibTeX key, everything else the CSL fields. Attachments and provenance live under
|
|
5
|
+
`custom.refman`, because CSL explicitly reserves `custom` for application-specific data
|
|
6
|
+
(`additionalProperties: false` applies only to the top level). The Record therefore
|
|
7
|
+
validates against the official schema and is still lossless.
|
|
8
|
+
|
|
9
|
+
**Considered options:** a schema of our own (free, but every third-party tool needs a
|
|
10
|
+
converter); CSL plus extra top-level fields (breaks validation); two files per entry (keeps
|
|
11
|
+
the schema pure, but must be kept in sync).
|
|
12
|
+
|
|
13
|
+
**Consequences:** CSL requires `type`; BibTeX types map through a table, unknown types fall
|
|
14
|
+
back to `article` and produce a warning instead of aborting.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Plugins through entry points, separate protocols
|
|
2
|
+
|
|
3
|
+
Everything that talks to the outside world is a plugin: Importers (BibTeX, CSL-JSON, PDF),
|
|
4
|
+
Resolvers (DOI, arXiv), Enrichers (extra fields), Layouts (file placement), Repositories
|
|
5
|
+
(SQLite, remote) and Renderers (citations). They are discovered through `entry_points`
|
|
6
|
+
groups (`pyrefman.importers`, `pyrefman.resolvers`, `pyrefman.enrichers`,
|
|
7
|
+
`pyrefman.layouts`, `pyrefman.repositories`, `pyrefman.renderers`), so that
|
|
8
|
+
`pip install pyrefman-crossref` takes effect without configuration; an explicit `register()`
|
|
9
|
+
covers tests where nothing is installed.
|
|
10
|
+
|
|
11
|
+
Six separate protocols instead of one generic hook, because each stage has its own failures
|
|
12
|
+
and delivers different data: a Resolver can fail without ending the import; a Renderer needs
|
|
13
|
+
different input than a Layout. A shared hook turns every signature into a special case.
|
|
14
|
+
|
|
15
|
+
**Considered options:** a single generic hook (every signature becomes a special case,
|
|
16
|
+
errors cannot be handled per stage); explicit registration only (no ecosystem, every
|
|
17
|
+
installation needs wiring code).
|
|
18
|
+
|
|
19
|
+
**Consequences:** the core knows only the protocols, never the concrete packages. A failing
|
|
20
|
+
Resolver is a report in the result, not a crash of the import.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# SQLite is an opt-in store, not the library's record
|
|
2
|
+
|
|
3
|
+
ADR-0001 says files are the record and the index is disposable. A `SqliteRepository` cannot honour that: it makes a database file the only home of the metadata. It exists anyway, because the `Repository` port is the design's central promise and a claim about a port that only one adapter satisfies is untested.
|
|
4
|
+
|
|
5
|
+
The adapter is therefore a deliberate exception, chosen explicitly by a caller (`ReferenceManager(..., repository=SqliteRepository(path))`), never a default. **A caller who picks it gives up** plain-text diffability, `organize` (there is nothing to move), and the guarantee that the library survives without the tool. `reconcile` still reports what it can see — a row whose document no longer parses — but `missing`, `changed` and `adopted` have no meaning without files.
|
|
6
|
+
|
|
7
|
+
**Considered options:** making SQLite the default store (fast, but every property ADR-0001 bought is gone); keeping the adapter out of the distribution entirely (the port stays untested against a second implementation).
|
|
8
|
+
|
|
9
|
+
**Consequences:** the two adapters behave the same through the façade for every case that does not involve files. Where they differ — `organize`, `reconcile` — the difference is visible in the port, not hidden in a conditional.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Decisions (ADRs)
|
|
2
|
+
|
|
3
|
+
Architecture decisions for `pyrefman`, one file per decision, each with context and the
|
|
4
|
+
rejected alternative.
|
|
5
|
+
|
|
6
|
+
```{toctree}
|
|
7
|
+
:maxdepth: 1
|
|
8
|
+
|
|
9
|
+
0001-files-are-the-record
|
|
10
|
+
0002-csl-yaml-as-record-format
|
|
11
|
+
0003-plugins-through-entry-points
|
|
12
|
+
0004-sqlite-is-an-opt-in-store
|
|
13
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Domain Docs
|
|
2
|
+
|
|
3
|
+
How the engineering skills should consume this repo's domain documentation when exploring the codebase.
|
|
4
|
+
|
|
5
|
+
## Before exploring, read these
|
|
6
|
+
|
|
7
|
+
- **`GLOSSARY.md`** at the repo root.
|
|
8
|
+
- **`CODING_STANDARDS.md`** at the repo root when reviewing: the judgement calls no linter
|
|
9
|
+
covers.
|
|
10
|
+
- **`docs/adr/`**: read ADRs that touch the area you're about to work in.
|
|
11
|
+
- **`docs/specs/`**: the current spec, which records the decisions the ADRs only summarise.
|
|
12
|
+
|
|
13
|
+
If any of these files don't exist, **proceed silently**. Don't flag their absence; don't suggest creating them upfront.
|
|
14
|
+
|
|
15
|
+
## File structure
|
|
16
|
+
|
|
17
|
+
Single-context repo:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
/
|
|
21
|
+
├── GLOSSARY.md
|
|
22
|
+
├── docs/
|
|
23
|
+
│ ├── adr/
|
|
24
|
+
│ ├── specs/
|
|
25
|
+
│ └── agents/
|
|
26
|
+
└── src/
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Use the glossary's vocabulary
|
|
30
|
+
|
|
31
|
+
When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `GLOSSARY.md`. Don't drift to synonyms the glossary explicitly avoids.
|
|
32
|
+
|
|
33
|
+
If the concept you need isn't in the glossary yet, that's a signal: either you're inventing language the project doesn't use (reconsider) or there's a real gap (note it for `/domain-modeling`).
|
|
34
|
+
|
|
35
|
+
## Flag ADR conflicts
|
|
36
|
+
|
|
37
|
+
If your output contradicts an existing ADR, surface it explicitly rather than silently overriding:
|
|
38
|
+
|
|
39
|
+
> _Contradicts ADR-0001 (files are the record), but worth reopening because…_
|
|
40
|
+
|
|
41
|
+
## Language
|
|
42
|
+
|
|
43
|
+
Everything in this repository is written in English — issues, specs, ADRs, code comments
|
|
44
|
+
and commit messages.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Issue tracker: GitHub
|
|
2
|
+
|
|
3
|
+
Issues and specs for this repo live as GitHub issues in `Icntaann/pyrefman`. Use the `gh` CLI for all operations.
|
|
4
|
+
|
|
5
|
+
## Conventions
|
|
6
|
+
|
|
7
|
+
- **Create an issue**: `gh issue create --title "..." --body "..."`. Use a file for multi-line bodies.
|
|
8
|
+
- **Read an issue**: `gh issue view <number> --json number,title,body,labels,comments`.
|
|
9
|
+
- **List issues**: `gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'` with appropriate `--label` and `--state` filters.
|
|
10
|
+
- **Make an issue a sub-issue of a parent**: `gh issue create --parent <parent> ...`, or `gh issue edit <parent> --add-sub-issue <child>` afterwards (`gh` 2.94+). Older `gh`: `gh api --method POST repos/<owner>/<repo>/issues/<parent>/sub_issues -F sub_issue_id=<child-db-id>`. Without sub-issues, put `Part of #<parent>` at the top of the child body.
|
|
11
|
+
- **Blocking**: use GitHub's native issue dependencies. Add an edge with `gh issue create --blocked-by <n>,<n> ...` or `gh issue edit <child> --add-blocked-by <blocker>` (`gh` 2.94+). Older `gh`: `gh api --method POST repos/<owner>/<repo>/issues/<child>/dependencies/blocked_by -F issue_id=<blocker-db-id>`, where `<blocker-db-id>` is the blocker's numeric database id (`gh api repos/<owner>/<repo>/issues/<n> --jq .id`). Where dependencies aren't available, fall back to a `Blocked by: #<n>, #<n>` line at the top of the child body. A ticket is unblocked when every blocker is closed.
|
|
12
|
+
- **Count open blockers**: `gh api repos/<owner>/<repo>/issues/<n> --jq .issue_dependencies_summary.blocked_by` (open blockers only; 0 means startable).
|
|
13
|
+
- **Comment on an issue**: `gh issue comment <number> --body "..."`
|
|
14
|
+
- **Apply / remove labels**: `gh issue edit <number> --add-label "..."` / `--remove-label "..."`
|
|
15
|
+
- **Close**: post the explanation with `gh issue comment <number> --body "..."`, then `gh issue close <number>`.
|
|
16
|
+
|
|
17
|
+
Infer the repo from `git remote -v`; `gh` does this automatically when run inside a clone.
|
|
18
|
+
|
|
19
|
+
File issues only into `Icntaann/pyrefman`. In a fork, `gh` can default to the upstream parent, so check the target with `gh repo view --json nameWithOwner` before the first `gh issue create` of a session.
|
|
20
|
+
|
|
21
|
+
## Pull requests as a triage surface
|
|
22
|
+
|
|
23
|
+
**PRs as a request surface: no.** _(Set to `yes` if this repo treats external PRs as feature requests; `/triage` reads this flag.)_
|
|
24
|
+
|
|
25
|
+
## When a skill says "publish to the issue tracker"
|
|
26
|
+
|
|
27
|
+
Create a GitHub issue.
|
|
28
|
+
|
|
29
|
+
## When a skill says "fetch the relevant ticket"
|
|
30
|
+
|
|
31
|
+
Read it as in **Read an issue** above.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Triage Labels
|
|
2
|
+
|
|
3
|
+
The skills speak in terms of five canonical triage roles. This file maps those roles to the actual label strings used in this repo's issue tracker.
|
|
4
|
+
|
|
5
|
+
| Label in mattpocock/skills | Label in our tracker | Meaning |
|
|
6
|
+
| -------------------------- | -------------------- | ---------------------------------------- |
|
|
7
|
+
| `needs-triage` | `needs-triage` | Maintainer needs to evaluate this issue |
|
|
8
|
+
| `needs-info` | `needs-info` | Waiting on reporter for more information |
|
|
9
|
+
| `ready-for-agent` | `ready-for-agent` | Fully specified, ready for an AFK agent |
|
|
10
|
+
| `ready-for-human` | `ready-for-human` | Requires human implementation |
|
|
11
|
+
| `wontfix` | `wontfix` | Will not be actioned |
|
|
12
|
+
|
|
13
|
+
When a skill mentions a role (e.g. "apply the AFK-ready triage label"), use the corresponding label string from this table.
|