paper-harness-cli 2.6.1__tar.gz → 2.7.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 (77) hide show
  1. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/CHANGELOG.md +18 -0
  2. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/PKG-INFO +8 -2
  3. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/README.md +5 -1
  4. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/SPEC.md +3 -2
  5. paper_harness_cli-2.7.0/docs/author-proxy-baseline.md +49 -0
  6. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/pyproject.toml +6 -1
  7. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/__init__.py +1 -1
  8. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/BRIEF.md +3 -1
  9. paper_harness_cli-2.7.0/src/paperops/annotations.py +395 -0
  10. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/build.py +1 -0
  11. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/cli.py +31 -1
  12. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/harness.py +2 -1
  13. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/skills/paper-brief/SKILL.md +28 -2
  14. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/skills/paper-check/SKILL.md +36 -2
  15. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/skills/paper-draft/SKILL.md +10 -2
  16. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/skills/paper-revise/SKILL.md +3 -0
  17. paper_harness_cli-2.7.0/tests/test_annotations.py +158 -0
  18. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/uv.lock +401 -1
  19. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/vscode/paperops-review/README.md +1 -1
  20. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/vscode/paperops-review/extension.js +42 -8
  21. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/vscode/paperops-review/merge.js +9 -1
  22. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/vscode/paperops-review/package.json +3 -3
  23. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/vscode/paperops-review/test/merge.test.js +7 -1
  24. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/.github/assets/conversation-dark.svg +0 -0
  25. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/.github/assets/conversation-light.svg +0 -0
  26. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/.github/assets/hero-dark.svg +0 -0
  27. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/.github/assets/hero-light.svg +0 -0
  28. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/.github/assets/make_readme_art.py +0 -0
  29. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/.github/workflows/ci.yml +0 -0
  30. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/.github/workflows/publish-pypi.yml +0 -0
  31. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/.gitignore +0 -0
  32. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/AGENTS.md +0 -0
  33. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/CLAUDE.md +0 -0
  34. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/docs/lessons-from-style.md +0 -0
  35. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/docs/results-and-model-readings.md +0 -0
  36. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/docs/review-baseline.md +0 -0
  37. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/docs/writing-intent.md +0 -0
  38. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/LOG.md +0 -0
  39. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/README.md +0 -0
  40. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/STYLE.md +0 -0
  41. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/STYLE.shared.md +0 -0
  42. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/figures/_template/figure.md +0 -0
  43. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/figures/_template/make.py +0 -0
  44. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/figures/common.py +0 -0
  45. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/figures/paper.mplstyle +0 -0
  46. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/gitignore +0 -0
  47. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/manuscript/main.tex +0 -0
  48. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/manuscript/numbers.tex +0 -0
  49. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/manuscript/preamble.en.tex +0 -0
  50. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/manuscript/preamble.ja.tex +0 -0
  51. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/manuscript/refs.bib +0 -0
  52. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/manuscript/sections/.gitkeep +0 -0
  53. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/_scaffold/paper.toml +0 -0
  54. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/context/__init__.py +0 -0
  55. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/context/_notes.py +0 -0
  56. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/context/_render.py +0 -0
  57. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/context/_sources.py +0 -0
  58. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/project.py +0 -0
  59. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/scaffold.py +0 -0
  60. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/skills/paper-draft/references/results-and-model.md +0 -0
  61. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/skills/paper-figure/SKILL.md +0 -0
  62. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/skills/paper-figure/references/open-data.md +0 -0
  63. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/skills/paper-predict/SKILL.md +0 -0
  64. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/tex/__init__.py +0 -0
  65. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/tex/_outline.py +0 -0
  66. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/src/paperops/tex/_source.py +0 -0
  67. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/tests/__init__.py +0 -0
  68. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/tests/conftest.py +0 -0
  69. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/tests/test_build.py +0 -0
  70. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/tests/test_figures.py +0 -0
  71. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/tests/test_harness.py +0 -0
  72. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/tests/test_project.py +0 -0
  73. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/tests/test_tex.py +0 -0
  74. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/vscode/paperops-review/.gitignore +0 -0
  75. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/vscode/paperops-review/.vscodeignore +0 -0
  76. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/vscode/paperops-review/package-lock.json +0 -0
  77. {paper_harness_cli-2.6.1 → paper_harness_cli-2.7.0}/vscode/paperops-review/test/host.js +0 -0
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.7.0(2026-11-30)
4
+
5
+ - `paper-check` に「著者の代わりに読む」手順を足した。この会話と BRIEF を見ていない読み手に PDF と STYLE(論文と共有)を渡し、
6
+ 著者が指摘しそうな箇所を、特に削る・縮める・丸める候補を中心に挙げさせる。STYLE の規則に当たるものと読者が失うもののない
7
+ 削除は直し、柱でない結果は `paper-brief` の手順 5 で置き方を選び直し、迷うものは著者に見せる。`paper-draft` は草稿を渡す前に
8
+ この手順を行う。同じ著者の論文 2 本で、著者が指摘する直前の版を読ませた測定に基づく([背景](docs/author-proxy-baseline.md))。
9
+ - #89 柱でない結果と段落の細部を、得るものと読者の負担を並べて選ぶようにした。`paper-brief` は、主要な発見に入らない
10
+ 結果ごとに、乗る文(その結果を前提に別のことを述べる文)と読者の負担(新しく覚える指標・モデルの別版・図・付録)を書き、
11
+ 置き方(本文 / 定義と結果を数文 / 一文か panel 1 枚 / 載せない+戻す条件)を選ぶ。結果を足す案には負担と
12
+ ページの見込みを添える。`paper-draft` は段落に持ち込んだ新しいものの使い道を確かめ、`paper-revise` は「これは要るか」に、
13
+ 失うものと戻す条件を示して答える。
14
+ - `pops annotations PDF`: PDF に付けたハイライト・下線・取り消し線と付箋(注釈)を、対応する TeX の行の `%>` コメントにする。
15
+ ハイライトした文字を source の行と照合し(CJK のフォントで数字や数式が抜ける PDF でも合うよう、文字だけを比べる)、
16
+ `pops build` が新たに書く SyncTeX(`-synctex=1`)で注釈のあるページの行に絞る。一文の中なら行末、複数の文なら段落の上に置く。
17
+ 同じコメントがあれば入れない。PDF の読み取りに pdfplumber を使うので、追加の依存 `[pdf]` にした。
18
+ - VS Code 拡張 Paperops Review 0.1.3: symlink の論文 dir などで原稿タブが外部の書き換えを拾わないときも保存できるようにした。
19
+ 未保存の編集が無い添削タブは原稿の更新を読み直し、未保存マークを付けない。`.tex` のタブにボタンを出す。
20
+
3
21
  ## 2.6.1(2026-11-27)
4
22
 
5
23
  - #88 `paper-draft` に、主な事実を主節に置き条件や図の位置を従属節・括弧に回して情報の重みを示す書き方と、
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: paper-harness-cli
3
- Version: 2.6.1
3
+ Version: 2.7.0
4
4
  Summary: Minimal harness for writing a paper with AI agents: brief, figures, review comments, learned style
5
5
  Project-URL: Homepage, https://github.com/Nkzono99/paperops
6
6
  Project-URL: Repository, https://github.com/Nkzono99/paperops
@@ -16,6 +16,8 @@ Classifier: Programming Language :: Python :: 3.12
16
16
  Classifier: Programming Language :: Python :: 3.13
17
17
  Classifier: Topic :: Text Processing :: Markup :: LaTeX
18
18
  Requires-Python: >=3.11
19
+ Provides-Extra: pdf
20
+ Requires-Dist: pdfplumber>=0.11; extra == 'pdf'
19
21
  Description-Content-Type: text/markdown
20
22
 
21
23
  <picture>
@@ -95,6 +97,10 @@ TeX に `%>` で始まるコメントを書きます。段落の上に書くと
95
97
 
96
98
  エージェントは指摘箇所を直したうえで、同じ好みを原稿全体へ広げ、規則として `STYLE.md`(論文をまたぐ好みは共有 STYLE)に残します。学んだ規則は毎回報告されるので、違っていれば「その規則は違う」と直せます。
97
99
 
100
+ - **PDF で添削する(任意)**: `pops build` の PDF に、PDF ビューアでハイライトと注釈を付けて保存し、`pops annotations <PDF>` で
101
+ TeX の対応する行へ `%> [p.5] 「ハイライトした文」 注釈` として入れます。一文の中のハイライトは行末に、複数の文にまたがるものは
102
+ 段落の上に置きます。照合はハイライトした文字で行い、`pops build` が書く SyncTeX で注釈のページに絞ります。ハイライトの無い付箋は、
103
+ 横にある行の文字か SyncTeX の位置で置きます。PDF を読むのに pdfplumber が要ります(`pip install 'paper-harness-cli[pdf]'`)。
98
104
  - **並行して添削する(任意)**: エージェントの修正中に自分でも書き込むときは、VS Code 拡張 [Paperops Review](https://github.com/Nkzono99/paperops/tree/main/vscode/paperops-review) を使うと変更を 3 方向マージできます。
99
105
  - **改稿から学ぶ**: 「この節の改稿から次の論文にも使えることを拾って」と頼むと、直接の書き換えや講評の採否から再利用できる判断を抽出します。
100
106
 
@@ -133,4 +139,4 @@ paper-rough-pipe/
133
139
 
134
140
  - **設計と開発**: [SPEC](https://github.com/Nkzono99/paperops/blob/main/SPEC.md) · [変更履歴](https://github.com/Nkzono99/paperops/blob/main/CHANGELOG.md) · [開発に参加する](https://github.com/Nkzono99/paperops/blob/main/AGENTS.md)
135
141
  - **手引き**: [結果とモデル説明](https://github.com/Nkzono99/paperops/blob/main/src/paperops/skills/paper-draft/references/results-and-model.md) · [図の公開データ(Zenodo 等)](https://github.com/Nkzono99/paperops/blob/main/src/paperops/skills/paper-figure/references/open-data.md) · [Paperops Review(VS Code 拡張)](https://github.com/Nkzono99/paperops/tree/main/vscode/paperops-review)
136
- - **背景と記録**: [原著 12 本の読解](https://github.com/Nkzono99/paperops/blob/main/docs/results-and-model-readings.md) · [添削からの具体例](https://github.com/Nkzono99/paperops/blob/main/docs/lessons-from-style.md) · [講評をどこで終えるか](https://github.com/Nkzono99/paperops/blob/main/docs/review-baseline.md)
142
+ - **背景と記録**: [原著 12 本の読解](https://github.com/Nkzono99/paperops/blob/main/docs/results-and-model-readings.md) · [添削からの具体例](https://github.com/Nkzono99/paperops/blob/main/docs/lessons-from-style.md) · [講評をどこで終えるか](https://github.com/Nkzono99/paperops/blob/main/docs/review-baseline.md) · [著者の指摘を先に拾えるか](https://github.com/Nkzono99/paperops/blob/main/docs/author-proxy-baseline.md) · [講評をどこで終えるか](https://github.com/Nkzono99/paperops/blob/main/docs/review-baseline.md)
@@ -75,6 +75,10 @@ TeX に `%>` で始まるコメントを書きます。段落の上に書くと
75
75
 
76
76
  エージェントは指摘箇所を直したうえで、同じ好みを原稿全体へ広げ、規則として `STYLE.md`(論文をまたぐ好みは共有 STYLE)に残します。学んだ規則は毎回報告されるので、違っていれば「その規則は違う」と直せます。
77
77
 
78
+ - **PDF で添削する(任意)**: `pops build` の PDF に、PDF ビューアでハイライトと注釈を付けて保存し、`pops annotations <PDF>` で
79
+ TeX の対応する行へ `%> [p.5] 「ハイライトした文」 注釈` として入れます。一文の中のハイライトは行末に、複数の文にまたがるものは
80
+ 段落の上に置きます。照合はハイライトした文字で行い、`pops build` が書く SyncTeX で注釈のページに絞ります。ハイライトの無い付箋は、
81
+ 横にある行の文字か SyncTeX の位置で置きます。PDF を読むのに pdfplumber が要ります(`pip install 'paper-harness-cli[pdf]'`)。
78
82
  - **並行して添削する(任意)**: エージェントの修正中に自分でも書き込むときは、VS Code 拡張 [Paperops Review](https://github.com/Nkzono99/paperops/tree/main/vscode/paperops-review) を使うと変更を 3 方向マージできます。
79
83
  - **改稿から学ぶ**: 「この節の改稿から次の論文にも使えることを拾って」と頼むと、直接の書き換えや講評の採否から再利用できる判断を抽出します。
80
84
 
@@ -113,4 +117,4 @@ paper-rough-pipe/
113
117
 
114
118
  - **設計と開発**: [SPEC](https://github.com/Nkzono99/paperops/blob/main/SPEC.md) · [変更履歴](https://github.com/Nkzono99/paperops/blob/main/CHANGELOG.md) · [開発に参加する](https://github.com/Nkzono99/paperops/blob/main/AGENTS.md)
115
119
  - **手引き**: [結果とモデル説明](https://github.com/Nkzono99/paperops/blob/main/src/paperops/skills/paper-draft/references/results-and-model.md) · [図の公開データ(Zenodo 等)](https://github.com/Nkzono99/paperops/blob/main/src/paperops/skills/paper-figure/references/open-data.md) · [Paperops Review(VS Code 拡張)](https://github.com/Nkzono99/paperops/tree/main/vscode/paperops-review)
116
- - **背景と記録**: [原著 12 本の読解](https://github.com/Nkzono99/paperops/blob/main/docs/results-and-model-readings.md) · [添削からの具体例](https://github.com/Nkzono99/paperops/blob/main/docs/lessons-from-style.md) · [講評をどこで終えるか](https://github.com/Nkzono99/paperops/blob/main/docs/review-baseline.md)
120
+ - **背景と記録**: [原著 12 本の読解](https://github.com/Nkzono99/paperops/blob/main/docs/results-and-model-readings.md) · [添削からの具体例](https://github.com/Nkzono99/paperops/blob/main/docs/lessons-from-style.md) · [講評をどこで終えるか](https://github.com/Nkzono99/paperops/blob/main/docs/review-baseline.md) · [著者の指摘を先に拾えるか](https://github.com/Nkzono99/paperops/blob/main/docs/author-proxy-baseline.md) · [講評をどこで終えるか](https://github.com/Nkzono99/paperops/blob/main/docs/review-baseline.md)
@@ -43,7 +43,7 @@ AI エージェントが論文 1 本を主張の設計から PDF まで作り、
43
43
  | path | 持ち主 | 内容 |
44
44
  |---|---|---|
45
45
  | `paper.toml` | project | `[paper] title, lang, track, main`、`[build] engine, bib, tex_bin`、`[style] shared`、`[[sources]] name, path, note` |
46
- | `BRIEF.md` | project | 状態、主張 1 文、問いと意義、主要な発見(発見ごとに状態・根拠・成立条件と置き場、賭けなら確かめ方・外れたら)、載せないもの、図の割り当て、段落骨子、これから要る計算(発表までに要るものと、行わない検証)、未決 |
46
+ | `BRIEF.md` | project | 状態、主張 1 文、問いと意義、主要な発見(発見ごとに状態・根拠・成立条件と置き場、賭けなら確かめ方・外れたら)、載せないもの(柱でない結果の置き方と理由)、図の割り当て、段落骨子、これから要る計算(発表までに要るものと、行わない検証)、未決 |
47
47
  | `STYLE.md` | project | この論文の規則。節: 文章、構成、図、用語と表記、候補、共有待ち |
48
48
  | 共有 STYLE(既定 `~/.config/paperops/STYLE.md`) | 著者 | 論文をまたぐ規則。`pops init` が無ければ作る |
49
49
  | `manuscript/` | project | `main.tex`、`preamble.tex`、`sections/`、`numbers.tex`、`refs.bib`。英語版は `manuscript/en/` |
@@ -98,7 +98,7 @@ run directory(`manifest.toml` を持つ)と `_` で始まる directory の
98
98
  | `paper-figure` | 図のメッセージ、source の data | `figures/<name>/`(設計、図、推敲記録)、初見の読者が読み取った内容 |
99
99
  | `paper-revise` | `%>` コメント、会話、著者の書き換え。振り返りでは改稿履歴 | 添削した原稿と STYLE の規則。振り返りでは判断の根拠と適用範囲 |
100
100
  | `paper-predict` | 主張に必要でまだ無い結果、source の case と過去の run | 予想の発見、これから要る計算、行わない検証、答え合わせの結果 |
101
- | `paper-check` | PDF、通常の点検では `BRIEF.md` など | 読者テストと照合。指定 PDF だけの講評では該当箇所と取捨の理由。改善案を求める講評では、通すのに必要なものと良くする案 |
101
+ | `paper-check` | PDF、通常の点検では `BRIEF.md` など。著者の代わりに読む手順では STYLE | 読者テストと照合。著者が指摘しそうな箇所(特に削る候補)と、その直しか著者に見せる候補。指定 PDF だけの講評では該当箇所と取捨の理由。改善案を求める講評では、通すのに必要なものと良くする案 |
102
102
 
103
103
  ## 7. 主張が伝わるようにする仕組み
104
104
 
@@ -106,6 +106,7 @@ run directory(`manifest.toml` を持つ)と `_` で始まる directory の
106
106
  次の 4 つで制御する。
107
107
 
108
108
  1. **選択を先に固定する。** `BRIEF.md` に主張 1 文と「載せないもの」を書き、著者が承認する。
109
+ 柱でない結果は主張に効くかだけでは選べないので、その結果に乗る文と、読者が新しく覚えるものを並べて置き方を選ぶ。
109
110
  2. **読者の判断に合わせて精度を選ぶ。** 根拠は出典で確かめ、本文は発見が伝わる詳しさで止める。
110
111
  条件を省くと発見の意味や適用先が変わるときに「成立条件と置き場」を使う。本文に載せる数値は `numbers.tex` から出典にたどれるようにする。
111
112
  3. **骨子で確かめる。** 詳しさの選択が結果やモデルの伝わり方を変える節には、段落骨子に読者の判断と説明の終点を一行添える。
@@ -0,0 +1,49 @@
1
+ # 著者の指摘を先に拾えるか: 添削の直前の版を読ませた結果
2
+
3
+ `paper-check` の「著者の代わりに読む」を作ったときの背景。著者が添削で同じ種類の指摘を繰り返していたので、
4
+ 点検の手順がその指摘を著者より先に挙げられるかを、実際の添削の履歴で測った(2026-11-30〜12-01)。
5
+
6
+ ## 測り方
7
+
8
+ - 対象: paperops で書いた同じ著者の論文 2 本(月面のシースのモデル論文)。各論文の `LOG.md` と Git の履歴から、
9
+ 著者が原稿や図への不満・疑問を述べた指摘(新しい作業の指示や承認は除く)と、その指摘の直前の版を取り出した。
10
+ - 版: 論文ごとに 5 つの版を作り直し、指摘の対象がその版にそのまま残っている指摘だけを測った(2 本で 92 件)。
11
+ - 読み手: 版ごとに、次の 4 つの条件で初見の agent に読ませた。各条件 1 回。
12
+ - 読者テスト: PDF だけ。`paper-check` の読者テストの問い。
13
+ - 講評: PDF だけ。`paper-check` の「通すのに必要なもの」と「良くする案」を分けた講評。
14
+ - 代わりに読む: PDF だけ。「著者がこの原稿を読んだら指摘しそうな箇所を最大 25 個」。
15
+ - 同・STYLE あり: 上と同じ依頼に、その版の時点の STYLE(論文と共有)を添えた。
16
+ - 判定: 版ごとに別の agent が、条件名を伏せた 4 つの回答と著者の指摘を突き合わせ、同じ箇所の同じ種類の問題を
17
+ 挙げていれば一致とした。根拠に引いた回答の一節が実在するかは script で確かめた。
18
+
19
+ ## 結果
20
+
21
+ | 指摘の種類 | 件数 | 読者テスト | 講評 | 代わりに読む | 同・STYLE あり |
22
+ |---|---|---|---|---|---|
23
+ | 多すぎる・要らない | 36 | 1 | 1 | 5 | 14 |
24
+ | 分かりにくい | 16 | 3 | 2 | 1 | 1 |
25
+ | 図 | 13 | 1 | 0 | 2 | 0 |
26
+ | 言い方 | 13 | 1 | 0 | 4 | 0 |
27
+ | 構成 | 7 | 0 | 0 | 0 | 0 |
28
+ | 足りない | 7 | 0 | 2 | 1 | 0 |
29
+ | 計 | 92 | 6 | 5 | 13 | 15 |
30
+
31
+ - 著者の指摘でいちばん多いのは「多すぎる・要らない」で、読者テストと講評はこれをほぼ挙げない。講評の良くする案は、
32
+ 足す案が削る案よりずっと多かった。
33
+ - STYLE を渡すと「多すぎる・要らない」に当たった。2 本とも 7 件ずつで、STYLE なしは 4 件と 1 件だった。
34
+ 2 本で同じ向きに効いたのはこの条件だけである。
35
+ - 「著者が指摘しそうな所」と頼み方を変えるだけの効果は、1 本目では読者テストの数倍だったが、2 本目では同じだった。
36
+ - 構成の指摘はどの条件でも当たらず、図も最大 2 件だった。
37
+ - 読者テストに「読むのにいちばん手間がかかった箇所」の問いを足しても、一致は増えなかった(その問いは外した)。
38
+
39
+ ## 手順に入れたこと
40
+
41
+ - `paper-check` に、PDF と STYLE を渡して、著者が指摘しそうな箇所を削る候補を中心に挙げさせる手順を足した。
42
+ 依頼文は測った「同・STYLE あり」に、削る候補を漏らさず挙げる一文を加えたもの。
43
+ - 草稿を著者に渡す前(`paper-draft` の手順 7)に行い、STYLE の規則に当たるものと、読者が失うもののない削除は先に直す。
44
+
45
+ ## 限界
46
+
47
+ - 論文 2 本、同じ著者・同じ分野、各条件 1 回。読み手の回ごとのばらつきは測っていない。
48
+ - 指摘のラベル付けと測る版の選び方は agent が行った。読み手と判定役は同じ系統のモデル。
49
+ - 一致は最も良い条件でも 92 件中 15 件で、著者が読むことの代わりにはならない。
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "paper-harness-cli"
7
- version = "2.6.1"
7
+ version = "2.7.0"
8
8
  description = "Minimal harness for writing a paper with AI agents: brief, figures, review comments, learned style"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -24,6 +24,9 @@ authors = [
24
24
  { name = "paperops maintainers" },
25
25
  ]
26
26
 
27
+ [project.optional-dependencies]
28
+ pdf = ["pdfplumber>=0.11"] # pops annotations: read highlights and notes from a PDF
29
+
27
30
  [project.urls]
28
31
  Homepage = "https://github.com/Nkzono99/paperops"
29
32
  Repository = "https://github.com/Nkzono99/paperops"
@@ -39,6 +42,8 @@ packages = ["src/paperops"]
39
42
  dev = [
40
43
  "matplotlib>=3.8", # only for testing the figure helpers in _scaffold/figures/
41
44
  "pytest>=7.0",
45
+ "pdfplumber>=0.11",
46
+ "pypdf>=4.0", # only for writing annotated PDFs in the tests
42
47
  "ruff>=0.4",
43
48
  ]
44
49
 
@@ -1,3 +1,3 @@
1
1
  """paperops: a minimal harness for writing a paper with AI agents."""
2
2
 
3
- __version__ = "2.6.1"
3
+ __version__ = "2.7.0"
@@ -39,7 +39,9 @@
39
39
 
40
40
  ## 載せないもの
41
41
 
42
- <!-- 主張に効かない結果と行き先(付録 / 別の論文 / 載せない)、理由を 1 行ずつ。 -->
42
+ <!-- 主要な発見に入らない結果と置き方(本文に数文 / 付録 / 別の論文 / 載せない)を 1 行ずつ。
43
+ 理由には、乗る文(この結果を前提に別のことを述べる文。報告するだけの文は数えない)と、読者の負担
44
+ (新しく覚える指標・モデルの別版・図・付録)を書く。載せないものには、戻す条件があれば添える(例: 査読で問われたら)。 -->
43
45
 
44
46
  ## 図の割り当て
45
47
 
@@ -0,0 +1,395 @@
1
+ """Turn PDF annotations (highlights and notes) into ``%>`` review comments in the TeX source.
2
+
3
+ The author reads the built PDF, highlights text and writes notes in any PDF viewer, and saves the
4
+ PDF. ``pops annotations PDF`` reads those annotations and places each one in the source:
5
+
6
+ * text-markup annotations (highlight, underline, ...) are matched by the marked text against the
7
+ source lines; the PDF of a CJK font often loses digits and math, so only letters are compared;
8
+ * the SyncTeX file of the last build (``build/<job>.synctex.gz``) narrows the search to the lines
9
+ typeset on the annotated page, and places notes without marked text by their height on the page.
10
+
11
+ A comment on one source line is appended to that line (``... %> note``, a sentence comment);
12
+ one that spans several lines goes on its own line above the first (a paragraph comment).
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ import gzip
18
+ import hashlib
19
+ import re
20
+ import unicodedata
21
+ from bisect import bisect_left
22
+ from dataclasses import dataclass, field
23
+ from pathlib import Path
24
+
25
+ from paperops.project import PaperopsError
26
+ from paperops.tex import Line, expand
27
+
28
+ MARKUP = {"Highlight", "Underline", "Squiggly", "StrikeOut"}
29
+ NOTES = {"Text", "FreeText"}
30
+ SENTENCE = 0.6 # share of the marked text's character n-grams that the matched lines must hold
31
+ EXTEND = 0.15 # share a neighbouring line must add to join a highlight that spans sentences
32
+ QUOTE_LIMIT = 40
33
+
34
+
35
+ @dataclass(frozen=True)
36
+ class Annotation:
37
+ page: int # 1-based
38
+ kind: str
39
+ quote: str # the marked text as the PDF gives it ("" for a note)
40
+ note: str # the author's text
41
+ top: float # from the top of the page, in PDF points
42
+ bottom: float
43
+ key: str
44
+ context: str = "" # for a note: the PDF text line it sits beside
45
+
46
+
47
+ @dataclass
48
+ class Placement:
49
+ annotation: Annotation
50
+ file: Path | None = None
51
+ lineno: int = 0 # 1-based line in ``file``
52
+ inline: bool = False # append to the line instead of a line above it
53
+ how: str = "" # "text", "position", or "" when not placed
54
+ comment: str = ""
55
+ skipped: bool = False # the same comment is already in the file
56
+
57
+
58
+ # ---------------------------------------------------------------- reading the PDF
59
+
60
+
61
+ def read_annotations(pdf_path: Path) -> list[Annotation]:
62
+ try:
63
+ import pdfplumber
64
+ except ImportError as exc: # optional dependency
65
+ raise PaperopsError(
66
+ "reading PDF annotations needs pdfplumber: install paper-harness-cli[pdf] "
67
+ "(uv tool install --reinstall 'paper-harness-cli[pdf] @ <path>')"
68
+ ) from exc
69
+ out: list[Annotation] = []
70
+ with pdfplumber.open(pdf_path) as pdf:
71
+ for page in pdf.pages:
72
+ for annot in page.annots:
73
+ data = annot.get("data") or {}
74
+ kind = _name(data.get("Subtype"))
75
+ if kind not in MARKUP | NOTES:
76
+ continue
77
+ note = _text(annot.get("contents") or data.get("Contents"))
78
+ boxes = _quads(data.get("QuadPoints"), page.height) or [
79
+ (annot["x0"], annot["top"], annot["x1"], annot["bottom"])
80
+ ]
81
+ quote = _marked_text(page.chars, boxes) if kind in MARKUP else ""
82
+ if not (quote or note):
83
+ continue
84
+ top = min(b[1] for b in boxes)
85
+ bottom = max(b[3] for b in boxes)
86
+ context = "" if quote else _line_beside(page.chars, (top + bottom) / 2)
87
+ key = (
88
+ _text(data.get("NM"))
89
+ or hashlib.sha1(
90
+ f"{page.page_number}:{top:.1f}:{kind}:{quote}:{note}".encode()
91
+ ).hexdigest()[:12]
92
+ )
93
+ out.append(
94
+ Annotation(page.page_number, kind, quote, note, top, bottom, key, context)
95
+ )
96
+ return out
97
+
98
+
99
+ def _name(value: object) -> str:
100
+ return str(getattr(value, "name", value) or "").lstrip("/")
101
+
102
+
103
+ def _text(value: object) -> str:
104
+ if isinstance(value, bytes):
105
+ for codec in ("utf-16", "utf-8", "latin-1"):
106
+ try:
107
+ value = value.decode(codec)
108
+ break
109
+ except UnicodeDecodeError:
110
+ continue
111
+ return " ".join(str(value or "").split())
112
+
113
+
114
+ def _quads(points: object, height: float) -> list[tuple[float, float, float, float]]:
115
+ """QuadPoints (PDF space, origin at the bottom) as (x0, top, x1, bottom) boxes."""
116
+ if not isinstance(points, list | tuple) or len(points) < 8:
117
+ return []
118
+ boxes = []
119
+ for i in range(0, len(points) - 7, 8):
120
+ xs = [float(points[i + j]) for j in (0, 2, 4, 6)]
121
+ ys = [float(points[i + j]) for j in (1, 3, 5, 7)]
122
+ boxes.append((min(xs), height - max(ys), max(xs), height - min(ys)))
123
+ return boxes
124
+
125
+
126
+ def _marked_text(chars: list[dict], boxes: list[tuple[float, float, float, float]]) -> str:
127
+ picked = []
128
+ for ch in chars:
129
+ cx = (ch["x0"] + ch["x1"]) / 2
130
+ cy = (ch["top"] + ch["bottom"]) / 2
131
+ if any(x0 - 1 <= cx <= x1 + 1 and t - 1 <= cy <= b + 1 for x0, t, x1, b in boxes):
132
+ picked.append(ch)
133
+ return _join(picked)
134
+
135
+
136
+ def _join(chars: list[dict]) -> str:
137
+ """Glyphs to text. PDFs carry no space glyphs, so put a space at a gap or a line break
138
+ between two Latin glyphs (none between CJK glyphs)."""
139
+ out: list[str] = []
140
+ prev = None
141
+ for ch in chars:
142
+ text = _CID.sub("", ch["text"])
143
+ if not text:
144
+ continue
145
+ if prev is not None:
146
+ new_row = abs(ch["top"] - prev["top"]) > 0.5 * (prev["bottom"] - prev["top"])
147
+ gap = ch["x0"] - prev["x1"] > 0.2 * (prev["bottom"] - prev["top"])
148
+ latin = prev["text"][-1:].isascii() and text[:1].isascii()
149
+ if (new_row and latin and not out[-1].endswith("-")) or (gap and not new_row):
150
+ out.append(" ")
151
+ out.append(text)
152
+ prev = ch
153
+ return " ".join("".join(out).split())
154
+
155
+
156
+ def _line_beside(chars: list[dict], y: float) -> str:
157
+ """The text line at height ``y`` (or the nearest one): where a note without marked text sits."""
158
+ if not chars:
159
+ return ""
160
+ row = min(
161
+ chars,
162
+ key=lambda c: (
163
+ 0 if c["top"] <= y <= c["bottom"] else min(abs(c["top"] - y), abs(c["bottom"] - y))
164
+ ),
165
+ )
166
+ mid = (row["top"] + row["bottom"]) / 2
167
+ same = [c for c in chars if c["top"] - 1 <= mid <= c["bottom"] + 1]
168
+ return _join(sorted(same, key=lambda c: c["x0"]))
169
+
170
+
171
+ # ---------------------------------------------------------------- matching text
172
+
173
+ _CID = re.compile(r"\(cid:\d+\)")
174
+ _DROP_WITH_ARG = re.compile(
175
+ r"\\(?:cite[a-z]*|ref|eqref|appref|label|includegraphics|bibliography\w*)\*?"
176
+ r"(?:\[[^\]]*\])*\{[^}]*\}"
177
+ )
178
+ _COMMAND = re.compile(r"\\[A-Za-z@]+\*?")
179
+
180
+
181
+ def norm_pdf(text: str) -> str:
182
+ text = unicodedata.normalize("NFKC", _CID.sub("", text))
183
+ return "".join(ch for ch in text if ch.isalpha()).lower()
184
+
185
+
186
+ def norm_tex(text: str) -> str:
187
+ text = _COMMAND.sub("", _DROP_WITH_ARG.sub("", text))
188
+ text = unicodedata.normalize("NFKC", text)
189
+ return "".join(ch for ch in text if ch.isalpha()).lower()
190
+
191
+
192
+ def _grams(text: str, n: int) -> set[str]:
193
+ if len(text) < n:
194
+ return {text} if text else set()
195
+ return {text[i : i + n] for i in range(len(text) - n + 1)}
196
+
197
+
198
+ # ---------------------------------------------------------------- SyncTeX
199
+
200
+
201
+ @dataclass
202
+ class SyncTeX:
203
+ """Source lines typeset on each page, with their heights (PDF points from the top)."""
204
+
205
+ pages: dict[int, list[tuple[float, Path, int]]] = field(default_factory=dict)
206
+
207
+ def lines_on(self, page: int) -> set[tuple[Path, int]]:
208
+ return {(path, line) for _, path, line in self.pages.get(page, [])}
209
+
210
+ def nearest(self, page: int, y: float) -> tuple[Path, int] | None:
211
+ records = self.pages.get(page)
212
+ if not records:
213
+ return None
214
+ ys = [r[0] for r in records]
215
+ i = bisect_left(ys, y) # the first record at or below y: the line the note sits on
216
+ _, path, line = records[min(i, len(records) - 1)]
217
+ return path, line
218
+
219
+
220
+ _INPUT = re.compile(r"^Input:(\d+):(.*)$")
221
+ _RECORD = re.compile(r"^[\[(hvxkg$](\d+),(\d+)(?::(-?\d+),(-?\d+))?")
222
+
223
+
224
+ def read_synctex(path: Path, workdir: Path) -> SyncTeX:
225
+ sync = SyncTeX()
226
+ if not path.is_file():
227
+ return sync
228
+ inputs: dict[str, Path] = {}
229
+ unit, mag, page = 1.0, 1000.0, 0
230
+ with gzip.open(path, "rt", encoding="utf-8", errors="replace") as fh:
231
+ for raw in fh:
232
+ line = raw.rstrip("\n")
233
+ if m := _INPUT.match(line):
234
+ p = Path(m.group(2))
235
+ inputs[m.group(1)] = (p if p.is_absolute() else workdir / p).resolve()
236
+ elif line.startswith("Unit:"):
237
+ unit = float(line[5:] or 1)
238
+ elif line.startswith("Magnification:"):
239
+ mag = float(line[14:] or 1000)
240
+ elif line.startswith("{") and line[1:].isdigit():
241
+ page = int(line[1:])
242
+ elif page and (m := _RECORD.match(line)) and m.group(3) is not None:
243
+ source = inputs.get(m.group(1))
244
+ if source is None:
245
+ continue
246
+ # SyncTeX positions are scaled points from the TeX origin (1 inch from the corner)
247
+ y = int(m.group(4)) * unit * mag / 1000 / 65536 * 72 / 72.27 + 72
248
+ sync.pages.setdefault(page, []).append((y, source, int(m.group(2))))
249
+ for records in sync.pages.values():
250
+ records.sort(key=lambda r: r[0])
251
+ return sync
252
+
253
+
254
+ # ---------------------------------------------------------------- placing
255
+
256
+
257
+ def place(
258
+ annotations: list[Annotation], main: Path, sync: SyncTeX, lang: str = "ja"
259
+ ) -> list[Placement]:
260
+ source = [ln for ln in expand(main) if ln.text.strip()]
261
+ normed = [norm_tex(ln.text) for ln in source]
262
+ index = {(ln.file.resolve(), ln.lineno): i for i, ln in enumerate(source)}
263
+ out = []
264
+ for ann in annotations:
265
+ result = Placement(ann)
266
+ quote = norm_pdf(ann.quote)
267
+ if quote:
268
+ _place_by_text(result, quote, source, normed, index, sync)
269
+ elif ann.context and len(norm_pdf(ann.context)) >= 6:
270
+ # a note beside a line: match that line's text (SyncTeX gives the end of a macro
271
+ # argument, e.g. the closing brace of a caption, for every line inside it)
272
+ _place_by_text(result, norm_pdf(ann.context), source, normed, index, sync)
273
+ if result.how:
274
+ result.how, result.inline = "position", True
275
+ if not result.how:
276
+ spot = sync.nearest(ann.page, ann.top)
277
+ i = index.get(spot) if spot else None
278
+ if i is None and spot: # the record may be on a blank or comment line
279
+ i = _next_text_line(spot, source, index)
280
+ if i is not None:
281
+ result.file, result.lineno = source[i].file, source[i].lineno
282
+ result.how = "position"
283
+ result.inline = not ann.quote or len(quote) < 8
284
+ if result.how:
285
+ result.comment = _comment(ann, lang)
286
+ out.append(result)
287
+ return out
288
+
289
+
290
+ def _place_by_text(
291
+ result: Placement,
292
+ quote: str,
293
+ source: list[Line],
294
+ normed: list[str],
295
+ index: dict[tuple[Path, int], int],
296
+ sync: SyncTeX,
297
+ ) -> None:
298
+ n = 3 if len(quote) >= 6 else 1
299
+ want = _grams(quote, n)
300
+ grams = [_grams(text, n) for text in normed]
301
+ cover = [len(want & g) / len(want) if want else 0.0 for g in grams]
302
+ on_page = {index[k] for k in sync.lines_on(result.annotation.page) if k in index}
303
+ near = {j for i in on_page for j in range(i - 3, i + 4)} # paragraph lines around a record
304
+ pools = [near, set(range(len(source)))] if near else [set(range(len(source)))]
305
+ for pool in pools:
306
+ best = max(pool, key=lambda i: (cover[i], -i), default=None)
307
+ if best is None or cover[best] == 0:
308
+ continue
309
+ # The marked text may run into the neighbouring sentences: take a neighbour when it
310
+ # holds a real share of what the lines so far do not (shared words do not count).
311
+ lo = hi = best
312
+ left = want - grams[best]
313
+ grew = True
314
+ while grew:
315
+ grew = False
316
+ for j in (lo - 1, hi + 1):
317
+ if j in pool and len(left & grams[j]) >= EXTEND * len(want):
318
+ left -= grams[j]
319
+ lo, hi, grew = min(lo, j), max(hi, j), True
320
+ if 1 - len(left) / len(want) >= SENTENCE:
321
+ _set(result, source[lo], inline=lo == hi)
322
+ return
323
+
324
+
325
+ def _set(result: Placement, line: Line, inline: bool) -> None:
326
+ result.file, result.lineno, result.inline, result.how = line.file, line.lineno, inline, "text"
327
+
328
+
329
+ def _next_text_line(
330
+ spot: tuple[Path, int], source: list[Line], index: dict[tuple[Path, int], int]
331
+ ) -> int | None:
332
+ path, lineno = spot
333
+ for k in range(lineno, lineno + 20):
334
+ if (path, k) in index:
335
+ return index[(path, k)]
336
+ return None
337
+
338
+
339
+ def _comment(ann: Annotation, lang: str) -> str:
340
+ """``[p.N] 「marked text」 note`` (English marked text in double quotes)."""
341
+ parts = [f"[p.{ann.page}]"]
342
+ if ann.quote:
343
+ quote = " ".join(_CID.sub("", ann.quote).split())
344
+ latin = quote.isascii()
345
+ if len(quote) > QUOTE_LIMIT:
346
+ quote = quote[: QUOTE_LIMIT - 1] + "…"
347
+ parts.append(f'"{quote}"' if latin else f"「{quote}」")
348
+ if ann.note:
349
+ parts.append(ann.note)
350
+ elif ann.kind == "StrikeOut":
351
+ parts.append("削除" if lang == "ja" else "delete")
352
+ return " ".join(parts)
353
+
354
+
355
+ def apply(placements: list[Placement]) -> None:
356
+ """Write the comments into the source files (bottom-up within each file)."""
357
+ by_file: dict[Path, list[Placement]] = {}
358
+ for p in placements:
359
+ if p.how and p.file:
360
+ by_file.setdefault(p.file, []).append(p)
361
+ for path, items in by_file.items():
362
+ raw = path.read_text(encoding="utf-8")
363
+ lines = raw.splitlines(keepends=True)
364
+ for p in sorted(items, key=lambda p: p.lineno, reverse=True):
365
+ if f"%> {p.comment}" in raw:
366
+ p.skipped = True
367
+ continue
368
+ i = p.lineno - 1
369
+ line = lines[i]
370
+ body = line.rstrip("\r\n")
371
+ end = line[len(body) :] or "\n"
372
+ if p.inline and "%" not in body:
373
+ lines[i] = f"{body} %> {p.comment}{end}"
374
+ else:
375
+ indent = body[: len(body) - len(body.lstrip())]
376
+ lines.insert(i, f"{indent}%> {p.comment}{end}")
377
+ path.write_text("".join(lines), encoding="utf-8")
378
+
379
+
380
+ def render(placements: list[Placement], root: Path) -> str:
381
+ out = []
382
+ for p in placements:
383
+ a = p.annotation
384
+ what = f"p.{a.page} {a.kind}"
385
+ if p.how:
386
+ rel = p.file.relative_to(root) if p.file and p.file.is_relative_to(root) else p.file
387
+ state = " (already there)" if p.skipped else ""
388
+ mode = "line end" if p.inline else "above"
389
+ out.append(f"{what} -> {rel}:{p.lineno} [{p.how}, {mode}]{state}: {p.comment}")
390
+ else:
391
+ out.append(f"{what} -> NOT PLACED: {a.quote or ''} {a.note}".rstrip())
392
+ placed = sum(1 for p in placements if p.how and not p.skipped)
393
+ missing = sum(1 for p in placements if not p.how)
394
+ out.append(f"{placed} placed, {missing} not placed, {len(placements)} annotations")
395
+ return "\n".join(out)
@@ -136,6 +136,7 @@ def build(project: Project, main: Path | None = None) -> BuildResult:
136
136
  "-interaction=nonstopmode",
137
137
  "-halt-on-error",
138
138
  "-file-line-error",
139
+ "-synctex=1", # pops annotations maps PDF positions back to source lines
139
140
  f"-output-directory={outdir}",
140
141
  main_path.name,
141
142
  ]
@@ -1,4 +1,4 @@
1
- """``pops``: init, update, context, outline, build."""
1
+ """``pops``: init, update, context, outline, build, annotations."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -70,6 +70,28 @@ def _build(args: argparse.Namespace) -> int:
70
70
  return 0 if result.ok else 1
71
71
 
72
72
 
73
+ def _annotations(args: argparse.Namespace) -> int:
74
+ from paperops.annotations import apply, place, read_annotations, read_synctex, render
75
+
76
+ project = load_project()
77
+ main = (project.root / args.main) if args.main else project.main_path
78
+ pdf = Path(args.pdf)
79
+ if not pdf.is_file():
80
+ raise PaperopsError(f"PDF not found: {pdf}")
81
+ try:
82
+ sub = main.parent.relative_to(project.manuscript_dir)
83
+ except ValueError:
84
+ sub = Path()
85
+ sync = read_synctex(project.root / "build" / sub / f"{main.stem}.synctex.gz", main.parent)
86
+ placements = place(read_annotations(pdf), main, sync, project.lang)
87
+ if not args.dry_run:
88
+ apply(placements)
89
+ print(render(placements, project.root))
90
+ if not sync.pages:
91
+ print("note: no SyncTeX file; run pops build so notes without marked text can be placed")
92
+ return 0
93
+
94
+
73
95
  def make_parser() -> argparse.ArgumentParser:
74
96
  parser = argparse.ArgumentParser(
75
97
  prog="pops", description="Minimal harness for writing a paper with AI agents."
@@ -118,6 +140,14 @@ def make_parser() -> argparse.ArgumentParser:
118
140
  build = sub.add_parser("build", help="build the PDF and summarize the log")
119
141
  build.add_argument("--main", default="", metavar="PATH", help="another main file")
120
142
  build.set_defaults(func=_build)
143
+
144
+ annotations = sub.add_parser(
145
+ "annotations", help="turn highlights and notes in a PDF into %%> comments in the source"
146
+ )
147
+ annotations.add_argument("pdf", help="the annotated PDF")
148
+ annotations.add_argument("--main", default="", metavar="PATH", help="another main file")
149
+ annotations.add_argument("--dry-run", action="store_true", help="show where they would go")
150
+ annotations.set_defaults(func=_annotations)
121
151
  return parser
122
152
 
123
153