zcode-app-cli 3.8.1-15 → 3.9.2-16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/bin/zcode.js +109 -47
  2. package/config.example.json +14 -0
  3. package/package.json +2 -2
  4. package/vendor/extraction.json +131 -5
  5. package/vendor/node_modules/@zcode/tui/dist/index.js +52 -4
  6. package/vendor/packages/browser-use-plugin/.zcode-plugin/plugin.json +1 -1
  7. package/vendor/packages/browser-use-plugin/dist/mcp/server.js +12862 -10414
  8. package/vendor/packages/browser-use-plugin/docs/api.json +5 -0
  9. package/vendor/packages/browser-use-plugin/docs/overview.md +3 -0
  10. package/vendor/packages/browser-use-plugin/package.json +1 -1
  11. package/vendor/packages/browser-use-plugin/scripts/browser-client.mjs +63 -7
  12. package/vendor/packages/browser-use-plugin/skills/control-browser/SKILL.md +4 -1
  13. package/vendor/packages/document-skills-plugin/.mcp.json +13 -0
  14. package/vendor/packages/document-skills-plugin/.zcode-plugin/plugin.json +19 -6
  15. package/vendor/packages/document-skills-plugin/package.json +3 -3
  16. package/vendor/packages/document-skills-plugin/skills/docx/SKILL.md +6 -2
  17. package/vendor/packages/document-skills-plugin/skills/docx/env_setup/env_check.sh +0 -0
  18. package/vendor/packages/document-skills-plugin/skills/docx/env_setup/setup_mac_linux.sh +0 -0
  19. package/vendor/packages/document-skills-plugin/skills/docx/setup.sh +0 -0
  20. package/vendor/packages/document-skills-plugin/skills/pdf/SKILL.md +39 -20
  21. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/academic.md +39 -47
  22. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/creative.md +11 -3
  23. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/poster.md +3 -0
  24. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process.md +3 -0
  25. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/report.md +41 -62
  26. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/env_check.sh +23 -15
  27. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup.md +37 -19
  28. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup_mac_linux.sh +0 -0
  29. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup_windows.ps1 +17 -19
  30. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/cover_render.py +487 -0
  31. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2poster.js +43 -11
  32. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf.py +145 -50
  33. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/setup.sh +23 -21
  34. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover-backgrounds.md +1 -1
  35. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover.md +139 -1347
  36. package/vendor/packages/document-skills-plugin/skills/pptx/LICENSE.txt +13 -0
  37. package/vendor/packages/document-skills-plugin/skills/pptx/SKILL.md +149 -180
  38. package/vendor/packages/document-skills-plugin/skills/xlsx/SKILL.md +6 -2
  39. package/vendor/packages/document-skills-plugin/skills/xlsx/env_setup/env_check.sh +0 -0
  40. package/vendor/packages/document-skills-plugin/skills/xlsx/env_setup/setup_mac_linux.sh +0 -0
  41. package/vendor/packages/document-skills-plugin/skills/xlsx/setup.sh +0 -0
  42. package/vendor/packages/zcode-cua-plugin/.zcode-plugin/plugin.json +19 -0
  43. package/vendor/packages/zcode-cua-plugin/dist/mcp/server.js +68048 -0
  44. package/vendor/packages/zcode-cua-plugin/node_modules/@img/colour/color.cjs +1596 -0
  45. package/vendor/packages/zcode-cua-plugin/node_modules/@img/colour/index.cjs +1 -0
  46. package/vendor/packages/zcode-cua-plugin/node_modules/@img/colour/package.json +58 -0
  47. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/lib/glib-2.0/include/glibconfig.h +221 -0
  48. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/lib/index.js +1 -0
  49. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.8.17.3 +0 -0
  50. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/package.json +42 -0
  51. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/versions.json +30 -0
  52. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-linux-x64/LICENSE +191 -0
  53. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64.node +0 -0
  54. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-linux-x64/package.json +46 -0
  55. package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/LICENSE +201 -0
  56. package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/lib/detect-libc.js +313 -0
  57. package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/lib/elf.js +39 -0
  58. package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/lib/filesystem.js +51 -0
  59. package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/lib/process.js +24 -0
  60. package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/package.json +44 -0
  61. package/vendor/packages/zcode-cua-plugin/node_modules/semver/LICENSE +15 -0
  62. package/vendor/packages/zcode-cua-plugin/node_modules/semver/bin/semver.js +191 -0
  63. package/vendor/packages/zcode-cua-plugin/node_modules/semver/classes/comparator.js +143 -0
  64. package/vendor/packages/zcode-cua-plugin/node_modules/semver/classes/index.js +7 -0
  65. package/vendor/packages/zcode-cua-plugin/node_modules/semver/classes/range.js +557 -0
  66. package/vendor/packages/zcode-cua-plugin/node_modules/semver/classes/semver.js +333 -0
  67. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/clean.js +8 -0
  68. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/cmp.js +54 -0
  69. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/coerce.js +62 -0
  70. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/compare-build.js +9 -0
  71. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/compare-loose.js +5 -0
  72. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/compare.js +7 -0
  73. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/diff.js +60 -0
  74. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/eq.js +5 -0
  75. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/gt.js +5 -0
  76. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/gte.js +5 -0
  77. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/inc.js +21 -0
  78. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/lt.js +5 -0
  79. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/lte.js +5 -0
  80. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/major.js +5 -0
  81. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/minor.js +5 -0
  82. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/neq.js +5 -0
  83. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/parse.js +18 -0
  84. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/patch.js +5 -0
  85. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/prerelease.js +8 -0
  86. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/rcompare.js +5 -0
  87. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/rsort.js +5 -0
  88. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/satisfies.js +12 -0
  89. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/sort.js +5 -0
  90. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/valid.js +8 -0
  91. package/vendor/packages/zcode-cua-plugin/node_modules/semver/index.js +91 -0
  92. package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/constants.js +37 -0
  93. package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/debug.js +11 -0
  94. package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/identifiers.js +29 -0
  95. package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/lrucache.js +42 -0
  96. package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/parse-options.js +17 -0
  97. package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/re.js +223 -0
  98. package/vendor/packages/zcode-cua-plugin/node_modules/semver/package.json +78 -0
  99. package/vendor/packages/zcode-cua-plugin/node_modules/semver/preload.js +4 -0
  100. package/vendor/packages/zcode-cua-plugin/node_modules/semver/range.bnf +16 -0
  101. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/gtr.js +6 -0
  102. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/intersects.js +9 -0
  103. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/ltr.js +6 -0
  104. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/max-satisfying.js +27 -0
  105. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/min-satisfying.js +26 -0
  106. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/min-version.js +63 -0
  107. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/outside.js +82 -0
  108. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/simplify.js +49 -0
  109. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/subset.js +249 -0
  110. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/to-comparators.js +10 -0
  111. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/valid.js +13 -0
  112. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/LICENSE +191 -0
  113. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/install/build.js +38 -0
  114. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/install/check.js +14 -0
  115. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/channel.js +177 -0
  116. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/colour.js +195 -0
  117. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/composite.js +212 -0
  118. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/constructor.js +499 -0
  119. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/index.js +16 -0
  120. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/input.js +809 -0
  121. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/is.js +143 -0
  122. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/libvips.js +207 -0
  123. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/operation.js +1016 -0
  124. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/output.js +1666 -0
  125. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/resize.js +595 -0
  126. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/sharp.js +121 -0
  127. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/utility.js +291 -0
  128. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/package.json +202 -0
  129. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/binding.gyp +298 -0
  130. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/common.cc +1130 -0
  131. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/common.h +402 -0
  132. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/metadata.cc +346 -0
  133. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/metadata.h +90 -0
  134. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/operations.cc +499 -0
  135. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/operations.h +137 -0
  136. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/pipeline.cc +1814 -0
  137. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/pipeline.h +408 -0
  138. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/sharp.cc +43 -0
  139. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/stats.cc +186 -0
  140. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/stats.h +62 -0
  141. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/utilities.cc +288 -0
  142. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/utilities.h +22 -0
  143. package/vendor/packages/zcode-cua-plugin/package.json +31 -0
  144. package/vendor/packages/zcode-cua-plugin/scripts/build-mcp.mjs +58 -0
  145. package/vendor/packages/zcode-cua-plugin/scripts/bump-zcode-cua-producer.mjs +291 -0
  146. package/vendor/packages/zcode-cua-plugin/scripts/check-cua-baseline.mjs +155 -0
  147. package/vendor/packages/zcode-cua-plugin/scripts/check-version-coherence.mjs +478 -0
  148. package/vendor/packages/zcode-cua-plugin/scripts/sync-cache.mjs +100 -0
  149. package/vendor/packages/zcode-cua-plugin/scripts/sync-skill-from-zcode-cua.mjs +115 -0
  150. package/vendor/packages/zcode-cua-plugin/skills/zcode-computer-use/SKILL.md +172 -0
  151. package/vendor/zcode.cjs +748 -740
  152. package/zcode-runtime.lock.json +3 -3
  153. package/vendor/packages/document-skills-plugin/skills/pptx/assets/font_list.txt +0 -80
  154. package/vendor/packages/document-skills-plugin/skills/pptx/scripts/general_judge.py +0 -529
@@ -1,5 +1,8 @@
1
1
  # Poster Scene Rules — Creative Pipeline (Poster-Specific Constraints)
2
2
 
3
+ > 🟡 **Playwright/Chromium preflight applies here too.** Posters render via Playwright/Chromium (optional deps). Before rendering, probe availability and — if missing — use **AskUserQuestion** to warn about the long install/download and get confirmation before installing. See `briefs/creative.md` top for the full preflight.
4
+
5
+
3
6
  > When poster / 海报 / 传单 / flyer / 宣传页 keywords are detected, load these rules on top of `creative.md`.
4
7
  > These rules take priority over `creative.md` generic rules; in case of conflict, this file prevails.
5
8
  >
@@ -2,6 +2,9 @@
2
2
 
3
3
  Work with existing PDFs: extract, merge, split, fill forms, convert formats, or **reformat** with a new design. Usually a Light triage path — except reformat, which escalates to Standard.
4
4
 
5
+ > 🟡 **Optional-engine preflight.** Some paths here use optional engines: **Playwright/Chromium** (HTML→PDF `convert.html`, xlsx/pptx→HTML fallback) and **LibreOffice/soffice** (Office→PDF). If a needed engine is missing, do NOT auto-install — use the **AskUserQuestion** tool to warn about the install/download time and get confirmation first. See `briefs/creative.md` top for the Playwright preflight pattern.
6
+
7
+
5
8
  ---
6
9
 
7
10
  ## Decision Tree
@@ -21,7 +21,7 @@ Structured documents via ReportLab: reports, proposals, contracts, white papers,
21
21
  1. BRIEF → Confirm document type, audience, page count, outline
22
22
  2. DESIGN → Run `pdf.py palette.generate --title "..."` → copy-paste output into script
23
23
  3. EDIT → Content transformation (extract data, define typographic roles)
24
- 4. COVER → Read typesetting/cover.md → render HTML cover via Playwright (default ON for reports ≥ 3 pages; skip only for resumes/letters/memos/forms)
24
+ 4. COVER → Read typesetting/cover.md → render ReportLab cover via scripts/cover_render.py (default ON for reports ≥ 3 pages; skip only for resumes/letters/memos/forms)
25
25
  5. BUILD → Write ReportLab code (fonts → styles → content → tables → charts)
26
26
  6. PREFLIGHT → code.sanitize → execute → meta.brand → font.check → toc.check → pages.clean → pdf_qa.py
27
27
  7. DELIVER → Merge cover + body → final PDF
@@ -383,22 +383,16 @@ ReportLab pushes the **entire block** to the next page, leaving the current page
383
383
  * Between H1 sections: `Spacer(1, 24)` (~2 lines)
384
384
  * NEVER use `Spacer(1, X)` where X > 24, except for H1 major breaks or cover page elements
385
385
 
386
- ### Cover Page: HTML/Playwright Unified Cover System
386
+ ### Cover Page: ReportLab Cover Engine
387
387
 
388
- **⚠️ Report route covers are ALWAYS generated via HTML/Playwright**, using the same 7-template system defined in `typesetting/cover.md`. This ensures visual consistency across all routes (Report, Creative, Academic) and avoids the limitations of ReportLab for complex cover layouts.
388
+ **⚠️ Report route covers are generated with ReportLab** via `scripts/cover_render.py`, using the template system defined in `typesetting/cover.md` (templates **01–05** for the Report route). Pure Python — **no HTML/Playwright/Chromium required.**
389
389
 
390
390
  **Pipeline (Report route):**
391
- 1. Generate **body PDF** via ReportLab (start with TOC or content - **no cover in story[]**)
392
- 2. Generate **cover HTML** following `typesetting/cover.md` 7-template system
393
- 3. **Run `poster_validate.py check-html` on cover HTML** — fix any ERRORs before rendering (overflow:hidden, font fallback, etc.)
394
- 4. **Run `cover_validate.js` on cover HTML** — detects text-vs-decorative-line overlaps. Non-zero exit = must fix before proceeding.
395
- ```bash
396
- node "$PDF_SKILL_DIR/scripts/cover_validate.js" cover.html
397
- ```
398
- 5. Render cover HTML → single-page PDF via Playwright (`html2poster.js`) — **NOT `html2pdf-next.js`** (which converts absolute→static and destroys cover layout)
399
- 6. **Merge: insert cover as page 0** of body PDF using pypdf → output single final PDF
400
-
401
- > **Why not ReportLab covers?** ReportLab is excellent for structured content (tables, paragraphs, flowables) but painful for visual design (geometric accents, precise absolute positioning, web fonts). HTML/CSS handles these natively. One cover system, one visual standard, zero inconsistency.
391
+ 1. Generate **body PDF** via ReportLab (start with TOC or content — **no cover in story[]**).
392
+ 2. Generate the **cover PDF** with `cover_render.py` (pick a template 01–05 per `typesetting/cover.md` Part 2; pass content + palette).
393
+ 3. **Merge: insert cover as page 1** of the body PDF using pypdf → single final PDF.
394
+
395
+ > **Why ReportLab covers now?** The cover engine reproduces the previous HTML designs in pure ReportLab, so the Report route no longer depends on Playwright/Chromium. Fonts are auto-detected from the host machine and chosen by cover style (see `cover.md` Part 3). One cover engine, one visual standard.
402
396
 
403
397
  **⚠️ Cover page is DEFAULT ON for all Report-route documents ≥ 3 pages.**
404
398
 
@@ -437,33 +431,31 @@ doc.build(story)
437
431
  # Output: body.pdf (no cover)
438
432
  ```
439
433
 
440
- #### Step 2: Generate Cover PDF via html2poster.js
434
+ #### Step 2: Generate Cover PDF via cover_render.py
441
435
 
442
436
  ```bash
443
- # ALWAYS use html2poster.js for cover rendering (NOT html2pdf-next.js)
444
- # Cover pages use position:absolute layout — html2pdf-next.js pre-render hooks
445
- # convert absolute→static and destroy the layout. html2poster.js preserves it.
446
- node "$PDF_SKILL_DIR/scripts/html2poster.js" cover.html --output cover.pdf --width 794px
437
+ # Pick a template 01-05 per typesetting/cover.md Part 2. Content via JSON.
438
+ python3 "$PDF_SKILL_DIR/scripts/cover_render.py" 03 --out cover.pdf --content cover_content.json
447
439
  ```
448
440
 
449
441
  Or from Python:
450
442
  ```python
451
- import subprocess, os
452
-
453
- def render_cover(html_path, pdf_path):
454
- """Render HTML cover to PDF via html2poster.js.
455
-
456
- ⚠️ ALWAYS use html2poster.js for covers (NOT html2pdf-next.js).
457
- Cover HTML uses position:absolute for layout. html2pdf-next.js pre-render
458
- hooks convert absolute→static to prevent multi-page overlap, which
459
- destroys cover layouts. html2poster.js preserves absolute positioning.
460
- """
461
- scripts_dir = os.path.expanduser('~/.openclaw/workspace/skills/pdf/scripts')
462
- subprocess.run([
463
- 'node', os.path.join(scripts_dir, 'html2poster.js'),
464
- html_path, '--output', pdf_path,
465
- '--width', '794px',
466
- ], check=True)
443
+ import sys, os
444
+ sys.path.insert(0, os.path.join(PDF_SKILL_DIR, "scripts"))
445
+ from cover_render import render_cover, detect_fonts
446
+
447
+ fonts = detect_fonts() # host-detected, style-driven; raises if no embeddable CJK font
448
+ content = {
449
+ "kicker": "2025 年度可持续发展报告 · ANNUAL ESG REPORT",
450
+ "hero": "青松环境科技", # entity/company name = Hero
451
+ "summary": "本报告系统披露……", # 2-4 lines; auto-fill if omitted
452
+ "meta": "发布单位:青松环境科技集团 · 2026 年 3 月",
453
+ "footer": "QINGSONG GREENTECH · DOC 2026-ESG-001",
454
+ "year": "2026", "word": "REPORT",
455
+ }
456
+ # palette: map pdf.py palette.cascade --format json into these keys
457
+ palette = {"primary": "#1e3a5f", "text": "#1a1a2e", "muted": "#6b7280", "bg": "#ffffff"}
458
+ render_cover("03", content, "cover.pdf", palette=palette, fonts=fonts)
467
459
  ```
468
460
 
469
461
  **Insertion script (single output PDF):**
@@ -497,35 +489,28 @@ def insert_cover(cover_pdf, body_pdf, output_pdf):
497
489
  writer.write(f)
498
490
  ```
499
491
 
500
- > **⚠️ Size pitfall:** Playwright `page.pdf(width='794px', height='1123px')` output PDF dimensions may differ from A4 (595.28×841.89pt) by 1-2pt. **Do not use PIL Image.save('x.pdf')** for PNG→PDF conversion — DPI mapping causes severe size errors. You must call `normalize_page_to_a4()` to unify dimensions before insertion.
501
-
502
- **Cover HTML template reference**: See `typesetting/cover.md` for the complete 7-Layout System with variants, typography scale, and bounding box rules.
492
+ > **⚠️ Size note:** `cover_render.py` outputs an exact A4 page (595.28×841.89pt), so it merges cleanly with the ReportLab body. `normalize_page_to_a4()` remains a harmless safety check. **Do not use PIL Image.save('x.pdf')** for any PDF conversion — DPI mapping causes severe size errors.
503
493
 
504
- **→ Full cover spec: `typesetting/cover.md`** - read it before designing any cover.
494
+ **→ Full cover spec: `typesetting/cover.md`** — read it before designing any cover (templates 01–09, selection matrix, font strategy).
505
495
 
506
- **Cover design rules (summary - see cover.md for details):**
507
- - Page size: `width: 794px; height: 1123px` (A4 at 96dpi)
508
- - `body { margin: 0; padding: 0; overflow: hidden; }` - REQUIRED to avoid white borders
509
- - Load Google Fonts via `<link href="..." rel="stylesheet">` in `<head>` (NOT `@import url(...)` in CSS — `@import` must be first rule or is silently ignored) — Playwright fetches them at render time
510
- - **Background must be white or very light** (`#fff` / `#fafafa` / `#f5f8fb`), no dark solid backgrounds or gradient backgrounds
511
- - Primary color used only for text, lines, geometric accents - never as large-area background
512
- - Sophistication = whitespace + typography + restrained geometric accents
496
+ **Cover design rules (summary — see cover.md for details):**
497
+ - Rendered by `scripts/cover_render.py` on an A4 canvas (bottom-left origin).
498
+ - Fonts are **auto-detected from the host** and chosen by cover style (sans for 01–05, serif for 06–09). CFF fonts (PingFang/Hiragino/Noto CJK) are skipped; missing heavy weights use faux-bold. See `cover.md` Part 3.
499
+ - **Background must be white or very light** for report templates 01–05; primary color only for text/lines/accents, never a large-area fill (academic 06–08 are dark by design).
500
+ - Sophistication = whitespace + typography + restrained geometric accents.
513
501
 
514
- **Cover Constitution (7-Layout System):**
515
- - **Pick a layout (1-7)** from `typesetting/cover.md` that matches the document tone. No global default - every selection must be a deliberate design decision. Layout 7 for government/bidding/proposal documents.
516
- - **Maximum 4 components** on any cover. Typical recipe: Title + subtitle + 1 geometric accent + metadata.
517
- - **Typography Scale**: Title ≈ 45pt, Subtitle ≈ 25pt, Meta ≥ 18pt (never below 14pt). Tiny text = FAIL.
518
- - **Background layer (optional)**: See `typesetting/cover-backgrounds.md` for 3 recipes (A=极简弧线, B=工程十字轴+立柱, C=锐角切割+出血文字). Background renders BELOW all foreground content at 2-5% opacity.
519
- - **Mandatory `<br>` chunking**: Title MUST break every 2-4 words (CJK) or 3-5 words (English). Single-line title = FAIL.
520
- - **Bounding Box spatial dispersion**: Group elements into 2-3 bounding boxes at opposite regions (e.g., top-left + bottom-right). Never cluster everything into middle 40%.
521
- - **Safe Zone**: 12% top/bottom, 14% left/right padding on cover pages.
522
- - **No body text on cover**: Cover = title + subtitle + date + optional geometric decoration. All content goes to page 2+.
502
+ **Cover Constitution (templates 01–09):**
503
+ - **Pick a template (01–05 for Report)** from `typesetting/cover.md` Part 2 matching the document intent. No global default — every selection is a deliberate design decision. Template **05** (Solid Sidebar) for government/bidding/proposal.
504
+ - **Typography Scale**: Hero ≈ 45–66pt, Meta ≥ 16pt (never below 14pt). Tiny text = FAIL.
505
+ - **Data binding**: Hero = entity/company name (largest, heaviest); Kicker = report type/subtitle (small). Never reverse.
506
+ - **Mandatory Summary** block (2–4 lines) — the engine auto-fills if omitted.
507
+ - **Content only** — cover = kicker + hero + summary + meta (+ optional footer). All body content goes to page 2+.
523
508
 
524
509
  ### ⚠️ Cover Page Isolation Rule (MANDATORY)
525
510
 
526
511
  **The cover page must ALWAYS be on its own page.** Cover content and subsequent content (TOC, body text, etc.) must NEVER appear on the same page. This is a hard rule.
527
512
 
528
- - **Report route (HTML/Playwright cover)**: The cover is a separate rendered page inserted as page 0 via pypdf - isolation is inherent in the merge pipeline
513
+ - **Report route (ReportLab cover)**: The cover is a separate `cover_render.py` PDF inserted as page 1 via pypdf — isolation is inherent in the merge pipeline
529
514
  - **Creative route**: Cover is part of the same HTML document but on its own `<section>` with page-break - isolation is handled by CSS
530
515
 
531
516
  If a generated PDF shows cover + TOC on the same page, it is a **critical bug** - regenerate immediately.
@@ -1627,12 +1612,6 @@ callout.setStyle(TableStyle([
1627
1612
  story.append(KeepTogether(callout))
1628
1613
  ```
1629
1614
 
1630
- ### Cover Pages (HTML/Playwright)
1631
- When the cover routes through Playwright:
1632
- - Use `Delta_Widget` components for KPIs and metrics.
1633
- - Use `Process_List` components for workflows and timelines.
1634
- - Use `Sidenote_Block` components (in `tufte_report` archetype) for citations and supplementary data.
1635
- - For data-heavy pages, add `data_points` arrays to any component - the engine renders them as content-aware background curves.
1636
1615
 
1637
1616
  ---
1638
1617
 
@@ -1,12 +1,16 @@
1
1
  #!/usr/bin/env bash
2
2
  # Lightweight environment check for PDF skill.
3
- # Exit 0 = all OK, exit 1 = missing dependencies.
3
+ # Exit 0 = all CORE deps OK, exit 1 = missing CORE dependency.
4
+ # Playwright/Chromium (Creative/HTML pipeline) and Tectonic (Academic/LaTeX) are
5
+ # OPTIONAL — reported as INFO, never cause a non-zero exit. Install them on demand
6
+ # (with the user's confirmation) only when a route actually needs them.
4
7
  # Also resolves and exports PDF_SKILL_DIR and FONT_DIR.
5
8
  # Usage: source env_check.sh (preferred, exports vars to caller)
6
9
  # or: bash env_check.sh [--quiet]
7
10
  QUIET=false; [ "${1:-}" = "--quiet" ] && QUIET=true
8
11
  FAIL=0
9
- check() { local desc="$1"; shift; if ! "$@" &>/dev/null; then $QUIET || echo "MISSING: $desc"; FAIL=1; fi; }
12
+ check() { local desc="$1"; shift; if ! "$@" &>/dev/null; then $QUIET || echo "MISSING (core): $desc"; FAIL=1; fi; }
13
+ optional() { local desc="$1"; shift; if "$@" &>/dev/null; then $QUIET || echo "optional OK: $desc"; else $QUIET || echo "optional MISSING: $desc (install on demand)"; fi; }
10
14
 
11
15
  # ── Resolve PDF_SKILL_DIR & FONT_DIR ──
12
16
  _ENV_CHECK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
@@ -20,30 +24,34 @@ else
20
24
  fi
21
25
  export FONT_DIR
22
26
 
27
+ # ── CORE (required): Python + ReportLab/pypdf toolchain + CJK font ──
23
28
  check "python3" command -v python3
24
- check "node" command -v node
25
29
  check "pikepdf" python3 -c "import pikepdf"
26
30
  check "pdfplumber" python3 -c "import pdfplumber"
27
31
  check "pypdf" python3 -c "import pypdf"
28
32
  check "reportlab" python3 -c "import reportlab"
29
33
  check "PyMuPDF" python3 -c "import fitz"
30
- check "playwright" node -e "require('playwright')"
31
34
 
32
- # LaTeX engine (tectonic) — needed for Academic pipeline
33
- if [ -x "$PDF_SKILL_DIR/scripts/tectonic" ]; then
34
- : # bundled binary OK
35
- elif command -v tectonic &>/dev/null; then
36
- : # system tectonic OK
37
- else
38
- $QUIET || echo "MISSING: tectonic (needed for LaTeX/Academic PDFs)"
39
- FAIL=1
35
+ # Font check: verify an embeddable CJK font is available (SimHei/Noto/WenQuanYi/Songti…)
36
+ if command -v fc-list &>/dev/null; then
37
+ fc-list :lang=zh 2>/dev/null | grep -qi "noto\|simhei\|simsun\|songti\|heiti\|wenquanyi\|yahei\|kai" \
38
+ || { $QUIET || echo "MISSING (core): CJK font"; FAIL=1; }
40
39
  fi
41
40
 
42
- # Font check: verify CJK fonts are available
43
- if command -v fc-list &>/dev/null; then
44
- fc-list :lang=zh 2>/dev/null | grep -qi "noto\|simhei\|wenquanyi" || { $QUIET || echo "MISSING: CJK fonts"; FAIL=1; }
41
+ # ── OPTIONAL: Creative/HTML pipeline (Node + Playwright + Chromium) ──
42
+ optional "node" command -v node
43
+ optional "playwright (npm)" node -e "require('playwright')"
44
+
45
+ # ── OPTIONAL: Academic/LaTeX pipeline (Tectonic) ──
46
+ if [ -x "$PDF_SKILL_DIR/scripts/tectonic" ] || command -v tectonic &>/dev/null; then
47
+ $QUIET || echo "optional OK: tectonic"
48
+ else
49
+ $QUIET || echo "optional MISSING: tectonic (LaTeX/Academic; install on demand)"
45
50
  fi
46
51
 
52
+ # ── OPTIONAL: Office→PDF (LibreOffice/soffice) ──
53
+ optional "libreoffice (soffice)" command -v soffice
54
+
47
55
  $QUIET || echo "PDF_SKILL_DIR=$PDF_SKILL_DIR"
48
56
  $QUIET || echo "FONT_DIR=$FONT_DIR"
49
57
  return $FAIL 2>/dev/null || exit $FAIL
@@ -43,42 +43,60 @@ Run the platform-appropriate setup script:
43
43
 
44
44
  | Category | Package | Purpose |
45
45
  |----------|---------|---------|
46
- | Runtime | Python 3 + pip | PDF generation and processing |
47
- | Runtime | Node.js + npm | Playwright for Creative pipeline |
48
- | Python pkg | pikepdf | PDF manipulation (merge/split/encrypt) |
49
- | Python pkg | pdfplumber | Text/table extraction |
50
- | Python pkg | pypdf | PDF reading/writing |
51
- | Python pkg | reportlab | Report pipeline PDF generation |
52
- | Python pkg | PyMuPDF (fitz) | Fast PDF rendering and extraction |
53
- | npm pkg | playwright | HTML-to-PDF for Creative pipeline |
54
- | Browser | Chromium (via Playwright) | Headless rendering |
46
+ | **Core** Runtime | Python 3 + pip | PDF generation and processing |
47
+ | **Core** Python pkg | reportlab | Report/cover pipeline PDF generation |
48
+ | **Core** Python pkg | pypdf | PDF reading/writing/merge |
49
+ | **Core** Python pkg | PyMuPDF (fitz) | Fast PDF rendering and extraction |
50
+ | **Core** Python pkg | pikepdf | PDF manipulation (merge/split/encrypt) |
51
+ | **Core** Python pkg | pdfplumber | Text/table extraction |
52
+ | **Core** Font | CJK fonts (TrueType: SimHei/Noto/WenQuanYi/Songti…) | Chinese text + covers |
53
+ | Optional | Node.js + npm | Only for the Creative/HTML pipeline |
54
+ | Optional | playwright (npm) | HTML-to-PDF for Creative pipeline |
55
+ | Optional | Chromium (via Playwright) | Headless rendering (large download) |
55
56
  | Optional | tectonic | LaTeX/Academic PDF compilation |
56
57
  | Optional | LibreOffice | Office-to-PDF conversion |
57
- | Font | CJK fonts (from CDN) | Chinese text in PDFs |
58
+
59
+ > **Covers no longer need Playwright.** All Report/Academic covers render with ReportLab
60
+ > (`scripts/cover_render.py`). Playwright/Chromium is required **only** for the Creative/poster
61
+ > pipeline and some HTML→PDF conversions; Tectonic **only** for the Academic/LaTeX route.
62
+ > Install these optional engines **on demand, after asking the user** (they involve large
63
+ > downloads / long first-run waits) — do not install them up front.
58
64
 
59
65
  ### Manual Install by Platform
60
66
 
61
67
  #### macOS
62
68
 
63
69
  ```bash
64
- brew install python3 node
65
- python3 -m pip install pikepdf pdfplumber pypdf reportlab PyMuPDF
70
+ # ── Core (always) ──
71
+ brew install python3
72
+ python3 -m pip install reportlab pypdf PyMuPDF pikepdf pdfplumber
73
+
74
+ # ── Optional: Creative/HTML pipeline (install on demand, with user's OK — large Chromium download) ──
75
+ brew install node
66
76
  npm install -g playwright@1.50.0 && npx playwright install chromium
67
77
  # Pinned to 1.50.0 — npmmirror has Chromium rev 1155 for this version
68
- brew install tectonic # optional: LaTeX
69
- brew install --cask libreoffice # optional: Office-to-PDF
78
+
79
+ # ── Optional: Academic/LaTeX (install on demand — downloads packages on first run) ──
80
+ brew install tectonic
81
+ # ── Optional: Office-to-PDF ──
82
+ brew install --cask libreoffice
70
83
  ```
71
84
 
72
85
  #### Linux (Debian/Ubuntu)
73
86
 
74
87
  ```bash
75
- sudo apt install python3 python3-pip nodejs npm
76
- python3 -m pip install pikepdf pdfplumber pypdf reportlab PyMuPDF
88
+ # ── Core (always) ──
89
+ sudo apt install python3 python3-pip
90
+ python3 -m pip install reportlab pypdf PyMuPDF pikepdf pdfplumber
91
+
92
+ # ── Optional: Creative/HTML pipeline (install on demand, with user's OK) ──
93
+ sudo apt install nodejs npm
77
94
  npm install -g playwright@1.50.0 && npx playwright install chromium && npx playwright install-deps
78
- # Pinned to 1.50.0 — npmmirror has Chromium rev 1155 for this version
79
- # optional:
95
+
96
+ # ── Optional: Academic/LaTeX (install on demand) ──
80
97
  conda install -c conda-forge tectonic # use Tsinghua mirror: conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
81
- sudo apt install libreoffice-core # LibreOffice
98
+ # ── Optional: Office-to-PDF ──
99
+ sudo apt install libreoffice-core
82
100
  ```
83
101
 
84
102
  #### Windows (PowerShell)
@@ -147,22 +147,21 @@ if ($PyCmd) {
147
147
  }
148
148
  Write-Host ""
149
149
 
150
- # ── Step 2d: Node.js + npm ──
151
- Write-Host "--- [4/9] Node.js + npm ---"
150
+ # ── Step 2d: Node.js + npm (OPTIONAL — Creative/HTML pipeline only) ──
151
+ Write-Host "--- [4/9] Node.js + npm (optional: Creative/HTML pipeline) ---"
152
152
  try {
153
153
  $nodeVer = & node --version 2>&1
154
154
  if ($LASTEXITCODE -eq 0) {
155
155
  Write-Ok "node ($nodeVer)"
156
156
  } else { throw "no node" }
157
157
  } catch {
158
- Write-Fail "node not found"
159
- Write-Info "Install option 1: winget install OpenJS.NodeJS.LTS"
160
- Write-Info "Install option 2: https://nodejs.org/"
161
- Write-Info "Install option 3: choco install nodejs-lts"
158
+ Write-Warn "node not found (optional — only for the Creative/poster/HTML->PDF route)"
159
+ Write-Info "Install on demand 1: winget install OpenJS.NodeJS.LTS"
160
+ Write-Info "Install on demand 2: https://nodejs.org/"
161
+ Write-Info "Install on demand 3: choco install nodejs-lts"
162
162
  if ($global:UseCN) {
163
163
  Write-Info "China alt: https://npmmirror.com/mirrors/node/"
164
164
  }
165
- $Errors++
166
165
  }
167
166
 
168
167
  try {
@@ -171,13 +170,14 @@ try {
171
170
  Write-Ok "npm ($npmVer)"
172
171
  } else { throw "no npm" }
173
172
  } catch {
174
- Write-Fail "npm not found (installed with Node.js)"
175
- $Errors++
173
+ Write-Warn "npm not found (optional — installed with Node.js)"
176
174
  }
177
175
  Write-Host ""
178
176
 
179
- # ── Step 2e: Playwright + Chromium ──
180
- Write-Host "--- [5/9] Playwright + Chromium ---"
177
+ # ── Step 2e: Playwright + Chromium (OPTIONAL — Creative/HTML pipeline only) ──
178
+ Write-Host "--- [5/9] Playwright + Chromium (optional: HTML->PDF engine) ---"
179
+ Write-Info "Optional. Covers now render with ReportLab; Playwright is only for Creative/poster/HTML->PDF."
180
+ Write-Info "Install on demand, with the user's confirmation (large download / long first-run wait)."
181
181
  try {
182
182
  $null = & node -e "require('playwright')" 2>&1
183
183
  if ($LASTEXITCODE -eq 0) {
@@ -185,26 +185,24 @@ try {
185
185
  Write-Ok "playwright ($pwVer)"
186
186
  } else { throw "no pw" }
187
187
  } catch {
188
- Write-Fail "playwright not installed"
188
+ Write-Warn "playwright not installed (optional)"
189
189
  if ($global:UseCN) {
190
- Write-Info "Install: npm install -g playwright@1.50.0 $($NpmMirrorArgs -join ' ')"
190
+ Write-Info "Install on demand: npm install -g playwright@1.50.0 $($NpmMirrorArgs -join ' ')"
191
191
  } else {
192
- Write-Info "Install: npm install -g playwright@1.50.0"
192
+ Write-Info "Install on demand: npm install -g playwright@1.50.0"
193
193
  }
194
- $Errors++
195
194
  }
196
195
 
197
196
  $PwCache = Join-Path $env:LOCALAPPDATA "ms-playwright"
198
197
  if (Test-Path "$PwCache\chromium-*") {
199
198
  Write-Ok "chromium installed"
200
199
  } else {
201
- Write-Fail "chromium not installed"
200
+ Write-Warn "chromium not installed (optional)"
202
201
  if ($global:UseCN) {
203
- Write-Info "Install: `$env:PLAYWRIGHT_DOWNLOAD_HOST='$PlaywrightHost'; npx playwright install chromium"
202
+ Write-Info "Install on demand: `$env:PLAYWRIGHT_DOWNLOAD_HOST='$PlaywrightHost'; npx playwright install chromium"
204
203
  } else {
205
- Write-Info "Install: npx playwright install chromium"
204
+ Write-Info "Install on demand: npx playwright install chromium"
206
205
  }
207
- $Errors++
208
206
  }
209
207
  Write-Host ""
210
208