feat(ocr): download the official Ollama installer, verify it, open it, then continue setup (desktop: macOS/Windows; Linux guide) #33
No reviewers
Labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
daniel/obsidian-remarkable-round-trip!33
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/ollama-installer-download"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #28 (item 1, installer download; items 2 and 3 are !31 and !32). Part of #8.
When "Set up local reading for me" finds no Ollama, v1 only links to ollama.com/download (
OllamaMissingModalinsrc/ollamasetup.ts). @daniel on #8: "direct download would be preferred". This MR adds that: one click downloads the official, signed installer, checks its published SHA-256, opens it with the OS, waits for Ollama to come up, and carries on into v1's flow (model pull, settings, Test connection).Research (done on #28; verified 2026-10-20)
https://ollama.com/download/{Ollama.dmg,OllamaSetup.exe}→ 307 →https://github.com/ollama/ollama/releases/latest/download/<asset>→ 302 →release-assets.githubusercontent.com. Latest is v0.40.6.Ollama.dmgis 214 MB.OllamaSetup.exeis 1.58 GB (GPU runtimes included). Tell the user the size before downloading.GET https://api.github.com/repos/ollama/ollama/releases/latestreturnstag_nameandassets[], each withname,size,browser_download_urlanddigest: "sha256:<hex>". Each release also shipssha256sum.txt, with lines<hex> ./<name>(includes./Ollama.dmgand./OllamaSetup.exe). The API digest forOllama.dmgmatchessha256sum.txt.OllamaSetup.exeis Authenticode-signed by "Ollama Inc." (Toronto) with a DigiCert EV code-signing cert, RFC 3161 timestamped. Checked by reading the PE security directory.scripts/build_darwin.shcodesigns with the Developer ID (--options=runtime), then notarises withnotarytooland staples.install.shneeds sudo and sets up a systemd service, so it stays guide-only: a copyablecurl -fsSL https://ollama.com/install.sh | sh.child_process.require("electron").shell.openPath(path)(renderer, non-sandboxed, which Obsidian is;electronis already external inesbuild.config.mjs). It resolves""on success, otherwise an error string.requestUrlfor the download: it buffers the whole body (1.58 GB in memory) and reports no progress. Use a streaming Node client, as v1 does for the pull.What to change
src/transport/ollamarelease.ts. Pure overHttpClient(requestUrl, which follows redirects):installerAsset(os: "macos" | "windows" | "linux" | "other"): string | null→"Ollama.dmg"/"OllamaSetup.exe"/null/null.latestInstaller(http, asset): Promise<{ version, url, size, sha256 }>. It GETs the releases/latest API withAccept: application/vnd.github+jsonand finds the asset by exactname.digest(stripsha256:, lower-case, must be 64 hex chars). Ifdigestis missing, fall back to fetching the same release'ssha256sum.txtasset and parsing it.urlmust start withhttps://github.com/ollama/ollama/releases/download/. Anything else throws.browser_download_url, never…/latest/download/…, so a release landing mid-download cannot swap the file under a known checksum.TransportErrors with readable text. Cases: a non-200 (a 403/429 from GitHub means "GitHub's rate limit, try again later or download by hand"), the asset missing, or no checksum.src/transport/nodedownload.ts. Same pattern assrc/transport/nodestream.ts: nothing imports Node, and the caller injectsload.nodeDownload(load)returns(url, dest, expect: { size, sha256 }, onProgress({ received, total }), signal?) => Promise<void>.load("https")/load("http")(picked per URL, as nodestream does, so tests can use a local http server),load("fs")andload("crypto"). Type them with minimal local interfaces, as nodestream does.https:tohttp:.dest + ".part"withfs.createWriteStream, feeding each chunk tocrypto.createHash("sha256").write()returns false,pause()the response, thenresume()ondrain.totalcomes fromcontent-length, elseexpect.size.expect. On a match, rename.part→dest. On a mismatch, unlink.partand reject with a clear "checksum mismatch"..part, reject. No partial file may be left behind.src/ollamainstall.ts. The UI, in the style ofOllamaPullModal.OllamaInstallModal, step 1, confirm: "Download the official Ollama installer (<version>,<size>) from GitHub and open it? It is saved to<dir>. You finish the installation in the installer." Buttons: Download and open (CTA) and Cancel. Never download silently.ProgressBarComponentand status text such asDownloading the Ollama installer — 0.1 / 0.2 GB (40%), throttled like v1 (PROGRESS_INTERVAL_MS). Cancel aborts. Closing the modal while downloading also aborts, as v1 does.open(file). A non-empty result string is an error, which goes to the fallback. Then show "Finish installing Ollama in the installer that just opened", with the macOS hint "drag Ollama to Applications, then open it".detectOllama(host.http, OLLAMA_LOCAL)every 3 s for up to 10 min while the modal is open. When Ollama is running, close and resolve "installed".openPath):notify()the reason and return to the missing modal, where v1's Open ollama.com/download link stays available.<os.tmpdir()>/remarkable-ink-ollama/, created recursive. Remove stale*.partfiles there before a new download. Keep the finished installer, because the DMG may still be mounted.src/main.ts(plugin edge). AdddesktopInstaller()next todesktopNdjson()(line ~2414), with the same guard:Platform.isDesktopAppplustypeof window.require === "function", elsenull.{ os, dir, download: nodeDownload(load), open: (file) => electron.shell.openPath(file) }.oscomes from Obsidian'sPlatform.isMacOS/Platform.isWin/Platform.isLinux, notprocess.platform.dirusesload("os").tmpdir()andload("path").join.electron.shell?.openPathis not a function, return null (link fallback).setUpLocalOllama()(line ~1964).src/ollamasetup.ts.installer: DesktopInstaller | nulltoOllamaSetupHost.OllamaMissingModal:installer !== nullandinstallerAsset(os)is non-null, add a CTA "Download and install Ollama". It runslatestInstaller→OllamaInstallModal; on "installed", recurse intosetUpLocalOllama(host, refresh), so v1's model pull and test follow on their own;curl -fsSL https://ollama.com/install.sh | shin a<pre><code>, with a Copy command button (navigator.clipboard.writeText, thennotify("Copied")), plus one line: it asks for your password (sudo) and installs Ollama as a system service.OllamaPullModal,pullModelor the rest of v1's flow.README.md→## Privacy: only when you press Download and install Ollama, the plugin contactsapi.github.comand GitHub's release downloads for Ollama's official installer, saves it to your system's temp folder (outside the vault), and opens it.docs/ocr-endpoint-setup.md→ One-click setup (desktop): replace the "links to ollama.com/download" bullet with the download, verify, open and wait flow, plus the Linux command.CHANGELOG-INK.md→ Unreleased: one bullet.Constraints and decisions — please read, @daniel
Bundle guard unchanged; no
child_process.scripts/check-bundle.mjsmust not be edited.fs,crypto,os,path,https) are reached only lazily, on desktop, through the injectedload(window.require), exactly as v1'snodestream.tsdoes forhttp.require("fs")(or anywindow.require("fs"), which the guard regex would also match) appears in source or bundle. Say this explicitly in the MR when you hand it in, for @daniel's review.Plugin-review risk, flagged for @daniel's decision. Obsidian's developer policies say plugins must not "install or update themselves or their dependencies". This flow does not install anything itself:
The plugin is currently installed by hand (README → Getting started), so the directory policies are good practice rather than binding. A reviewer could still read the policy strictly. Separately, the submission rule "Node/Electron APIs →
isDesktopOnly: true" already sits in tension with v1's lazyhttp; this MR does not changemanifest.json.Decided against:
Ollama-darwin.zip: opening it extracts into the temp dir rather than/Applications.requestUrl: it buffers the whole file.install.sh: it needs sudo, and the guard rules outchild_process.…/latest/download/URLs: checksum race.Out of scope: !31 (
OLLAMA_ORIGINSdocs) and !32 (LM Studio detect, which also edits the not-running branch ofsetUpLocalOllama). Mergeorigin/mainbefore finishing and resolve overlaps. Do not touch #4 or #5.Validation contract
npx vitest run src/__tests__/ollamarelease.test.ts src/__tests__/nodedownload.test.tsFAILS on main (the modules do not exist).ollamarelease.test.ts, with a fakeHttpClientper URL:digestparsed;digest→sha256sum.txtfallback;browser_download_url→ throws;TransportError;installerAssetmapping.nodedownload.test.ts, with a localhttpserver and Node'screateRequireasload, likesrc/__tests__/nodestream.test.ts, writing intofs.mkdtempSync(os.tmpdir()):.part;.part;size.npm ci && npx vitest run src/__tests__/ollamarelease.test.ts src/__tests__/nodedownload.test.ts→ PASS. Then:npx vitest run→ whole suite PASS;npm run lint→ exit 0;npm run build→ exit 0, ending with check-bundle's "bundle clean" line;git diff --exit-code origin/main -- scripts/check-bundle.mjs manifest.json→ exit 0;grep -nE 'require\(\s*["'"'"'\](fs|path|stream|child_process)' main.js→ no output. Prove that grep can see a hit first, e.g. against a scratch file containingrequire("fs")`.openPathand the installers cannot run in CI. State plainly in the MR that the macOS/Windows end-to-end path is untested and needs a manual try on each OS.flake.nixin this repo; use plainnpm/npx.)🤖 Generated with Claude Code
✅ Agent run completed
6m46s · 33 turns · $2.49 · pushed
agent/ollama-installer-download· session saved — new comments resume this run⚠️ Verification gate not satisfied: awaiting intent review. Outcome parked — not marked done.
claude referenced this pull request2026-10-20 20:08:04 +02:00
claude referenced this pull request2026-10-20 20:08:04 +02:00
What changed
src/transport/ollamarelease.ts:installerAsset(os)andlatestInstaller(http, asset).releases/latestand takes the SHA-256 fromdigest, falling back tosha256sum.txt.https://github.com/ollama/ollama/releases/download/(…/latest/download/, other hosts and http are refused).TransportErrors; a 403/429 is explained as GitHub's rate limit, with a pointer to download by hand.src/transport/nodedownload.ts:nodeDownload(load)streams to<dest>.part.drain).dest. Any mismatch, error or abort closes the stream and unlinks the.part, so no partial file is left.nodePrepareDircreates<tmpdir>/remarkable-ink-ollama/and clears stale*.partfiles.src/ollamainstall.ts,ollamasetup.tsandmain.ts:shell.openPath→ "Finish installing Ollama…" (with the macOS drag-to-Applications hint) → checks for Ollama every 3 s for 10 min, plus Check again and Close buttons → carries on into v1's model pull and Test connection.curl -fsSL https://ollama.com/install.sh | shwith Copy command and the sudo/system-service line.main.ts:desktopInstaller()sits next todesktopNdjson()with the same guard. It returns null when there is noelectron.shell.openPath, and the dialogue then keeps only the link.OllamaPullModalandpullModelare unchanged.docs/ocr-endpoint-setup.md→ One-click setup; a CHANGELOG-INK bullet.origin/main(including !31) is merged in with no conflicts.@daniel, please review:
require("fs"), and nochild_process. Node modules (fs,crypto,os,path,http/https) andelectronare reached only lazily, on desktop, through the injectedload(window.require), asnodestream.tsdoes.require("fs")orwindow.require("fs")appears in source or bundle.load("fs"),load("path")etc., which the guard regex does not match, andcheck-bundle.mjsis unchanged.manifest.jsonis unchanged (isDesktopOnly: false, the same tension as v1's lazyhttp).shell.openPathand the actual installers cannot run in CI or this sandbox. The download, folder, open and wait steps are covered only against a local server and fakes. Please try "Download and install Ollama" by hand once on macOS (DMG mount → drag to Applications) and once on Windows (1.58 GBOllamaSetup.exe).Verify
npx vitest run src/__tests__/ollamarelease.test.ts src/__tests__/nodedownload.test.ts: 24 pass. Both files failed before the modules existed.src/__tests__/ollamainstall.test.ts(8 tests) drives the dialogues from "Ollama isn't running" back into v1's flow, including the open-fails, checksum-fails, rate-limit and cancel fallbacks. Mutating theopenPatherror check makes it fail, so it does catch regressions.npx vitest run: 794/794 pass.npm run lint: exit 0.npm run build: exit 0, ending with "bundle clean".git diff --exit-code origin/main -- scripts/check-bundle.mjs manifest.json: exit 0.require\((fs|path|stream|child_process)grep onmain.jsfinds nothing. Run against a scratch file containingrequire("fs"), it does find the hit.Follow-ups
setUpLocalOllama, so expect a small conflict there when one of the two lands after the other.✅ Agent run completed
1m9s · 15 turns · $0.50
Acceptance-intent assessment
#28 is a "decide and research, then split into MR hand-offs" issue. The research is answered on #28 (note 45129) and the work is split three ways: item 2 → !31 (already on
origin/mainas665992f), item 3 → !32, and item 1 → this MR, which that note names as the one that closes #28. This diff delivers all of item 1: it downloads the official installer, verifies its checksum, opens it, waits for Ollama, and falls back to v1's link on failure. It also stays inside the issue's constraints (desktop-only, nochild_process, guard unchanged, v1's pull flow untouched).Criteria
Ollama.dmg, WindowsOllamaSetup.exe, opened withshell.openPath).installerAssetmaps macos →Ollama.dmg, windows →OllamaSetup.exe, linux/other → null.desktopInstaller()insrc/main.tsopens the file withelectron.shell.openPath.OllamaInstallModaltreats a non-empty result string as a failure.OllamaMissingModalshowscurl -fsSL https://ollama.com/install.sh | shin<pre><code>, with a Copy command button and the sudo/system-service line. Linux gets no download.https://github.com/ollama/ollama/releases/download/(version-pinned, never/latest/download/), and a test checks that other URLs are refused.<os.tmpdir()>/remarkable-ink-ollama/, outside the vault.nodePrepareDircreates it recursively, clears stale*.partfiles and keeps finished installers.nodedownload.ts, same injected-loadpattern as v1'snodestream.ts) drives aProgressBarComponentandDownloading the Ollama installer — x / y GB (n%)text, throttled atPROGRESS_INTERVAL_MS. Cancel aborts, and so does closing the modal.digest, falling back tosha256sum.txt, and must be 64 hex chars..part→ dest..part. Tests cover the checksum mismatch, size mismatch, abort, redirect limit and https→http refusal.openPatherrors allnotify()the reason and return "failed".setUpLocalOllamathen goes back toOllamaMissingModal, where Open ollama.com/download stays as a secondary button.OLLAMA_ORIGINS. Answered on #28 (not needed) and delivered by !31, already merged intomain. Correctly out of scope here.Platform.isDesktopApppluswindow.require, and returns null otherwise.load. A grep ofsrcfindsrequire("fs")only inside comments.git diff --exit-code origin/main -- scripts/check-bundle.mjs manifest.jsonexits 0.child_process.OllamaPullModal,pullModel) is untouched. Theollamasetup.tshunks only touch the not-running branch andOllamaMissingModal. #4 and #5 are untouched.I re-ran
ollamarelease,nodedownloadandollamainstalltests: 32 passed, 0 failed.Notes (not blocking):
openPathinstaller path is untested in CI, and the MR says so. It needs the manual try on each OS before release.Verdict
Approved
@claude resolve merge conflicts
🤖 Agent is working on this — turn 40
Last activity: assistant message — updated 22:46:10 UTC
Last message:
Since my last update: I merged
origin/maininto the branch and resolved the conflicts (7dc3cfc). Most of the overlap was with !32 (LM Studio):src/ollamasetup.ts: when Ollama isn't running,setUpLocalOllamanow checks for LM Studio first, as on main. If LM Studio isn't running, or you press Use Ollama instead, you get the "Ollama isn't running" dialogue, which still has Download and install Ollama (macOS/Windows), the Linux command and the link. A successful install starts the flow again from the top, finds Ollama running and carries on into the model pull.helpers/obsidian.ts): it now uses main'sModal.opened,NoticeandDropdownComponent, plus this branch'sProgressBarComponentand the rule that a modal's close only runs once.ollamainstall.test.tsnow usesModal.opened. Two LM Studio tests failed after the merge because their fake host had noinstallerfield; I addedinstaller: nulland they pass.CHANGELOG-INK.mdanddocs/ocr-endpoint-setup.md: both sides' entries are kept.Checked locally:
npx vitest run: 838 pass, 0 fail.npm run lint: exit 0.npm run build: exit 0, ends with "bundle clean".check-bundle.mjsandmanifest.jsonare unchanged from main.require("fs"|"path"|…)grep finds nothing inmain.js(the same grep does find a plantedrequire("fs")in a scratch file).No pipeline has run on the new head yet. Installing on real macOS and Windows still needs a manual try.