priorwork 0.1.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.
Files changed (56) hide show
  1. priorwork-0.1.0/LICENSE +21 -0
  2. priorwork-0.1.0/PKG-INFO +447 -0
  3. priorwork-0.1.0/README.md +419 -0
  4. priorwork-0.1.0/priorwork/__init__.py +3 -0
  5. priorwork-0.1.0/priorwork/__main__.py +3 -0
  6. priorwork-0.1.0/priorwork/api.py +496 -0
  7. priorwork-0.1.0/priorwork/assets/en/AGENTS.md +90 -0
  8. priorwork-0.1.0/priorwork/assets/en/skills/survey-check/SKILL.md +47 -0
  9. priorwork-0.1.0/priorwork/assets/en/skills/survey-extract/SKILL.md +52 -0
  10. priorwork-0.1.0/priorwork/assets/en/skills/survey-new/SKILL.md +58 -0
  11. priorwork-0.1.0/priorwork/assets/en/skills/survey-screen/SKILL.md +56 -0
  12. priorwork-0.1.0/priorwork/assets/en/skills/survey-snowball/SKILL.md +33 -0
  13. priorwork-0.1.0/priorwork/assets/en/templates/literature_review.md +71 -0
  14. priorwork-0.1.0/priorwork/assets/env.example +35 -0
  15. priorwork-0.1.0/priorwork/assets/ja/AGENTS.md +90 -0
  16. priorwork-0.1.0/priorwork/assets/ja/skills/survey-check/SKILL.md +47 -0
  17. priorwork-0.1.0/priorwork/assets/ja/skills/survey-extract/SKILL.md +52 -0
  18. priorwork-0.1.0/priorwork/assets/ja/skills/survey-new/SKILL.md +58 -0
  19. priorwork-0.1.0/priorwork/assets/ja/skills/survey-screen/SKILL.md +56 -0
  20. priorwork-0.1.0/priorwork/assets/ja/skills/survey-snowball/SKILL.md +33 -0
  21. priorwork-0.1.0/priorwork/assets/ja/templates/literature_review.md +71 -0
  22. priorwork-0.1.0/priorwork/check.py +234 -0
  23. priorwork-0.1.0/priorwork/cli.py +776 -0
  24. priorwork-0.1.0/priorwork/doctor.py +149 -0
  25. priorwork-0.1.0/priorwork/export.py +236 -0
  26. priorwork-0.1.0/priorwork/fulltext.py +188 -0
  27. priorwork-0.1.0/priorwork/i18n.py +98 -0
  28. priorwork-0.1.0/priorwork/lang_ja.py +531 -0
  29. priorwork-0.1.0/priorwork/scaffold.py +463 -0
  30. priorwork-0.1.0/priorwork/snowball.py +60 -0
  31. priorwork-0.1.0/priorwork/ssci.py +231 -0
  32. priorwork-0.1.0/priorwork/survey.py +706 -0
  33. priorwork-0.1.0/priorwork/workspace.py +100 -0
  34. priorwork-0.1.0/priorwork/zotero.py +267 -0
  35. priorwork-0.1.0/priorwork.egg-info/PKG-INFO +447 -0
  36. priorwork-0.1.0/priorwork.egg-info/SOURCES.txt +54 -0
  37. priorwork-0.1.0/priorwork.egg-info/dependency_links.txt +1 -0
  38. priorwork-0.1.0/priorwork.egg-info/entry_points.txt +2 -0
  39. priorwork-0.1.0/priorwork.egg-info/requires.txt +7 -0
  40. priorwork-0.1.0/priorwork.egg-info/top_level.txt +1 -0
  41. priorwork-0.1.0/pyproject.toml +50 -0
  42. priorwork-0.1.0/setup.cfg +4 -0
  43. priorwork-0.1.0/tests/test_api.py +99 -0
  44. priorwork-0.1.0/tests/test_check_citations.py +87 -0
  45. priorwork-0.1.0/tests/test_check_depth.py +29 -0
  46. priorwork-0.1.0/tests/test_check_fulltext_cli.py +129 -0
  47. priorwork-0.1.0/tests/test_cli_json.py +114 -0
  48. priorwork-0.1.0/tests/test_doctor.py +66 -0
  49. priorwork-0.1.0/tests/test_english.py +69 -0
  50. priorwork-0.1.0/tests/test_export.py +88 -0
  51. priorwork-0.1.0/tests/test_extension.py +89 -0
  52. priorwork-0.1.0/tests/test_i18n.py +83 -0
  53. priorwork-0.1.0/tests/test_migrate_lit.py +107 -0
  54. priorwork-0.1.0/tests/test_scaffold.py +208 -0
  55. priorwork-0.1.0/tests/test_ssci.py +41 -0
  56. priorwork-0.1.0/tests/test_survey.py +203 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Takahiro Yoshida
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,447 @@
1
+ Metadata-Version: 2.4
2
+ Name: priorwork
3
+ Version: 0.1.0
4
+ Summary: Build literature reviews for the social sciences in conversation with an AI agent (Semantic Scholar + OpenAlex + SSCI)
5
+ Author: yoshida-kd
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/yoshida-kd/priorwork
8
+ Project-URL: Issues, https://github.com/yoshida-kd/priorwork/issues
9
+ Project-URL: Changelog, https://github.com/yoshida-kd/priorwork/blob/main/vscode-extension/CHANGELOG.md
10
+ Keywords: literature review,systematic review,social science,semantic scholar,openalex,ssci,zotero
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Natural Language :: English
15
+ Classifier: Natural Language :: Japanese
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Scientific/Engineering
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: requests>=2.31
22
+ Requires-Dist: python-dotenv>=1.0
23
+ Requires-Dist: pypdf>=4.0
24
+ Requires-Dist: markdown-it-py>=3.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # Prior Work
30
+
31
+ **Literature reviews for the social sciences, built in conversation with an AI agent**
32
+
33
+ [日本語](README.ja.md)
34
+
35
+ Prior Work is a toolkit for writing topic-based literature reviews in economics, sociology,
36
+ political science, management, psychology and neighbouring fields together with an AI agent
37
+ (Claude Code, Antigravity and others). The VS Code extension puts screening, searching and checks
38
+ in the sidebar.
39
+
40
+ - **The chat is the screen; the repository is the memory.** Candidates, decisions and the search
41
+ log live in JSON under `.priorwork/surveys/`, so a survey picks up where it left off in the next
42
+ conversation.
43
+ - **You decide.** The agent presents numbered candidates with a recommendation and records your
44
+ answer ("include 2, 5, 7"). In VS Code, a page per paper takes one key per decision.
45
+ - **Fabrication is caught mechanically.** `priorwork check` finds author–year citations in the
46
+ text that match no registered paper, and DOIs that point to other papers.
47
+ - **People read only the reports.** `priorwork export` writes the version for reading (HTML);
48
+ the state and caches stay out of the way in `.priorwork/`.
49
+
50
+ ```
51
+ ① scope → ② search → ③ screen → ④ chase citations → ⑤ fill in from the text → ⑥ check
52
+ /survey-new /survey-screen /survey-snowball /survey-extract /survey-check
53
+ ```
54
+
55
+ ## How it fits together
56
+
57
+ | | The engine (the `priorwork` command and the VS Code extension) | A workspace |
58
+ | :--- | :--- | :--- |
59
+ | Holds | the code and the originals of `AGENTS.md` and the skills | the reports, their state, `.env` |
60
+ | Comes from | PyPI (`pip install priorwork`) and the VS Code Marketplace (Prior Work) | you (a private GitHub repository) |
61
+ | Updated by | releases | `./priorwork upgrade` |
62
+
63
+ A workspace pins the engine's version in `requirements.txt`, so nothing changes behind your back;
64
+ `./priorwork upgrade` moves it to a new release in one command. Workspaces hold no copy of the
65
+ code, so updates never conflict.
66
+
67
+ ---
68
+
69
+ ## Setup
70
+
71
+ ### From VS Code
72
+
73
+ 1. Install **Prior Work** from the Extensions view. You need **Python 3.10 or later** and **git**.
74
+ 2. In the Prior Work activity bar, choose **Create a Workspace**, then an empty folder and the
75
+ language of the reports (English or Japanese). The extension creates a `.venv` in that folder,
76
+ installs `priorwork` from PyPI and runs `priorwork init`.
77
+ 3. **Open .env** and set your API keys (see *API keys* below).
78
+ 4. **New Survey** → **Search** → **Screen Candidates**. Leave filling in the cards and writing to
79
+ your agent.
80
+
81
+ What the extension does:
82
+
83
+ - The sidebar: each survey's next steps, and its papers as *to screen*, *maybe*, *included* and
84
+ *excluded*, with include / maybe / exclude on each (several at once, too).
85
+ - A page per paper: the abstract, the SSCI status, warnings and the scope's criteria, with **I**
86
+ include, **M** maybe and **X** exclude (with a reason). It then moves on to the next unscreened
87
+ paper.
88
+ - Search (by relevance, boolean bulk search, SSCI journals only), citation chasing, adding by DOI,
89
+ full texts, checks (in the Problems panel), the report for reading, diagnosis, `sync` and
90
+ `upgrade`, and moving a lit workspace.
91
+ - When the agent changes the state from the terminal, the sidebar follows.
92
+
93
+ ### From the command line
94
+
95
+ ```bash
96
+ mkdir my-surveys && cd my-surveys
97
+ python3 -m venv .venv
98
+ .venv/bin/pip install priorwork
99
+ .venv/bin/priorwork init --lang en # runs git init and writes reports/ .priorwork/ AGENTS.md skills ./priorwork .env.example …
100
+ cp .env.example .env # add your API keys (.env is kept out of Git)
101
+ ./priorwork doctor # diagnose the setup (--online also checks the connections)
102
+ git add -A && git commit -m "Initialize priorwork workspace"
103
+ gh repo create my-surveys --private --source=. --push # or create it on the web and git remote add
104
+ ```
105
+
106
+ Keep the workspace in a **private** GitHub repository: the reports and state files contain
107
+ abstracts. To continue on another machine, clone it, run
108
+ `python3 -m venv .venv && .venv/bin/pip install -r requirements.txt` and recreate `.env`.
109
+
110
+ `--lang` is the workspace's language: the headings of the reports, `AGENTS.md` and the skills. It
111
+ is fixed when the workspace is created. The language of the command's messages is separate: it is
112
+ `PRIORWORK_LANG` (`en` or `ja`), or else the locale (the VS Code extension follows VS Code's
113
+ display language).
114
+
115
+ What goes into Git (`priorwork sync` manages `.gitignore`):
116
+
117
+ | In Git | Not in Git |
118
+ | :--- | :--- |
119
+ | `reports/*.md`, `.priorwork/surveys/` (the state), `.priorwork/config.json`, `.priorwork/sync.json`, `AGENTS.md` and the skills, `./priorwork`, `requirements.txt`, `.env.example` | `.env` (API keys), `.venv/`, `.priorwork/cache/` (full texts), `.priorwork/data/` (the SSCI list, which may not be shared under its licence), the output of `priorwork export` |
120
+
121
+ `./priorwork doctor` also checks that the workspace is a Git repository with a GitHub remote and
122
+ that `.env` has not been committed by mistake.
123
+
124
+ What `priorwork init` creates:
125
+
126
+ ```text
127
+ my-surveys/
128
+ ├── reports/ # the reports (the working .md, and .html etc. from priorwork export)
129
+ ├── AGENTS.md, CLAUDE.md # instructions for agents (written by priorwork sync; do not edit)
130
+ ├── AGENTS.local.md # instructions for this workspace only (edit freely)
131
+ ├── .claude/skills/ # the skills for each step (a symlink to .agent/skills)
132
+ ├── .agent/skills/ # written by priorwork sync
133
+ ├── priorwork # the wrapper (./priorwork; uses .venv when there is one)
134
+ ├── requirements.txt # the engine's version (priorwork==X.Y.Z)
135
+ ├── .env / .env.example
136
+ └── .priorwork/
137
+ ├── config.json # the workspace's language
138
+ ├── surveys/ # the state (in Git)
139
+ ├── cache/ # extracted full texts, the Zotero index (not in Git)
140
+ └── data/ # the SSCI journal list CSV (not in Git)
141
+ ```
142
+
143
+ ### Updating the engine
144
+
145
+ ```bash
146
+ ./priorwork upgrade # to the latest version on PyPI (--to 0.4.0 for a given one)
147
+ ```
148
+
149
+ It rewrites `requirements.txt`, runs `pip install` and syncs `AGENTS.md` and the skills. If
150
+ `pip install` fails, `requirements.txt` is restored.
151
+
152
+ `./priorwork status` warns when `AGENTS.md` and the skills do not match the engine's version.
153
+ `priorwork sync` overwrites only files it wrote itself; anything else is left alone unless you
154
+ pass `--force`.
155
+
156
+ ### Moving a workspace from lit
157
+
158
+ Prior Work was developed under the name `lit`. A lit workspace (`.lit/`, `./lit`) moves like this;
159
+ opened in VS Code, the sidebar offers **Move to Prior Work** (and installs priorwork into `.venv`
160
+ first if needed).
161
+
162
+ ```bash
163
+ .venv/bin/pip install priorwork
164
+ .venv/bin/priorwork migrate
165
+ git status # review the moves and commit them
166
+ ```
167
+
168
+ - `.lit/` becomes `.priorwork/` (state, caches, the sync record); the workspace's language is Japanese.
169
+ - `./lit` is replaced by `./priorwork`; `litsurvey @ git+…` in `requirements.txt` becomes
170
+ `priorwork==X.Y.Z`, and lit's block in `.gitignore` is replaced.
171
+ - The markers of the managed blocks in the reports (`<!-- BEGIN lit:… -->`) become
172
+ `<!-- BEGIN priorwork:… -->`; the text and the cards you wrote stay as they are.
173
+ `<!-- lit:ignore-citation … -->` still works.
174
+ - Rename `LIT_MAX_RETRIES` and the like in `.env` to `PRIORWORK_…` (`doctor` points them out).
175
+
176
+ The even older template (`surveys/` holding both md and json, with a copy of the code in
177
+ `litsurvey/`) moves with `priorwork migrate [--clean]`; `--clean` deletes the copied code. Old
178
+ files that are overwritten are kept in `.priorwork/cache/migrate-backup/`.
179
+
180
+ ### API keys
181
+
182
+ They go into the workspace's `.env`.
183
+
184
+ | Variable | Purpose |
185
+ | :--- | :--- |
186
+ | `SEMANTIC_SCHOLAR_API_KEY` | A [Semantic Scholar API key](https://www.semanticscholar.org/product/api#api-key-form) (recommended). Without one, searches often fail on the rate limit |
187
+ | `OPENALEX_API_KEY` / `OPENALEX_MAILTO` | Optional. OpenAlex works without a key, with a daily usage cap |
188
+ | `ZOTERO_API_KEY` / `ZOTERO_USER_ID` | Optional. The Zotero link (read only); see below |
189
+ | `ZOTERO_WEBDAV_URL` / `ZOTERO_WEBDAV_USER` / `ZOTERO_WEBDAV_PASSWORD` | Optional. If Zotero syncs files through WebDAV (Nextcloud and the like) |
190
+ | `ZOTERO_DATA_DIR` | Optional. Zotero's data folder when Zotero runs on this machine (default `~/Zotero`) |
191
+
192
+ ### The Zotero link (optional)
193
+
194
+ With it, priorwork shows which included papers are in Zotero (`priorwork zotero`, `status`,
195
+ `check`) and gets full texts from the PDFs attached there (`priorwork fulltext`). It never writes
196
+ to Zotero or WebDAV.
197
+
198
+ 1. Create an API key at https://www.zotero.org/settings/keys with **only "Allow library access"**
199
+ (no notes, no write access). "Your user ID for use in API calls" on the same page is the user ID.
200
+ 2. For WebDAV sync, set the URL of the folder that holds the PDF zips (the URL set in Zotero plus
201
+ `zotero/`) and the credentials. With Nextcloud, share the `zotero` folder **read only** with a
202
+ dedicated user and use that user's app password.
203
+ 3. Check the connection with `./priorwork zotero` (it shows the size of the library and the WebDAV result).
204
+
205
+ If WebDAV reports "folder not found", check the URL. With Nextcloud under a sub-path (such as
206
+ `https://example.com/nextcloud/`), include that path:
207
+
208
+ ```
209
+ https://example.com/nextcloud/remote.php/dav/files/<user>/zotero/
210
+ ```
211
+
212
+ ### The SSCI journal list (recommended)
213
+
214
+ Only Clarivate's [Master Journal List](https://mjl.clarivate.com/) settles whether a journal is in
215
+ the SSCI. Download the SSCI list as CSV and put it in `.priorwork/data/` (keep the downloaded file
216
+ name; it stays out of Git). Without it, the status is **guessed** from a built-in list of about 100
217
+ major journals.
218
+
219
+ | Shown | Meaning |
220
+ | :--- | :--- |
221
+ | ✅ SSCI (checked against the list) | the ISSN or the name matches the list |
222
+ | 🟡 Probably SSCI (guessed from the journal name; verify) | no list set; matches the built-in list |
223
+ | 🔍 Journal (SSCI not verified) / ⚪ Not in SSCI | a journal of unknown status / not in the list |
224
+ | 📕 Book / ❌ Working paper / preprint / ❓ Unknown venue | left out of search results by default |
225
+
226
+ ---
227
+
228
+ ## Usage
229
+
230
+ ### With your agent
231
+
232
+ Open the workspace in Claude Code (or another agent) and say, for example, "I want to start a
233
+ review on the employment effects of minimum wages." The agent follows `AGENTS.md` and uses the
234
+ skills for each step (`.agent/skills/`); you can also call a skill directly, like `/survey-new`.
235
+
236
+ | Skill | What it does | What you decide |
237
+ | :--- | :--- | :--- |
238
+ | `/survey-new` | creates the survey and runs the first searches | research question, period, criteria, depth |
239
+ | `/survey-screen` | presents candidates 5–10 at a time with a recommendation (or screen them yourself in VS Code) | include / exclude (with a reason) / maybe |
240
+ | `/survey-snowball` | chases the references and citations of the included papers | decisions on the new candidates |
241
+ | `/survey-extract` | gets the full texts and fills in the paper cards (RQ, identification, …) | where the PDFs are; whether abstracts are enough |
242
+ | `/survey-check` | checks the survey and fixes what it finds | findings that cannot be resolved |
243
+
244
+ When you come back, say "let's continue"; the agent looks at `./priorwork status` for progress and
245
+ the next steps.
246
+
247
+ ### Depth (quick / full)
248
+
249
+ A survey has a depth, agreed in `/survey-new` and changeable later with
250
+ `./priorwork scope SURVEY --depth full`.
251
+
252
+ | | quick | full |
253
+ | :--- | :--- | :--- |
254
+ | Suits | a narrow topic, or just an overview | a broad topic with subtopics, or when coverage matters |
255
+ | Searches | one or two queries | several queries per subtopic |
256
+ | Citation chasing | optional | yes |
257
+ | Cards | abstracts are fine | core papers checked in the full text |
258
+
259
+ The numbers are guides, not limits. The rules and `priorwork check` are the same at both depths.
260
+
261
+ ### The files of a survey
262
+
263
+ | File | Contents | Editing |
264
+ | :--- | :--- | :--- |
265
+ | `reports/YYYYMMDD_<slug>.md` | the working report | write the text and the card fields by hand; `priorwork` regenerates everything between `<!-- BEGIN priorwork:… -->` and `<!-- END priorwork:… -->` |
266
+ | `.priorwork/surveys/YYYYMMDD_<slug>.json` | candidates, decisions and reasons (with their history), the search log, the scope, the depth, the report's language | changed only by `priorwork` (and the VS Code extension) |
267
+
268
+ - **The version for reading** comes from `./priorwork export <survey>` (`reports/YYYYMMDD_<slug>.html`,
269
+ to open in a browser or print to PDF). It leaves out the markers, empty fields, the template's
270
+ hints and the abstracts (`--with-abstracts` keeps them). `--format docx` (needs pandoc) and
271
+ `--format md` are also available. While cards are unchecked or empty, or `check` reports
272
+ ERRORs, it is marked *Draft* at the top. The output stays out of Git.
273
+ - **The comparison matrix** (section 2) is built from the paper cards (section 3). After editing
274
+ cards, run `./priorwork render`.
275
+ - **The references** (section 8) are generated from the included papers, with DOIs (no citation
276
+ keys; add papers to Zotero by hand). Included papers that would be cited the same way in the
277
+ text are told apart as 2001a / 2001b, by title (the cards and the matrix use the same labels).
278
+ - **The search log** (appendix) records the searches, the counts, the reasons for exclusion and how
279
+ many decisions were revised. A paper's history (e.g. Maybe → Excluded (theory only) → Included)
280
+ shows in `./priorwork list`.
281
+ - The card of a paper that is no longer included is kept, with what was written, in the JSON, and
282
+ comes back when the paper is included again.
283
+
284
+ ### Commands
285
+
286
+ ```bash
287
+ # Workspace
288
+ ./priorwork init [DIR] [--lang en|ja] # set up a workspace
289
+ ./priorwork sync [--force|--diff] # update AGENTS.md, the skills and ./priorwork
290
+ ./priorwork upgrade [--to X.Y.Z] # update the engine, then sync
291
+ ./priorwork doctor [--online] # diagnose the setup
292
+ ./priorwork migrate [--clean] # move a lit workspace or the old layout
293
+
294
+ # Surveys
295
+ ./priorwork status [SURVEY] # the list / progress and next steps
296
+ ./priorwork new "<topic>" --slug <slug> [--depth quick|full] [--question ... --years ... --fields ... --inclusion ... --exclusion ...]
297
+ ./priorwork scope SURVEY --question "..." [--depth quick|full] # change the scope
298
+ ./priorwork list SURVEY [--status candidate maybe] [--abstract]
299
+ ./priorwork include SURVEY 2 5 7
300
+ ./priorwork exclude SURVEY 3 --reason "theory only" # an exclusion needs a reason
301
+ ./priorwork maybe SURVEY 9 ./priorwork reset SURVEY 9 # maybe / back to candidate
302
+ ./priorwork add SURVEY <DOI>... [--candidate] # register by DOI (included by default)
303
+ ./priorwork render SURVEY
304
+ ./priorwork check SURVEY [--offline]
305
+ ./priorwork export SURVEY [--format html|docx|md] [-o PATH] [--with-abstracts]
306
+ ./priorwork fulltext SURVEY <number> [--pdf <path>]
307
+ ./priorwork zotero [SURVEY] [--refresh]
308
+
309
+ # Finding literature
310
+ ./priorwork search "<English query>" [--into SURVEY] [--bulk] [--sort citations|relevance|recent|cpy] [--year 2010-2024] [--ssci-only] [--limit N]
311
+ ./priorwork snowball SURVEY [--direction both|references|citations] [--limit N] [--min-links N]
312
+ ./priorwork get <DOI>
313
+ ./priorwork citations <DOI> [--sort cited] ./priorwork references <DOI> [--sort cited]
314
+ ./priorwork journal "<journal or ISSN>"
315
+ ```
316
+
317
+ `SURVEY` is the file name without the extension, or the slug. Most commands print JSON with
318
+ `--json` (for the VS Code extension and scripts).
319
+
320
+ ---
321
+
322
+ ## How it works
323
+
324
+ ### Searching
325
+
326
+ - **A normal search** is Semantic Scholar's relevance search.
327
+ - **`--bulk`** is Semantic Scholar's bulk search: `+` (and), `|` (or), `-` (not) and `"phrases"`,
328
+ most cited first. It finds the classics that keyword search buries.
329
+ - The order (`--sort`): `citations`, `relevance`, `recent` or `cpy` (citations per year), always
330
+ with the better SSCI status first.
331
+ - When both a working paper and its published version are found, only the published one is kept.
332
+
333
+ ### Which source does what
334
+
335
+ | Task | Semantic Scholar | OpenAlex |
336
+ | :--- | :--- | :--- |
337
+ | Search | ✔ | not used (poorer relevance) |
338
+ | Verifying details | — | ✔ S2's results are matched by DOI in batches; journal, ISSN, volume and issue come from OpenAlex |
339
+ | Getting a paper (`get` / `add`) | ✔ first | for DOIs S2 does not have |
340
+ | Citation links (`citations` / `references`) | ✔ `--sort recent` | `--sort cited`, or when S2 lacks them |
341
+ | Re-checking DOIs in `snowball` / `check` | — | ✔ |
342
+
343
+ Semantic Scholar searches well, but its records of classic papers are sometimes broken (the DOI of
344
+ another paper or of an SSRN version, missing ISSNs, missing papers). DOIs and ISSNs are therefore
345
+ taken from what OpenAlex confirms, and problems are flagged with ⚠️.
346
+
347
+ | Warning | Meaning |
348
+ | :--- | :--- |
349
+ | The DOI points to another title | S2's DOI belongs to another paper (a reply, say) |
350
+ | The DOI is a working paper / preprint version | S2 names a journal, but the DOI is an SSRN-style version |
351
+ | OpenAlex does not know the DOI / No DOI / DOI not verified | a wrong or missing DOI, or it could not be checked |
352
+ | May be a book review or comment | a title like "…, by Author", or a single page |
353
+
354
+ ### Chasing citations (snowball)
355
+
356
+ The references and citing papers of the included papers are collected from OpenAlex and
357
+ registered as candidates, ordered by how many included papers each is linked to. With three or
358
+ more included papers, only those with at least two links are taken by default.
359
+
360
+ ### Full texts
361
+
362
+ PDFs are never stored in the workspace. priorwork looks for one in this order and keeps only the
363
+ extracted text, in `.priorwork/cache/fulltext/` (outside Git):
364
+
365
+ 1. the file given with `--pdf`
366
+ 2. a PDF attached in the local Zotero (`zotero.sqlite`, opened read only, matched by DOI)
367
+ 3. a PDF attached in Zotero found through the Web API (from WebDAV's `<key>.zip` or Zotero File Storage)
368
+ 4. the text Zotero indexed (no page breaks; a fallback)
369
+ 5. an open-access PDF
370
+
371
+ Publishers usually refuse automated downloads, so for papers that are not open access, attach the
372
+ PDF in Zotero first.
373
+
374
+ ### Checks
375
+
376
+ | Check | Level |
377
+ | :--- | :--- |
378
+ | Author–year citations in the text and the cards ("Author (year)", "(Author, year; …)") match registered papers | ERROR (unregistered) / WARN (not included) |
379
+ | 2001a / 2001b match the references | WARN |
380
+ | DOIs in the text are registered | ERROR |
381
+ | ⚠️ on included papers; the DOI and title agree in OpenAlex | ERROR |
382
+ | The evidence level of each card (unchecked / abstract only / full text checked) and empty fields | WARN |
383
+ | The Markdown matches the state file (a forgotten `render`) | WARN |
384
+ | Unscreened candidates, non-SSCI included papers, included papers missing from Zotero, citations taken for organisations or table numbers | INFO |
385
+
386
+ Citations are found with regular expressions, so not every style is caught. Narrative
387
+ (`Acemoglu et al. (2001, 2005)`, `Dell (2010, p. 5)`) and parenthetical
388
+ (`(e.g., Dell 2010; Acemoglu et al., 2001a)`) citations are.
389
+
390
+ Organisations and acronyms such as "World Bank (2010)" or "OECD (2019)" are reported as INFO, not
391
+ ERROR. Something that is not a citation can be excluded with a comment in the report:
392
+
393
+ ```markdown
394
+ <!-- priorwork:ignore-citation Smith (2015) -->
395
+ ```
396
+
397
+ ### What cannot be registered
398
+
399
+ Papers in domestic journals (J-STAGE and the like) are often in neither Semantic Scholar nor
400
+ OpenAlex, so `priorwork get` / `add` cannot register them. Since the target is international
401
+ peer-reviewed journals, they are out of scope for now.
402
+
403
+ ### Other
404
+
405
+ - **Retries**: HTTP 429 / 5xx / network errors are retried up to five times, waiting 5→10→20→40→60 s (`PRIORWORK_MAX_RETRIES`).
406
+ - **Cache**: API responses are kept in `~/.cache/priorwork/` for seven days (`PRIORWORK_CACHE_TTL_DAYS`, `PRIORWORK_NO_CACHE=1`, `--no-cache`).
407
+ - **Messages**: `PRIORWORK_LANG=en|ja`, or else the locale.
408
+
409
+ ---
410
+
411
+ ## Development
412
+
413
+ ```bash
414
+ python3 -m venv .venv
415
+ .venv/bin/pip install -e ".[dev]"
416
+ .venv/bin/python -m pytest # no network needed
417
+ bin/priorwork --help # run the code of this checkout
418
+ ```
419
+
420
+ ```text
421
+ .
422
+ ├── priorwork/
423
+ │ ├── cli.py # the commands (including --json output)
424
+ │ ├── i18n.py / lang_ja.py # messages: English source, Japanese catalogue
425
+ │ ├── workspace.py # a workspace's paths and language
426
+ │ ├── scaffold.py # init / sync / upgrade / migrate
427
+ │ ├── survey.py # the state and the generated Markdown
428
+ │ ├── api.py # Semantic Scholar / OpenAlex
429
+ │ ├── ssci.py # SSCI status
430
+ │ ├── snowball.py # citation chasing
431
+ │ ├── fulltext.py # full texts (Zotero / open access)
432
+ │ ├── zotero.py # Zotero Web API / WebDAV (read only)
433
+ │ ├── check.py # checks
434
+ │ ├── export.py # the version for reading
435
+ │ ├── doctor.py # diagnosis
436
+ │ └── assets/ # what workspaces receive: AGENTS.md, skills and the report template per language (en/, ja/), env.example
437
+ ├── vscode-extension/ # the VS Code extension (TypeScript)
438
+ ├── tests/
439
+ └── bin/priorwork # the development wrapper
440
+ ```
441
+
442
+ When you change `AGENTS.md` or a skill, edit both `priorwork/assets/en/` and
443
+ `priorwork/assets/ja/`; workspaces receive them through `priorwork sync`.
444
+
445
+ ## License
446
+
447
+ MIT