qubicl-cli 0.1.0-dev.0 → 0.1.1

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 (91) hide show
  1. package/README.md +129 -19
  2. package/dist/SBOM.spdx.json +222 -0
  3. package/dist/THIRD_PARTY_NOTICES.txt +244 -0
  4. package/dist/assets/chromium-seccomp.json +181 -0
  5. package/dist/assets/computer/BROWSER_SKILLS_THIRD_PARTY_NOTICES.txt +23 -0
  6. package/dist/assets/computer/Dockerfile +191 -49
  7. package/dist/assets/computer/PLAYWRIGHT_THIRD_PARTY_NOTICES.txt +217 -0
  8. package/dist/assets/computer/SKILLS_THIRD_PARTY_NOTICES.txt +29 -0
  9. package/dist/assets/computer/THIRD_PARTY_NOTICES.txt +28 -0
  10. package/dist/assets/computer/WEB_THIRD_PARTY_NOTICES.txt +42 -0
  11. package/dist/assets/computer/browser-skills-requirements.txt +12 -0
  12. package/dist/assets/computer/chromium-wrapper.sh +12 -0
  13. package/dist/assets/computer/control.mjs +112 -52
  14. package/dist/assets/computer/entrypoint.sh +272 -35
  15. package/dist/assets/computer/libreoffice-registrymodifications.xcu +8 -0
  16. package/dist/assets/computer/manifests/browser.json +72 -0
  17. package/dist/assets/computer/manifests/computer.json +76 -0
  18. package/dist/assets/computer/manifests/file-system.json +42 -0
  19. package/dist/assets/computer/manifests/workstation.json +78 -0
  20. package/dist/assets/computer/node_modules/playwright-core/LICENSE +202 -0
  21. package/dist/assets/computer/node_modules/playwright-core/NOTICE +5 -0
  22. package/dist/assets/computer/node_modules/playwright-core/ThirdPartyNotices.txt +13 -0
  23. package/dist/assets/computer/node_modules/playwright-core/browsers.json +75 -0
  24. package/dist/assets/computer/node_modules/playwright-core/index.js +17 -0
  25. package/dist/assets/computer/node_modules/playwright-core/index.mjs +28 -0
  26. package/dist/assets/computer/node_modules/playwright-core/lib/bootstrap.js +88 -0
  27. package/dist/assets/computer/node_modules/playwright-core/lib/coreBundle.js +74830 -0
  28. package/dist/assets/computer/node_modules/playwright-core/lib/utilsBundle.js +90764 -0
  29. package/dist/assets/computer/node_modules/playwright-core/lib/utilsBundle.js.LICENSE +2179 -0
  30. package/dist/assets/computer/node_modules/playwright-core/lib/webp_codec.LICENSE +173 -0
  31. package/dist/assets/computer/node_modules/playwright-core/lib/webp_codec.wasm +0 -0
  32. package/dist/assets/computer/node_modules/playwright-core/lib/xdg-open +1267 -0
  33. package/dist/assets/computer/node_modules/playwright-core/package.json +34 -0
  34. package/dist/assets/computer/skills/core/docx/LICENSE +21 -0
  35. package/dist/assets/computer/skills/core/docx/SKILL.md +21 -0
  36. package/dist/assets/computer/skills/core/docx/references/revisions-and-comments.md +88 -0
  37. package/dist/assets/computer/skills/core/docx/scripts/docx_comments.py +289 -0
  38. package/dist/assets/computer/skills/core/docx/scripts/docx_common.py +94 -0
  39. package/dist/assets/computer/skills/core/docx/scripts/docx_create.py +177 -0
  40. package/dist/assets/computer/skills/core/docx/scripts/docx_edit.py +250 -0
  41. package/dist/assets/computer/skills/core/docx/scripts/docx_read.py +149 -0
  42. package/dist/assets/computer/skills/core/docx/scripts/docx_revisions.py +147 -0
  43. package/dist/assets/computer/skills/core/docx/scripts/docx_template.py +70 -0
  44. package/dist/assets/computer/skills/core/docx/scripts/docx_validate.py +156 -0
  45. package/dist/assets/computer/skills/core/ocr-and-documents/LICENSE +21 -0
  46. package/dist/assets/computer/skills/core/ocr-and-documents/SKILL.md +24 -0
  47. package/dist/assets/computer/skills/core/ocr-and-documents/scripts/ocr_document.py +132 -0
  48. package/dist/assets/computer/skills/core/pdf/LICENSE +21 -0
  49. package/dist/assets/computer/skills/core/pdf/SKILL.md +25 -0
  50. package/dist/assets/computer/skills/core/pdf/references/forms.md +100 -0
  51. package/dist/assets/computer/skills/core/pdf/scripts/_raster.py +76 -0
  52. package/dist/assets/computer/skills/core/pdf/scripts/pdf_create.py +130 -0
  53. package/dist/assets/computer/skills/core/pdf/scripts/pdf_fill_form.py +97 -0
  54. package/dist/assets/computer/skills/core/pdf/scripts/pdf_form_layout.py +168 -0
  55. package/dist/assets/computer/skills/core/pdf/scripts/pdf_make_form.py +145 -0
  56. package/dist/assets/computer/skills/core/pdf/scripts/pdf_merge.py +50 -0
  57. package/dist/assets/computer/skills/core/pdf/scripts/pdf_meta.py +115 -0
  58. package/dist/assets/computer/skills/core/pdf/scripts/pdf_page_image.py +99 -0
  59. package/dist/assets/computer/skills/core/pdf/scripts/pdf_read.py +153 -0
  60. package/dist/assets/computer/skills/core/pdf/scripts/pdf_secure.py +71 -0
  61. package/dist/assets/computer/skills/core/pdf/scripts/pdf_split.py +84 -0
  62. package/dist/assets/computer/skills/core/pdf/scripts/pdf_stamp.py +143 -0
  63. package/dist/assets/computer/skills/core/pdf/scripts/pdf_watermark.py +51 -0
  64. package/dist/assets/computer/skills/core/plan/LICENSE +21 -0
  65. package/dist/assets/computer/skills/core/plan/SKILL.md +21 -0
  66. package/dist/assets/computer/skills/core/powerpoint/LICENSE +21 -0
  67. package/dist/assets/computer/skills/core/powerpoint/SKILL.md +18 -0
  68. package/dist/assets/computer/skills/core/powerpoint/scripts/pptx_create.py +214 -0
  69. package/dist/assets/computer/skills/core/powerpoint/scripts/pptx_edit.py +436 -0
  70. package/dist/assets/computer/skills/core/powerpoint/scripts/pptx_from_template.py +88 -0
  71. package/dist/assets/computer/skills/core/powerpoint/scripts/pptx_read.py +131 -0
  72. package/dist/assets/computer/skills/core/powerpoint/scripts/pptx_render.py +93 -0
  73. package/dist/assets/computer/skills/core/xlsx/LICENSE +21 -0
  74. package/dist/assets/computer/skills/core/xlsx/SKILL.md +22 -0
  75. package/dist/assets/computer/skills/core/xlsx/references/restructuring.md +71 -0
  76. package/dist/assets/computer/skills/core/xlsx/scripts/csv_to_xlsx.py +104 -0
  77. package/dist/assets/computer/skills/core/xlsx/scripts/xlsx_create.py +259 -0
  78. package/dist/assets/computer/skills/core/xlsx/scripts/xlsx_edit.py +263 -0
  79. package/dist/assets/computer/skills/core/xlsx/scripts/xlsx_read.py +160 -0
  80. package/dist/assets/computer/skills/core/xlsx/scripts/xlsx_recalc.py +110 -0
  81. package/dist/assets/computer/skills/core/xlsx/scripts/xlsx_restructure.py +337 -0
  82. package/dist/assets/computer/skills/core/xlsx/scripts/xlsx_to_csv.py +69 -0
  83. package/dist/assets/computer/skills/core-catalog.json +246 -0
  84. package/dist/assets/computer/skills-requirements.txt +18 -0
  85. package/dist/assets/computer/web-provider.py +592 -0
  86. package/dist/assets/computer/web-requirements.txt +37 -0
  87. package/dist/assets/gateway/Dockerfile +3 -1
  88. package/dist/assets/gateway/gateway.mjs +69 -40
  89. package/dist/assets/image-catalog.json +183 -0
  90. package/dist/qubicl.mjs +297 -167
  91. package/package.json +8 -8
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env python3
2
+ """Extract page ranges from a PDF, optionally rotating and/or compressing pages."""
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ import sys
8
+
9
+
10
+ def parse_pages(spec: str, page_count: int) -> list[int]:
11
+ """Parse a 1-based page spec like '1-3,5,9-' into 0-based indices."""
12
+ indices: list[int] = []
13
+ for part in spec.split(","):
14
+ part = part.strip()
15
+ if not part:
16
+ continue
17
+ if "-" in part:
18
+ start_s, _, end_s = part.partition("-")
19
+ start = int(start_s) if start_s else 1
20
+ end = int(end_s) if end_s else page_count
21
+ else:
22
+ start = end = int(part)
23
+ if start < 1 or end > page_count or start > end:
24
+ raise ValueError(f"Page range {part!r} out of bounds (1-{page_count})")
25
+ indices.extend(range(start - 1, end))
26
+ return indices
27
+
28
+
29
+ def main() -> int:
30
+ for stream in (sys.stdout, sys.stderr):
31
+ try:
32
+ stream.reconfigure(encoding="utf-8")
33
+ except Exception:
34
+ pass
35
+ parser = argparse.ArgumentParser(
36
+ description="Split/extract pages from a PDF (pypdf). Pages are 1-based: '1-3,5,9-'.")
37
+ parser.add_argument("pdf", help="Input PDF path")
38
+ parser.add_argument("--pages", required=True, help="1-based page spec, e.g. '1-3,5,9-'")
39
+ parser.add_argument("-o", "--output", required=True, help="Output PDF path")
40
+ parser.add_argument("--rotate", type=int, default=0,
41
+ help="Rotate extracted pages clockwise (multiple of 90)")
42
+ parser.add_argument("--compress", action="store_true",
43
+ help="Deflate content streams (modest savings; does not recompress images)")
44
+ parser.add_argument("--password", help="Password if the input is encrypted")
45
+ args = parser.parse_args()
46
+
47
+ if args.rotate % 90 != 0:
48
+ print("Error: --rotate must be a multiple of 90", file=sys.stderr)
49
+ return 2
50
+
51
+ try:
52
+ from pypdf import PdfReader, PdfWriter
53
+ except ImportError:
54
+ print("Required Qubicl PDF dependency is unavailable: pypdf", file=sys.stderr)
55
+ return 2
56
+
57
+ reader = PdfReader(args.pdf)
58
+ if reader.is_encrypted:
59
+ if args.password is None or not reader.decrypt(args.password):
60
+ print("Error: input is encrypted; pass --password", file=sys.stderr)
61
+ return 3
62
+ try:
63
+ indices = parse_pages(args.pages, len(reader.pages))
64
+ except ValueError as exc:
65
+ print(f"Error: {exc}", file=sys.stderr)
66
+ return 2
67
+
68
+ writer = PdfWriter()
69
+ for idx in indices:
70
+ page = reader.pages[idx]
71
+ if args.rotate:
72
+ page.rotate(args.rotate)
73
+ writer.add_page(page)
74
+ if args.compress:
75
+ for page in writer.pages:
76
+ page.compress_content_streams()
77
+ with open(args.output, "wb") as fh:
78
+ writer.write(fh)
79
+ print(json.dumps({"output": args.output, "page_count": len(indices), "rotated": args.rotate}))
80
+ return 0
81
+
82
+
83
+ if __name__ == "__main__":
84
+ sys.exit(main())
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env python3
2
+ """Stamp text or an image at coordinates onto selected PDF pages.
3
+
4
+ Builds an in-memory single-page overlay with reportlab, then merges it
5
+ onto each selected page with pypdf. Coordinates are PDF points, origin
6
+ bottom-left. Covers 'sign here' arrows, diagonal DRAFT banners, and
7
+ page-corner labels.
8
+
9
+ Examples:
10
+ pdf_stamp.py in.pdf -o out.pdf --text "DRAFT" --x 200 --y 400 \
11
+ --font-size 60 --rotation 45 --opacity 0.3 --color "#cc0000"
12
+ pdf_stamp.py in.pdf -o out.pdf --image sig.png --x 400 --y 60 \
13
+ --width 120 --pages 3
14
+ """
15
+ from __future__ import annotations
16
+
17
+ import argparse
18
+ import io
19
+ import json
20
+ import sys
21
+
22
+
23
+ def parse_pages(spec: str, page_count: int) -> list[int]:
24
+ pages: set[int] = set()
25
+ for part in spec.split(","):
26
+ part = part.strip()
27
+ if not part:
28
+ continue
29
+ if "-" in part:
30
+ start_s, _, end_s = part.partition("-")
31
+ start = int(start_s) if start_s else 1
32
+ end = int(end_s) if end_s else page_count
33
+ pages.update(range(start, end + 1))
34
+ else:
35
+ pages.add(int(part))
36
+ bad = [p for p in pages if not 1 <= p <= page_count]
37
+ if bad:
38
+ raise ValueError(f"pages out of range 1-{page_count}: {sorted(bad)}")
39
+ return sorted(pages)
40
+
41
+
42
+ def build_overlay(args, page_width: float, page_height: float) -> bytes:
43
+ from reportlab.lib.colors import HexColor
44
+ from reportlab.pdfgen import canvas
45
+ buf = io.BytesIO()
46
+ c = canvas.Canvas(buf, pagesize=(page_width, page_height))
47
+ c.saveState()
48
+ try:
49
+ c.setFillAlpha(float(args.opacity))
50
+ c.setStrokeAlpha(float(args.opacity))
51
+ except Exception:
52
+ pass # very old reportlab: no alpha support
53
+ c.translate(float(args.x), float(args.y))
54
+ if args.rotation:
55
+ c.rotate(float(args.rotation))
56
+ if args.text:
57
+ c.setFont(args.font, float(args.font_size))
58
+ c.setFillColor(HexColor(args.color))
59
+ c.drawString(0, 0, args.text)
60
+ else:
61
+ kwargs = {}
62
+ if args.width:
63
+ kwargs["width"] = float(args.width)
64
+ if args.height:
65
+ kwargs["height"] = float(args.height)
66
+ if "width" in kwargs and "height" not in kwargs:
67
+ from PIL import Image as PILImage
68
+ with PILImage.open(args.image) as im:
69
+ kwargs["height"] = kwargs["width"] * im.height / im.width
70
+ c.drawImage(args.image, 0, 0, mask="auto", **kwargs)
71
+ c.restoreState()
72
+ c.save()
73
+ return buf.getvalue()
74
+
75
+
76
+ def main() -> int:
77
+ for stream in (sys.stdout, sys.stderr):
78
+ try:
79
+ stream.reconfigure(encoding="utf-8")
80
+ except Exception:
81
+ pass
82
+ parser = argparse.ArgumentParser(description="Stamp text or an image onto PDF pages.")
83
+ parser.add_argument("pdf", help="Input PDF path")
84
+ parser.add_argument("-o", "--output", required=True, help="Output PDF path")
85
+ what = parser.add_mutually_exclusive_group(required=True)
86
+ what.add_argument("--text", help="Text to stamp")
87
+ what.add_argument("--image", help="Image file to stamp (PNG/JPEG)")
88
+ parser.add_argument("--x", type=float, required=True, help="X in points (origin bottom-left)")
89
+ parser.add_argument("--y", type=float, required=True, help="Y in points")
90
+ parser.add_argument("--pages", default="1-", help="1-based ranges, e.g. '1-3,5' (default: all)")
91
+ parser.add_argument("--font", default="Helvetica", help="Font name (default Helvetica)")
92
+ parser.add_argument("--font-size", type=float, default=24, help="Font size in points")
93
+ parser.add_argument("--color", default="#000000", help="Text color as #RRGGBB")
94
+ parser.add_argument("--rotation", type=float, default=0, help="Degrees counterclockwise")
95
+ parser.add_argument("--opacity", type=float, default=1.0, help="0.0-1.0 (default 1.0)")
96
+ parser.add_argument("--width", type=float, help="Image width in points")
97
+ parser.add_argument("--height", type=float, help="Image height in points")
98
+ parser.add_argument("--under", action="store_true",
99
+ help="Place the stamp under existing content instead of over it")
100
+ parser.add_argument("--password", help="Password if the input is encrypted")
101
+ args = parser.parse_args()
102
+
103
+ try:
104
+ from pypdf import PdfReader, PdfWriter
105
+ except ImportError:
106
+ print("Required Qubicl PDF dependencies are unavailable: pypdf and reportlab",
107
+ file=sys.stderr)
108
+ return 2
109
+
110
+ reader = PdfReader(args.pdf)
111
+ if reader.is_encrypted:
112
+ if args.password is None or not reader.decrypt(args.password):
113
+ print("Error: input is encrypted; pass --password", file=sys.stderr)
114
+ return 3
115
+ try:
116
+ pages = set(parse_pages(args.pages, len(reader.pages)))
117
+ except ValueError as exc:
118
+ print(f"Error: {exc}", file=sys.stderr)
119
+ return 4
120
+
121
+ writer = PdfWriter()
122
+ overlay_cache: dict[tuple[float, float], object] = {}
123
+ for idx, page in enumerate(reader.pages, start=1):
124
+ if idx in pages:
125
+ size = (float(page.mediabox.width), float(page.mediabox.height))
126
+ if size not in overlay_cache:
127
+ overlay_pdf = PdfReader(io.BytesIO(build_overlay(args, *size)))
128
+ overlay_cache[size] = overlay_pdf.pages[0]
129
+ stamp = overlay_cache[size]
130
+ if args.under:
131
+ page.merge_page(stamp, over=False)
132
+ else:
133
+ page.merge_page(stamp)
134
+ writer.add_page(page)
135
+ with open(args.output, "wb") as fh:
136
+ writer.write(fh)
137
+ print(json.dumps({"output": args.output, "stamped_pages": sorted(pages),
138
+ "kind": "text" if args.text else "image"}, ensure_ascii=False))
139
+ return 0
140
+
141
+
142
+ if __name__ == "__main__":
143
+ sys.exit(main())
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env python3
2
+ """Stamp/watermark every page of a PDF with page 1 of another PDF."""
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ import sys
8
+
9
+
10
+ def main() -> int:
11
+ for stream in (sys.stdout, sys.stderr):
12
+ try:
13
+ stream.reconfigure(encoding="utf-8")
14
+ except Exception:
15
+ pass
16
+ parser = argparse.ArgumentParser(
17
+ description="Overlay (stamp) or underlay (watermark) a one-page PDF onto every page.")
18
+ parser.add_argument("pdf", help="Input PDF path")
19
+ parser.add_argument("--stamp", required=True, help="One-page PDF to apply (page 1 is used)")
20
+ parser.add_argument("-o", "--output", required=True, help="Output PDF path")
21
+ parser.add_argument("--under", action="store_true",
22
+ help="Place stamp under the page content (background watermark)")
23
+ parser.add_argument("--password", help="Password if the input is encrypted")
24
+ args = parser.parse_args()
25
+
26
+ try:
27
+ from pypdf import PdfReader, PdfWriter
28
+ except ImportError:
29
+ print("Required Qubicl PDF dependency is unavailable: pypdf", file=sys.stderr)
30
+ return 2
31
+
32
+ reader = PdfReader(args.pdf)
33
+ if reader.is_encrypted:
34
+ if args.password is None or not reader.decrypt(args.password):
35
+ print("Error: input is encrypted; pass --password", file=sys.stderr)
36
+ return 3
37
+ stamp_page = PdfReader(args.stamp).pages[0]
38
+
39
+ writer = PdfWriter()
40
+ writer.append(reader)
41
+ for page in writer.pages:
42
+ page.merge_page(stamp_page, over=not args.under)
43
+ with open(args.output, "wb") as fh:
44
+ writer.write(fh)
45
+ print(json.dumps({"output": args.output, "page_count": len(writer.pages),
46
+ "mode": "under" if args.under else "over"}))
47
+ return 0
48
+
49
+
50
+ if __name__ == "__main__":
51
+ sys.exit(main())
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Nous Research
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: plan
3
+ description: Create a concrete, reviewable implementation or project plan without performing the planned changes. Use for architecture proposals, migration plans, release plans, debugging strategies, and any request to plan before acting.
4
+ ---
5
+
6
+ # Plan
7
+
8
+ Stay in planning mode for this turn. Inspect relevant context with read-only Qubicl tools, but do not edit project files, start deployments, publish, commit, or perform the proposed work.
9
+
10
+ Write a concise Markdown plan in the active workspace. Prefer `write_file` for a new plan and `edit_file` for an existing one. Use a user-provided destination; otherwise write under `.agents/plans/` with a descriptive kebab-case filename.
11
+
12
+ Include only useful sections:
13
+
14
+ - goal and success criteria;
15
+ - current evidence and assumptions;
16
+ - ordered implementation steps;
17
+ - files or components likely to change;
18
+ - validation and rollback;
19
+ - risks, tradeoffs, and unresolved decisions.
20
+
21
+ Use exact local paths and commands when known. Clearly label anything inferred. End by summarizing the decisions required before implementation.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nous Research
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: powerpoint
3
+ description: Create, inspect, edit, template, render, and verify PowerPoint PPTX presentations using Qubicl's pinned local presentation tools. Use for slide decks, speaker notes, charts, images, templates, and visual presentation review.
4
+ ---
5
+
6
+ # PowerPoint workflows
7
+
8
+ Keep decks and rendered previews under `/home/qubicl`. Obtain this skill's `resourceRoot` from `skill_view` and run bundled helpers with `/opt/qubicl/skills-venv/bin/python`. Qubicl computer and workstation images contain the pinned PPTX library; do not install dependencies during a task.
9
+
10
+ Useful helpers beneath `<resourceRoot>/scripts/`:
11
+
12
+ - `pptx_read.py FILE --outline|--notes|--images DIR`
13
+ - `pptx_create.py SPEC.json OUTPUT.pptx`
14
+ - `pptx_edit.py FILE` for text, charts, images, slide order, backgrounds, links, footers, and notes
15
+ - `pptx_from_template.py TEMPLATE.pptx OUTPUT.pptx --values VALUES.json`
16
+ - `pptx_render.py FILE --outdir DIR`
17
+
18
+ Inspect the source deck before editing. Prefer a new output for structural changes. Validate by reading the resulting outline and notes. On workstation computers, render slides through LibreOffice and Poppler for visual QA; on computer computers, structured operations remain available but rendering may be unavailable. Check representative first, middle, and last slides rather than assuming a successful save preserved layout.
@@ -0,0 +1,214 @@
1
+ #!/usr/bin/env python3
2
+ """Create a .pptx presentation from a JSON deck spec.
3
+
4
+ Spec format (all positions/sizes in inches, colors as RRGGBB hex):
5
+ {
6
+ "slide_size": "16:9", // or "4:3" (default "16:9")
7
+ "slides": [
8
+ {"layout": "title", "title": "My Deck", "subtitle": "Q3 review"},
9
+ {"layout": "title_content", "title": "Agenda",
10
+ "bullets": ["Top item",
11
+ {"text": "Sub item", "level": 1, "bold": true,
12
+ "size": 18, "color": "CC0000", "font": "Arial",
13
+ "italic": false,
14
+ "link": "https://example.com/agenda"}],
15
+ "background": "1F2937", // solid slide background (hex)
16
+ "footer": "Confidential", // footer placeholder text
17
+ "slide_number": true, // enable slide-number placeholder
18
+ "notes": "Speaker notes for this slide"},
19
+ {"layout": "blank", "title": "Widgets",
20
+ "images": [{"path": "logo.png", "left": 1, "top": 1, "width": 3}],
21
+ "tables": [{"left": 1, "top": 2, "width": 6, "height": 2,
22
+ "rows": [["H1", "H2"], ["a", "b"]]}],
23
+ "shapes": [{"type": "rounded_rectangle", "left": 8, "top": 1,
24
+ "width": 3, "height": 1, "fill": "4472C4",
25
+ "text": "Callout", "text_color": "FFFFFF"}],
26
+ "charts": [{"type": "bar", "left": 1, "top": 3, "width": 6,
27
+ "height": 3.5, "title": "Sales",
28
+ "categories": ["Q1", "Q2"],
29
+ "series": {"North": [10, 20], "South": [7, 13]}}]}
30
+ ]
31
+ }
32
+ Layouts: title, title_content, section, two_content, title_only, blank
33
+ Chart types: bar, bar_h, line, pie Shape types: rectangle,
34
+ rounded_rectangle, oval, diamond, right_arrow, chevron
35
+ """
36
+ import argparse
37
+ import copy
38
+ import json
39
+ import sys
40
+
41
+ from pptx import Presentation
42
+ from pptx.chart.data import CategoryChartData
43
+ from pptx.dml.color import RGBColor
44
+ from pptx.enum.chart import XL_CHART_TYPE
45
+ from pptx.enum.shapes import MSO_SHAPE
46
+ from pptx.util import Inches, Pt
47
+
48
+ LAYOUTS = {"title": 0, "title_content": 1, "section": 2,
49
+ "two_content": 3, "title_only": 5, "blank": 6}
50
+ CHART_TYPES = {"bar": XL_CHART_TYPE.COLUMN_CLUSTERED,
51
+ "bar_h": XL_CHART_TYPE.BAR_CLUSTERED,
52
+ "line": XL_CHART_TYPE.LINE_MARKERS,
53
+ "pie": XL_CHART_TYPE.PIE}
54
+ SHAPE_TYPES = {"rectangle": MSO_SHAPE.RECTANGLE,
55
+ "rounded_rectangle": MSO_SHAPE.ROUNDED_RECTANGLE,
56
+ "oval": MSO_SHAPE.OVAL, "diamond": MSO_SHAPE.DIAMOND,
57
+ "right_arrow": MSO_SHAPE.RIGHT_ARROW,
58
+ "chevron": MSO_SHAPE.CHEVRON}
59
+
60
+
61
+ def style_run(run, spec):
62
+ """Apply font styling from a bullet/text spec dict to a run."""
63
+ font = run.font
64
+ if spec.get("size"):
65
+ font.size = Pt(spec["size"])
66
+ if spec.get("bold") is not None:
67
+ font.bold = spec["bold"]
68
+ if spec.get("italic") is not None:
69
+ font.italic = spec["italic"]
70
+ if spec.get("font"):
71
+ font.name = spec["font"]
72
+ if spec.get("color"):
73
+ font.color.rgb = RGBColor.from_string(spec["color"])
74
+ if spec.get("link"):
75
+ run.hyperlink.address = spec["link"]
76
+
77
+
78
+ def add_bullets(text_frame, bullets):
79
+ text_frame.clear()
80
+ for i, item in enumerate(bullets):
81
+ if isinstance(item, str):
82
+ item = {"text": item}
83
+ para = text_frame.paragraphs[0] if i == 0 else text_frame.add_paragraph()
84
+ para.level = int(item.get("level", 0))
85
+ run = para.add_run()
86
+ run.text = item.get("text", "")
87
+ style_run(run, item)
88
+
89
+
90
+ def copy_layout_placeholder(slide, ph_idx):
91
+ """Copy a layout placeholder (footer=11, slide number=12) onto the
92
+ slide so it actually renders; returns the shape or None if the layout
93
+ does not provide it."""
94
+ for ph in slide.slide_layout.placeholders:
95
+ if ph.placeholder_format.idx == ph_idx:
96
+ slide.shapes._spTree.append(copy.deepcopy(ph._element))
97
+ for shape in slide.placeholders:
98
+ if shape.placeholder_format.idx == ph_idx:
99
+ return shape
100
+ return None
101
+
102
+
103
+ def build_slide(prs, spec):
104
+ layout_idx = LAYOUTS.get(spec.get("layout", "title_content"), 1)
105
+ slide = prs.slides.add_slide(prs.slide_layouts[layout_idx])
106
+
107
+ if spec.get("background"):
108
+ fill = slide.background.fill
109
+ fill.solid()
110
+ fill.fore_color.rgb = RGBColor.from_string(spec["background"])
111
+ if spec.get("slide_number"):
112
+ copy_layout_placeholder(slide, 12)
113
+ if spec.get("footer"):
114
+ shape = copy_layout_placeholder(slide, 11)
115
+ if shape is not None:
116
+ shape.text_frame.text = spec["footer"]
117
+
118
+ if spec.get("title") is not None and slide.shapes.title is not None:
119
+ slide.shapes.title.text = spec["title"]
120
+ if spec.get("subtitle") is not None:
121
+ for ph in slide.placeholders:
122
+ if ph.placeholder_format.idx == 1:
123
+ ph.text = spec["subtitle"]
124
+ break
125
+ if spec.get("bullets"):
126
+ body = next((ph for ph in slide.placeholders
127
+ if ph.placeholder_format.idx != 0), None)
128
+ if body is None:
129
+ body = slide.shapes.add_textbox(Inches(0.5), Inches(1.5),
130
+ Inches(9), Inches(5))
131
+ add_bullets(body.text_frame, spec["bullets"])
132
+
133
+ for img in spec.get("images", []):
134
+ kwargs = {}
135
+ if img.get("width"):
136
+ kwargs["width"] = Inches(img["width"])
137
+ if img.get("height"):
138
+ kwargs["height"] = Inches(img["height"])
139
+ slide.shapes.add_picture(img["path"], Inches(img.get("left", 1)),
140
+ Inches(img.get("top", 1)), **kwargs)
141
+
142
+ for tbl in spec.get("tables", []):
143
+ rows = tbl["rows"]
144
+ shape = slide.shapes.add_table(
145
+ len(rows), len(rows[0]), Inches(tbl.get("left", 1)),
146
+ Inches(tbl.get("top", 2)), Inches(tbl.get("width", 6)),
147
+ Inches(tbl.get("height", 2)))
148
+ for r, row in enumerate(rows):
149
+ for c, val in enumerate(row):
150
+ shape.table.cell(r, c).text = str(val)
151
+
152
+ for shp in spec.get("shapes", []):
153
+ shape = slide.shapes.add_shape(
154
+ SHAPE_TYPES.get(shp.get("type", "rectangle"), MSO_SHAPE.RECTANGLE),
155
+ Inches(shp.get("left", 1)), Inches(shp.get("top", 1)),
156
+ Inches(shp.get("width", 2)), Inches(shp.get("height", 1)))
157
+ if shp.get("fill"):
158
+ shape.fill.solid()
159
+ shape.fill.fore_color.rgb = RGBColor.from_string(shp["fill"])
160
+ if shp.get("text"):
161
+ shape.text_frame.text = shp["text"]
162
+ if shp.get("text_color"):
163
+ run = shape.text_frame.paragraphs[0].runs[0]
164
+ run.font.color.rgb = RGBColor.from_string(shp["text_color"])
165
+
166
+ for cht in spec.get("charts", []):
167
+ data = CategoryChartData()
168
+ data.categories = cht["categories"]
169
+ for name, values in cht["series"].items():
170
+ data.add_series(name, values)
171
+ frame = slide.shapes.add_chart(
172
+ CHART_TYPES.get(cht.get("type", "bar"),
173
+ XL_CHART_TYPE.COLUMN_CLUSTERED),
174
+ Inches(cht.get("left", 1)), Inches(cht.get("top", 2)),
175
+ Inches(cht.get("width", 6)), Inches(cht.get("height", 4)), data)
176
+ if cht.get("title"):
177
+ frame.chart.has_title = True
178
+ frame.chart.chart_title.text_frame.text = cht["title"]
179
+
180
+ if spec.get("notes"):
181
+ slide.notes_slide.notes_text_frame.text = spec["notes"]
182
+ return slide
183
+
184
+
185
+ def main(argv=None):
186
+ if hasattr(sys.stdout, "reconfigure"):
187
+ sys.stdout.reconfigure(encoding="utf-8", errors="replace")
188
+ parser = argparse.ArgumentParser(
189
+ description="Create a .pptx deck from a JSON spec.",
190
+ epilog=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
191
+ parser.add_argument("spec", help="path to JSON deck spec")
192
+ parser.add_argument("output", help="output .pptx path")
193
+ args = parser.parse_args(argv)
194
+
195
+ with open(args.spec, encoding="utf-8") as fh:
196
+ spec = json.load(fh)
197
+
198
+ prs = Presentation()
199
+ if spec.get("slide_size", "16:9") == "16:9":
200
+ prs.slide_width, prs.slide_height = Inches(13.333), Inches(7.5)
201
+ else:
202
+ prs.slide_width, prs.slide_height = Inches(10), Inches(7.5)
203
+
204
+ for slide_spec in spec.get("slides", []):
205
+ build_slide(prs, slide_spec)
206
+
207
+ prs.save(args.output)
208
+ print(json.dumps({"ok": True, "output": args.output,
209
+ "slides": len(prs.slides._sldIdLst)}))
210
+ return 0
211
+
212
+
213
+ if __name__ == "__main__":
214
+ sys.exit(main())