Repository navigation
Conversation
added 2 commits
November 25, 2026 19:11
Two fixes: one for Windows machines, one for manuscripts that use CRLF.
1. Windows interpreter discovery
The candidate list had no Windows shape at all -- no "py" launcher, no
versioned command, no common install directory -- and a failed probe was
collapsed into "not installed". A user with Python 3.9 on the machine was
told to "install Python >=3.10", with nothing to act on.
- new miniapp/node/python_discovery.mjs: candidates are {command, args}
and cover py, py -3, py -3.10 ... py -3.14, py.exe, versioned commands,
python.exe and absolute paths under %LOCALAPPDATA%, %PROGRAMFILES% and
C:\Python3xx -- 36 candidates on Windows. The macOS/Linux list is
unchanged, word for word.
- the probe classifies the outcome: version high enough / too low /
command missing / present but the version cannot be read. The message
therefore names the version it found and the executable it came from.
- discovery and engine start share one "command + prefix arguments" pair,
so "py -3" is used for both, not only for probing.
- the settings page and the engine start failure share one message:
not installed / too old (3.9 and below cannot run this engine) /
installed but not on PATH (point FS_PYTHON at it) / Microsoft Store
placeholder alias that cannot report its version.
The requirement is unchanged: the engine needs Python >= 3.10.
2. Browser-layer CRLF preservation
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 every save rewrote the whole file with LF
endings -- a CRLF manuscript lost all its CR bytes on the first edit.
- new miniapp/node/eol.mjs: split with the endings kept apart, recognise
crlf / lf / mixed, put the original endings back.
- the Node shell reads the real endings from disk before the save, hands
the engine an LF-only body and restores the endings afterwards: lines
the save did not touch keep their exact endings (a mixed file stays
mixed), the edited lines take the file's dominant ending, and the text
is never altered -- only the endings move. If the file changed
underneath while the save ran, the endings are left alone.
The vendored Python engine is untouched by both changes.
Verified:
- upstream checker: plugins/unclemoc/factscribe OK (0 errors, 0 warnings);
npm run check exits 0 (92/92 checker self-tests).
- package 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).
- 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 it as 667 bytes with 0 CRLF.
Not verified:
- Windows end to end. There is no Windows machine here. The 36 Windows
candidates are generated from the platform string and covered by unit
tests, but no run on a real Windows host has been done.
- Linux hosts, as before.
…ackage The vendored copy of the Python engine in this package predates the newline-fidelity work. It read user files in universal-newline mode, so a CRLF file was already LF by the time the text reached the page, and it wrote several user-owned files in platform default text mode, where a CRLF string is written as \r\r\n on Windows. The Node shell restored the endings after each save, but the engine itself still lost them, and the Node layer can only put a file back when its line contents still match. Re-vendor the engine from the FactScribe source tree, which now carries the newline-fidelity work: - new factscribe/textio.py: read_text_exact / write_text_exact / append_text_exact keep the file's own line endings, and to_lf gives the analysis layer an explicit normalisation point; - the read side uses read_text_exact, the write side write_text_exact; - machine-generated artefacts (JSON reports, audit matrices, manifests) keep using the platform default, so their format stays predictable. The vendored tree is produced by miniapp/build.sh and is byte-identical to the source tree apart from the excluded web/ directory. Measured on the vendored sample paper, saving through this package: a 678-byte section with 11 CRLF endings came back as 678 bytes with 11 CRLF endings and the same sha256; the LF file (667 bytes, 11 LF) and the mixed file (668 bytes, 1 CRLF + 10 LF) came back byte-identical. With the previous engine the Node layer had to repair the file after every CRLF and mixed save; with this engine the engine's own write is already faithful. Not verified: Windows end to end, and Linux.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes for the FactScribe Paper Workbench package: on Windows the Mini App can now find the Python interpreter the machine already has, and saving a manuscript no longer rewrites its line endings. The vendored Python engine has been upgraded to a newline-faithful build as well, so the engine itself keeps the file's own line endings instead of leaving that to the Node shell to put back afterwards.
Written by MiniMax Code (MCode)
Windows interpreter discovery
The candidate list had no Windows shape at all — no
pylauncher, no versioned command, no common install directory — and a failed probe was collapsed into "not installed". A user with Python 3.9 on the machine was told to "install Python >=3.10", with nothing they could act on.miniapp/node/python_discovery.mjs. Candidates are now{command, args}pairs and coverpy,py -3,py -3.10…py -3.14,py.exe, the versioned commands,python.exe, and absolute paths under%LOCALAPPDATA%,%PROGRAMFILES%andC:\Python3xx— 36 candidates on Windows. The macOS/Linux list is unchanged, word for word.py -3starts the engine too, not only the probe.FS_PYTHONat it) / a Microsoft Store placeholder alias that cannot report its version.The requirement itself is unchanged: the engine needs Python >= 3.10.
Browser-layer CRLF preservation
The engine used to read sections with Python's universal-newline mode — CRLF became LF before the text ever reached the page — and wrote the file back byte for byte. Every save therefore rewrote the whole file with LF endings, so a CRLF manuscript lost all its CR bytes on the first edit. The browser layer is the first line of defence and stays.
miniapp/node/eol.mjs: split the text with the endings kept apart, recognisecrlf/lf/mixed, and put the original endings back.The vendored Python engine keeps line endings too
The package ships a copy of the Python engine under
miniapp/node/engine/, and that copy was still the older build. It read user files in universal-newline mode, so a CRLF file was already LF by the time the text reached the page, and it wrote several user-owned files in platform default text mode, where a CRLF string is written as\r\r\non Windows. The Node shell puts the endings back after each save, so the file on disk looked right — but the engine had already lost the endings, and the Node layer can only repair a file whose line contents still match.The vendored engine has been re-vendored from the engine source tree:
factscribe/textio.py:read_text_exact/write_text_exact/append_text_exactread and write with the file's own line endings — no universal-newline translation on the way in, no platform translation on the way out — andto_lfgives the analysis layer one explicit place where line endings are normalised in memory. Machine-generated artefacts (JSON reports, audit matrices, manifests) keep the platform default, so their format stays predictable.read_text_exact; the write side useswrite_text_exact.miniapp/build.shand is byte-identical to the source tree apart from the excludedweb/directory.Tested environment and results
plugins/unclemoc/factscribe: OK— 0 errors, 0 warnings.npm run checkexits 0 (92/92 checker self-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).repaired: 1for the CRLF file and for the mixed file); with the new engine the engine's own write is already faithful and nothing has to be repaired.line1\nline2\n; the newread_text_exactreturnsline1\r\nline2\r\n.What was not verified
\nstays\n), so the write-side corruption cannot be observed on this machine at all; only the read side is observable here. The write-side claim rests on Python's documented Windows text-mode behaviour, not on a measurement taken on a Windows host.npm run checkwarningsNone — the package reports 0 errors and 0 warnings, so there is nothing to explain.
Access and minimum client version
No new access is declared, and the minimum client version is unchanged at 3.1.2.
plugin.jsonmoves from 1.1.0 to 1.2.0.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.