metatron-cli 0.2.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Matt Weber
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,174 @@
1
+ Metadata-Version: 2.4
2
+ Name: metatron-cli
3
+ Version: 0.2.1
4
+ Summary: Multi-project web feed manager with cross-outlet deduplication
5
+ Author-email: Matt Weber <matt.weber@beefree.io>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/mattweberio/metatron
8
+ Project-URL: Repository, https://github.com/mattweberio/metatron
9
+ Project-URL: Issues, https://github.com/mattweberio/metatron/issues
10
+ Keywords: rss,feeds,deduplication,news,aggregator,web,ingestion
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
17
+ Classifier: Topic :: Text Processing :: Markup
18
+ Requires-Python: >=3.12
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: feedparser>=6.0
22
+ Requires-Dist: requests>=2.31
23
+ Requires-Dist: trafilatura>=1.12
24
+ Requires-Dist: fastapi>=0.110
25
+ Requires-Dist: uvicorn[standard]>=0.27
26
+ Requires-Dist: httpx>=0.27
27
+ Requires-Dist: pydantic>=2.0
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest>=9.0; extra == "test"
30
+ Requires-Dist: pytest-asyncio>=0.23; extra == "test"
31
+ Dynamic: license-file
32
+
33
+ # Metatron
34
+
35
+ Multi-project web feed manager with cross-outlet deduplication.
36
+
37
+ You point Metatron at sources, organized by project. It polls them, dedups
38
+ the articles (URL canonicalization → normalized title → token overlap →
39
+ LLM tiebreaker), and serves you the unique articles via a small HTTP API.
40
+ RSS is the source it speaks today; the architecture is medium-agnostic and
41
+ grows to other web sources over time.
42
+
43
+ It does this one thing. It doesn't curate, it doesn't summarize, it doesn't
44
+ have opinions about what's interesting. That's for whatever calls it.
45
+
46
+ ## Install
47
+
48
+ The CLI is `metatron`. The published package is `metatron-cli` (the bare
49
+ `metatron` name was already taken on PyPI):
50
+
51
+ ```bash
52
+ pipx install metatron-cli # from PyPI
53
+ pipx install git+https://github.com/mattweberio/metatron # from GitHub (latest main)
54
+ ```
55
+
56
+ ## Configure
57
+
58
+ ```bash
59
+ metatron config init # writes ~/.config/metatron/config.toml
60
+ metatron config show # prints the resolved config
61
+ ```
62
+
63
+ Edit `~/.config/metatron/config.toml`. The LLM tiebreaker — needed to catch
64
+ "same story, different outlet" duplicates — requires an Anthropic API key:
65
+
66
+ ```toml
67
+ [llm]
68
+ api_key = "sk-ant-..."
69
+ model = "claude-sonnet-4-6"
70
+
71
+ [api]
72
+ api_token = "your-bearer-token"
73
+ ```
74
+
75
+ Without an LLM key, dedup falls back to URL + normalized-title matching only.
76
+ Cross-outlet duplicates from different sources will leak through.
77
+
78
+ ## Run
79
+
80
+ ```bash
81
+ metatron serve # HTTP API on 127.0.0.1:8765
82
+ ```
83
+
84
+ ## Use
85
+
86
+ Bearer-token auth on everything except `/health`.
87
+
88
+ ```bash
89
+ TOKEN="your-bearer-token"
90
+ BASE="http://127.0.0.1:8765"
91
+
92
+ # Create a project
93
+ curl -s -X POST "$BASE/projects" \
94
+ -H "Authorization: Bearer $TOKEN" \
95
+ -H "Content-Type: application/json" \
96
+ -d '{"name": "ai-news"}'
97
+
98
+ # Add feeds
99
+ PROJECT_ID=...
100
+ curl -s -X POST "$BASE/projects/$PROJECT_ID/feeds" \
101
+ -H "Authorization: Bearer $TOKEN" \
102
+ -H "Content-Type: application/json" \
103
+ -d '{"url": "https://hnrss.org/frontpage"}'
104
+
105
+ # List deduplicated articles
106
+ curl -s -H "Authorization: Bearer $TOKEN" \
107
+ "$BASE/projects/$PROJECT_ID/articles?limit=20"
108
+
109
+ # Force a synchronous refresh
110
+ curl -s -X POST -H "Authorization: Bearer $TOKEN" \
111
+ "$BASE/projects/$PROJECT_ID/refresh"
112
+ ```
113
+
114
+ ## Bulk feed import
115
+
116
+ ```bash
117
+ metatron seed-feeds my-project ./feeds.json
118
+ ```
119
+
120
+ Where `feeds.json` is:
121
+ ```json
122
+ {
123
+ "feeds": [
124
+ { "url": "https://hnrss.org/frontpage", "name": "Hacker News", "category": "tech" },
125
+ { "url": "https://www.theverge.com/rss/index.xml", "name": "The Verge", "category": "tech" }
126
+ ]
127
+ }
128
+ ```
129
+
130
+ ## How dedup works
131
+
132
+ Cheapest-to-most-expensive, short-circuits on first match:
133
+
134
+ 1. **Canonical URL.** Strip `utm_*`, `fbclid`, etc. Same canonical URL → exact duplicate, dropped.
135
+ 2. **Normalized title.** Lowercase, drop punctuation, strip newsroom prefixes ("BREAKING: ", "UPDATE - "). Same → joins the existing article's cluster.
136
+ 3. **Token overlap.** Jaccard similarity on title + summary tokens. ≥0.12 → shortlist candidate (top 5).
137
+ 4. **Sonnet tiebreaker.** Claude Sonnet reads both articles and decides "same story" or "different story." Same → joins cluster.
138
+
139
+ Articles in a cluster are stored individually (you can see the alternative
140
+ sources via `GET /articles/{id}`) but `/projects/{id}/articles` returns
141
+ only the canonical from each cluster.
142
+
143
+ ## Storage
144
+
145
+ Single SQLite file at `~/.local/share/metatron/metatron.db`. WAL mode, FK
146
+ constraints on. Override with `[database].path` in config.
147
+
148
+ ## API endpoints
149
+
150
+ | Method | Path | Description |
151
+ |--------|---------------------------------------|----------------------------------------------|
152
+ | GET | `/health` | Liveness; reports LLM enablement |
153
+ | POST | `/projects` | Create a project |
154
+ | GET | `/projects` | List projects |
155
+ | DELETE | `/projects/{id}` | Delete a project (cascades feeds + articles) |
156
+ | POST | `/projects/{id}/feeds` | Add a feed |
157
+ | GET | `/projects/{id}/feeds` | List feeds |
158
+ | DELETE | `/feeds/{id}` | Remove a feed |
159
+ | GET | `/projects/{id}/articles?since=&limit=` | List deduped articles |
160
+ | POST | `/projects/{id}/refresh` | Synchronously poll project's feeds |
161
+ | GET | `/articles/{id}` | Article detail + cluster members |
162
+
163
+ ## Development
164
+
165
+ ```bash
166
+ python3 -m pytest -q
167
+ ```
168
+
169
+ Tests cover normalization, the DB layer, the dedup pipeline (with a fake
170
+ LLM judge), the feed poller (with mocked RSS), and the API surface.
171
+
172
+ ## License
173
+
174
+ MIT. See [LICENSE](./LICENSE).
@@ -0,0 +1,142 @@
1
+ # Metatron
2
+
3
+ Multi-project web feed manager with cross-outlet deduplication.
4
+
5
+ You point Metatron at sources, organized by project. It polls them, dedups
6
+ the articles (URL canonicalization → normalized title → token overlap →
7
+ LLM tiebreaker), and serves you the unique articles via a small HTTP API.
8
+ RSS is the source it speaks today; the architecture is medium-agnostic and
9
+ grows to other web sources over time.
10
+
11
+ It does this one thing. It doesn't curate, it doesn't summarize, it doesn't
12
+ have opinions about what's interesting. That's for whatever calls it.
13
+
14
+ ## Install
15
+
16
+ The CLI is `metatron`. The published package is `metatron-cli` (the bare
17
+ `metatron` name was already taken on PyPI):
18
+
19
+ ```bash
20
+ pipx install metatron-cli # from PyPI
21
+ pipx install git+https://github.com/mattweberio/metatron # from GitHub (latest main)
22
+ ```
23
+
24
+ ## Configure
25
+
26
+ ```bash
27
+ metatron config init # writes ~/.config/metatron/config.toml
28
+ metatron config show # prints the resolved config
29
+ ```
30
+
31
+ Edit `~/.config/metatron/config.toml`. The LLM tiebreaker — needed to catch
32
+ "same story, different outlet" duplicates — requires an Anthropic API key:
33
+
34
+ ```toml
35
+ [llm]
36
+ api_key = "sk-ant-..."
37
+ model = "claude-sonnet-4-6"
38
+
39
+ [api]
40
+ api_token = "your-bearer-token"
41
+ ```
42
+
43
+ Without an LLM key, dedup falls back to URL + normalized-title matching only.
44
+ Cross-outlet duplicates from different sources will leak through.
45
+
46
+ ## Run
47
+
48
+ ```bash
49
+ metatron serve # HTTP API on 127.0.0.1:8765
50
+ ```
51
+
52
+ ## Use
53
+
54
+ Bearer-token auth on everything except `/health`.
55
+
56
+ ```bash
57
+ TOKEN="your-bearer-token"
58
+ BASE="http://127.0.0.1:8765"
59
+
60
+ # Create a project
61
+ curl -s -X POST "$BASE/projects" \
62
+ -H "Authorization: Bearer $TOKEN" \
63
+ -H "Content-Type: application/json" \
64
+ -d '{"name": "ai-news"}'
65
+
66
+ # Add feeds
67
+ PROJECT_ID=...
68
+ curl -s -X POST "$BASE/projects/$PROJECT_ID/feeds" \
69
+ -H "Authorization: Bearer $TOKEN" \
70
+ -H "Content-Type: application/json" \
71
+ -d '{"url": "https://hnrss.org/frontpage"}'
72
+
73
+ # List deduplicated articles
74
+ curl -s -H "Authorization: Bearer $TOKEN" \
75
+ "$BASE/projects/$PROJECT_ID/articles?limit=20"
76
+
77
+ # Force a synchronous refresh
78
+ curl -s -X POST -H "Authorization: Bearer $TOKEN" \
79
+ "$BASE/projects/$PROJECT_ID/refresh"
80
+ ```
81
+
82
+ ## Bulk feed import
83
+
84
+ ```bash
85
+ metatron seed-feeds my-project ./feeds.json
86
+ ```
87
+
88
+ Where `feeds.json` is:
89
+ ```json
90
+ {
91
+ "feeds": [
92
+ { "url": "https://hnrss.org/frontpage", "name": "Hacker News", "category": "tech" },
93
+ { "url": "https://www.theverge.com/rss/index.xml", "name": "The Verge", "category": "tech" }
94
+ ]
95
+ }
96
+ ```
97
+
98
+ ## How dedup works
99
+
100
+ Cheapest-to-most-expensive, short-circuits on first match:
101
+
102
+ 1. **Canonical URL.** Strip `utm_*`, `fbclid`, etc. Same canonical URL → exact duplicate, dropped.
103
+ 2. **Normalized title.** Lowercase, drop punctuation, strip newsroom prefixes ("BREAKING: ", "UPDATE - "). Same → joins the existing article's cluster.
104
+ 3. **Token overlap.** Jaccard similarity on title + summary tokens. ≥0.12 → shortlist candidate (top 5).
105
+ 4. **Sonnet tiebreaker.** Claude Sonnet reads both articles and decides "same story" or "different story." Same → joins cluster.
106
+
107
+ Articles in a cluster are stored individually (you can see the alternative
108
+ sources via `GET /articles/{id}`) but `/projects/{id}/articles` returns
109
+ only the canonical from each cluster.
110
+
111
+ ## Storage
112
+
113
+ Single SQLite file at `~/.local/share/metatron/metatron.db`. WAL mode, FK
114
+ constraints on. Override with `[database].path` in config.
115
+
116
+ ## API endpoints
117
+
118
+ | Method | Path | Description |
119
+ |--------|---------------------------------------|----------------------------------------------|
120
+ | GET | `/health` | Liveness; reports LLM enablement |
121
+ | POST | `/projects` | Create a project |
122
+ | GET | `/projects` | List projects |
123
+ | DELETE | `/projects/{id}` | Delete a project (cascades feeds + articles) |
124
+ | POST | `/projects/{id}/feeds` | Add a feed |
125
+ | GET | `/projects/{id}/feeds` | List feeds |
126
+ | DELETE | `/feeds/{id}` | Remove a feed |
127
+ | GET | `/projects/{id}/articles?since=&limit=` | List deduped articles |
128
+ | POST | `/projects/{id}/refresh` | Synchronously poll project's feeds |
129
+ | GET | `/articles/{id}` | Article detail + cluster members |
130
+
131
+ ## Development
132
+
133
+ ```bash
134
+ python3 -m pytest -q
135
+ ```
136
+
137
+ Tests cover normalization, the DB layer, the dedup pipeline (with a fake
138
+ LLM judge), the feed poller (with mocked RSS), and the API surface.
139
+
140
+ ## License
141
+
142
+ MIT. See [LICENSE](./LICENSE).
@@ -0,0 +1,53 @@
1
+ [project]
2
+ name = "metatron-cli"
3
+ version = "0.2.1"
4
+ description = "Multi-project web feed manager with cross-outlet deduplication"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = { text = "MIT" }
8
+ authors = [{ name = "Matt Weber", email = "matt.weber@beefree.io" }]
9
+ keywords = ["rss", "feeds", "deduplication", "news", "aggregator", "web", "ingestion"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Environment :: Console",
13
+ "Intended Audience :: Developers",
14
+ "License :: OSI Approved :: MIT License",
15
+ "Programming Language :: Python :: 3.12",
16
+ "Topic :: Internet :: WWW/HTTP :: Indexing/Search",
17
+ "Topic :: Text Processing :: Markup",
18
+ ]
19
+
20
+ dependencies = [
21
+ "feedparser>=6.0",
22
+ "requests>=2.31",
23
+ "trafilatura>=1.12",
24
+ "fastapi>=0.110",
25
+ "uvicorn[standard]>=0.27",
26
+ "httpx>=0.27",
27
+ "pydantic>=2.0",
28
+ ]
29
+
30
+ [project.optional-dependencies]
31
+ test = [
32
+ "pytest>=9.0",
33
+ "pytest-asyncio>=0.23",
34
+ ]
35
+
36
+ [project.scripts]
37
+ metatron = "metatron.cli:main"
38
+
39
+ [project.urls]
40
+ Homepage = "https://github.com/mattweberio/metatron"
41
+ Repository = "https://github.com/mattweberio/metatron"
42
+ Issues = "https://github.com/mattweberio/metatron/issues"
43
+
44
+ [build-system]
45
+ requires = ["setuptools>=68.0"]
46
+ build-backend = "setuptools.build_meta"
47
+
48
+ [tool.setuptools.packages.find]
49
+ where = ["src"]
50
+
51
+ [tool.pytest.ini_options]
52
+ testpaths = ["tests"]
53
+ asyncio_mode = "auto"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,51 @@
1
+ """Metatron — multi-project RSS feed manager with cross-outlet deduplication."""
2
+
3
+ __version__ = "0.2.0"
4
+
5
+ from metatron.config import (
6
+ ApiConfig,
7
+ ConfigError,
8
+ DatabaseConfig,
9
+ LlmConfig,
10
+ MetatronConfig,
11
+ PollerConfig,
12
+ )
13
+ from metatron.db import Database
14
+ from metatron.dedup import (
15
+ BatchPlan,
16
+ CheapDecision,
17
+ DedupConfig,
18
+ build_batch_plan,
19
+ cheap_decide,
20
+ run_batch,
21
+ )
22
+ from metatron.llm import BatchJudge, ClusterGroup, ClusterItem
23
+ from metatron.normalize import canonicalize_url, jaccard, normalize_title, tokenize
24
+ from metatron.poller import Poller, poll_feeds, refresh_project_now
25
+
26
+ __all__ = [
27
+ "__version__",
28
+ "ApiConfig",
29
+ "BatchJudge",
30
+ "BatchPlan",
31
+ "CheapDecision",
32
+ "ClusterGroup",
33
+ "ClusterItem",
34
+ "ConfigError",
35
+ "Database",
36
+ "DatabaseConfig",
37
+ "DedupConfig",
38
+ "LlmConfig",
39
+ "MetatronConfig",
40
+ "Poller",
41
+ "PollerConfig",
42
+ "build_batch_plan",
43
+ "canonicalize_url",
44
+ "cheap_decide",
45
+ "jaccard",
46
+ "normalize_title",
47
+ "poll_feeds",
48
+ "refresh_project_now",
49
+ "run_batch",
50
+ "tokenize",
51
+ ]