2.2 KiB
2.2 KiB
PDF Export Tool Implementation Plan
For agentic workers: Execute inline using executing-plans. No delegation required.
Goal: Reuse a logged-in Chrome order tab to export a named PDF without a print dialog.
Architecture: MV3 extension captures a static visible form and permitted assets, then POSTs it to a paired loopback Node service. An isolated offline Chromium process renders the PDF, with exclusive filename reservation preventing overwrite.
Tech Stack: Node.js 22+, playwright-core, Chrome MV3, node:test.
Spec: docs/tool-design.md
Global Constraints
- No remote debugging port or account credential persistence.
- Only user-triggered captures of https://bpm.skyworthdigital.com/.
- Local helper listens on 127.0.0.1:18765; requests need extension Origin and random pairing token.
- Four naming fields required; existing files preserved.
- Browser renderer has scripts and network disabled.
Task 1: Export core
- Write tests for missing fields, Windows-safe names, collision preservation and real PDF bytes.
- Run
node --test tests/core.test.cjsand confirm missing functionality fails. - Implement
src/exporter.cjs:buildFilename(metadata),renderSnapshot(snapshot, options)and offline browser lifecycle. - Run tests using installed Chrome and local fixture markup.
Task 2: Browser capture and bridge
- Write DOM fixture tests for
captureOrder()bindings, live values and hidden secrets removal; write HTTP tests for origin, token and size checks. - Confirm tests fail before implementation.
- Implement extension capture, asset bundling and popup; implement
src/server.cjswith authenticated POST/exportand GET/health. - Run tests; malformed submissions must never start a renderer or write a file.
Task 3: Packaging and acceptance
- Add direct Node Windows command launcher, configuration example, dependency setup and Chinese README.
- Run full tests and real captured-page regression, render the resulting PDF and inspect pages.
- Check extension manifest and scripts; document that live extension loading requires user action and is not yet verified.
- Deliver startup and extension-loading paths, output naming and exact verification limits.