nber-cli 0.2.0__tar.gz → 0.3.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.
- nber_cli-0.3.1/CHANGELOG.md +52 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/PKG-INFO +1 -1
- nber_cli-0.3.1/docs/en/changelog.md +56 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/cli.md +119 -1
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/configuration.md +58 -1
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/getting-started.md +30 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/index.md +4 -1
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/python-api.md +110 -1
- nber_cli-0.3.1/docs/zh/changelog.md +56 -0
- nber_cli-0.3.1/docs/zh/cli.md +293 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/configuration.md +58 -1
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/getting-started.md +30 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/index.md +4 -1
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/python-api.md +110 -1
- {nber_cli-0.2.0 → nber_cli-0.3.1}/pyproject.toml +1 -1
- nber_cli-0.3.1/src/nber_cli/__init__.py +74 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/src/nber_cli/cli.py +228 -4
- {nber_cli-0.2.0 → nber_cli-0.3.1}/src/nber_cli/core/models.py +34 -0
- nber_cli-0.3.1/src/nber_cli/db.py +495 -0
- nber_cli-0.3.1/src/nber_cli/feed.py +299 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/src/nber_cli/formatters.py +62 -1
- {nber_cli-0.2.0 → nber_cli-0.3.1}/src/nber_cli/mcp.py +8 -1
- {nber_cli-0.2.0 → nber_cli-0.3.1}/tests/conftest.py +12 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/tests/test_cli.py +376 -3
- nber_cli-0.3.1/tests/test_db.py +205 -0
- nber_cli-0.3.1/tests/test_feed.py +382 -0
- nber_cli-0.3.1/tests/test_info_cache.py +148 -0
- nber_cli-0.3.1/tests/test_logs.py +121 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/uv.lock +1 -1
- nber_cli-0.2.0/CHANGELOG.md +0 -25
- nber_cli-0.2.0/docs/en/changelog.md +0 -25
- nber_cli-0.2.0/docs/zh/changelog.md +0 -25
- nber_cli-0.2.0/docs/zh/cli.md +0 -175
- nber_cli-0.2.0/src/nber_cli/__init__.py +0 -33
- {nber_cli-0.2.0 → nber_cli-0.3.1}/.claude/agents/code-to-docs.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/.claude/agents/sync-docs-for-i18n.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/.claude/settings.json +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/.claude-plugin/marketplace.json +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/.codex/config.toml +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/.github/workflows/docs.yml +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/.github/workflows/lint.yml +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/.github/workflows/publish.yml +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/.github/workflows/pytest.yml +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/.gitignore +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/.mcp.json +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/.python-version +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/LICENSE +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/README.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/README.zh-CN.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/agents/claude-code.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/agents/codex.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/agents/index.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/agents/openclaw.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/agents/others.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/contributing.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/development.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/mcp.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/en/policy.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/agents/claude-code.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/agents/codex.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/agents/index.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/agents/openclaw.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/agents/others.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/contributing.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/development.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/mcp.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/docs/zh/policy.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/mkdocs.yml +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/plugins/nber-cli/.claude-plugin/plugin.json +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/plugins/nber-cli/.codex-plugin/plugin.json +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/plugins/nber-cli/.mcp.json +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/plugins/nber-cli/skills/NBER-CLI/SKILL.md +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/src/nber_cli/__main__.py +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/src/nber_cli/config.py +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/src/nber_cli/core/__init__.py +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/src/nber_cli/download.py +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/src/nber_cli/fetcher.py +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/tests/__init__.py +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/tests/test_downloader.py +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/tests/test_fetcher.py +0 -0
- {nber_cli-0.2.0 → nber_cli-0.3.1}/tests/test_main.py +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [0.3.1] - 2026-06-03
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- `db init` and `db migrate` top-level subcommands replace `feed init` and `feed migrate`. The database is now general-purpose and stores feed cache, behavior logs, and paper metadata cache.
|
|
9
|
+
- `info_cache` table caches paper metadata fetched via `info` and the MCP `get_paper_info` tool. Subsequent lookups return immediately from the cache.
|
|
10
|
+
- `query_log`, `download_log`, and `info_log` tables record search keywords, download outcomes, and paper info lookups for later auditing.
|
|
11
|
+
- `schema_version` field written to `~/.nber-cli/config.json` so future schema migrations can roll forward safely.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Default database renamed from `feed.db` to `nber.db`. Existing `~/.nber-cli/feed.db` installations continue to work without manual steps.
|
|
15
|
+
- Database schema upgraded from `user_version = 1` to `user_version = 2`. Existing v1 databases are upgraded automatically on next CLI invocation; original `feed_items` rows are preserved.
|
|
16
|
+
- Database code consolidated into `nber_cli.db`. The original `init_feed_database`, `migrate_feed_database`, and `get_feed_database_path` helpers are kept as thin compatibility wrappers.
|
|
17
|
+
|
|
18
|
+
## [0.3.0] - 2026-06-03
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- `feed init` subcommand: initialize a local SQLite feed cache and write its path to user config.
|
|
22
|
+
- `feed fetch` subcommand: fetch NBER's new working papers RSS feed, cache seen items, and show newly discovered papers by default.
|
|
23
|
+
- `feed fetch --max-items`: limit displayed feed output. When used without `--display-all`, display-all behavior is enabled automatically.
|
|
24
|
+
- `feed migrate` subcommand: move the feed cache database and SQLite sidecar files to a new path, then update user config.
|
|
25
|
+
- `feed clean` subcommand: clean cached feed database records by age, date range, or all records after interactive confirmation.
|
|
26
|
+
- Python API exports for feed cache helpers and feed result models.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- Added user config support at `~/.nber-cli/config.json` for the feed cache database path.
|
|
30
|
+
- Expanded English and Chinese documentation for feed commands, configuration, Python API, and release notes.
|
|
31
|
+
|
|
32
|
+
## [0.2.0] - 2026-05-31
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
- `download` subcommand: single paper ID or batch mode (`--batch`), explicit file path (`--file`), target directory (`--save-base`).
|
|
36
|
+
- `info` subcommand: paper metadata with `--all` flag for full details and `--format json` option.
|
|
37
|
+
- `search` subcommand: full-text search with date filters (`--start-date`, `--end-date`), pagination (`--page`, `--per-page`), `--format json` option.
|
|
38
|
+
- `mcp-server` subcommand: MCP server for AI agent integration with stdio and streamable_http transports.
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
- Reworked CLI into subcommand syntax (`nber-cli <subcommand>`).
|
|
42
|
+
- Simplified downloader to direct async HTTP PDF fetches (removed database-backed state tracking).
|
|
43
|
+
- Removed legacy web UI module and script entrypoint.
|
|
44
|
+
|
|
45
|
+
## [0.1.4] - 2025-08-09
|
|
46
|
+
|
|
47
|
+
### Added
|
|
48
|
+
- Added `--version` / `-v` flag to display current version.
|
|
49
|
+
- Added comprehensive help message with examples.
|
|
50
|
+
- Added `__main__.py` file to support `python -m nber_cli` usage.
|
|
51
|
+
- Added argument grouping for better CLI organization.
|
|
52
|
+
- Added automatic help display when no arguments are provided.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nber-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: A command line interface for reaching the National Bureau of Economic Research (NBER) paper without brower.
|
|
5
5
|
Project-URL: Homepage, https://github.com/sepinetam/nber-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/sepinetam/nber-cli
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented here.
|
|
4
|
+
|
|
5
|
+
## 0.3.1 - 2026-06-03
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added `nber-cli db init` and `nber-cli db migrate` for initializing and relocating the local database. These replace `feed init` and `feed migrate`.
|
|
10
|
+
- Added `info_cache` table so repeated `nber-cli info` and MCP `get_paper_info` calls return immediately from cache.
|
|
11
|
+
- Added `query_log`, `download_log`, and `info_log` tables for recording search keywords, download outcomes, and info lookups.
|
|
12
|
+
- Added `schema_version` field in `~/.nber-cli/config.json` for forward-compatible schema upgrades.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Renamed default database file from `feed.db` to `nber.db`. Existing `~/.nber-cli/feed.db` installations keep working without manual steps.
|
|
17
|
+
- Upgraded database schema from version 1 to version 2 with automatic upgrade on next invocation.
|
|
18
|
+
- Consolidated database code into `nber_cli.db`. Old `init_feed_database` and `migrate_feed_database` helpers remain as thin compatibility wrappers.
|
|
19
|
+
|
|
20
|
+
## 0.3.0 - 2026-06-03
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- Added `nber-cli feed init` for creating a local SQLite feed cache.
|
|
25
|
+
- Added `nber-cli feed fetch` for fetching NBER's new working papers RSS feed and showing newly cached items.
|
|
26
|
+
- Added `nber-cli feed fetch --max-items` for limiting displayed feed output.
|
|
27
|
+
- Added `nber-cli feed migrate` for moving the feed cache database and updating user config.
|
|
28
|
+
- Added `nber-cli feed clean` for cleaning cached feed database records with confirmation.
|
|
29
|
+
- Added Python API documentation for feed cache helpers and feed data models.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- Added user config documentation for `~/.nber-cli/config.json` and `feed.db-path`.
|
|
34
|
+
- Expanded English and Chinese feed cache documentation across CLI, getting started, configuration, and Python API pages.
|
|
35
|
+
|
|
36
|
+
## 0.2.0 - 2026-05-27
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- Reworked the CLI into `nber-cli download ...` subcommand syntax.
|
|
41
|
+
- Added `--file/-f` and `--save-base/-s` path handling behavior.
|
|
42
|
+
- Added `--batch/-b` multi-ID download mode.
|
|
43
|
+
- Removed database-backed download state tracking.
|
|
44
|
+
- Simplified the downloader to direct async HTTP PDF fetches.
|
|
45
|
+
- Updated documentation for the v0.2 command model.
|
|
46
|
+
- Removed the legacy web UI module and script entrypoint.
|
|
47
|
+
|
|
48
|
+
## 0.1.4 - 2025-08-09
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- Added `--version` / `-v` flag to display current version.
|
|
53
|
+
- Added comprehensive help message with examples.
|
|
54
|
+
- Added `__main__.py` support for `python -m nber_cli`.
|
|
55
|
+
- Added argument grouping for better CLI organization.
|
|
56
|
+
- Added automatic help display when no arguments are provided.
|
|
@@ -22,6 +22,8 @@ Running `nber-cli` without a subcommand prints the top-level help and exits succ
|
|
|
22
22
|
| `download` | Download one or more paper PDFs. |
|
|
23
23
|
| `info` | Show metadata and abstract for one paper. |
|
|
24
24
|
| `search` | Search NBER working papers. |
|
|
25
|
+
| `db` | Manage the local SQLite database. |
|
|
26
|
+
| `feed` | Manage the NBER new working papers RSS feed cache. |
|
|
25
27
|
| `mcp-server` | Start the MCP server for agents. |
|
|
26
28
|
|
|
27
29
|
## download
|
|
@@ -139,6 +141,122 @@ nber-cli search "inflation" -f json
|
|
|
139
141
|
|
|
140
142
|
When only `--start-date` is provided, NBER-CLI automatically uses the current date as the end date.
|
|
141
143
|
|
|
144
|
+
## feed
|
|
145
|
+
|
|
146
|
+
`feed` works with NBER's new working papers RSS feed and the local SQLite database. The database tracks which RSS items have already been seen, so `feed fetch` can show only newly discovered papers by default.
|
|
147
|
+
|
|
148
|
+
### feed fetch
|
|
149
|
+
|
|
150
|
+
Fetch the RSS feed, store all fetched items in the cache, and display only new items by default:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
nber-cli feed fetch
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Display all fetched RSS items, including items already present in the cache:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
nber-cli feed fetch --display-all true
|
|
160
|
+
nber-cli feed fetch --display-all
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Limit displayed output:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
nber-cli feed fetch --max-items 5
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
When `--max-items` is provided and `--display-all` is omitted, `--display-all` defaults to `true`. This makes `nber-cli feed fetch --max-items 5` show the first five fetched RSS items instead of showing nothing when there are no new items.
|
|
170
|
+
|
|
171
|
+
Return JSON:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
nber-cli feed fetch --format json
|
|
175
|
+
nber-cli feed fetch -f json
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### feed clean
|
|
179
|
+
|
|
180
|
+
Clean cached feed database records. This deletes records from the local cache, not from NBER. Deleted cache records may be fetched again as new items if they still appear in the RSS feed.
|
|
181
|
+
|
|
182
|
+
Clean records not seen for 30 days:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
nber-cli feed clean
|
|
186
|
+
nber-cli feed clean --days 30
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Clean all cached records:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
nber-cli feed clean --all
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Clean records by last-seen date:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
nber-cli feed clean --end-date 2026-05-31
|
|
199
|
+
nber-cli feed clean --start-date 2026-05-01 --end-date 2026-05-31
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
`--end-date` without `--start-date` cleans from the earliest cached record through the end date. `--start-date` and `--end-date` are inclusive. Passing only `--start-date` is invalid.
|
|
203
|
+
|
|
204
|
+
Before deleting anything, `feed clean` prints how many cached records match and asks for confirmation:
|
|
205
|
+
|
|
206
|
+
```text
|
|
207
|
+
This operation is irreversible.
|
|
208
|
+
Deleted cache records may be fetched again as new items if they still appear in the RSS feed.
|
|
209
|
+
Continue? [y/N]:
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Only `y` or `Y` continues. Any other response aborts without deleting records.
|
|
213
|
+
|
|
214
|
+
### feed Options
|
|
215
|
+
|
|
216
|
+
| Subcommand | Option | Description |
|
|
217
|
+
| --- | --- | --- |
|
|
218
|
+
| `fetch` | `--display-all [true|false]` | Display all fetched RSS items instead of only new items. |
|
|
219
|
+
| `fetch` | `--format`, `-f` | Output format: `list` or `json`. Defaults to `list`. |
|
|
220
|
+
| `fetch` | `--max-items` | Maximum number of feed items to display. |
|
|
221
|
+
| `clean` | `--days` | Clean cached records not seen for this many days. Defaults to `30`. |
|
|
222
|
+
| `clean` | `--all` | Clean all cached feed records. |
|
|
223
|
+
| `clean` | `--start-date` | Clean cached records last seen on or after this date, formatted `YYYY-MM-DD`. |
|
|
224
|
+
| `clean` | `--end-date` | Clean cached records last seen on or before this date, formatted `YYYY-MM-DD`. |
|
|
225
|
+
|
|
226
|
+
## db
|
|
227
|
+
|
|
228
|
+
`db` manages the local SQLite database used by `info`, `search`, `download`, and `feed` for cache and behavior logs.
|
|
229
|
+
|
|
230
|
+
### db init
|
|
231
|
+
|
|
232
|
+
Initialize the database and write its path to the user config:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
nber-cli db init
|
|
236
|
+
nber-cli db init --db-path ~/.nber-cli/nber.db
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
If `--db-path` is omitted, the default database path is `~/.nber-cli/nber.db`.
|
|
240
|
+
|
|
241
|
+
If an existing `~/.nber-cli/feed.db` from 0.3.0 is present and no `nber.db` exists yet, NBER-CLI uses that legacy file in place. Schema is automatically upgraded from version 1 to version 2 on first use.
|
|
242
|
+
|
|
243
|
+
### db migrate
|
|
244
|
+
|
|
245
|
+
Move the database to a new path and update the user config:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
nber-cli db migrate ~/data/nber.db
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Migration moves the SQLite database file and any SQLite sidecar files such as `-wal`, `-shm`, and `-journal`. The target path must not already exist.
|
|
252
|
+
|
|
253
|
+
### db Options
|
|
254
|
+
|
|
255
|
+
| Subcommand | Option | Description |
|
|
256
|
+
| --- | --- | --- |
|
|
257
|
+
| `init` | `--db-path` | SQLite database path. Defaults to `~/.nber-cli/nber.db`. |
|
|
258
|
+
| `migrate` | `new_db_path` | New SQLite database path. |
|
|
259
|
+
|
|
142
260
|
## mcp-server
|
|
143
261
|
|
|
144
262
|
Start the default stdio MCP server:
|
|
@@ -172,4 +290,4 @@ For client configuration and tool details, see [MCP Server](mcp.md).
|
|
|
172
290
|
|
|
173
291
|
## Output Formats
|
|
174
292
|
|
|
175
|
-
`info` and `
|
|
293
|
+
`info`, `search`, and `feed fetch` default to `list`, a readable text format. Use `--format json` when piping output into scripts or agent workflows.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Configuration
|
|
2
2
|
|
|
3
|
-
NBER-CLI
|
|
3
|
+
Most NBER-CLI runtime behavior uses built-in defaults. The local database also uses a small user config file to remember the SQLite database path selected by `nber-cli db init` or `nber-cli db migrate`.
|
|
4
4
|
|
|
5
5
|
## Runtime Defaults
|
|
6
6
|
|
|
@@ -15,6 +15,63 @@ NBER-CLI currently uses built-in runtime defaults rather than a user configurati
|
|
|
15
15
|
|
|
16
16
|
These values live in `NBERCLIConfig` and `NBER_CLI_CONFIG`.
|
|
17
17
|
|
|
18
|
+
## User Config File
|
|
19
|
+
|
|
20
|
+
The user config file is:
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
~/.nber-cli/config.json
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Current schema:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"schema_version": 2,
|
|
31
|
+
"feed": {
|
|
32
|
+
"db-path": "/Users/name/.nber-cli/nber.db"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`feed.db-path` points to the SQLite database used by `info`, `search`, `download`, and `feed`. The historical `feed` key name is preserved for backward compatibility; the database itself is general-purpose.
|
|
38
|
+
|
|
39
|
+
`schema_version` records the current database schema version. NBER-CLI updates it after `db init` or schema upgrades.
|
|
40
|
+
|
|
41
|
+
## Local Database
|
|
42
|
+
|
|
43
|
+
Default database path:
|
|
44
|
+
|
|
45
|
+
```text
|
|
46
|
+
~/.nber-cli/nber.db
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Initialize the default database:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
nber-cli db init
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Initialize at a custom path:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
nber-cli db init --db-path ~/data/nber.db
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Move an existing database and update the config:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
nber-cli db migrate ~/data/nber.db
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
If you upgraded from 0.3.0 and still have `~/.nber-cli/feed.db`, NBER-CLI will keep using that legacy file when no `nber.db` is present. The schema is upgraded automatically on first invocation.
|
|
68
|
+
|
|
69
|
+
The database holds:
|
|
70
|
+
|
|
71
|
+
- `feed_items` and `feed_fetches`: RSS cache used by `feed fetch` and `feed clean`.
|
|
72
|
+
- `info_cache`: paper metadata cache used by `info` and the MCP `get_paper_info` tool.
|
|
73
|
+
- `query_log`, `download_log`, `info_log`: behavior logs for search keywords, download outcomes, and info lookups.
|
|
74
|
+
|
|
18
75
|
## Output Paths
|
|
19
76
|
|
|
20
77
|
Single download default:
|
|
@@ -73,6 +73,36 @@ Use `--all` to include related fields and published-version information when NBE
|
|
|
73
73
|
nber-cli info w25000 --all
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
## Follow New Papers with the Feed Cache
|
|
77
|
+
|
|
78
|
+
Initialize the local database:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
nber-cli db init
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Fetch the NBER new working papers RSS feed:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
nber-cli feed fetch
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The first fetch stores the current RSS items in the cache and displays them as new. Later fetches show only items that were not already cached.
|
|
91
|
+
|
|
92
|
+
Limit output while showing the latest fetched items:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
nber-cli feed fetch --max-items 5
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Clean old cache records:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
nber-cli feed clean --days 30
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`feed clean` asks for confirmation before deleting cached records.
|
|
105
|
+
|
|
76
106
|
## Download a PDF
|
|
77
107
|
|
|
78
108
|
Download into the current directory:
|
|
@@ -8,6 +8,7 @@ NBER-CLI focuses on the common research loop around NBER working papers:
|
|
|
8
8
|
|
|
9
9
|
- Search for papers by keyword, author, title, abstract, or paper number.
|
|
10
10
|
- Inspect a paper's title, authors, date, abstract, URL, and related metadata.
|
|
11
|
+
- Follow new working papers through NBER's RSS feed and a local cache.
|
|
11
12
|
- Download a PDF by paper ID.
|
|
12
13
|
- Run batch downloads into a target directory.
|
|
13
14
|
- Serve paper search, lookup, and download operations as MCP tools.
|
|
@@ -19,6 +20,7 @@ Run without installing:
|
|
|
19
20
|
```bash
|
|
20
21
|
uvx nber-cli search "Labor Economic"
|
|
21
22
|
uvx nber-cli info w25000
|
|
23
|
+
uvx nber-cli feed fetch --max-items 5
|
|
22
24
|
uvx nber-cli download w34567
|
|
23
25
|
```
|
|
24
26
|
|
|
@@ -28,6 +30,7 @@ Install as a reusable command:
|
|
|
28
30
|
uv tool install nber-cli
|
|
29
31
|
nber-cli search "Labor Economic"
|
|
30
32
|
nber-cli info w25000
|
|
33
|
+
nber-cli feed fetch --max-items 5
|
|
31
34
|
nber-cli download w34567
|
|
32
35
|
```
|
|
33
36
|
|
|
@@ -66,4 +69,4 @@ Add it to an MCP client:
|
|
|
66
69
|
|
|
67
70
|
## Project Status
|
|
68
71
|
|
|
69
|
-
The current public command model is `nber-cli` v0.
|
|
72
|
+
The current public command model is `nber-cli` v0.3.0. The CLI is intentionally small and script-friendly: text output is optimized for human reading, and `--format json` is available where structured output matters.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
NBER-CLI exposes the same core functionality as importable Python functions. The API is asynchronous because lookup, search, and downloads perform network I/O.
|
|
4
4
|
|
|
5
|
+
Feed cache helpers are synchronous because they perform local SQLite work and a synchronous RSS fetch.
|
|
6
|
+
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
@@ -90,6 +92,75 @@ async def main() -> None:
|
|
|
90
92
|
asyncio.run(main())
|
|
91
93
|
```
|
|
92
94
|
|
|
95
|
+
## Work with the Local Database
|
|
96
|
+
|
|
97
|
+
Initialize the default database:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from nber_cli import init_database
|
|
101
|
+
|
|
102
|
+
db_path = init_database()
|
|
103
|
+
print(db_path)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Fetch the NBER RSS feed and display new cached items:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from nber_cli import feed_results, fetch_feed
|
|
110
|
+
|
|
111
|
+
result = fetch_feed()
|
|
112
|
+
payload = feed_results(result)
|
|
113
|
+
print(payload["new_count"])
|
|
114
|
+
for item in payload["results"]:
|
|
115
|
+
print(item["id"], item["title"])
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Display all fetched RSS items and limit the returned items:
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from nber_cli import fetch_feed
|
|
122
|
+
|
|
123
|
+
result = fetch_feed(display_all=True, max_items=5)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Move the database:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from pathlib import Path
|
|
130
|
+
|
|
131
|
+
from nber_cli import migrate_database
|
|
132
|
+
|
|
133
|
+
old_path, new_path = migrate_database(Path("~/data/nber.db"))
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Clean cached feed database records:
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from nber_cli import clean_feed_cache
|
|
140
|
+
|
|
141
|
+
preview = clean_feed_cache(days=30, dry_run=True)
|
|
142
|
+
print(preview.matched_count)
|
|
143
|
+
|
|
144
|
+
result = clean_feed_cache(days=30)
|
|
145
|
+
print(result.deleted_count)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`clean_feed_cache` deletes local cache records only. If deleted records still appear in the RSS feed, a later `fetch_feed` call may return them as new items again.
|
|
149
|
+
|
|
150
|
+
Read or write the paper metadata cache directly:
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from nber_cli import read_info_cache, write_info_cache
|
|
154
|
+
from nber_cli import get_nber
|
|
155
|
+
import asyncio
|
|
156
|
+
|
|
157
|
+
paper = read_info_cache(None, "w25000")
|
|
158
|
+
if paper is None:
|
|
159
|
+
paper = asyncio.run(get_nber(25000))
|
|
160
|
+
write_info_cache(None, paper)
|
|
161
|
+
print(paper.title)
|
|
162
|
+
```
|
|
163
|
+
|
|
93
164
|
## Data Models
|
|
94
165
|
|
|
95
166
|
### NBER
|
|
@@ -118,6 +189,43 @@ asyncio.run(main())
|
|
|
118
189
|
| `start_date` | `str` or `None` | Applied start date. |
|
|
119
190
|
| `end_date` | `str` or `None` | Applied end date. |
|
|
120
191
|
|
|
192
|
+
### NBERFeedItem
|
|
193
|
+
|
|
194
|
+
| Field | Type | Description |
|
|
195
|
+
| --- | --- | --- |
|
|
196
|
+
| `paper_id` | `str` | Paper ID, for example `w35254`. |
|
|
197
|
+
| `title` | `str` | Paper title parsed from the RSS item. |
|
|
198
|
+
| `authors` | `list[str]` | Author names parsed from the RSS title. |
|
|
199
|
+
| `abstract` | `str` | RSS item description. |
|
|
200
|
+
| `url` | `str` | Canonical NBER paper URL without the RSS fragment. |
|
|
201
|
+
| `source_url` | `str` | Original RSS item URL. |
|
|
202
|
+
| `guid` | `str` | RSS item GUID. |
|
|
203
|
+
|
|
204
|
+
### NBERFeedFetchResult
|
|
205
|
+
|
|
206
|
+
| Field | Type | Description |
|
|
207
|
+
| --- | --- | --- |
|
|
208
|
+
| `source_url` | `str` | RSS feed URL. |
|
|
209
|
+
| `database_path` | `Path` | SQLite cache database path. |
|
|
210
|
+
| `total_fetched` | `int` | Number of RSS items fetched. |
|
|
211
|
+
| `new_count` | `int` | Number of fetched items that were not already in the cache. |
|
|
212
|
+
| `display_all` | `bool` | Whether returned items include all fetched items. |
|
|
213
|
+
| `items` | `list[NBERFeedItem]` | Items selected for display or structured output. |
|
|
214
|
+
| `max_items` | `int` or `None` | Display limit when provided. |
|
|
215
|
+
|
|
216
|
+
### NBERFeedCleanResult
|
|
217
|
+
|
|
218
|
+
| Field | Type | Description |
|
|
219
|
+
| --- | --- | --- |
|
|
220
|
+
| `database_path` | `Path` | SQLite cache database path. |
|
|
221
|
+
| `matched_count` | `int` | Number of cache records matching the clean criteria. |
|
|
222
|
+
| `deleted_count` | `int` | Number of cache records deleted. |
|
|
223
|
+
| `mode` | `str` | Clean mode: `days`, `all`, or `date-range`. |
|
|
224
|
+
| `days` | `int` or `None` | Day threshold for `days` mode. |
|
|
225
|
+
| `start_date` | `str` or `None` | Inclusive start date for `date-range` mode. |
|
|
226
|
+
| `end_date` | `str` or `None` | Inclusive end date for `date-range` mode. |
|
|
227
|
+
| `dry_run` | `bool` | Whether the operation only counted matching records. |
|
|
228
|
+
|
|
121
229
|
### DownloadFailure
|
|
122
230
|
|
|
123
231
|
| Field | Type | Description |
|
|
@@ -137,12 +245,13 @@ asyncio.run(main())
|
|
|
137
245
|
Use formatter helpers when you want stable dictionaries for JSON output or MCP-style responses:
|
|
138
246
|
|
|
139
247
|
```python
|
|
140
|
-
from nber_cli import info, related, search_results
|
|
248
|
+
from nber_cli import feed_results, info, related, search_results
|
|
141
249
|
```
|
|
142
250
|
|
|
143
251
|
- `info(paper)` returns core metadata.
|
|
144
252
|
- `related(paper)` returns related optional fields.
|
|
145
253
|
- `search_results(results)` returns a structured search payload.
|
|
254
|
+
- `feed_results(result)` returns a structured feed fetch payload.
|
|
146
255
|
|
|
147
256
|
For human-readable text output, use the text formatters:
|
|
148
257
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# 更新日志
|
|
2
|
+
|
|
3
|
+
这里记录项目的重要变更。
|
|
4
|
+
|
|
5
|
+
## 0.3.1 - 2026-06-03
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- 添加 `nber-cli db init` 和 `nber-cli db migrate`,用于初始化和迁移本地数据库,替代原先的 `feed init` 和 `feed migrate`。
|
|
10
|
+
- 添加 `info_cache` 表,重复执行 `nber-cli info` 或 MCP `get_paper_info` 时直接从缓存返回。
|
|
11
|
+
- 添加 `query_log`、`download_log`、`info_log` 表,记录搜索关键词、下载结果和 info 查询。
|
|
12
|
+
- 在 `~/.nber-cli/config.json` 中写入 `schema_version` 字段,便于后续的 schema 升级。
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- 默认数据库文件从 `feed.db` 改名为 `nber.db`。已经安装了 `~/.nber-cli/feed.db` 的用户无需手动迁移。
|
|
17
|
+
- 数据库 schema 从版本 1 升级到版本 2,下次启动时自动完成升级。
|
|
18
|
+
- 公共数据库代码迁移到 `nber_cli.db`,原先的 `init_feed_database` 和 `migrate_feed_database` 作为薄薄的兼容层保留。
|
|
19
|
+
|
|
20
|
+
## 0.3.0 - 2026-06-03
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- 添加 `nber-cli feed init`,用于创建本地 SQLite feed 缓存。
|
|
25
|
+
- 添加 `nber-cli feed fetch`,用于获取 NBER 最新工作论文 RSS feed 并显示新缓存的条目。
|
|
26
|
+
- 添加 `nber-cli feed fetch --max-items`,用于限制 feed 输出数量。
|
|
27
|
+
- 添加 `nber-cli feed migrate`,用于移动 feed 缓存数据库并更新用户配置。
|
|
28
|
+
- 添加 `nber-cli feed clean`,用于在确认后清理 feed 缓存数据库记录。
|
|
29
|
+
- 补充 feed 缓存辅助函数和 feed 数据模型的 Python API 文档。
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- 添加 `~/.nber-cli/config.json` 和 `feed.db-path` 的用户配置文档。
|
|
34
|
+
- 扩展中英文 CLI、快速开始、配置和 Python API 页面中的 feed 缓存文档。
|
|
35
|
+
|
|
36
|
+
## 0.2.0 - 2026-05-27
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- 将 CLI 重构为 `nber-cli download ...` 子命令语法。
|
|
41
|
+
- 添加 `--file/-f` 和 `--save-base/-s` 路径处理行为。
|
|
42
|
+
- 添加 `--batch/-b` 多编号下载模式。
|
|
43
|
+
- 移除基于数据库的下载状态跟踪。
|
|
44
|
+
- 将下载器简化为直接异步 HTTP PDF 获取。
|
|
45
|
+
- 更新 v0.2 命令模型文档。
|
|
46
|
+
- 移除旧 web UI 模块和脚本入口。
|
|
47
|
+
|
|
48
|
+
## 0.1.4 - 2025-08-09
|
|
49
|
+
|
|
50
|
+
### Added
|
|
51
|
+
|
|
52
|
+
- 添加 `--version` / `-v` 参数用于显示当前版本。
|
|
53
|
+
- 添加更完整的帮助信息和示例。
|
|
54
|
+
- 添加 `__main__.py` 以支持 `python -m nber_cli`。
|
|
55
|
+
- 添加参数分组以改善 CLI 结构。
|
|
56
|
+
- 不带参数运行时自动显示帮助信息。
|