Update build system and path handling
- Use Node filesystem APIs instead of shell commands for temp cleanup - Add absolute path helpers for cross-platform compatibility - Generate both main.js and dist/main.js artifacts - Improve error handling in document downloader - Track additional document metadata in sync tracker - Replace Unix-specific `find` with recursive directory traversal The build system now generates two output files (main.js and dist/main.js) for better compatibility with Obsidian's plugin loading. Path handling has been centralized in new utilities to ensure cross-platform behavior, replacing shell commands that had Windows compatibility issues.
This commit is contained in:
+18
-16
@@ -39,12 +39,12 @@
|
||||
| 15 | No dependency validation | `src/ocr/pipeline.ts` | Added `validateDependencies()` on load |
|
||||
| 16 | No page batching | `src/ocr/pipeline.ts` | Batched GLM-OCR requests with `maxPagesPerBatch` |
|
||||
| 17 | No progress feedback | `src/ocr/pipeline.ts` | Progress notices every 5 pages and per batch |
|
||||
| 18 | Windows `rm` incompatibility | `src/ocr/pipeline.ts` | Uses `rd /s /q` on Windows, `rm -rf` otherwise |
|
||||
| 18 | Windows `rm` incompatibility | `src/ocr/pipeline.ts` | Uses Node filesystem APIs for temp cleanup |
|
||||
| 19 | `getPageFiles()` assumes root | `src/utils/zip.ts` | Recursively searches for `.rm` files |
|
||||
| 20 | Temp dir uses absolute path | `src/ocr/pipeline.ts` | Uses vault-relative path `.obsidian/rmapi-tmp` |
|
||||
| 20 | Temp dir path handling | `src/ocr/pipeline.ts` | Uses an absolute filesystem path under `.obsidian/rmapi-tmp` for shell tools |
|
||||
| 21 | No HTTP timeout | `src/ocr/glmocr-client.ts`, `src/ocr/style-refiner.ts` | Added `--max-time 60` to curl |
|
||||
| 22 | No LLM output validation | `src/ocr/style-refiner.ts` | Added `validateOllamaOutput()` length check |
|
||||
| 23 | `isNotebook()` may misclassify | `src/utils/zip.ts` | Falls back to `file` command if ambiguous |
|
||||
| 23 | Unix-only recursive listing | `src/utils/zip.ts` | Uses Node recursive directory traversal instead of `find` |
|
||||
|
||||
---
|
||||
|
||||
@@ -52,8 +52,9 @@
|
||||
|
||||
```
|
||||
obidian-remarkable/
|
||||
├── main.js # Built plugin entry loaded by Obsidian
|
||||
├── dist/
|
||||
│ └── main.js # Built plugin (~17 KB, minified)
|
||||
│ └── main.js # Secondary built artifact
|
||||
├── src/
|
||||
│ ├── main.ts # Plugin entry: ribbon, commands, status bar, auto-sync, dependency validation
|
||||
│ ├── settings.ts # Settings tab with validation + 2 new settings
|
||||
@@ -72,6 +73,7 @@ obidian-remarkable/
|
||||
│ │ └── render.ts # .rm page → PNG via drawj2d or rM2svg (configurable path)
|
||||
│ └── utils/
|
||||
│ ├── process.ts # Child process runner with error handling
|
||||
│ ├── paths.ts # Vault-relative and absolute path helpers
|
||||
│ └── zip.ts # .rm zip extraction + notebook detection + recursive page search
|
||||
├── main.ts # Entry point (re-exports plugin)
|
||||
├── manifest.json # Obsidian plugin manifest (fixed)
|
||||
@@ -108,7 +110,7 @@ User clicks ribbon icon / auto-sync interval
|
||||
→ ls --json / (root)
|
||||
→ For each CollectionType: recurse into subfolder
|
||||
→ For each DocumentType:
|
||||
→ Skip if lastSynced >= modifiedClient (incremental)
|
||||
→ Skip if tracked remoteVersion and remoteModified match (incremental)
|
||||
→ sanitizeFileName() for safe filesystem names
|
||||
→ mkdir downloadPath (vault-relative)
|
||||
→ rmapi get → download .rm file
|
||||
@@ -164,8 +166,8 @@ flowchart TB
|
||||
| **0** | `unzip` | `.rm` file | Extracted directory | `.rm` files are zip archives |
|
||||
| **1** | Custom parser | `content.json` | Raw text | Best-effort; may return empty string |
|
||||
| **2** | `drawj2d` or `rM2svg` | `.rm` page files | `page-0.png`, `page-1.png`, ... | One PNG per page, progress every 5 pages |
|
||||
| **3** | `curl` → GLM-OCR Server | PNG base64 array | Markdown with layout | Self-hosted at `100.103.83.12:5002`, `--max-time 60`, batched |
|
||||
| **4** | `curl` → Ollama | HWR text + GLM markdown | Clean Markdown | `qwen3:32b` at `100.103.83.12:11435`, output length validated |
|
||||
| **3** | `curl` → GLM-OCR Server | PNG base64 array | Markdown with layout | Self-hosted at configured server URL, `--max-time 60`, batched |
|
||||
| **4** | `curl` → Ollama | HWR text + GLM markdown | Clean Markdown | Configured Ollama host/model, output length validated |
|
||||
|
||||
### Style Refinement Prompt (Option A)
|
||||
|
||||
@@ -200,9 +202,9 @@ OUTPUT ONLY THE FINAL REFINED MARKDOWN.
|
||||
| `downloadPath` | `remarkable/` | Vault folder for downloads |
|
||||
| `convertToPdf` | `true` | Auto-download annotated PDFs |
|
||||
| `enableHandwritingMd` | `true` | **Trigger OCR pipeline after sync** |
|
||||
| `glmocrServerUrl` | `http://100.103.83.12:5002` | GLM-OCR SDK Server |
|
||||
| `glmocrApiKey` | `any-string` | Dummy key for self-hosted |
|
||||
| `ollamaHost` | `http://100.103.83.12:11435` | Ollama server |
|
||||
| `glmocrServerUrl` | `http://localhost:5002` | GLM-OCR SDK Server |
|
||||
| `glmocrApiKey` | empty | API key for GLM-OCR Server |
|
||||
| `ollamaHost` | `http://localhost:11435` | Ollama server |
|
||||
| `styleModel` | `qwen3:32b` | Model for markdown cleanup |
|
||||
| `pageRenderer` | `drawj2d` | `.rm` → PNG tool |
|
||||
| `javaPath` | `java` | Java runtime for drawj2d |
|
||||
@@ -224,7 +226,7 @@ OUTPUT ONLY THE FINAL REFINED MARKDOWN.
|
||||
- **Page renderer**:
|
||||
- **drawj2d**: Java JAR (recommended for Paper Pro v3.x) + `drawj2dPath` setting
|
||||
- **rM2svg**: Binary + `rsvg-convert` or ImageMagick
|
||||
- **Standard CLI tools**: `unzip`, `curl`, `base64`, `file` (validated on load)
|
||||
- **Standard CLI tools**: `unzip`, `curl` (validated on load)
|
||||
|
||||
---
|
||||
|
||||
@@ -243,7 +245,7 @@ OUTPUT ONLY THE FINAL REFINED MARKDOWN.
|
||||
| **Dependency validation** | User knows what's missing before OCR fails |
|
||||
| **Progress feedback** | Better UX for large notebooks |
|
||||
| **Output validation** | Trust but verify LLM output |
|
||||
| **Windows compatibility** | Uses `rd /s /q` on Windows, `rm -rf` on Unix |
|
||||
| **Windows compatibility** | Uses Node filesystem APIs for temp cleanup |
|
||||
| **Recursive page search** | Handles `.rm` files in subdirectories |
|
||||
|
||||
---
|
||||
@@ -259,7 +261,7 @@ npm run build
|
||||
npm run dev
|
||||
|
||||
# Install in Obsidian
|
||||
Copy the `obidian-remarkable` folder to:
|
||||
Run `npm run build`, then copy the plugin folder containing `manifest.json` and root `main.js` to:
|
||||
- Linux: ~/.config/obsidian/plugins/
|
||||
- macOS: ~/Library/Application Support/obsidian/plugins/
|
||||
- Windows: %APPDATA%\obsidian\plugins\
|
||||
@@ -270,9 +272,9 @@ Copy the `obidian-remarkable` folder to:
|
||||
## 🐛 Known Limitations
|
||||
|
||||
1. **HWR extraction is best-effort**: reMarkable v3.x `content.json` format isn't fully documented. If no HWR text is found, the pipeline falls back to GLM-OCR alone.
|
||||
2. **Page renderer path**: `drawj2d.jar` is assumed in PATH. You may need to set an absolute path in settings (future improvement).
|
||||
3. **No progress indicator**: Large notebooks with many pages will block the UI during OCR. Consider adding a progress modal.
|
||||
4. **Temp directory**: Uses `.obsidian/rmapi-tmp` and cleans up with `rm -rf` or `rd /s /q`.
|
||||
2. **OCR runtime dependencies**: GLM-OCR, Ollama, and a page renderer must be running/installed outside Obsidian.
|
||||
3. **Progress UX**: Large notebooks use notices for progress, but there is no cancellable progress modal yet.
|
||||
4. **Temp directory**: Uses an absolute filesystem path at `<vault>/.obsidian/rmapi-tmp` and cleans it up with Node filesystem APIs.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user