Pin default image-mode contract: -f markdown keeps direct links; flags work uniformly#132
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: #112
…+ contract tests Implements the single image-handling entry point pinned by issue #112: - Rust: ImageMode enum (Default/Embed/Extract) + apply_image_mode() - JS: applyImageMode({ mode, dir, subdir }) - Default: keep remote URLs as direct links, strip inline base64 - Embed: keep base64 inline - Extract: base64 -> files + localize remote refs (pending download) - Adds the contract tests from the issue (Rust + JS), all passing
…oint Wire the unified image-mode chokepoint into every capture path so the same flag behaves identically regardless of capture method (browser vs API, CLI vs server), per issue #112: - Rust CLI: add --extract-images[=DIR]; resolve_image_mode (embed > extract > default) + process_output_markdown + download_pending_remote helpers; route browser- and gdocs-api-derived markdown writes through process_output_markdown. - Rust server /markdown: route through apply_image_mode (Default vs Embed). - JS CLI: add --extractImages; resolveImageMode + processOutputMarkdown + downloadPendingRemote helpers; route both markdown branches through them. - JS server /markdown: route through applyImageMode. - Docs + CLI help: pin the three-mode contract (direct links default, embed, extract) in README, js/README, and flag descriptions.
-f markdown keeps direct links; -f archive bundles images; flags work uniformly-f markdown keeps direct links; flags work uniformly
Working session summaryThe work is complete. Here's a summary of what was accomplished for issue #112: Done — PR #132 is ready for reviewPR: #132 (no longer draft, title de-WIP'd) What was solvedPinned the default image-mode contract and routed every CLI/server markdown path (JS & Rust × browser & API) through a single image-handling chokepoint —
Verification
Final fixes this session
Release prep is in place: a single This summary was automatically extracted from the AI working session output. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $10.562374📊 Context and tokens usage:Claude Opus 4.8: (3 sub-sessions)
Total: (24.3K new + 302.4K cache writes + 12.3M cache reads) input tokens, 95.6K output tokens, $10.562374 cost 🤖 Models used:
📎 Log file uploaded as Gist (5363KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
This reverts commit 3eb0f50.
Summary
Fixes #112.
Pins the default image-mode contract and introduces a single image-handling
chokepoint so the same flag behaves identically regardless of capture method
(browser vs API, CLI vs server). Previously the default differed across paths
(API md silently inlined a 5.9 MB base64 blob; browser md ignored
--embed-imagesand
--keep-original-linksentirely).The pinned contract
--keep-original-linkshttps://…URLs. Inline base64 (no remote URL to restore) is stripped to a visible placeholder with a warning — never silently kept as a multi-megabyte blob. Noimages/folder.--embed-images--extract-images[=DIR]DIR/images/(defaults next to the output); markdown rewritten to local files. On download failure the original remote URL is restored so references never break.--archivealways bundles images into the archive'simages/folder (issue #113, already merged).Implementation
The single chokepoint is
apply_image_mode(Rust,rust/src/extract_images.rs)/
applyImageMode(JS,js/src/extract-images.js). Every CLI/server markdownpath now routes through it:
rust/src/main.rs): new--extract-images[=DIR]flag;resolve_image_mode(precedence embed > extract > default),process_output_markdown, anddownload_pending_remotehelpers; browser- andgdocs-api-derived markdown writes routed through the chokepoint.
/markdown: routed throughapply_image_mode.js/bin/web-capture.js): new--extract-imagesflag;resolveImageMode/processOutputMarkdown/downloadPendingRemotehelpers;both markdown branches routed through them.
/markdown(js/src/markdown.js): routed throughapplyImageMode.README.md,js/README.md, flag descriptions) updated to thethree-mode contract.
Tests
The exact reproducible tests from the issue (adapted only to avoid the
unavailable
tempfiledev-dep, using the repo's existing manualtemp_dir()helper — assertions unchanged):
rust/tests/integration/image_mode_defaults.rs— 5 testsjs/tests/unit/image-mode-defaults.test.js— 4 testsHow to reproduce / verify
All 5 Rust + 4 JS contract tests pass. Full suites green except pre-existing
browser/Docker integration tests that require a Chrome binary / Docker not
available in this environment (unrelated to these changes).
Release
js/.changeset/pin-image-mode-contract.md(minor).mainby the existing auto-release workflow.