nber-cli 0.5.0__tar.gz → 0.6.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.
- {nber_cli-0.5.0 → nber_cli-0.6.0}/.claude-plugin/marketplace.json +2 -2
- {nber_cli-0.5.0 → nber_cli-0.6.0}/CHANGELOG.md +15 -1
- {nber_cli-0.5.0 → nber_cli-0.6.0}/PKG-INFO +3 -2
- {nber_cli-0.5.0 → nber_cli-0.6.0}/README.md +1 -1
- {nber_cli-0.5.0 → nber_cli-0.6.0}/README.zh-CN.md +1 -1
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/changelog.md +15 -1
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/cli.md +6 -4
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/configuration.md +18 -4
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/getting-started.md +2 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/mcp.md +1 -1
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/policy.md +1 -1
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/python-api.md +16 -7
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/changelog.md +18 -1
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/cli.md +6 -4
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/configuration.md +18 -4
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/getting-started.md +2 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/mcp.md +1 -1
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/policy.md +1 -1
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/python-api.md +16 -7
- {nber_cli-0.5.0 → nber_cli-0.6.0}/plugins/nber-cli/.claude-plugin/plugin.json +1 -1
- {nber_cli-0.5.0 → nber_cli-0.6.0}/plugins/nber-cli/.codex-plugin/plugin.json +1 -1
- nber_cli-0.6.0/plugins/nber-cli/skills/NBER-CLI/SKILL.md +268 -0
- nber_cli-0.6.0/plugins/nber-cli/skills/NBER-CLI/examples/use-of-automation.md +110 -0
- nber_cli-0.6.0/plugins/nber-cli/skills/NBER-CLI/examples/use-of-db.md +78 -0
- nber_cli-0.6.0/plugins/nber-cli/skills/NBER-CLI/examples/use-of-download.md +63 -0
- nber_cli-0.6.0/plugins/nber-cli/skills/NBER-CLI/examples/use-of-error-handling.md +76 -0
- nber_cli-0.6.0/plugins/nber-cli/skills/NBER-CLI/examples/use-of-feed.md +254 -0
- nber_cli-0.6.0/plugins/nber-cli/skills/NBER-CLI/examples/use-of-info.md +44 -0
- nber_cli-0.6.0/plugins/nber-cli/skills/NBER-CLI/examples/use-of-json-pipeline.md +89 -0
- nber_cli-0.6.0/plugins/nber-cli/skills/NBER-CLI/examples/use-of-mcp-server.md +49 -0
- nber_cli-0.6.0/plugins/nber-cli/skills/NBER-CLI/examples/use-of-search.md +52 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/pyproject.toml +2 -1
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/cli.py +14 -4
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/config.schema.json +2 -2
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/db.py +185 -175
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/feed.py +20 -10
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/test_cli.py +14 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/test_db.py +18 -9
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/test_info_cache.py +2 -2
- {nber_cli-0.5.0 → nber_cli-0.6.0}/uv.lock +128 -1
- nber_cli-0.5.0/plugins/nber-cli/skills/NBER-CLI/SKILL.md +0 -92
- {nber_cli-0.5.0 → nber_cli-0.6.0}/.claude/agents/code-to-docs.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/.claude/agents/sync-docs-for-i18n.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/.claude/settings.json +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/.codex/config.toml +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/.github/workflows/docs.yml +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/.github/workflows/lint.yml +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/.github/workflows/publish.yml +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/.github/workflows/pytest.yml +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/.gitignore +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/.mcp.json +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/.python-version +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/LICENSE +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/agents/claude-code.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/agents/codex.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/agents/index.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/agents/openclaw.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/agents/others.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/contributing.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/development.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/en/index.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/agents/claude-code.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/agents/codex.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/agents/index.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/agents/openclaw.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/agents/others.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/contributing.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/development.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/docs/zh/index.md +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/mkdocs.yml +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/plugins/nber-cli/.mcp.json +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/__init__.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/__main__.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/config.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/config_store.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/core/__init__.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/core/models.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/download.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/fetcher.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/formatters.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/info_cache.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/src/nber_cli/mcp.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/__init__.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/conftest.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/test_config_store.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/test_downloader.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/test_feed.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/test_fetcher.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/test_info_cache_flow.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/test_logs.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/test_main.py +0 -0
- {nber_cli-0.5.0 → nber_cli-0.6.0}/tests/test_mcp.py +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
|
|
3
3
|
"name": "nber-cli",
|
|
4
4
|
"description": "Claude Code marketplace for NBER-CLI research workflows.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.6.0",
|
|
6
6
|
"owner": {
|
|
7
7
|
"name": "Song Tan",
|
|
8
8
|
"email": "sepinetam@gmail.com",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
{
|
|
13
13
|
"name": "nber-cli",
|
|
14
14
|
"description": "Use NBER-CLI to search, inspect, download, and serve NBER working paper workflows.",
|
|
15
|
-
"version": "0.
|
|
15
|
+
"version": "0.6.0",
|
|
16
16
|
"author": {
|
|
17
17
|
"name": "Song Tan",
|
|
18
18
|
"email": "sepinetam@gmail.com"
|
|
@@ -6,7 +6,21 @@ This file is the canonical release history. The English mirror at `docs/en/chang
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
-
## [0.
|
|
9
|
+
## [0.6.0] - 2026-07-05
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- Migrated the database layer from raw `sqlite3` to SQLModel/SQLAlchemy. All tables are now declared as SQLModel models with explicit indexes.
|
|
13
|
+
- `db init --db-path` and `db migrate <new_db_path>` now accept `sqlite:///path/to/nber.db` URLs in addition to file paths.
|
|
14
|
+
- Feed fetching, cache cleanup, query logging, download logging, info logging, and info-cache writes now use explicit SQLAlchemy sessions and commits.
|
|
15
|
+
- `config.schema.json` now describes the database path as a "Path or sqlite:/// URL".
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- Added `sqlmodel>=0.0.24` and SQLAlchemy to project dependencies.
|
|
19
|
+
- Added CLI tests for `sqlite:///` database path handling.
|
|
20
|
+
- Added release notes for v0.6.0.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- Updated the version fallback in `cli.py` from `0.4.0` to `0.6.0`.
|
|
10
24
|
|
|
11
25
|
### Security
|
|
12
26
|
- RSS feed parsing now uses `defusedxml` to block XML external entity (XXE) and entity expansion attacks.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nber-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: A command-line interface for accessing National Bureau of Economic Research (NBER) papers without a browser.
|
|
5
5
|
Project-URL: Homepage, https://github.com/sepinetam/nber-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/sepinetam/nber-cli
|
|
@@ -25,6 +25,7 @@ Requires-Dist: certifi
|
|
|
25
25
|
Requires-Dist: defusedxml>=0.7.1
|
|
26
26
|
Requires-Dist: fake-useragent
|
|
27
27
|
Requires-Dist: mcp>=1.27.1
|
|
28
|
+
Requires-Dist: sqlmodel>=0.0.24
|
|
28
29
|
Description-Content-Type: text/markdown
|
|
29
30
|
|
|
30
31
|
# NBER-CLI
|
|
@@ -48,7 +49,7 @@ A command line interface for reaching the National Bureau of Economic Research (
|
|
|
48
49
|
- Download single papers or batches as PDF files.
|
|
49
50
|
- Track newly released NBER working papers through a local RSS feed cache (`nber-cli feed fetch` / `feed clean`).
|
|
50
51
|
- Cache paper metadata locally (`nber-cli info` writes to `info_cache`) with a sliding TTL, plus a behavior log for `search`, `download`, and `info` lookups.
|
|
51
|
-
- Store the cache, RSS items, and behavior logs in a local SQLite database at `~/.nber-cli/nber.db
|
|
52
|
+
- Store the cache, RSS items, and behavior logs in a local SQLite database at `~/.nber-cli/nber.db`, managed through SQLModel/SQLAlchemy and configurable with a filesystem path or `sqlite:///...` URL.
|
|
52
53
|
- Expose the same core workflows as MCP tools for AI agents.
|
|
53
54
|
- Return human-readable output by default, with JSON output for automation.
|
|
54
55
|
|
|
@@ -19,7 +19,7 @@ A command line interface for reaching the National Bureau of Economic Research (
|
|
|
19
19
|
- Download single papers or batches as PDF files.
|
|
20
20
|
- Track newly released NBER working papers through a local RSS feed cache (`nber-cli feed fetch` / `feed clean`).
|
|
21
21
|
- Cache paper metadata locally (`nber-cli info` writes to `info_cache`) with a sliding TTL, plus a behavior log for `search`, `download`, and `info` lookups.
|
|
22
|
-
- Store the cache, RSS items, and behavior logs in a local SQLite database at `~/.nber-cli/nber.db
|
|
22
|
+
- Store the cache, RSS items, and behavior logs in a local SQLite database at `~/.nber-cli/nber.db`, managed through SQLModel/SQLAlchemy and configurable with a filesystem path or `sqlite:///...` URL.
|
|
23
23
|
- Expose the same core workflows as MCP tools for AI agents.
|
|
24
24
|
- Return human-readable output by default, with JSON output for automation.
|
|
25
25
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
- 下载单篇或批量论文 PDF。
|
|
19
19
|
- 通过本地 RSS feed 缓存追踪 NBER 新发布的工作论文(`nber-cli feed fetch` / `feed clean`)。
|
|
20
20
|
- 本地缓存论文元数据(`nber-cli info` 会写入 `info_cache`),采用滑动 TTL;同时为 `search`、`download` 和 `info` 查询记录行为日志。
|
|
21
|
-
- 把缓存、RSS 条目和行为日志统一存放在本地 SQLite 数据库 `~/.nber-cli/nber.db
|
|
21
|
+
- 把缓存、RSS 条目和行为日志统一存放在本地 SQLite 数据库 `~/.nber-cli/nber.db`,由 SQLModel/SQLAlchemy 管理,路径可用普通文件路径或 `sqlite:///...` URL 配置。
|
|
22
22
|
- 通过 MCP 工具把核心能力暴露给 AI Agent。
|
|
23
23
|
- 默认输出适合阅读的文本,也支持 JSON 输出用于自动化流程。
|
|
24
24
|
|
|
@@ -6,7 +6,21 @@ This page mirrors the canonical `CHANGELOG.md` at the repository root. The Chine
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
-
## 0.
|
|
9
|
+
## 0.6.0 - 2026-07-05
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- Migrated the database layer from raw `sqlite3` to SQLModel/SQLAlchemy. All tables are now declared as SQLModel models with explicit indexes.
|
|
13
|
+
- `db init --db-path` and `db migrate <new_db_path>` now accept `sqlite:///path/to/nber.db` URLs in addition to file paths.
|
|
14
|
+
- Feed fetching, cache cleanup, query logging, download logging, info logging, and info-cache writes now use explicit SQLAlchemy sessions and commits.
|
|
15
|
+
- `config.schema.json` now describes the database path as a "Path or sqlite:/// URL".
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- Added `sqlmodel>=0.0.24` and SQLAlchemy to project dependencies.
|
|
19
|
+
- Added CLI tests for `sqlite:///` database path handling.
|
|
20
|
+
- Added release notes for v0.6.0.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- Updated the version fallback in `cli.py` from `0.4.0` to `0.6.0`.
|
|
10
24
|
|
|
11
25
|
### Security
|
|
12
26
|
|
|
@@ -239,7 +239,7 @@ When only `--start-date` is provided, NBER-CLI automatically uses the current da
|
|
|
239
239
|
|
|
240
240
|
## feed
|
|
241
241
|
|
|
242
|
-
`feed` works with NBER's new working papers RSS feed and the local
|
|
242
|
+
`feed` works with NBER's new working papers RSS feed and the local database. The database tracks which RSS items have already been seen, so `feed fetch` can show only newly discovered papers by default.
|
|
243
243
|
|
|
244
244
|
### feed fetch
|
|
245
245
|
|
|
@@ -325,7 +325,7 @@ Only `y` or `Y` continues. Any other response aborts without deleting records.
|
|
|
325
325
|
|
|
326
326
|
## db
|
|
327
327
|
|
|
328
|
-
`db` manages the local SQLite database used by `info`, `search`, `download`, and `feed` for cache and behavior logs.
|
|
328
|
+
`db` manages the local SQLite database used by `info`, `search`, `download`, and `feed` for cache and behavior logs. The database is stored on the user's machine and accessed through SQLModel/SQLAlchemy; commands accept either a filesystem path or a `sqlite:///...` URL.
|
|
329
329
|
|
|
330
330
|
### db init
|
|
331
331
|
|
|
@@ -334,6 +334,7 @@ Initialize the database and write its path to the user config:
|
|
|
334
334
|
```bash
|
|
335
335
|
nber-cli db init
|
|
336
336
|
nber-cli db init --db-path ~/.nber-cli/nber.db
|
|
337
|
+
nber-cli db init --db-path sqlite:////Users/name/data/nber.db
|
|
337
338
|
```
|
|
338
339
|
|
|
339
340
|
If `--db-path` is omitted, the default database path is `~/.nber-cli/nber.db`.
|
|
@@ -346,6 +347,7 @@ Move the database to a new path and update the user config:
|
|
|
346
347
|
|
|
347
348
|
```bash
|
|
348
349
|
nber-cli db migrate ~/data/nber.db
|
|
350
|
+
nber-cli db migrate sqlite:////Users/name/data/nber.db
|
|
349
351
|
```
|
|
350
352
|
|
|
351
353
|
Migration moves the SQLite database file and any SQLite sidecar files such as `-wal`, `-shm`, and `-journal`. The target path must not already exist.
|
|
@@ -354,8 +356,8 @@ Migration moves the SQLite database file and any SQLite sidecar files such as `-
|
|
|
354
356
|
|
|
355
357
|
| Subcommand | Option | Description |
|
|
356
358
|
| --- | --- | --- |
|
|
357
|
-
| `init` | `--db-path` | SQLite database path. Defaults to `~/.nber-cli/nber.db`. |
|
|
358
|
-
| `migrate` | `new_db_path` | New SQLite database path. |
|
|
359
|
+
| `init` | `--db-path` | SQLite database path or `sqlite:///...` URL. Defaults to `~/.nber-cli/nber.db`. |
|
|
360
|
+
| `migrate` | `new_db_path` | New SQLite database path or `sqlite:///...` URL. |
|
|
359
361
|
|
|
360
362
|
## mcp-server
|
|
361
363
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Configuration
|
|
2
2
|
|
|
3
|
-
Most NBER-CLI runtime behavior uses built-in defaults. The local database also uses a small user config file to remember the
|
|
3
|
+
Most NBER-CLI runtime behavior uses built-in defaults. The local database also uses a small user config file to remember the database location selected by `nber-cli db init` or `nber-cli db migrate`.
|
|
4
4
|
|
|
5
5
|
## Runtime Defaults
|
|
6
6
|
|
|
@@ -25,7 +25,7 @@ The following list is exhaustive — values not listed here are constants.
|
|
|
25
25
|
| --- | --- | --- |
|
|
26
26
|
| `info.cache_enabled` | Yes | `~/.nber-cli/config.json`; toggle via `nber-cli info cache --turn-on/--off` |
|
|
27
27
|
| `info.cache_ttl_days` | Yes | `~/.nber-cli/config.json`; set via `nber-cli info cache --set-refresh <N>` |
|
|
28
|
-
| `feed.db-path` (
|
|
28
|
+
| `feed.db-path` (database path or `sqlite:///...` URL) | Yes | `~/.nber-cli/config.json`; set via `nber-cli db init --db-path ...` or `nber-cli db migrate ...` |
|
|
29
29
|
| Request timeout | **No** | Code constant in `NBERCLIConfig` |
|
|
30
30
|
| Retry count / request attempts | **No** | Code constant in `NBERCLIConfig` |
|
|
31
31
|
| Download connection limits | **No** | Code constant in `NBERCLIConfig` |
|
|
@@ -57,7 +57,7 @@ Current schema:
|
|
|
57
57
|
}
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
`feed.db-path` points to the
|
|
60
|
+
`feed.db-path` points to the local database used by `info`, `search`, `download`, and `feed`. It may be a normal filesystem path or a SQLite URL such as `sqlite:///relative/nber.db` or `sqlite:////Users/name/data/nber.db`. The historical `feed` key name is preserved for backward compatibility; the database itself is general-purpose.
|
|
61
61
|
|
|
62
62
|
`schema_version` records the current database schema version. NBER-CLI updates it after `db init` or schema upgrades.
|
|
63
63
|
|
|
@@ -87,6 +87,12 @@ Initialize at a custom path:
|
|
|
87
87
|
nber-cli db init --db-path ~/data/nber.db
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
+
Initialize with a SQLite URL:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
nber-cli db init --db-path sqlite:////Users/name/data/nber.db
|
|
94
|
+
```
|
|
95
|
+
|
|
90
96
|
Move an existing database and update the config:
|
|
91
97
|
|
|
92
98
|
```bash
|
|
@@ -101,6 +107,14 @@ The database holds:
|
|
|
101
107
|
- `info_cache`: paper metadata cache used by `info` and the MCP `get_paper_info` tool. Cache reads are gated by `info.cache_enabled` and respect the `info.cache_ttl_days` TTL.
|
|
102
108
|
- `query_log`, `download_log`, `info_log`: behavior logs for search keywords, download outcomes, and info lookups.
|
|
103
109
|
|
|
110
|
+
### Storage, Safety, and Extensibility
|
|
111
|
+
|
|
112
|
+
The database is local-only. NBER-CLI does not send this cache or log database to project infrastructure, and no NBER-CLI server receives a copy. By default it lives under `~/.nber-cli/nber.db`; when `db init` or `db migrate` is used on macOS or Linux, the selected file must stay inside the user's home directory. This keeps the default persistence model predictable and avoids accidental writes into system or shared locations.
|
|
113
|
+
|
|
114
|
+
The on-disk format is SQLite, so the database is a self-contained file plus standard SQLite sidecar files when WAL or journaling is active. Schema changes are versioned with SQLite's `PRAGMA user_version`; NBER-CLI refuses to write to a database created by a newer schema version, which protects data from accidental downgrade writes. Operations that update cache or log rows use transactions through the SQLModel/SQLAlchemy engine, and non-critical log/cache writes fail soft so a local database problem does not break search, download, or metadata lookup workflows.
|
|
115
|
+
|
|
116
|
+
The Python access layer is SQLModel on top of SQLAlchemy. Tables are declared as typed SQLModel models, while the public API still returns filesystem `Path` values for compatibility. This gives the current CLI a stable SQLite file today and leaves room for future database work, such as richer typed queries, stricter schema migrations, or additional SQLAlchemy-supported backends, without changing the user-facing commands first.
|
|
117
|
+
|
|
104
118
|
## Database Operations
|
|
105
119
|
|
|
106
120
|
The database is created and upgraded automatically the first time any command that touches it runs. Running `nber-cli db init` is **not** required before using `info`, `search`, `download`, or `feed`; it exists for callers that want to pre-create the file or pin a non-default path. After `db init` (or after the first successful run), the schema version is recorded in `~/.nber-cli/config.json` under `schema_version`.
|
|
@@ -124,7 +138,7 @@ The database is created and upgraded automatically the first time any command th
|
|
|
124
138
|
|
|
125
139
|
### Migrate and Reset
|
|
126
140
|
|
|
127
|
-
`nber-cli db migrate <new_db_path>` moves the database to a new path, including any SQLite `-wal`, `-shm`, and `-journal` sidecar files, and updates `feed.db-path` in the user config. The destination must not already exist; the command refuses to overwrite an existing file.
|
|
141
|
+
`nber-cli db migrate <new_db_path>` moves the database to a new path or SQLite URL, including any SQLite `-wal`, `-shm`, and `-journal` sidecar files, and updates `feed.db-path` in the user config. The destination must not already exist; the command refuses to overwrite an existing file.
|
|
128
142
|
|
|
129
143
|
There is no built-in command to reset the database to an empty state. The supported ways to start over are:
|
|
130
144
|
|
|
@@ -97,6 +97,8 @@ Initialize the local database:
|
|
|
97
97
|
nber-cli db init
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
The database is a local SQLite file, managed through SQLModel/SQLAlchemy. By default it is stored at `~/.nber-cli/nber.db`; advanced users can choose another path or a `sqlite:///...` URL with `nber-cli db init --db-path ...`.
|
|
101
|
+
|
|
100
102
|
Fetch the NBER new working papers RSS feed:
|
|
101
103
|
|
|
102
104
|
```bash
|
|
@@ -119,7 +119,7 @@ The MCP server performs network requests to NBER and can write PDFs to disk thro
|
|
|
119
119
|
|
|
120
120
|
### Local Persistence and Caching
|
|
121
121
|
|
|
122
|
-
`get_paper_info` honors the same `info_cache` toggle and TTL as the CLI. When the cache is enabled, the tool reads from `info_cache` on a hit and writes a new row on a miss, mirroring the CLI behavior. Every call also appends a row to `info_log` so the local database records the lookup; the local database is shared with the CLI at the path configured in `~/.nber-cli/config.json`. Tool responses do not flag whether the result came from the cache; if the caller needs that signal it must look at its own call history or use the CLI directly.
|
|
122
|
+
`get_paper_info` honors the same `info_cache` toggle and TTL as the CLI. When the cache is enabled, the tool reads from `info_cache` on a hit and writes a new row on a miss, mirroring the CLI behavior. Every call also appends a row to `info_log` so the local database records the lookup; the SQLModel/SQLAlchemy-backed local database is shared with the CLI at the path or `sqlite:///...` URL configured in `~/.nber-cli/config.json`. Tool responses do not flag whether the result came from the cache; if the caller needs that signal it must look at its own call history or use the CLI directly.
|
|
123
123
|
|
|
124
124
|
### Differences From the CLI
|
|
125
125
|
|
|
@@ -13,7 +13,7 @@ NBER-CLI is a command-line and MCP utility for searching NBER working papers, re
|
|
|
13
13
|
## Project Boundaries
|
|
14
14
|
|
|
15
15
|
- **No project-side storage**: NBER-CLI does not operate servers, caches, mirrors, CDNs, or other infrastructure for storing NBER papers or metadata. Requests go directly from the user's machine or agent runtime to NBER's website.
|
|
16
|
-
- **Default local persistence on the user machine**: NBER-CLI does keep a local SQLite database at `~/.nber-cli/nber.db` (or the path configured by `nber-cli db init` / `db migrate`) and a user config file at `~/.nber-cli/config.json`. By default the following commands and tools write to that database without any extra user input:
|
|
16
|
+
- **Default local persistence on the user machine**: NBER-CLI does keep a local SQLite database at `~/.nber-cli/nber.db` (or the path / `sqlite:///...` URL configured by `nber-cli db init` / `db migrate`) and a user config file at `~/.nber-cli/config.json`. The database is accessed through SQLModel/SQLAlchemy and remains on the user's machine unless the user copies or exports it. By default the following commands and tools write to that database without any extra user input:
|
|
17
17
|
- `nber-cli search` records every query, including the keyword, the applied filters, and the result count, in the `query_log` table.
|
|
18
18
|
- `nber-cli download` records every attempt, including the paper ID, success or failure status, the saved PDF path, and the error message when relevant, in the `download_log` table. Single download and batch download both write one row per attempt.
|
|
19
19
|
- `nber-cli info` and the MCP `get_paper_info` tool each write a row to the `info_log` table for the looked-up paper.
|
|
@@ -2,7 +2,7 @@
|
|
|
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
|
|
5
|
+
Feed cache helpers are synchronous because they perform local database work and a synchronous RSS fetch.
|
|
6
6
|
|
|
7
7
|
## API Boundaries
|
|
8
8
|
|
|
@@ -113,6 +113,15 @@ db_path = init_database()
|
|
|
113
113
|
print(db_path)
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
+
Initialize with a SQLite URL:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from nber_cli import init_database
|
|
120
|
+
|
|
121
|
+
db_path = init_database("sqlite:////Users/name/data/nber.db")
|
|
122
|
+
print(db_path)
|
|
123
|
+
```
|
|
124
|
+
|
|
116
125
|
Fetch the NBER RSS feed and display new cached items:
|
|
117
126
|
|
|
118
127
|
```python
|
|
@@ -237,11 +246,11 @@ The same `clear_info_cache` function also supports `delete_all=True` and `start_
|
|
|
237
246
|
|
|
238
247
|
## Database and Logging Helpers
|
|
239
248
|
|
|
240
|
-
These helpers are part of the top-level public API and are safe to call from user code. They wrap the SQLite
|
|
249
|
+
These helpers are part of the top-level public API and are safe to call from user code. They wrap the local SQLite database that `info`, `search`, `download`, and `feed` use internally through SQLModel/SQLAlchemy. Logging and cache writers fail soft: when a database error occurs, the helper prints a one-line warning to `stderr` and returns `None` (for recorders) instead of raising, so they do not break the calling command. Cache readers return `None` or `0` on partial database errors. Callers that need stronger guarantees can inspect the resolved local database path directly.
|
|
241
250
|
|
|
242
251
|
### `get_database_path(db_path=None) -> Path`
|
|
243
252
|
|
|
244
|
-
Return the resolved SQLite database path. When `db_path` is `None`, NBER-CLI uses the
|
|
253
|
+
Return the resolved SQLite database path. `db_path` may be a `Path`, a filesystem path string, or a `sqlite:///...` URL. When `db_path` is `None`, NBER-CLI uses the location configured in `~/.nber-cli/config.json`, or falls back to the default `~/.nber-cli/nber.db`, or the legacy `~/.nber-cli/feed.db` file when present. The returned path is always absolute, even when the input was a SQLite URL. The database file is **not** required to exist.
|
|
245
254
|
|
|
246
255
|
### `get_schema_version(db_path=None) -> int`
|
|
247
256
|
|
|
@@ -324,7 +333,7 @@ Parse raw NBER RSS XML into a list of `NBERFeedItem` objects. Items must carry a
|
|
|
324
333
|
| Field | Type | Description |
|
|
325
334
|
| --- | --- | --- |
|
|
326
335
|
| `source_url` | `str` | RSS feed URL. |
|
|
327
|
-
| `database_path` | `Path` | SQLite cache database path. |
|
|
336
|
+
| `database_path` | `Path` | Resolved local SQLite cache database path. |
|
|
328
337
|
| `total_fetched` | `int` | Number of RSS items fetched. |
|
|
329
338
|
| `new_count` | `int` | Number of fetched items that were not already in the cache. |
|
|
330
339
|
| `display_all` | `bool` | Whether returned items include all fetched items. |
|
|
@@ -335,7 +344,7 @@ Parse raw NBER RSS XML into a list of `NBERFeedItem` objects. Items must carry a
|
|
|
335
344
|
|
|
336
345
|
| Field | Type | Description |
|
|
337
346
|
| --- | --- | --- |
|
|
338
|
-
| `database_path` | `Path` | SQLite cache database path. |
|
|
347
|
+
| `database_path` | `Path` | Resolved local SQLite cache database path. |
|
|
339
348
|
| `matched_count` | `int` | Number of cache records matching the clean criteria. |
|
|
340
349
|
| `deleted_count` | `int` | Number of cache records deleted. |
|
|
341
350
|
| `mode` | `str` | Clean mode: `days`, `all`, or `date-range`. |
|
|
@@ -348,7 +357,7 @@ Parse raw NBER RSS XML into a list of `NBERFeedItem` objects. Items must carry a
|
|
|
348
357
|
|
|
349
358
|
| Field | Type | Description |
|
|
350
359
|
| --- | --- | --- |
|
|
351
|
-
| `database_path` | `Path` | SQLite cache database path. |
|
|
360
|
+
| `database_path` | `Path` | Resolved local SQLite cache database path. |
|
|
352
361
|
| `matched_count` | `int` | Number of cache records matching the clean criteria. |
|
|
353
362
|
| `deleted_count` | `int` | Number of cache records deleted. |
|
|
354
363
|
| `mode` | `str` | Clean mode: `days`, `all`, or `date-range`. |
|
|
@@ -451,7 +460,7 @@ Produced by `feed_results(result)`:
|
|
|
451
460
|
| Field | Type | Notes |
|
|
452
461
|
| --- | --- | --- |
|
|
453
462
|
| `source_url` | `str` | The RSS feed URL that was fetched. |
|
|
454
|
-
| `database_path` | `str` |
|
|
463
|
+
| `database_path` | `str` | Resolved absolute path of the local SQLite database the items were written to. |
|
|
455
464
|
| `total_fetched` | `int` | Total items parsed from the feed. |
|
|
456
465
|
| `new_count` | `int` | Items that were not already in the local cache. |
|
|
457
466
|
| `display_all` | `bool` | `true` when `results` includes all fetched items, `false` when limited to new ones. |
|
|
@@ -6,7 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
## 未发布
|
|
8
8
|
|
|
9
|
-
## 0.
|
|
9
|
+
## 0.6.0 - 2026-07-05
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- 数据库层从原生 `sqlite3` 迁移到 SQLModel/SQLAlchemy。所有表均声明为带显式索引的 SQLModel 模型。
|
|
14
|
+
- `db init --db-path` 和 `db migrate <new_db_path>` 除文件路径外,现在也接受 `sqlite:///path/to/nber.db` URL。
|
|
15
|
+
- Feed 拉取、缓存清理、查询日志、下载日志、info 日志和 info 缓存写入现在使用显式的 SQLAlchemy Session 并提交。
|
|
16
|
+
- `config.schema.json` 将数据库路径描述为 "Path or sqlite:/// URL"。
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- 项目依赖中新增 `sqlmodel>=0.0.24` 及其 SQLAlchemy 传递依赖。
|
|
21
|
+
- 新增针对 `sqlite:///` 数据库路径处理的 CLI 测试。
|
|
22
|
+
- 新增 v0.6.0 release notes。
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- 将 `cli.py` 中的版本 fallback 从 `0.4.0` 更新为 `0.6.0`。
|
|
10
27
|
|
|
11
28
|
### Security
|
|
12
29
|
|
|
@@ -239,7 +239,7 @@ nber-cli search "inflation" -f json
|
|
|
239
239
|
|
|
240
240
|
## feed
|
|
241
241
|
|
|
242
|
-
`feed` 用于处理 NBER 最新工作论文 RSS feed
|
|
242
|
+
`feed` 用于处理 NBER 最新工作论文 RSS feed 和本地数据库。数据库会记录哪些 RSS 条目已经见过,因此 `feed fetch` 默认只显示新发现的论文。
|
|
243
243
|
|
|
244
244
|
### feed fetch
|
|
245
245
|
|
|
@@ -325,7 +325,7 @@ Continue? [y/N]:
|
|
|
325
325
|
|
|
326
326
|
## db
|
|
327
327
|
|
|
328
|
-
`db` 用于管理本地 SQLite 数据库,`info`、`search`、`download` 和 `feed`
|
|
328
|
+
`db` 用于管理本地 SQLite 数据库,`info`、`search`、`download` 和 `feed` 会用这个数据库存放缓存和行为日志。数据库保存在用户机器上,并通过 SQLModel/SQLAlchemy 访问;命令参数既接受普通文件路径,也接受 `sqlite:///...` URL。
|
|
329
329
|
|
|
330
330
|
### db init
|
|
331
331
|
|
|
@@ -334,6 +334,7 @@ Continue? [y/N]:
|
|
|
334
334
|
```bash
|
|
335
335
|
nber-cli db init
|
|
336
336
|
nber-cli db init --db-path ~/.nber-cli/nber.db
|
|
337
|
+
nber-cli db init --db-path sqlite:////Users/name/data/nber.db
|
|
337
338
|
```
|
|
338
339
|
|
|
339
340
|
如果省略 `--db-path`,默认数据库路径是 `~/.nber-cli/nber.db`。
|
|
@@ -346,6 +347,7 @@ nber-cli db init --db-path ~/.nber-cli/nber.db
|
|
|
346
347
|
|
|
347
348
|
```bash
|
|
348
349
|
nber-cli db migrate ~/data/nber.db
|
|
350
|
+
nber-cli db migrate sqlite:////Users/name/data/nber.db
|
|
349
351
|
```
|
|
350
352
|
|
|
351
353
|
迁移会移动 SQLite 数据库文件,以及 `-wal`、`-shm`、`-journal` 等 SQLite sidecar 文件。目标路径不能已经存在。
|
|
@@ -354,8 +356,8 @@ nber-cli db migrate ~/data/nber.db
|
|
|
354
356
|
|
|
355
357
|
| 子命令 | 选项 | 说明 |
|
|
356
358
|
| --- | --- | --- |
|
|
357
|
-
| `init` | `--db-path` | SQLite
|
|
358
|
-
| `migrate` | `new_db_path` | 新的 SQLite
|
|
359
|
+
| `init` | `--db-path` | SQLite 数据库路径或 `sqlite:///...` URL,默认是 `~/.nber-cli/nber.db`。 |
|
|
360
|
+
| `migrate` | `new_db_path` | 新的 SQLite 数据库路径或 `sqlite:///...` URL。 |
|
|
359
361
|
|
|
360
362
|
## mcp-server
|
|
361
363
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 配置
|
|
2
2
|
|
|
3
|
-
NBER-CLI 的大多数运行时行为使用内置默认值。本地数据库还会使用一个小型用户配置文件,用来记住 `nber-cli db init` 或 `nber-cli db migrate`
|
|
3
|
+
NBER-CLI 的大多数运行时行为使用内置默认值。本地数据库还会使用一个小型用户配置文件,用来记住 `nber-cli db init` 或 `nber-cli db migrate` 选择的数据库位置。
|
|
4
4
|
|
|
5
5
|
## 运行时默认值
|
|
6
6
|
|
|
@@ -25,7 +25,7 @@ NBER-CLI 的大多数运行时行为使用内置默认值。本地数据库还
|
|
|
25
25
|
| --- | --- | --- |
|
|
26
26
|
| `info.cache_enabled` | 是 | `~/.nber-cli/config.json`;用 `nber-cli info cache --turn-on/--off` 切换 |
|
|
27
27
|
| `info.cache_ttl_days` | 是 | `~/.nber-cli/config.json`;用 `nber-cli info cache --set-refresh <N>` 设置 |
|
|
28
|
-
| `feed.db-path
|
|
28
|
+
| `feed.db-path`(数据库路径或 `sqlite:///...` URL) | 是 | `~/.nber-cli/config.json`;用 `nber-cli db init --db-path ...` 或 `nber-cli db migrate ...` 设置 |
|
|
29
29
|
| 请求超时 | **否** | `NBERCLIConfig` 中的代码常量 |
|
|
30
30
|
| 重试次数 / 请求尝试次数 | **否** | `NBERCLIConfig` 中的代码常量 |
|
|
31
31
|
| 下载连接上限 | **否** | `NBERCLIConfig` 中的代码常量 |
|
|
@@ -57,7 +57,7 @@ NBER-CLI 的大多数运行时行为使用内置默认值。本地数据库还
|
|
|
57
57
|
}
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
`feed.db-path` 指向 `info`、`search`、`download` 和 `feed`
|
|
60
|
+
`feed.db-path` 指向 `info`、`search`、`download` 和 `feed` 都会使用的本地数据库。它可以是普通文件路径,也可以是 `sqlite:///relative/nber.db` 或 `sqlite:////Users/name/data/nber.db` 这样的 SQLite URL。`feed` 这个 key 名称保留以保持向后兼容,数据库本身是通用的。
|
|
61
61
|
|
|
62
62
|
`schema_version` 记录当前数据库 schema 的版本。NBER-CLI 在 `db init` 或 schema 升级后更新该字段。
|
|
63
63
|
|
|
@@ -87,6 +87,12 @@ nber-cli db init
|
|
|
87
87
|
nber-cli db init --db-path ~/data/nber.db
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
+
用 SQLite URL 初始化:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
nber-cli db init --db-path sqlite:////Users/name/data/nber.db
|
|
94
|
+
```
|
|
95
|
+
|
|
90
96
|
移动已有数据库并更新配置:
|
|
91
97
|
|
|
92
98
|
```bash
|
|
@@ -101,6 +107,14 @@ nber-cli db migrate ~/data/nber.db
|
|
|
101
107
|
- `info_cache`:`info` 和 MCP `get_paper_info` 工具使用的论文元数据缓存。读取行为受 `info.cache_enabled` 控制,并受 `info.cache_ttl_days` 的 TTL 约束。
|
|
102
108
|
- `query_log`、`download_log`、`info_log`:搜索关键词、下载结果和 info 查询的行为日志。
|
|
103
109
|
|
|
110
|
+
### 存储、安全性与扩展性
|
|
111
|
+
|
|
112
|
+
数据库只保存在本机。NBER-CLI 不会把这份缓存或日志数据库发送到项目侧基础设施,也没有 NBER-CLI 服务器会接收副本。默认位置是 `~/.nber-cli/nber.db`;在 macOS 或 Linux 上使用 `db init` 或 `db migrate` 时,选择的数据库文件必须位于用户 home 目录内。这样可以让默认持久化位置更可预期,也避免误写到系统目录或共享目录。
|
|
113
|
+
|
|
114
|
+
磁盘格式仍然是 SQLite,因此数据库是一个自包含文件;启用 WAL 或 journal 时会再带有标准 SQLite sidecar 文件。schema 通过 SQLite 的 `PRAGMA user_version` 记录版本;如果数据库来自更新的 schema 版本,NBER-CLI 会拒绝写入,避免旧版本程序误写新结构。缓存和日志更新通过 SQLModel/SQLAlchemy engine 以事务方式执行;非关键的日志和缓存写入采用软失败策略,所以本地数据库问题不会中断搜索、下载或元数据查询主流程。
|
|
115
|
+
|
|
116
|
+
Python 访问层使用 SQLModel,并建立在 SQLAlchemy 之上。表结构以带类型的 SQLModel 模型声明,同时公共 API 为了兼容仍返回文件系统 `Path`。这让当前 CLI 继续使用稳定的 SQLite 文件,同时为未来的数据库能力留下空间,例如更丰富的类型化查询、更严格的 schema 迁移,或在不先改变用户命令的情况下接入更多 SQLAlchemy 支持的后端。
|
|
117
|
+
|
|
104
118
|
## 数据库操作
|
|
105
119
|
|
|
106
120
|
数据库会在首次运行任何触及它的命令时自动创建并完成 schema 升级。`info`、`search`、`download` 和 `feed` 的使用者**不必**先执行 `nber-cli db init`;该命令的存在是为了让调用方可以预创建文件或指定非默认路径。`db init` 执行后(或首次成功运行后),schema 版本会写入 `~/.nber-cli/config.json` 的 `schema_version` 字段。
|
|
@@ -124,7 +138,7 @@ nber-cli db migrate ~/data/nber.db
|
|
|
124
138
|
|
|
125
139
|
### 迁移与重置
|
|
126
140
|
|
|
127
|
-
`nber-cli db migrate <new_db_path>`
|
|
141
|
+
`nber-cli db migrate <new_db_path>` 把数据库移至新路径或 SQLite URL,包括所有 SQLite `-wal`、`-shm`、`-journal` sidecar 文件,并更新用户配置中的 `feed.db-path`。目标路径不能已经存在;该命令会拒绝覆盖现有文件。
|
|
128
142
|
|
|
129
143
|
目前没有“直接清空数据库”的内建命令。可行的重置方式有:
|
|
130
144
|
|
|
@@ -119,7 +119,7 @@ MCP server 会向 NBER 发起网络请求,并可以通过 `download_paper` 写
|
|
|
119
119
|
|
|
120
120
|
### 本地持久化与缓存
|
|
121
121
|
|
|
122
|
-
`get_paper_info` 遵守与 CLI 相同的 `info_cache` 开关和 TTL。缓存开启时,命中会从 `info_cache` 读取,未命中会写入新行,行为与 CLI 一致。每次调用还会向 `info_log`
|
|
122
|
+
`get_paper_info` 遵守与 CLI 相同的 `info_cache` 开关和 TTL。缓存开启时,命中会从 `info_cache` 读取,未命中会写入新行,行为与 CLI 一致。每次调用还会向 `info_log` 追加一行,使本地数据库记录这次查询;这个由 SQLModel/SQLAlchemy 访问的本地数据库与 CLI 共用,由 `~/.nber-cli/config.json` 中配置的路径或 `sqlite:///...` URL 决定。工具的返回值不会标明结果是否来自缓存;调用方需要该信号时,应自己检查调用历史或直接使用 CLI。
|
|
123
123
|
|
|
124
124
|
### 与 CLI 的差异
|
|
125
125
|
|
|
@@ -11,7 +11,7 @@ NBER-CLI 是一个命令行与 MCP 工具,用于帮助用户搜索 NBER 工作
|
|
|
11
11
|
## 项目边界
|
|
12
12
|
|
|
13
13
|
- **不进行项目侧存储**:NBER-CLI 不运营用于存储 NBER 论文或元数据的服务器、缓存、镜像、CDN 或其他基础设施。请求直接从用户的设备或 Agent 运行环境发往 NBER 网站。
|
|
14
|
-
- **用户机器上的默认本地持久化**:NBER-CLI 会在用户机器上保留一个本地 SQLite 数据库,默认位于 `~/.nber-cli/nber.db`(或 `nber-cli db init` / `db migrate`
|
|
14
|
+
- **用户机器上的默认本地持久化**:NBER-CLI 会在用户机器上保留一个本地 SQLite 数据库,默认位于 `~/.nber-cli/nber.db`(或 `nber-cli db init` / `db migrate` 配置的路径 / `sqlite:///...` URL),并保留一个用户配置文件 `~/.nber-cli/config.json`。数据库通过 SQLModel/SQLAlchemy 访问,除非用户自行复制或导出,否则它只留在用户机器上。下列命令和工具会在没有额外用户输入的情况下默认写入该数据库:
|
|
15
15
|
- `nber-cli search` 会把每次查询的关键词、筛选条件和结果数量记录到 `query_log` 表。
|
|
16
16
|
- `nber-cli download` 会把每次下载尝试的论文编号、成功或失败状态、保存的 PDF 路径以及失败时的错误信息记录到 `download_log` 表。单篇下载和批量下载都会按尝试次数逐条写入。
|
|
17
17
|
- `nber-cli info` 与 MCP `get_paper_info` 工具会把每次查询的论文编号写入 `info_log` 表。
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
NBER-CLI 暴露了与 CLI 相同核心能力的 Python 函数。由于查询、搜索和下载都涉及网络 I/O,这些 API 是异步的。
|
|
4
4
|
|
|
5
|
-
feed
|
|
5
|
+
feed 缓存辅助函数是同步的,因为它们主要执行本地数据库操作和同步 RSS 获取。
|
|
6
6
|
|
|
7
7
|
## API 边界
|
|
8
8
|
|
|
@@ -113,6 +113,15 @@ db_path = init_database()
|
|
|
113
113
|
print(db_path)
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
+
使用 SQLite URL 初始化:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from nber_cli import init_database
|
|
120
|
+
|
|
121
|
+
db_path = init_database("sqlite:////Users/name/data/nber.db")
|
|
122
|
+
print(db_path)
|
|
123
|
+
```
|
|
124
|
+
|
|
116
125
|
获取 NBER RSS feed 并显示新的缓存条目:
|
|
117
126
|
|
|
118
127
|
```python
|
|
@@ -237,11 +246,11 @@ print(f"Deleted: {result.deleted_count}")
|
|
|
237
246
|
|
|
238
247
|
## 数据库与日志辅助函数
|
|
239
248
|
|
|
240
|
-
这些辅助函数属于顶层公共 API
|
|
249
|
+
这些辅助函数属于顶层公共 API,可以在用户代码中安全调用。它们通过 SQLModel/SQLAlchemy 包装了 `info`、`search`、`download` 和 `feed` 内部使用的本地 SQLite 数据库。日志与缓存写入采用“软失败”策略:数据库异常发生时,函数会向 `stderr` 输出一行 warning(对于记录器返回 `None`),而不会抛出异常,因此不会打断调用方的主命令。缓存读取器在数据库局部错误下返回 `None` 或 `0`。需要更强保证的调用方可以直接检查解析后的本地数据库路径。
|
|
241
250
|
|
|
242
251
|
### `get_database_path(db_path=None) -> Path`
|
|
243
252
|
|
|
244
|
-
返回解析后的 SQLite
|
|
253
|
+
返回解析后的 SQLite 数据库路径。`db_path` 可以是 `Path`、文件路径字符串,也可以是 `sqlite:///...` URL。当 `db_path` 为 `None` 时,NBER-CLI 优先使用 `~/.nber-cli/config.json` 中配置的位置,回退到默认 `~/.nber-cli/nber.db`,在文件存在时回退到旧版 `~/.nber-cli/feed.db`。即使输入是 SQLite URL,返回值也始终是绝对路径。**不要求**该数据库文件实际存在。
|
|
245
254
|
|
|
246
255
|
### `get_schema_version(db_path=None) -> int`
|
|
247
256
|
|
|
@@ -324,7 +333,7 @@ print(f"Deleted: {result.deleted_count}")
|
|
|
324
333
|
| 字段 | 类型 | 说明 |
|
|
325
334
|
| --- | --- | --- |
|
|
326
335
|
| `source_url` | `str` | RSS feed URL。 |
|
|
327
|
-
| `database_path` | `Path` | SQLite 缓存数据库路径。 |
|
|
336
|
+
| `database_path` | `Path` | 解析后的本地 SQLite 缓存数据库路径。 |
|
|
328
337
|
| `total_fetched` | `int` | 本次获取到的 RSS 条目数量。 |
|
|
329
338
|
| `new_count` | `int` | 本次获取到且缓存中原本不存在的条目数量。 |
|
|
330
339
|
| `display_all` | `bool` | 返回条目是否包含所有获取到的条目。 |
|
|
@@ -335,7 +344,7 @@ print(f"Deleted: {result.deleted_count}")
|
|
|
335
344
|
|
|
336
345
|
| 字段 | 类型 | 说明 |
|
|
337
346
|
| --- | --- | --- |
|
|
338
|
-
| `database_path` | `Path` | SQLite 缓存数据库路径。 |
|
|
347
|
+
| `database_path` | `Path` | 解析后的本地 SQLite 缓存数据库路径。 |
|
|
339
348
|
| `matched_count` | `int` | 符合清理条件的缓存记录数量。 |
|
|
340
349
|
| `deleted_count` | `int` | 已删除的缓存记录数量。 |
|
|
341
350
|
| `mode` | `str` | 清理模式:`days`、`all` 或 `date-range`。 |
|
|
@@ -348,7 +357,7 @@ print(f"Deleted: {result.deleted_count}")
|
|
|
348
357
|
|
|
349
358
|
| 字段 | 类型 | 说明 |
|
|
350
359
|
| --- | --- | --- |
|
|
351
|
-
| `database_path` | `Path` | SQLite 缓存数据库路径。 |
|
|
360
|
+
| `database_path` | `Path` | 解析后的本地 SQLite 缓存数据库路径。 |
|
|
352
361
|
| `matched_count` | `int` | 符合清理条件的缓存记录数量。 |
|
|
353
362
|
| `deleted_count` | `int` | 已删除的缓存记录数量。 |
|
|
354
363
|
| `mode` | `str` | 清理模式:`days`、`all` 或 `date-range`。 |
|
|
@@ -451,7 +460,7 @@ from nber_cli.formatters import feed_results_text, info_text, search_results_tex
|
|
|
451
460
|
| 字段 | 类型 | 备注 |
|
|
452
461
|
| --- | --- | --- |
|
|
453
462
|
| `source_url` | `str` | 本次抓取的 RSS feed URL。 |
|
|
454
|
-
| `database_path` | `str` |
|
|
463
|
+
| `database_path` | `str` | 写入条目的本地 SQLite 数据库解析后绝对路径。 |
|
|
455
464
|
| `total_fetched` | `int` | 本次从 feed 解析出的条目数。 |
|
|
456
465
|
| `new_count` | `int` | 本地缓存中原本不存在的条目数。 |
|
|
457
466
|
| `display_all` | `bool` | `results` 包含全部条目时为 `true`;只包含新条目时为 `false`。 |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://anthropic.com/claude-code/plugin.schema.json",
|
|
3
3
|
"name": "nber-cli",
|
|
4
4
|
"description": "Use NBER-CLI to search, inspect, download, and serve NBER working paper workflows.",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.6.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Song Tan",
|
|
8
8
|
"email": "sepinetam@gmail.com"
|