Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/unclemoc/factscribe/.minimax-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"schemaVersion": 1,
"name": "factscribe",
"displayName": "FactScribe 论文工作台",
"version": "1.2.0",
"version": "1.3.0",
"description": "A local workbench for writing papers: open your manuscript projects, read the check report, the fact ledger and the knowledge base, and let the assistant propose edits you approve before anything reaches the file. Numbers and citations stay pinned to the ledger; the AI proposes, you decide.",
"author": "UncleMoc · BGISMALL",
"icon": "icon.png",
Expand Down
60 changes: 39 additions & 21 deletions plugins/unclemoc/factscribe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,29 @@ The engine is written in Python. Its source is vendored into the package, so the

### Line endings

A save keeps the line endings your file already had. The engine reads sections with Python's
universal-newline mode (CRLF becomes LF before the text ever reaches the page) and writes the
file back byte for byte, so without a second step **every save rewrites the whole file with LF
endings** — a CRLF manuscript loses all its CR bytes on the first edit. The Node shell therefore
reads the real endings from the file on disk before the save, hands the engine an LF-only body,
and puts the original endings back afterwards: lines the save did not touch keep their exact
endings (a file with mixed endings stays mixed), the edited lines take the file's dominant
ending, and the text itself is never altered — only the endings move. If the file changed
underneath while the save was running, the endings are left alone instead of being overwritten.
A save keeps the line endings your file already had.

The engine reads a section with Python's universal-newline mode (CRLF becomes LF before the text
ever reaches the page) and writes the file back byte for byte, so without a second step **every
save rewrites the whole file with LF endings** — a CRLF manuscript loses all its CR bytes on the
first edit. Two independent steps prevent that:

- The engine restores the endings itself. Every line it wrote keeps the ending of the line it
replaced; a line the user typed gets the file's dominant ending. The AI draft block inserted
into a manuscript is written with the file's dominant ending as well, so a CRLF manuscript gets
a CRLF draft block instead of a stray run of LF lines.
- The Node shell keeps a second, independent safety net: before a save it reads the real endings
from the text files on disk, hands the engine an LF-only body, and puts the original endings
back afterwards — lines the save did not touch keep their exact endings (a file with mixed
endings stays mixed), the changed lines take the file's dominant ending. It moves endings only,
never a character of text, and if the file changed underneath while the save was running it
leaves the endings alone instead of overwriting somebody else's edit.

The two steps were measured against each other on the same files (CRLF, LF and mixed-ending
manuscripts, each saved with and without a content change, plus an AI draft insertion): when the
engine restores the endings correctly the shell's pass produces byte-identical output in every
case but one, and in that one case it is the shell's result that keeps the untouched line's
original ending.

On first use the page asks for your paper root directory: any directory that contains a
`factscribe.toml` is treated as a paper project. It can be changed later from the settings page.
Expand All @@ -83,17 +97,21 @@ On first use the page asks for your paper root directory: any directory that con
- Minimum client version: 3.1.2. The package declares `agentAccess: ["session.run"]`, which
needs 3.1.2; no `engines` bound is declared, so clients from 3.1.2 on still install it and
only lose the assistant model picker when their client does not expose the model catalogue.
- Node 26.7 with the package's own tests: `node --test tests/*.test.mjs` — 19 cases, all
green (16 unit cases for the line-ending module, plus 3 end-to-end cases that start the
vendored Python engine and save into a copy of the sample paper).
- The line-ending round trip was measured on the vendored sample paper: a 678-byte section with
11 CRLF endings came back with all 11 endings and the same text. Without the fix the engine's
own save rewrote the same file as 667 bytes with 0 CRLF endings — every CR byte lost.
- The package's own tests: `node --test tests/*.test.mjs` — 32 cases, all green: 16 unit cases
for the line-ending module, 8 cases for the status-code passthrough (the shell must not turn
the engine's 409/400/404 into a 502), and 8 end-to-end cases that start the vendored Python
engine and save into a copy of the sample paper. Run on Node 20.20.2, 22.23.5 and 26.7.0 —
32/32 green on each, no case skipped.
- The line-ending round trip was measured on the vendored sample paper: a section of 678 bytes
with 11 CRLF endings came back with all 11 endings and the same text. The same section without
the CR bytes weighs 667 bytes with 0 CRLF endings — that is what a save would leave behind if
the endings were not restored.
- Not verified: Windows and Linux hosts. The package ships no platform-specific binary and the
Node entry uses only Node built-ins, but no run on those platforms has been done. The Windows
interpreter discovery (`py` launcher, versioned commands, common install directories) is
covered by unit tests, but no end-to-end run on a real Windows machine has been done; the 36
Windows candidates are generated from the platform string, not measured on Windows.
covered by unit tests, but no end-to-end run on a real Windows machine has been done; the
Windows candidate list is generated from the platform string (31 to 37 entries, depending on
which environment variables are set), not measured on Windows.

## Data & access

Expand All @@ -104,10 +122,10 @@ On first use the page asks for your paper root directory: any directory that con
`proposals/` (proposal records) and `custom-models.json` (an API key you typed yourself, mode
0600). Inside your paper directory, only where you click: `sections/*.tex` (atomic write plus a
`.bak` copy, refused when the file changed underneath) and `facts/draft/` for imported drafts.
Opening a disk also records `last_opened` in that disk's `factscribe.toml`. Restoring the
original line endings after a save writes the same file again through a sibling temporary file
(`<name>.eol-tmp-<pid>`) and renames it over the original, so no extra file is left behind; the
temporary file is removed if the write fails.
Opening a disk also records `last_opened` in that disk's `factscribe.toml`. Putting the
original line endings back after a save writes the same file again through a sibling temporary
file (`<name>.eol-tmp-<pid>`) and renames it over the original, so no extra file is left behind;
the temporary file is removed if the write fails.
- **Network hosts**: none by default. The Node service and the Python engine listen on loopback
only (`127.0.0.1`). If you add a custom model in the panel, the Node shell sends the prompt to
the OpenAI-compatible endpoint you typed; the host Agent turn is run by the Host on your
Expand Down
34 changes: 23 additions & 11 deletions plugins/unclemoc/factscribe/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,23 @@ MiniMax Code 3.1.11 起也可以直接从 Git 仓库导入:贴仓库地址、

### 行尾保真

保存会保留文件原来的行尾。引擎读章节用 Python 的通用换行模式(CRLF 在到达页面前就变成
LF 了),写文件又是逐字节写回,所以没有第二道工序的话,**每保存一次整篇就被改成 LF 行尾**——
CRLF 的稿子一编辑就把 CR 全丢了。Node 薄壳因此在保存前先从磁盘读出原文件真正的行尾,
交给引擎的正文一律是 LF 形态,引擎写完再按原风格把行尾摆回去:这次保存没碰到的行连原来的
行尾都原样留着(混合行尾的稿子保存后仍是混合的),被改动的那几行走该文件的主导行尾,正文
一个字都不动——只有行尾在动。保存期间文件被别处改过,就不去动行尾,不覆盖别人的改动。
保存会保留文件原来的行尾。

引擎读章节用 Python 的通用换行模式(CRLF 在到达页面前就变成 LF 了),写文件又是逐字节写回,
所以没有第二道工序的话,**每保存一次整篇就被改成 LF 行尾**——CRLF 的稿子一编辑就把 CR 全丢了。
这里有两道互相独立的工序挡着:

- 引擎自己把行尾还原回去。它写出的每一行都沿用它替换掉的那一行的行尾;用户新输入的行按该文件的
主导行尾落。插进稿子里的 AI 草稿块同样按所在文件的主导行尾落——CRLF 的稿子插进去的草稿块
也是 CRLF,不会冒出一段 LF 行。
- Node 薄壳还有第二道兜底:保存前先把磁盘上文本文件真正的行尾读下来,交给引擎的正文一律是 LF
形态,引擎写完再按原风格把行尾摆回去——这次保存没碰到的行连原来的行尾都原样留着(混合行尾的
稿子保存后仍是混合的),被改动的那几行走该文件的主导行尾。它只动行尾,一个正文字符都不动;
保存期间文件被别处改过,就不去动行尾,不覆盖别人的改动。

这两道工序在同样的文件上互相量过(CRLF/LF/混合三种稿子,各存一次与改完再存,外加插一次 AI
草稿):引擎自己把行尾还原对的时候,薄壳这一道在九组场景里有八组与它逐字节相同;剩下那一组里,
是薄壳的落盘保住了那句没被改动的行原来的行尾。

首次打开会让你填**论文根目录**:含 `factscribe.toml` 的目录会被当作论文项目,之后可在设置页改。

Expand All @@ -71,14 +82,15 @@ CRLF 的稿子一编辑就把 CR 全丢了。Node 薄壳因此在保存前先从
- 最低客户端版本:3.1.2。本包声明 `agentAccess: ["session.run"]`(该能力需要 3.1.2);
没有声明 `engines` 下限,所以 3.1.2 起的客户端都能装,只是客户端不提供模型目录时
面板里少一个模型下拉。
- Node 26.7 与随包测试:`node --test tests/*.test.mjs` —— 19 例全绿(行尾模块 16 例
单测,加上 3 例真引擎端到端:拉起随包 Python 引擎,在样例盘副本上真存一次)。
- 随包测试:`node --test tests/*.test.mjs` —— 32 例全绿:行尾模块 16 例单测、状态码透传 8 例
(薄壳不能把引擎的 409/400/404 压成 502)、端到端 8 例(拉起随包 Python 引擎,在样例盘副本上
真存一次)。在 Node 20.20.2/22.23.5/26.7.0 上各跑一遍,均为 32/32 全绿、0 例跳过。
- 行尾往返在随包样例盘上实测过:678 字节、11 个 CRLF 的章节文件,保存后 11 个 CRLF 一个不少、
正文一字不差;不修的话,引擎自己那次保存会把它写成 667 字节、0 个 CRLF——CR 全丢。
正文一字不差;同一份文件去掉 CR 字节是 667 字节、0 个 CRLF——不还原行尾的话,保存完就是这个样子。
- **未验证**:Windows 与 Linux 宿主。包内没有平台专属二进制、Node 入口只用内置模块,
但没有在这两个平台上实跑过。Windows 上的解释器发现(`py` 启动器、版本化命令、
常见安装目录)有单元测试覆盖,但没有在 Windows 真机上端到端跑过;那 36 个 Windows
候选是按平台字符串生成的,不是在 Windows 上量出来的。
常见安装目录)有单元测试覆盖,但没有在 Windows 真机上端到端跑过;那批 Windows 候选是按平台
字符串生成的(31 到 37 条,看设了哪些环境变量),不是在 Windows 上量出来的。

## 数据与访问

Expand Down
38 changes: 38 additions & 0 deletions plugins/unclemoc/factscribe/miniapp/client/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1599,3 +1599,41 @@ body.nav-collapsed .nav-splitter{display:none}
.fi-src{flex:0 0 auto;max-width:22%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
font-size:11px;color:#9b9a96}


/* ================================================================
第 ④ 步收口:引用(增/删)与图片(预览)——旧节级前端那两页搬过来的
================================================================ */

/* 项目列表页头部:装示例 与 新建 排一组 */
.pv-head-btns .pv-new{margin-left:0}
.pv-sample{white-space:nowrap}

/* 引用清单 */
.cite-sum{font-size:11px;color:#6f6e69;margin:0 0 6px}
.cite-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
.cite-row{border:1px solid #ececeb;border-radius:7px;padding:7px 8px;background:#fff}
.cite-row.s-bad_id,.cite-row.s-duplicate{border-color:#e8c3c0;background:#fdf7f6}
.cite-line1{display:flex;align-items:center;gap:6px}
.cite-key{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;color:#2f2e2b;
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:130px}
.cite-status{font-size:10px;color:#6f6e69;border:1px solid #e6e6e4;border-radius:999px;padding:1px 6px;
white-space:nowrap;flex:0 0 auto}
.cite-row.s-bad_id .cite-status,.cite-row.s-duplicate .cite-status{color:#8c2f22;border-color:#e8c3c0}
.cite-del{margin-left:auto;border:none;background:none;color:#9b9a96;font-size:12px;cursor:pointer;padding:0 2px;
line-height:1;flex:0 0 auto}
.cite-del:hover{color:#8c2f22}
.cite-title{font-size:12px;color:#37352f;margin-top:3px;line-height:1.45;
display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.cite-meta{font-size:10.5px;color:#8f8d86;margin-top:2px}

/* 图片清单 */
.asset-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}
.asset-cell{border:1px solid #ececeb;border-radius:7px;background:#fff;padding:4px;cursor:pointer;
display:flex;flex-direction:column;gap:3px;align-items:center;font-family:inherit}
.asset-cell:hover{border-color:#b8b5ac}
.asset-cell img{width:100%;height:52px;object-fit:cover;border-radius:4px;background:#f4f3f1;display:block}
.asset-name{font-size:10px;color:#6f6e69;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.asset-empty,.asset-more{font-size:11px;color:#8f8d86;margin:2px 0 0;grid-column:1/-1}
.asset-more{margin-top:4px}
.asset-view{display:flex;justify-content:center;align-items:center}
.asset-full{max-width:100%;max-height:62vh;border-radius:6px;background:#fff}
Loading