papilot 0.6.0 → 0.8.0
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.
- package/README.md +58 -30
- package/README.zh-CN.md +58 -30
- package/bin/doctor.mjs +53 -6
- package/bin/installation.d.mts +8 -0
- package/bin/installation.mjs +54 -0
- package/bin/papilot.mjs +6 -2
- package/dist/assets/_virtual_papilot-licenses-D7ro6ecN.js +7597 -0
- package/dist/assets/index-Cc-awdNn.css +1 -0
- package/dist/assets/index-D_VX51no.js +265 -0
- package/dist/assets/latex-BarqJFtQ.svg +1 -0
- package/dist/assets/{math-DY-H5SfX.js → math-V9uUaUzA.js} +1 -1
- package/dist/assets/pdf-view-Bnb2uIBE.js +598 -0
- package/dist/index.html +2 -2
- package/examples/papilot-paper/main.tex +1 -1
- package/examples/papilot-paper/sections/02-using.tex +3 -1
- package/examples/papilot-paper/sections/09-agents.tex +8 -5
- package/package.json +15 -7
- package/scripts/service.ts +1 -0
- package/skills/ai-review.md +18 -0
- package/skills/latex-warnings.md +1 -1
- package/src/conversation.ts +6 -0
- package/src/note-groups.ts +30 -0
- package/src/notes.ts +34 -10
- package/src/server/acp.ts +354 -0
- package/src/server/agents.ts +237 -47
- package/src/server/ai-review-routes.ts +72 -0
- package/src/server/ai-review.ts +38 -0
- package/src/server/annotation-placement.ts +99 -0
- package/src/server/app.ts +216 -21
- package/src/server/attachments.ts +128 -0
- package/src/server/build-problems.ts +329 -0
- package/src/server/changes.ts +28 -2
- package/src/server/codex.ts +2 -1
- package/src/server/cursor.ts +153 -0
- package/src/server/diagnostics.ts +45 -0
- package/src/server/git-overview.ts +69 -0
- package/src/server/imports.ts +205 -0
- package/src/server/latex-installation.ts +43 -0
- package/src/server/main.ts +8 -42
- package/src/server/manuscript.ts +212 -12
- package/src/server/note-results.ts +65 -0
- package/src/server/paths.ts +1 -1
- package/src/server/references.ts +70 -0
- package/src/server/review.ts +6 -5
- package/src/server/skill-library.ts +113 -0
- package/src/server/skill-routes.ts +19 -0
- package/src/server/skills.ts +29 -19
- package/src/server/start.ts +51 -0
- package/src/server/store.ts +44 -4
- package/src/server/update-install.ts +124 -0
- package/src/server/update-worker.ts +78 -0
- package/src/server/updates.ts +152 -0
- package/src/server/workspace.ts +450 -60
- package/src/shared.ts +120 -10
- package/src/skill-icons.ts +18 -0
- package/src/skill-metadata.ts +45 -0
- package/src/task-caption.ts +20 -0
- package/vendor/latex-review/dist/web/assets/index-7VKAte5x.js +19 -0
- package/vendor/latex-review/dist/web/assets/index-DEz-LsGl.css +1 -0
- package/vendor/latex-review/dist/web/index.html +2 -2
- package/vendor/latex-review/src/core/bib.ts +692 -0
- package/vendor/latex-review/src/core/build.ts +5 -1
- package/vendor/latex-review/src/core/changes.ts +39 -0
- package/vendor/latex-review/src/core/delivery.ts +109 -0
- package/vendor/latex-review/src/core/review.ts +12 -4
- package/vendor/latex-review/src/core/store.ts +3 -0
- package/vendor/latex-review/src/core/tasks.ts +5 -2
- package/vendor/latex-review/src/core/verify.ts +784 -0
- package/vendor/latex-review/src/core/view.ts +204 -0
- package/vendor/latex-review/src/render/round.ts +11 -0
- package/vendor/latex-review/src/server.ts +81 -1
- package/vendor/latex-review/src/types.ts +141 -0
- package/vendor/latex-review/src/web/effect-preferences.ts +10 -0
- package/vendor/latex-review/src/web/i18n.ts +1 -1
- package/vendor/latex-review/src/web/overview.tsx +1 -5
- package/vendor/latex-review/src/web/references.tsx +499 -0
- package/vendor/latex-review/src/web/review.tsx +381 -230
- package/vendor/latex-review/src/web/shortcuts.ts +53 -0
- package/vendor/latex-review/src/web/style.css +295 -0
- package/vendor/latex-review/src/web/zh-CN.ts +95 -26
- package/dist/assets/index-BNGqA0_L.css +0 -1
- package/dist/assets/index-Bt9UXsGX.js +0 -222
- package/dist/assets/pdf-view-BGp3W-RG.js +0 -598
- package/vendor/latex-review/dist/web/assets/index-AFBj4gQ9.js +0 -19
- package/vendor/latex-review/dist/web/assets/index-DfC0GURl.css +0 -1
package/README.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
<h1>
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/logo-dark.svg">
|
|
6
|
+
<img src="docs/assets/logo.svg" width="48" height="48" align="absmiddle" alt="Papilot logo">
|
|
7
|
+
</picture>
|
|
8
|
+
Papilot
|
|
9
|
+
</h1>
|
|
7
10
|
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
<p><b>A Cursor-like workspace for your papers:<br>annotate and review PDFs directly without ever touching LaTeX.</b></p>
|
|
11
|
+
<p><b>A Cursor-like workspace for your papers: annotate and review PDFs directly without ever touching LaTeX.</b></p>
|
|
11
12
|
|
|
12
13
|
<p>English · <a href="README.zh-CN.md">简体中文</a></p>
|
|
13
14
|
|
|
@@ -20,51 +21,64 @@
|
|
|
20
21
|
[](https://www.latex-project.org)
|
|
21
22
|
[](https://github.com/cu1ch3n/papilot/pulls)
|
|
22
23
|
|
|
23
|
-
[
|
|
24
|
-
[](#-agents)
|
|
25
|
-
[](#-agents)
|
|
26
|
-
|
|
27
|
-
<br>
|
|
24
|
+
**Contents:** [Features](#-features) · [Quick start](#-quick-start) · [Agents](#-agents) · [Documentation](#-documentation) · [Community](#-community) · [Friends](#-friends) · [License](#-license)
|
|
28
25
|
|
|
29
|
-
<img src="docs/assets/demo.gif" alt="Papilot:
|
|
26
|
+
<img src="docs/assets/demo.gif" alt="Papilot: mark up a passage of the PDF, hand it to an agent, accept the typeset change and commit it" width="100%">
|
|
30
27
|
|
|
31
28
|
</div>
|
|
32
29
|
|
|
33
|
-
<br>
|
|
34
|
-
|
|
35
30
|
You read and mark up the PDF the way a supervisor marks up a draft. An AI agent makes the edits in LaTeX, and every change comes back to you as a before-and-after of the typeset page. Nothing touches your paper until you accept it.
|
|
36
31
|
|
|
32
|
+
> [!TIP]
|
|
33
|
+
> **New in 0.7:** a redesigned workspace, color-grouped notes, files and images in tasks, a skill library, and a choice of where accepted changes go. See the [changelog](CHANGELOG.md).
|
|
34
|
+
|
|
37
35
|
## ✨ Features
|
|
38
36
|
|
|
39
37
|
<table>
|
|
40
38
|
<tr>
|
|
41
39
|
<td width="50%" valign="top">
|
|
42
|
-
<img src="docs/assets/
|
|
40
|
+
<img src="docs/assets/readme-note.jpg" alt="Two passages in a yellow note group and a region note on an equation">
|
|
43
41
|
<h3>📝 Mark up the PDF</h3>
|
|
44
|
-
Select a sentence or
|
|
42
|
+
Select a sentence or box an equation and say what should change. SyncTeX hands the agent the exact LaTeX lines. Color related notes into a group and give the whole group one instruction.
|
|
45
43
|
</td>
|
|
46
44
|
<td width="50%" valign="top">
|
|
47
|
-
<img src="docs/assets/
|
|
45
|
+
<img src="docs/assets/readme-review.jpg" alt="A change shown before and after on the typeset page, with Accept, Reject and Comment">
|
|
48
46
|
<h3>✅ Approve change by change</h3>
|
|
49
|
-
Each edit comes back as a typeset diff. Accept, reject or comment
|
|
47
|
+
Each edit comes back as a typeset diff, together with the places it moves elsewhere, such as renumbered equations and the table of contents. Accept, reject or comment, and undo any decision.
|
|
50
48
|
</td>
|
|
51
49
|
</tr>
|
|
52
50
|
<tr>
|
|
53
51
|
<td width="50%" valign="top">
|
|
54
|
-
<img src="docs/assets/
|
|
52
|
+
<img src="docs/assets/readme-deliver.jpg" alt="The finished review with an agent-written commit message, Apply to working directory and Commit">
|
|
53
|
+
<h3>📦 Choose where it goes</h3>
|
|
54
|
+
Accepted changes stay inside the task until you finish reviewing. Then apply them to your working directory, or commit them to a separate <code>papilot/…</code> branch with a message the agent writes.
|
|
55
|
+
</td>
|
|
56
|
+
<td width="50%" valign="top">
|
|
57
|
+
<img src="docs/assets/readme-git.jpg" alt="The Git panel with a staged file, a generated commit message, task worktrees and the commit graph">
|
|
58
|
+
<h3>🌿 Git without leaving the page</h3>
|
|
59
|
+
Stage files and commit them with a message an agent writes, then pull and push. Every task's worktree shows in the commit graph, and an agent can resolve conflicts when you merge a co-author's changes.
|
|
60
|
+
</td>
|
|
61
|
+
</tr>
|
|
62
|
+
<tr>
|
|
63
|
+
<td width="50%" valign="top">
|
|
64
|
+
<img src="docs/assets/readme-contents.jpg" alt="The PDF viewer with its contents panel open">
|
|
55
65
|
<h3>📖 Read it like a real PDF</h3>
|
|
56
66
|
Jump to any section from the contents, search every page and zoom in sharply. Selecting text picks exactly the printed words.
|
|
57
67
|
</td>
|
|
58
68
|
<td width="50%" valign="top">
|
|
59
|
-
<
|
|
60
|
-
<
|
|
61
|
-
|
|
69
|
+
<h3>🧰 And more</h3>
|
|
70
|
+
<ul>
|
|
71
|
+
<li>✨ <b>Skills</b> such as Polish, Proofread and Check math, one <code>/</code> away. Write your own in Settings.</li>
|
|
72
|
+
<li>📎 <b>Files and images</b> attached to any task or message</li>
|
|
73
|
+
<li>🤖 <b>Codex, Claude, Cursor, Kimi Code, GLM, DeepSeek, Qwen Code, OpenCode or Antigravity</b>: whichever is on your computer, with your own login</li>
|
|
74
|
+
<li>🌳 <b>A Git worktree for every task</b>, up to two running at once</li>
|
|
75
|
+
<li>🌗 <b>Light and dark</b>, in English or Chinese</li>
|
|
76
|
+
<li>📱 <b>Runs on your computer</b>, and you can open it from your phone</li>
|
|
77
|
+
</ul>
|
|
62
78
|
</td>
|
|
63
79
|
</tr>
|
|
64
80
|
</table>
|
|
65
81
|
|
|
66
|
-
Also: ✨ **skills** such as Polish, Proofread and Check math, one `/` away, plus your own · 🤖 **Codex, Claude or Antigravity**, each with your own login · 🌳 **every task in its own Git worktree**, up to two at once · 🌗 **light and dark** · 📱 **runs on your computer**, and you can open it from your phone.
|
|
67
|
-
|
|
68
82
|
## 🚀 Quick start
|
|
69
83
|
|
|
70
84
|
> [!NOTE]
|
|
@@ -75,19 +89,27 @@ npm install -g papilot
|
|
|
75
89
|
papilot demo
|
|
76
90
|
```
|
|
77
91
|
|
|
78
|
-
Open **http://127.0.0.1:7274** and choose **
|
|
92
|
+
Open **http://127.0.0.1:7274** and choose **Manuscript** in the sidebar. The demo adds an example paper to revise: a 26-page LaTeX paper about Papilot itself, full of equations. When you are ready, run `papilot` and choose **Add paper…** from the paper menu to select a LaTeX folder or drop a ZIP. Papilot identifies the main file, prepares Git history and tries compilation, with help for any errors during import.
|
|
79
93
|
|
|
80
94
|
## 🤖 Agents
|
|
81
95
|
|
|
82
96
|
| Agent | Sign in once | How Papilot runs it |
|
|
83
97
|
| --- | --- | --- |
|
|
84
98
|
| **Codex** | `papilot codex login` | Through the Codex app server, in its workspace sandbox. Papilot uses your `codex` if you have one, or installs it on first start. |
|
|
85
|
-
| **Claude** |
|
|
99
|
+
| **Claude** | Install [Claude Code](https://code.claude.com) and run `claude auth login`, or start `papilot` with `ANTHROPIC_API_KEY` set | With Claude Code installed, runs `claude -p` on your own login (your Claude plan or a key), in Claude Code's sandbox. Without it, through the Claude Agent SDK, which needs an API key. |
|
|
100
|
+
| **Cursor** | Start `papilot` with `CURSOR_API_KEY` set | Through the Cursor SDK, downloaded the first time, in Cursor's sandbox. The SDK does not use the Cursor app or CLI login. |
|
|
101
|
+
| **Kimi Code** | Install [Kimi Code CLI](https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started) and run `kimi login` | Runs `kimi acp` with your local configuration; streams replies, resumes sessions and forwards tool approvals. |
|
|
102
|
+
| **GLM** | Start `papilot` with `ZHIPU_API_KEY` (or `ZAI_API_KEY`) set | Claude Code on Zhipu's Anthropic-compatible endpoint, as Zhipu documents for GLM Coding Plan. |
|
|
103
|
+
| **DeepSeek** | Install [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`npm install -g @deepseek-ai/dsh`) and set up a model in it | Runs `dsh acp` in its workspace sandbox; anything outside the worktree asks for approval. |
|
|
104
|
+
| **Qwen Code** | Install [Qwen Code](https://github.com/QwenLM/qwen-code) and sign in by running `qwen` | Runs `qwen --acp` in Auto Edit mode: edits go ahead, commands ask for approval. |
|
|
105
|
+
| **OpenCode** | Install [OpenCode](https://opencode.ai) and connect a provider with `opencode auth login` | Runs `opencode acp` with your providers; commands and anything outside the worktree ask for approval. |
|
|
86
106
|
| **Antigravity** | Install Antigravity and sign in to `agy` | `agy -p`, one process per turn, editing files only. If your region needs it, set `PAPILOT_AGY_PROXY`. |
|
|
87
107
|
|
|
88
|
-
Papilot
|
|
108
|
+
Papilot finds the agents on your computer by itself and offers only those; Codex is always there. After installing or signing in to one while Papilot is running, select **Reconnect**. If a CLI is not on the server’s `PATH`, point `PAPILOT_KIMI_BIN`, `PAPILOT_DSH_BIN`, `PAPILOT_QWEN_BIN` or `PAPILOT_OPENCODE_BIN` at it. See the [agent guide](docs/guide.md#agents) for what each one supports and the tested versions.
|
|
89
109
|
|
|
90
|
-
|
|
110
|
+
Papilot never stores your credentials. CLI agents use their own login, and a key you set for Claude, Cursor or GLM goes only to that service. An agent that is found but not signed in shows as unavailable.
|
|
111
|
+
|
|
112
|
+
Having trouble getting started? Open **Settings → Runtime** and choose **Agents** for agent setup or **LaTeX** for the detected distribution, version, and location, or run `papilot doctor` for environment checks and fixes and `papilot doctor --repo /path/to/paper` to check a paper too. Add `--json` for a machine-readable report. Diagnostics do not install software, start the server or change your paper. See the [diagnostics guide](docs/guide.md#diagnostics) for what is checked.
|
|
91
113
|
|
|
92
114
|
<details>
|
|
93
115
|
<summary><b>⚙️ Options and remote access</b></summary>
|
|
@@ -101,9 +123,11 @@ papilot service install # macOS: start after login, restart if it exits
|
|
|
101
123
|
npm uninstall -g papilot # remove it; your state stays in ~/.papilot until you delete it
|
|
102
124
|
```
|
|
103
125
|
|
|
126
|
+
When a release is available, **New version** appears next to **Settings**. Click it to install from the browser. Papilot waits for tasks and PDF builds to finish, restarts, and reconnects the page. Updates keep your data and preserve the previous installation for rollback. See [Updates](docs/guide.md#updates).
|
|
127
|
+
|
|
104
128
|
Papilot listens only on `127.0.0.1`. To use it from another device, publish it on your tailnet with Tailscale Serve and set `PAPILOT_PUBLIC_ORIGIN` and `PAPILOT_TAILSCALE_LOGIN`. Papilot then checks the host, the browser origin and the Tailscale identity of every request. The [guide](docs/guide.md#remote-access-with-tailscale) has the steps.
|
|
105
129
|
|
|
106
|
-
To invite an advisor or co-authors, give Papilot a public HTTPS address with `PAPILOT_ACCOUNT_ORIGIN` and open **
|
|
130
|
+
To invite an advisor or co-authors, give Papilot a public HTTPS address with `PAPILOT_ACCOUNT_ORIGIN` and open **Settings → Sharing**: each person signs in with a passkey and sees only the papers you share. Invite only people you would trust with access to the computer Papilot runs on; see [Collaborators](docs/guide.md#collaborators).
|
|
107
131
|
|
|
108
132
|
</details>
|
|
109
133
|
|
|
@@ -136,6 +160,10 @@ If Papilot saves you time on a paper, a ⭐ helps other researchers find it.
|
|
|
136
160
|
|
|
137
161
|
<a href="https://github.com/cu1ch3n/papilot/graphs/contributors"><img src="https://contrib.rocks/image?repo=cu1ch3n/papilot" alt="Papilot contributors"></a>
|
|
138
162
|
|
|
163
|
+
## 🔗 Friends
|
|
164
|
+
|
|
165
|
+
[LINUX DO](https://linux.do/)
|
|
166
|
+
|
|
139
167
|
## 📄 License
|
|
140
168
|
|
|
141
169
|
[MIT](LICENSE) © 2026 Cui Chen. The bundled review engine in [`vendor/latex-review`](vendor/latex-review) is also MIT-licensed.
|
package/README.zh-CN.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
<h1>
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/logo-dark.svg">
|
|
6
|
+
<img src="docs/assets/logo.svg" width="48" height="48" align="absmiddle" alt="Papilot 标志">
|
|
7
|
+
</picture>
|
|
8
|
+
Papilot
|
|
9
|
+
</h1>
|
|
7
10
|
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
<p><b>像 Cursor 一样改论文:<br>直接在 PDF 上批注和审阅,完全不用碰 LaTeX。</b></p>
|
|
11
|
+
<p><b>像 Cursor 一样改论文:直接在 PDF 上批注和审阅,完全不用碰 LaTeX。</b></p>
|
|
11
12
|
|
|
12
13
|
<p><a href="README.md">English</a> · 简体中文</p>
|
|
13
14
|
|
|
@@ -20,51 +21,64 @@
|
|
|
20
21
|
[](https://www.latex-project.org)
|
|
21
22
|
[](https://github.com/cu1ch3n/papilot/pulls)
|
|
22
23
|
|
|
23
|
-
[
|
|
24
|
-
[](#-智能体)
|
|
25
|
-
[](#-智能体)
|
|
26
|
-
|
|
27
|
-
<br>
|
|
24
|
+
**目录:** [功能](#-功能) · [快速开始](#-快速开始) · [智能体](#-智能体) · [文档](#-文档) · [社区](#-社区) · [友情链接](#-友情链接) · [许可证](#-许可证)
|
|
28
25
|
|
|
29
|
-
<img src="docs/assets/demo.gif" alt="Papilot
|
|
26
|
+
<img src="docs/assets/demo.gif" alt="Papilot:在 PDF 上批注一段文字,交给智能体,接受排版后的改动并提交" width="100%">
|
|
30
27
|
|
|
31
28
|
</div>
|
|
32
29
|
|
|
33
|
-
<br>
|
|
34
|
-
|
|
35
30
|
你像导师批改学生的稿子一样,直接在 PDF 上阅读和批注;AI 智能体去改 LaTeX,每一处改动都以排版后修改前后的对比回到你面前。你点头之前,论文一个字都不会变。
|
|
36
31
|
|
|
32
|
+
> [!TIP]
|
|
33
|
+
> **0.7 新功能**:全新设计的工作台、按颜色分组的批注、任务中附带文件和图片、技能库,以及接受的改动保存到哪里由你选择。详见[更新日志](CHANGELOG.md)。
|
|
34
|
+
|
|
37
35
|
## ✨ 功能
|
|
38
36
|
|
|
39
37
|
<table>
|
|
40
38
|
<tr>
|
|
41
39
|
<td width="50%" valign="top">
|
|
42
|
-
<img src="docs/assets/
|
|
40
|
+
<img src="docs/assets/readme-note.zh-CN.jpg" alt="两段文字在黄色批注组里,一个公式上有区域批注">
|
|
43
41
|
<h3>📝 在 PDF 上批注</h3>
|
|
44
|
-
选中一句话或框出一个公式,写下要怎么改。SyncTeX 会把对应的 LaTeX
|
|
42
|
+
选中一句话或框出一个公式,写下要怎么改。SyncTeX 会把对应的 LaTeX 行准确交给智能体。相关的批注可以用颜色归成一组,整组只写一条要求。
|
|
45
43
|
</td>
|
|
46
44
|
<td width="50%" valign="top">
|
|
47
|
-
<img src="docs/assets/
|
|
45
|
+
<img src="docs/assets/readme-review.zh-CN.jpg" alt="排版页面上改动的修改前后对比,带接受、拒绝和评论按钮">
|
|
48
46
|
<h3>✅ 逐条点头</h3>
|
|
49
|
-
|
|
47
|
+
每处改动都以排版后的差异呈现,连同它在别处引起的变化,比如重新编号的公式和目录。接受、拒绝或评论,任何决定都能撤销。
|
|
50
48
|
</td>
|
|
51
49
|
</tr>
|
|
52
50
|
<tr>
|
|
53
51
|
<td width="50%" valign="top">
|
|
54
|
-
<img src="docs/assets/
|
|
52
|
+
<img src="docs/assets/readme-deliver.zh-CN.jpg" alt="审阅结束后,带智能体写好的提交信息,以及「应用到工作目录」和「提交」按钮">
|
|
53
|
+
<h3>📦 改动去哪由你定</h3>
|
|
54
|
+
审阅结束前,接受的改动只保存在任务里。之后可以应用到工作目录,也可以提交到独立的 <code>papilot/…</code> 分支,提交信息由智能体来写。
|
|
55
|
+
</td>
|
|
56
|
+
<td width="50%" valign="top">
|
|
57
|
+
<img src="docs/assets/readme-git.zh-CN.jpg" alt="Git 面板:已暂存的文件、自动生成的提交信息、任务工作树和提交关系图">
|
|
58
|
+
<h3>🌿 不离开页面用 Git</h3>
|
|
59
|
+
暂存文件,让智能体写提交信息,再 pull、push。每个任务的工作树都显示在提交关系图里;合并合作者的改动时,冲突可以交给智能体解决。
|
|
60
|
+
</td>
|
|
61
|
+
</tr>
|
|
62
|
+
<tr>
|
|
63
|
+
<td width="50%" valign="top">
|
|
64
|
+
<img src="docs/assets/readme-contents.zh-CN.jpg" alt="打开目录面板的 PDF 阅读器">
|
|
55
65
|
<h3>📖 像本地 PDF 一样阅读</h3>
|
|
56
66
|
用目录随意跳转,全文搜索,缩放清晰。选中的文字与印出的词完全对齐。
|
|
57
67
|
</td>
|
|
58
68
|
<td width="50%" valign="top">
|
|
59
|
-
<
|
|
60
|
-
<
|
|
61
|
-
|
|
69
|
+
<h3>🧰 还有</h3>
|
|
70
|
+
<ul>
|
|
71
|
+
<li>✨ <b>技能(skill)</b>,如润色、校对、检查数学,输入 <code>/</code> 即可选用,也能在设置里写你自己的</li>
|
|
72
|
+
<li>📎 任务和消息都能附带<b>文件和图片</b></li>
|
|
73
|
+
<li>🤖 <b>Codex、Claude、Cursor、Kimi Code、GLM、DeepSeek、Qwen Code、OpenCode 或 Antigravity</b>:电脑上装了哪个就用哪个,各用你自己的登录</li>
|
|
74
|
+
<li>🌳 <b>每个任务都有独立的 Git 工作树</b>,最多两个同时运行</li>
|
|
75
|
+
<li>🌗 <b>浅色与深色</b>,界面支持中文和英文</li>
|
|
76
|
+
<li>📱 <b>运行在你的电脑上</b>,也能用手机打开</li>
|
|
77
|
+
</ul>
|
|
62
78
|
</td>
|
|
63
79
|
</tr>
|
|
64
80
|
</table>
|
|
65
81
|
|
|
66
|
-
此外:✨ **技能(skill)**,如润色、校对、检查数学,输入 `/` 即可选用,也能添加你自己的 · 🤖 **Codex、Claude 或 Antigravity**,各用你自己的登录 · 🌳 **每个任务都有独立的 Git 工作树**,最多两个同时运行 · 🌗 **浅色与深色** · 📱 **运行在你的电脑上**,也能用手机打开。
|
|
67
|
-
|
|
68
82
|
## 🚀 快速开始
|
|
69
83
|
|
|
70
84
|
> [!NOTE]
|
|
@@ -75,19 +89,27 @@ npm install -g papilot
|
|
|
75
89
|
papilot demo
|
|
76
90
|
```
|
|
77
91
|
|
|
78
|
-
打开 **http://127.0.0.1:7274**,在侧栏选择
|
|
92
|
+
打开 **http://127.0.0.1:7274**,在侧栏选择 **稿件**。demo 会添加一篇示例论文供你修改:一篇讲 Papilot 本身的 26 页 LaTeX 论文,满是公式。准备好之后,运行 `papilot`,在论文菜单中选择 **添加论文…**,选择 LaTeX 文件夹或拖入 ZIP。Papilot 会识别主文件、准备 Git 历史并尝试编译,遇到问题可在导入窗口中重试或请求助手修复。
|
|
79
93
|
|
|
80
94
|
## 🤖 智能体
|
|
81
95
|
|
|
82
96
|
| 智能体 | 登录(一次即可) | Papilot 如何运行它 |
|
|
83
97
|
| --- | --- | --- |
|
|
84
98
|
| **Codex** | `papilot codex login` | 通过 Codex app server 在其工作区沙箱中运行;已装有 `codex` 就直接用,没有则在首次启动时自动安装。 |
|
|
85
|
-
| **Claude** |
|
|
99
|
+
| **Claude** | 安装 [Claude Code](https://code.claude.com) 并运行 `claude auth login`,或设置好 `ANTHROPIC_API_KEY` 再启动 `papilot` | 装了 Claude Code 时,用你自己的登录(Claude 订阅或密钥)运行 `claude -p`,在 Claude Code 的沙箱中工作;没装时通过 Claude Agent SDK 运行,需要 API 密钥。 |
|
|
100
|
+
| **Cursor** | 设置好 `CURSOR_API_KEY` 再启动 `papilot` | 通过 Cursor SDK 在 Cursor 的沙箱中运行,首次使用时下载;该 SDK 不使用 Cursor 应用或 CLI 的登录。 |
|
|
101
|
+
| **Kimi Code** | 安装 [Kimi Code CLI](https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started),运行 `kimi login` | 通过 `kimi acp` 使用本机配置,支持流式回复、会话恢复和工具审批。 |
|
|
102
|
+
| **GLM** | 设置好 `ZHIPU_API_KEY`(或 `ZAI_API_KEY`)再启动 `papilot` | 按智谱为 GLM Coding Plan 给出的方式,让 Claude Code 连接智谱的 Anthropic 兼容接口。 |
|
|
103
|
+
| **DeepSeek** | 安装 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(`npm install -g @deepseek-ai/dsh`)并在其中配置好模型 | 通过 `dsh acp` 在其工作区沙箱中运行;工作树以外的操作需要审批。 |
|
|
104
|
+
| **Qwen Code** | 安装 [Qwen Code](https://github.com/QwenLM/qwen-code),运行 `qwen` 登录 | 以自动编辑模式运行 `qwen --acp`:改文件直接进行,运行命令需要审批。 |
|
|
105
|
+
| **OpenCode** | 安装 [OpenCode](https://opencode.ai),用 `opencode auth login` 连接模型服务商 | 用你配置的服务商运行 `opencode acp`;运行命令和工作树以外的操作需要审批。 |
|
|
86
106
|
| **Antigravity** | 安装 Antigravity 并登录 `agy` | 运行 `agy -p`,每轮一个进程,只编辑文件;所在地区需要代理时设置 `PAPILOT_AGY_PROXY`。 |
|
|
87
107
|
|
|
88
|
-
Papilot
|
|
108
|
+
Papilot 会自动找出电脑上已有的智能体,只列出这些;Codex 始终可用。Papilot 运行期间安装或登录了新的智能体,点击 **重新连接** 即可。如果服务找不到 CLI,可以用 `PAPILOT_KIMI_BIN`、`PAPILOT_DSH_BIN`、`PAPILOT_QWEN_BIN` 或 `PAPILOT_OPENCODE_BIN` 指定其路径。各智能体支持的功能和已验证的版本见[智能体指南](docs/guide.md#agents)。
|
|
89
109
|
|
|
90
|
-
|
|
110
|
+
Papilot 从不保存你的凭据。CLI 智能体使用各自的登录;为 Claude、Cursor 或 GLM 设置的密钥只会交给对应的服务。已找到但没有登录的智能体会显示为不可用。
|
|
111
|
+
|
|
112
|
+
启动遇到问题?打开 **设置 → 运行环境**,在**智能体**中查看智能体配置,或在 **LaTeX** 中查看识别到的发行版、版本和位置,或运行 `papilot doctor` 检查环境并查看修复建议,用 `papilot doctor --repo /path/to/paper` 一并检查论文。加上 `--json` 可输出机器可读的报告。诊断不会安装软件、启动服务或修改论文。检查范围见[诊断指南](docs/guide.md#diagnostics)。
|
|
91
113
|
|
|
92
114
|
<details>
|
|
93
115
|
<summary><b>⚙️ 选项与远程访问</b></summary>
|
|
@@ -101,9 +123,11 @@ papilot service install # macOS:登录后自动启动,退出后自动
|
|
|
101
123
|
npm uninstall -g papilot # 卸载;状态仍保留在 ~/.papilot,可自行删除
|
|
102
124
|
```
|
|
103
125
|
|
|
126
|
+
有新版本时,**设置** 旁会出现 **有新版本**,点击即可在浏览器中安装。Papilot 会等任务和 PDF 编译结束后重启,并重新连接页面。更新会保留你的数据,也会保留上一版安装以便回滚。详见[更新](docs/guide.md#updates)。
|
|
127
|
+
|
|
104
128
|
Papilot 只监听 `127.0.0.1`。若要从其他设备访问,用 Tailscale Serve 把它发布到你的 tailnet,并设置 `PAPILOT_PUBLIC_ORIGIN` 和 `PAPILOT_TAILSCALE_LOGIN`;Papilot 会校验每个请求的主机、浏览器来源和 Tailscale 身份。具体步骤见[指南](docs/guide.md#remote-access-with-tailscale)。
|
|
105
129
|
|
|
106
|
-
要邀请导师或合作者,用 `PAPILOT_ACCOUNT_ORIGIN` 给 Papilot 一个公开的 HTTPS 地址,然后打开
|
|
130
|
+
要邀请导师或合作者,用 `PAPILOT_ACCOUNT_ORIGIN` 给 Papilot 一个公开的 HTTPS 地址,然后打开 **设置 → 共享**:每个人用通行密钥登录,只能看到你共享的论文。只邀请你愿意让其访问运行 Papilot 的这台电脑的人,详见[协作者](docs/guide.md#collaborators)。
|
|
107
131
|
|
|
108
132
|
</details>
|
|
109
133
|
|
|
@@ -136,6 +160,10 @@ npm run build && npm start
|
|
|
136
160
|
|
|
137
161
|
<a href="https://github.com/cu1ch3n/papilot/graphs/contributors"><img src="https://contrib.rocks/image?repo=cu1ch3n/papilot" alt="Papilot 贡献者"></a>
|
|
138
162
|
|
|
163
|
+
## 🔗 友情链接
|
|
164
|
+
|
|
165
|
+
[LINUX DO](https://linux.do/) 是一个交流技术、分享开源项目的中文社区。Papilot 认同真诚、友善、团结、专业的社区理念,欢迎大家去发现有趣的项目、交流使用经验。
|
|
166
|
+
|
|
139
167
|
## 📄 许可证
|
|
140
168
|
|
|
141
169
|
[MIT](LICENSE) © 2026 Cui Chen。内置的审阅引擎 [`vendor/latex-review`](vendor/latex-review) 同样采用 MIT 许可证。
|
package/bin/doctor.mjs
CHANGED
|
@@ -34,6 +34,13 @@ function executable(command, env = process.env) {
|
|
|
34
34
|
try { fs.accessSync(file, fs.constants.X_OK); return fs.statSync(file).isFile(); } catch { return false; }
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
+
// Agent CLIs are also looked for where they install themselves, as the server does.
|
|
38
|
+
function agentExecutable(command) {
|
|
39
|
+
if (command.includes('/') || command.includes('\\')) return executable(command);
|
|
40
|
+
const home = process.env.HOME || os.homedir();
|
|
41
|
+
const dirs = ['.local/bin', '.claude/local', '.kimi-code/bin', '.opencode/bin', '.bun/bin', '.npm-global/bin'].map(dir => path.join(home, dir)).concat('/opt/homebrew/bin', '/usr/local/bin');
|
|
42
|
+
return executable(command) || executable(command, { PATH: dirs.join(path.delimiter) });
|
|
43
|
+
}
|
|
37
44
|
function command(file, args, options = {}) {
|
|
38
45
|
return new Promise(resolve => {
|
|
39
46
|
// Never return raw stderr: login commands can print credentials or account data.
|
|
@@ -141,14 +148,24 @@ export async function doctor(args) {
|
|
|
141
148
|
return false;
|
|
142
149
|
}
|
|
143
150
|
async function claudeCheck() {
|
|
151
|
+
// With Claude Code installed, Claude runs claude -p on its own login; only the login state is read.
|
|
152
|
+
const cli = agentExecutable(process.env.PAPILOT_CLAUDE_BIN || 'claude');
|
|
153
|
+
if (cli) {
|
|
154
|
+
const result = await command(cli, ['auth', 'status', '--json']);
|
|
155
|
+
let login = null;
|
|
156
|
+
try { login = JSON.parse(result.stdout); } catch { /* Reported below. */ }
|
|
157
|
+
const ready = Boolean(login?.loggedIn);
|
|
158
|
+
check('agent.claude', ready, 'warn', `${cli}: ${ready ? `Claude Code signed in${login.subscriptionType ? ` (${login.subscriptionType} plan)` : ''}; generation was not tested` : login ? 'Claude Code is not signed in' : result.reason || 'login status unavailable'}.`, 'Run claude auth login, then select Reconnect in Papilot. Set PAPILOT_CLAUDE_BIN if needed.');
|
|
159
|
+
return ready;
|
|
160
|
+
}
|
|
144
161
|
const sdk = installedModule('@anthropic-ai/claude-agent-sdk') || installedModule('@anthropic-ai/claude-agent-sdk', path.join(data, 'agents'));
|
|
145
162
|
const configured = ['ANTHROPIC_API_KEY', 'ANTHROPIC_AUTH_TOKEN', 'CLAUDE_CODE_USE_BEDROCK', 'CLAUDE_CODE_USE_VERTEX', 'CLAUDE_CODE_USE_FOUNDRY'].some(key => Boolean(process.env[key]));
|
|
146
|
-
check('agent.claude', Boolean(sdk && configured), 'warn', !configured ? 'Claude
|
|
163
|
+
check('agent.claude', Boolean(sdk && configured), configured ? 'warn' : 'info', !configured ? 'Claude Code is not installed and no Claude API key is configured, so Papilot does not offer Claude.' : sdk ? 'Claude SDK installed; API credentials configured (not validated).' : 'Claude API credentials configured; the Agent SDK is not installed yet.', !configured ? 'Install Claude Code and sign in with claude auth login to use your Claude plan, or start Papilot with ANTHROPIC_API_KEY or a supported cloud provider configured.' : 'Start papilot once to install the Claude Agent SDK.');
|
|
147
164
|
return Boolean(sdk && configured);
|
|
148
165
|
}
|
|
149
166
|
async function agyCheck() {
|
|
150
|
-
const file =
|
|
151
|
-
if (!file) { check('agent.antigravity', false, '
|
|
167
|
+
const file = agentExecutable(process.env.PAPILOT_AGY_BIN || 'agy');
|
|
168
|
+
if (!file) { check('agent.antigravity', false, 'info', missingAgent('agy', 'PAPILOT_AGY_BIN'), 'Install Antigravity and sign in to agy on this host. If already installed, correct PAPILOT_AGY_BIN or the server PATH, then restart Papilot.'); return false; }
|
|
152
169
|
const proxy = process.env.PAPILOT_AGY_PROXY;
|
|
153
170
|
const env = proxy ? { ...process.env, HTTPS_PROXY: proxy, HTTP_PROXY: proxy, https_proxy: proxy, http_proxy: proxy, NO_PROXY: '127.0.0.1,localhost' } : process.env;
|
|
154
171
|
const result = await command(file, ['models'], { env });
|
|
@@ -156,7 +173,37 @@ export async function doctor(args) {
|
|
|
156
173
|
check('agent.antigravity', ready, 'warn', `${file}: ${ready ? 'model listing succeeded (no generation tested)' : result.reason || 'no models returned'}.`, 'Sign in to agy and try agy models. If your region requires a proxy, set PAPILOT_AGY_PROXY.');
|
|
157
174
|
return ready;
|
|
158
175
|
}
|
|
159
|
-
|
|
176
|
+
// ACP agents: the CLI must offer its ACP mode. Login is not checked, so no credential is read.
|
|
177
|
+
function missingAgent(command, variable) {
|
|
178
|
+
return process.env[variable] ? `${variable} does not resolve to a runnable executable in Papilot's environment.`
|
|
179
|
+
: `${command} was not found on the PATH or in the standard agent folders available to Papilot. It may be installed for a different user or shell.`;
|
|
180
|
+
}
|
|
181
|
+
async function acpCheck(id, name, bin, help, install, update) {
|
|
182
|
+
const file = agentExecutable(process.env[bin.env] || bin.name);
|
|
183
|
+
if (!file) { check(`agent.${id}`, false, 'info', missingAgent(bin.name, bin.env), `${install}. If already installed, correct ${bin.env} or the server PATH, then restart Papilot.`); return false; }
|
|
184
|
+
const result = await command(file, help);
|
|
185
|
+
const ready = result.ok && /\bACP\b|Agent Client Protocol/i.test(result.stdout + '\n' + result.stderr);
|
|
186
|
+
check(`agent.${id}`, ready, 'warn', `${file}: ${ready ? 'ACP command available; login and generation were not tested' : result.reason || 'ACP command unavailable'}.`, `${update} Set ${bin.env} if needed.`);
|
|
187
|
+
return ready;
|
|
188
|
+
}
|
|
189
|
+
const kimiCheck = () => acpCheck('kimi', 'Kimi CLI', { env: 'PAPILOT_KIMI_BIN', name: 'kimi' }, ['acp', '--help'], 'Install Kimi Code CLI and run kimi login', 'Update Kimi Code CLI and run kimi login.');
|
|
190
|
+
const qwenCheck = () => acpCheck('qwen', 'Qwen Code', { env: 'PAPILOT_QWEN_BIN', name: 'qwen' }, ['--help'], 'Install Qwen Code and sign in by running qwen once', 'Update Qwen Code and sign in by running qwen once.');
|
|
191
|
+
const deepseekCheck = () => acpCheck('deepseek', 'DeepSeek Harness (dsh)', { env: 'PAPILOT_DSH_BIN', name: 'dsh' }, ['acp', '--help'], 'Install DeepSeek Harness with npm install -g @deepseek-ai/dsh and set up a model in dsh', 'Update DeepSeek Harness and set up a model in dsh.');
|
|
192
|
+
const opencodeCheck = () => acpCheck('opencode', 'OpenCode', { env: 'PAPILOT_OPENCODE_BIN', name: 'opencode' }, ['acp', '--help'], 'Install OpenCode and connect a provider with opencode auth login', 'Update OpenCode and connect a provider with opencode auth login.');
|
|
193
|
+
// SDK agents: a key in the environment (or the SDK's own login) selects them; keys are not validated.
|
|
194
|
+
async function cursorCheck() {
|
|
195
|
+
const configured = Boolean(process.env.CURSOR_API_KEY) || fs.existsSync(path.join(os.homedir(), '.cursor/sdk/auth.json'));
|
|
196
|
+
const sdk = installedModule('@cursor/sdk') || installedModule('@cursor/sdk', path.join(data, 'agents'));
|
|
197
|
+
check('agent.cursor', Boolean(configured && sdk), configured ? 'warn' : 'info', !configured ? 'Neither CURSOR_API_KEY nor a saved Cursor SDK login was found for the user running Papilot.' : sdk ? 'Cursor SDK installed; SDK credentials detected (not validated).' : 'Cursor SDK credentials detected; the SDK is installed on first use.', !configured ? 'Start Papilot with CURSOR_API_KEY set to a key from the Cursor dashboard, or configure the Cursor SDK login. The Cursor app and CLI login are not used. Restart Papilot after changing its environment.' : 'Start papilot and choose Cursor once to install the SDK.');
|
|
198
|
+
return configured;
|
|
199
|
+
}
|
|
200
|
+
async function glmCheck() {
|
|
201
|
+
const configured = Boolean(process.env.ZHIPU_API_KEY || process.env.ZAI_API_KEY);
|
|
202
|
+
const sdk = installedModule('@anthropic-ai/claude-agent-sdk') || installedModule('@anthropic-ai/claude-agent-sdk', path.join(data, 'agents'));
|
|
203
|
+
check('agent.glm', Boolean(configured && sdk), configured ? 'warn' : 'info', !configured ? 'ZHIPU_API_KEY or ZAI_API_KEY is not set, so Papilot does not offer GLM.' : sdk ? `GLM key configured for ${process.env.ZHIPU_API_KEY ? 'open.bigmodel.cn' : 'api.z.ai'} (not validated).` : 'GLM key configured; the Claude Agent SDK that runs GLM is installed on first use.', !configured ? 'Start Papilot with ZHIPU_API_KEY (open.bigmodel.cn) or ZAI_API_KEY (api.z.ai) set to your GLM Coding Plan or API key.' : 'Start papilot and choose GLM once to install the Claude Agent SDK.');
|
|
204
|
+
return configured;
|
|
205
|
+
}
|
|
206
|
+
const agents = await Promise.all([codexCheck(), claudeCheck(), cursorCheck(), agyCheck(), kimiCheck(), glmCheck(), deepseekCheck(), qwenCheck(), opencodeCheck()]);
|
|
160
207
|
check('agents', agents.some(Boolean), 'warn', agents.some(Boolean) ? 'At least one agent passed its configuration check; live editing was not tested.' : 'No agent passed its configuration check. PDF reading can still be used with a working TeX installation.', 'Configure one agent before starting editing tasks.');
|
|
161
208
|
|
|
162
209
|
if (repo) {
|
|
@@ -232,14 +279,14 @@ export async function doctor(args) {
|
|
|
232
279
|
}
|
|
233
280
|
}
|
|
234
281
|
// Keep reports stable even though independent probes finish in any order.
|
|
235
|
-
const order = ['node', 'dependencies', 'frontend', 'review-engine', 'data', 'git', 'latexmk', 'synctex', 'tex-engines', 'agent.codex', 'agent.claude', 'agent.antigravity', 'agents', 'project', 'project.git', 'project.head', 'project.main', 'project.engine', 'project.worktrees', 'remote', 'server', 'service', 'service.tools', 'service.data'];
|
|
282
|
+
const order = ['node', 'dependencies', 'frontend', 'review-engine', 'data', 'git', 'latexmk', 'synctex', 'tex-engines', 'agent.codex', 'agent.claude', 'agent.cursor', 'agent.antigravity', 'agent.kimi', 'agent.glm', 'agent.deepseek', 'agent.qwen', 'agent.opencode', 'agents', 'project', 'project.git', 'project.head', 'project.main', 'project.engine', 'project.worktrees', 'remote', 'server', 'service', 'service.tools', 'service.data'];
|
|
236
283
|
checks.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
|
|
237
284
|
const report = { name: 'Papilot', version: pkg.version, ok: !checks.some(item => !item.ok && item.severity === 'error'), checks };
|
|
238
285
|
if (json) console.log(JSON.stringify(report, null, 2));
|
|
239
286
|
else {
|
|
240
287
|
console.log(`Papilot ${pkg.version} doctor\n`);
|
|
241
288
|
for (const item of checks) {
|
|
242
|
-
console.log(`${item.ok ? '✓' : item.severity === 'error' ? '✗' : '!'} ${item.id}: ${item.detail}`);
|
|
289
|
+
console.log(`${item.ok ? '✓' : item.severity === 'error' ? '✗' : item.severity === 'info' ? '-' : '!'} ${item.id}: ${item.detail}`);
|
|
243
290
|
if (item.fix) console.log(` Fix: ${item.fix}`);
|
|
244
291
|
}
|
|
245
292
|
const errors = checks.filter(item => !item.ok && item.severity === 'error').length;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function stableVersion(value: unknown): value is string;
|
|
2
|
+
export function devRevision(value: unknown): string | null;
|
|
3
|
+
export function releaseVersion(value: unknown): value is string;
|
|
4
|
+
export function newerVersion(next: string, current: string): boolean;
|
|
5
|
+
export function readJson(file: string): any;
|
|
6
|
+
export function writeJson(file: string, value: unknown): void;
|
|
7
|
+
export function activeInstallation(root: string, data: string): string;
|
|
8
|
+
export function waitForActivation(data: string): Promise<void>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
export const stableVersion = value => typeof value === 'string' && /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(value) && value.length < 40;
|
|
5
|
+
export const devRevision = value => typeof value === 'string' && value.length < 100 && /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)-dev\.([a-f0-9]{40})$/.exec(value)?.[4] || null;
|
|
6
|
+
export const releaseVersion = value => stableVersion(value) || Boolean(devRevision(value));
|
|
7
|
+
export function newerVersion(next, current) {
|
|
8
|
+
if (!stableVersion(next)) return false;
|
|
9
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(.*)$/.exec(current);
|
|
10
|
+
if (!match) return false;
|
|
11
|
+
const parts = next.split('.').map(BigInt), previous = match.slice(1, 4).map(BigInt);
|
|
12
|
+
for (let i = 0; i < 3; i++) if (parts[i] !== previous[i]) return parts[i] > previous[i];
|
|
13
|
+
return match[4].startsWith('-');
|
|
14
|
+
}
|
|
15
|
+
export function readJson(file) { try { return JSON.parse(fs.readFileSync(file, 'utf8')); } catch { return null; } }
|
|
16
|
+
export function writeJson(file, value) {
|
|
17
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
18
|
+
const temporary = file + '.' + process.pid + '.tmp';
|
|
19
|
+
fs.writeFileSync(temporary, JSON.stringify(value), { mode: 0o600 });
|
|
20
|
+
fs.renameSync(temporary, file);
|
|
21
|
+
}
|
|
22
|
+
// Updates live beside the database, never over a global installation or checkout.
|
|
23
|
+
// All launch methods (CLI, npm start, launchd) enter through main.ts.
|
|
24
|
+
export function activeInstallation(root, data) {
|
|
25
|
+
const active = readJson(path.join(data, 'updates/active.json'));
|
|
26
|
+
const version = readJson(path.join(root, 'package.json'))?.version;
|
|
27
|
+
if (!active || !releaseVersion(active.version)) return root;
|
|
28
|
+
// Explicit channel selections also cover dev builds and returning to stable.
|
|
29
|
+
// Older activation records retain their upgrade-only behavior.
|
|
30
|
+
if (!['stable', 'dev'].includes(active.channel) && !newerVersion(active.version, version)) return root;
|
|
31
|
+
if (active.channel && (active.channel === 'dev') !== Boolean(devRevision(active.version))) return root;
|
|
32
|
+
if (typeof active.root !== 'string') return root;
|
|
33
|
+
try {
|
|
34
|
+
const releases = fs.realpathSync(path.join(data, 'updates/releases')) + path.sep;
|
|
35
|
+
if (!fs.realpathSync(active.root).startsWith(releases)) return root;
|
|
36
|
+
} catch { return root; }
|
|
37
|
+
const pkg = readJson(path.join(active.root, 'package.json'));
|
|
38
|
+
if (pkg?.name !== 'papilot' || pkg.version !== active.version || !fs.existsSync(path.join(active.root, 'src/server/start.ts'))) return root;
|
|
39
|
+
return active.root;
|
|
40
|
+
}
|
|
41
|
+
export async function waitForActivation(data) {
|
|
42
|
+
const file = path.join(data, 'updates/active.json');
|
|
43
|
+
for (let attempt = 0; attempt < 200; attempt++) {
|
|
44
|
+
const active = readJson(file);
|
|
45
|
+
if (active?.phase !== 'pending') return;
|
|
46
|
+
try { process.kill(active.pid, 0); }
|
|
47
|
+
catch {
|
|
48
|
+
if (active.previous) writeJson(file, active.previous); else fs.rmSync(file, { force: true });
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
52
|
+
}
|
|
53
|
+
throw new Error('The update is still restarting.');
|
|
54
|
+
}
|
package/bin/papilot.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
|
5
5
|
import os from 'node:os';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { activeInstallation } from './installation.mjs';
|
|
8
9
|
|
|
9
10
|
const usage = `Usage: papilot [doctor | demo | codex <args> | service install | service stop] [--port <number>] [--data <folder>]
|
|
10
11
|
|
|
@@ -18,7 +19,9 @@ const usage = `Usage: papilot [doctor | demo | codex <args> | service install |
|
|
|
18
19
|
--data <folder> Keep state in another folder (PAPILOT_DATA, default ~/.papilot)
|
|
19
20
|
--version Print the version`;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
let pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
23
|
+
const packageRoot = fileURLToPath(new URL('..', import.meta.url));
|
|
24
|
+
const installedPackage = () => JSON.parse(readFileSync(path.join(activeInstallation(packageRoot, process.env.PAPILOT_DATA || path.join(os.homedir(), '.papilot')), 'package.json'), 'utf8'));
|
|
22
25
|
const args = process.argv.slice(2);
|
|
23
26
|
async function main() {
|
|
24
27
|
const doctor = args[0] === 'doctor';
|
|
@@ -37,7 +40,7 @@ async function main() {
|
|
|
37
40
|
}
|
|
38
41
|
else if (arg === '--data' && args[i + 1]) process.env.PAPILOT_DATA = path.resolve(args[++i]);
|
|
39
42
|
else if (arg === '--version' || arg === '-v') {
|
|
40
|
-
console.log(
|
|
43
|
+
console.log(installedPackage().version);
|
|
41
44
|
process.exit(0);
|
|
42
45
|
} else {
|
|
43
46
|
if (arg !== '--help' && arg !== '-h') console.error(`Unknown argument: ${arg}\n`);
|
|
@@ -78,6 +81,7 @@ async function main() {
|
|
|
78
81
|
const emitWarning = process.emitWarning;
|
|
79
82
|
process.emitWarning = (warning, ...rest) => String(warning).includes('SQLite') ? undefined : emitWarning.call(process, warning, ...rest);
|
|
80
83
|
process.env.PAPILOT_DATA ||= path.join(os.homedir(), '.papilot');
|
|
84
|
+
pkg = installedPackage();
|
|
81
85
|
|
|
82
86
|
// Papilot drives Codex through its app server. A codex on PATH at least as new
|
|
83
87
|
// as the tested version is used as it is; otherwise that version is installed
|