@kolbo/kolbo-code-linux-arm64-musl 1.1.74 → 2.0.0

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 (239) hide show
  1. package/bin/kolbo +0 -0
  2. package/package.json +1 -1
  3. package/skills/brainstorming/SKILL.md +164 -0
  4. package/skills/brainstorming/scripts/frame-template.html +214 -0
  5. package/skills/brainstorming/scripts/helper.js +88 -0
  6. package/skills/brainstorming/scripts/server.cjs +354 -0
  7. package/skills/brainstorming/scripts/start-server.sh +148 -0
  8. package/skills/brainstorming/scripts/stop-server.sh +56 -0
  9. package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  10. package/skills/brainstorming/visual-companion.md +287 -0
  11. package/skills/dispatching-parallel-agents/SKILL.md +182 -0
  12. package/skills/docx/.skillfish.json +10 -0
  13. package/skills/docx/SKILL.md +196 -0
  14. package/skills/docx/docx-js.md +350 -0
  15. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  16. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  17. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  18. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  19. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  20. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  21. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  22. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  23. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  24. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  25. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  26. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  27. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  28. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  29. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  30. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  31. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  32. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  33. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  34. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  35. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  36. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  37. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  38. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  39. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  40. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  41. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  42. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  43. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  44. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  45. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  46. package/skills/docx/ooxml/schemas/mce/mc.xsd +75 -0
  47. package/skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
  48. package/skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
  49. package/skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
  50. package/skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
  51. package/skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
  52. package/skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  53. package/skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
  54. package/skills/docx/ooxml/scripts/pack.py +159 -0
  55. package/skills/docx/ooxml/scripts/unpack.py +29 -0
  56. package/skills/docx/ooxml/scripts/validate.py +69 -0
  57. package/skills/docx/ooxml/scripts/validation/__init__.py +15 -0
  58. package/skills/docx/ooxml/scripts/validation/base.py +951 -0
  59. package/skills/docx/ooxml/scripts/validation/docx.py +274 -0
  60. package/skills/docx/ooxml/scripts/validation/pptx.py +315 -0
  61. package/skills/docx/ooxml/scripts/validation/redlining.py +279 -0
  62. package/skills/docx/ooxml.md +599 -0
  63. package/skills/docx/scripts/__init__.py +1 -0
  64. package/skills/docx/scripts/document.py +1272 -0
  65. package/skills/docx/scripts/templates/comments.xml +3 -0
  66. package/skills/docx/scripts/templates/commentsExtended.xml +3 -0
  67. package/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
  68. package/skills/docx/scripts/templates/commentsIds.xml +3 -0
  69. package/skills/docx/scripts/templates/people.xml +3 -0
  70. package/skills/docx/scripts/utilities.py +374 -0
  71. package/skills/executing-plans/SKILL.md +70 -0
  72. package/skills/finishing-a-development-branch/SKILL.md +200 -0
  73. package/skills/fullstack-app/SKILL.md +621 -0
  74. package/skills/kolbo/SKILL.md +19 -263
  75. package/skills/ollama-vision/SKILL.md +105 -0
  76. package/skills/pdf/.skillfish.json +10 -0
  77. package/skills/pdf/FORMS.md +205 -0
  78. package/skills/pdf/REFERENCE.md +612 -0
  79. package/skills/pdf/SKILL.md +293 -0
  80. package/skills/pdf/scripts/check_bounding_boxes.py +70 -0
  81. package/skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
  82. package/skills/pdf/scripts/check_fillable_fields.py +12 -0
  83. package/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
  84. package/skills/pdf/scripts/create_validation_image.py +41 -0
  85. package/skills/pdf/scripts/extract_form_field_info.py +152 -0
  86. package/skills/pdf/scripts/fill_fillable_fields.py +114 -0
  87. package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
  88. package/skills/photo-studio/SKILL.md +122 -0
  89. package/skills/pptx/.skillfish.json +10 -0
  90. package/skills/pptx/SKILL.md +483 -0
  91. package/skills/pptx/html2pptx.md +626 -0
  92. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  93. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  94. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  95. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  96. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  97. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  98. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  99. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  100. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  101. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  102. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  103. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  104. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  105. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  106. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  107. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  108. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  109. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  110. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  111. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  112. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  113. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  114. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  115. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  116. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  117. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  118. package/skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  119. package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  120. package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  121. package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  122. package/skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  123. package/skills/pptx/ooxml/schemas/mce/mc.xsd +75 -0
  124. package/skills/pptx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
  125. package/skills/pptx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
  126. package/skills/pptx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
  127. package/skills/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
  128. package/skills/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
  129. package/skills/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  130. package/skills/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
  131. package/skills/pptx/ooxml/scripts/pack.py +159 -0
  132. package/skills/pptx/ooxml/scripts/unpack.py +29 -0
  133. package/skills/pptx/ooxml/scripts/validate.py +69 -0
  134. package/skills/pptx/ooxml/scripts/validation/__init__.py +15 -0
  135. package/skills/pptx/ooxml/scripts/validation/base.py +951 -0
  136. package/skills/pptx/ooxml/scripts/validation/docx.py +274 -0
  137. package/skills/pptx/ooxml/scripts/validation/pptx.py +315 -0
  138. package/skills/pptx/ooxml/scripts/validation/redlining.py +279 -0
  139. package/skills/pptx/ooxml.md +427 -0
  140. package/skills/pptx/scripts/html2pptx.js +995 -0
  141. package/skills/pptx/scripts/inventory.py +1020 -0
  142. package/skills/pptx/scripts/rearrange.py +231 -0
  143. package/skills/pptx/scripts/replace.py +385 -0
  144. package/skills/pptx/scripts/thumbnail.py +450 -0
  145. package/skills/receiving-code-review/SKILL.md +213 -0
  146. package/skills/requesting-code-review/SKILL.md +105 -0
  147. package/skills/requesting-code-review/code-reviewer.md +146 -0
  148. package/skills/subagent-driven-development/SKILL.md +277 -0
  149. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
  150. package/skills/subagent-driven-development/implementer-prompt.md +113 -0
  151. package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  152. package/skills/supabase/.skillfish.json +10 -0
  153. package/skills/supabase/SKILL.md +106 -0
  154. package/skills/supabase/assets/feedback-issue-template.md +17 -0
  155. package/skills/supabase/references/skill-feedback.md +17 -0
  156. package/skills/supabase-postgres-best-practices/.skillfish.json +10 -0
  157. package/skills/supabase-postgres-best-practices/SKILL.md +64 -0
  158. package/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
  159. package/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
  160. package/skills/supabase-postgres-best-practices/references/_template.md +34 -0
  161. package/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
  162. package/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
  163. package/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
  164. package/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
  165. package/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
  166. package/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
  167. package/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
  168. package/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
  169. package/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
  170. package/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
  171. package/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
  172. package/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
  173. package/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
  174. package/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
  175. package/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
  176. package/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
  177. package/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
  178. package/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
  179. package/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
  180. package/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
  181. package/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
  182. package/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
  183. package/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
  184. package/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
  185. package/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
  186. package/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
  187. package/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
  188. package/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
  189. package/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
  190. package/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
  191. package/skills/supabase-postgres-best-practices/references/security-rls-performance.md +57 -0
  192. package/skills/supabase-quickstart/SKILL.md +400 -0
  193. package/skills/systematic-debugging/CREATION-LOG.md +119 -0
  194. package/skills/systematic-debugging/SKILL.md +296 -0
  195. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  196. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  197. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  198. package/skills/systematic-debugging/find-polluter.sh +63 -0
  199. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  200. package/skills/systematic-debugging/test-academic.md +14 -0
  201. package/skills/systematic-debugging/test-pressure-1.md +58 -0
  202. package/skills/systematic-debugging/test-pressure-2.md +68 -0
  203. package/skills/systematic-debugging/test-pressure-3.md +69 -0
  204. package/skills/test-driven-development/SKILL.md +371 -0
  205. package/skills/test-driven-development/testing-anti-patterns.md +299 -0
  206. package/skills/using-git-worktrees/SKILL.md +218 -0
  207. package/skills/using-superpowers/SKILL.md +115 -0
  208. package/skills/using-superpowers/references/codex-tools.md +100 -0
  209. package/skills/using-superpowers/references/gemini-tools.md +33 -0
  210. package/skills/verification-before-completion/SKILL.md +139 -0
  211. package/skills/video-production/SKILL.md +8 -7
  212. package/skills/writing-plans/SKILL.md +152 -0
  213. package/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  214. package/skills/writing-skills/SKILL.md +655 -0
  215. package/skills/writing-skills/anthropic-best-practices.md +1150 -0
  216. package/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  217. package/skills/writing-skills/graphviz-conventions.dot +172 -0
  218. package/skills/writing-skills/persuasion-principles.md +187 -0
  219. package/skills/writing-skills/render-graphs.js +168 -0
  220. package/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  221. package/skills/xlsx/.skillfish.json +10 -0
  222. package/skills/xlsx/SKILL.md +288 -0
  223. package/skills/xlsx/recalc.py +178 -0
  224. package/skills/color-grading/SKILL.md +0 -152
  225. package/skills/ffmpeg-patterns/SKILL.md +0 -240
  226. package/skills/image-prompting-guide/SKILL.md +0 -143
  227. package/skills/music-prompting/SKILL.md +0 -146
  228. package/skills/production-review/SKILL.md +0 -152
  229. package/skills/short-form-video/SKILL.md +0 -168
  230. package/skills/sound-design/SKILL.md +0 -154
  231. package/skills/storytelling/SKILL.md +0 -139
  232. package/skills/subtitle-production/SKILL.md +0 -244
  233. package/skills/subtitle-production/reference/burn_to_video.py +0 -222
  234. package/skills/subtitle-production/reference/export_srts.py +0 -127
  235. package/skills/subtitle-production/reference/gen_srt.py +0 -42
  236. package/skills/typography-video/SKILL.md +0 -182
  237. package/skills/typography-video/reference/KineticTitleScene.tsx +0 -345
  238. package/skills/video-editing/SKILL.md +0 -128
  239. package/skills/video-prompting-guide/SKILL.md +0 -268
@@ -0,0 +1,152 @@
1
+ import json
2
+ import sys
3
+
4
+ from pypdf import PdfReader
5
+
6
+
7
+ # Extracts data for the fillable form fields in a PDF and outputs JSON that
8
+ # Claude uses to fill the fields. See FORMS.md.
9
+
10
+
11
+ # This matches the format used by PdfReader `get_fields` and `update_page_form_field_values` methods.
12
+ def get_full_annotation_field_id(annotation):
13
+ components = []
14
+ while annotation:
15
+ field_name = annotation.get('/T')
16
+ if field_name:
17
+ components.append(field_name)
18
+ annotation = annotation.get('/Parent')
19
+ return ".".join(reversed(components)) if components else None
20
+
21
+
22
+ def make_field_dict(field, field_id):
23
+ field_dict = {"field_id": field_id}
24
+ ft = field.get('/FT')
25
+ if ft == "/Tx":
26
+ field_dict["type"] = "text"
27
+ elif ft == "/Btn":
28
+ field_dict["type"] = "checkbox" # radio groups handled separately
29
+ states = field.get("/_States_", [])
30
+ if len(states) == 2:
31
+ # "/Off" seems to always be the unchecked value, as suggested by
32
+ # https://opensource.adobe.com/dc-acrobat-sdk-docs/standards/pdfstandards/pdf/PDF32000_2008.pdf#page=448
33
+ # It can be either first or second in the "/_States_" list.
34
+ if "/Off" in states:
35
+ field_dict["checked_value"] = states[0] if states[0] != "/Off" else states[1]
36
+ field_dict["unchecked_value"] = "/Off"
37
+ else:
38
+ print(f"Unexpected state values for checkbox `${field_id}`. Its checked and unchecked values may not be correct; if you're trying to check it, visually verify the results.")
39
+ field_dict["checked_value"] = states[0]
40
+ field_dict["unchecked_value"] = states[1]
41
+ elif ft == "/Ch":
42
+ field_dict["type"] = "choice"
43
+ states = field.get("/_States_", [])
44
+ field_dict["choice_options"] = [{
45
+ "value": state[0],
46
+ "text": state[1],
47
+ } for state in states]
48
+ else:
49
+ field_dict["type"] = f"unknown ({ft})"
50
+ return field_dict
51
+
52
+
53
+ # Returns a list of fillable PDF fields:
54
+ # [
55
+ # {
56
+ # "field_id": "name",
57
+ # "page": 1,
58
+ # "type": ("text", "checkbox", "radio_group", or "choice")
59
+ # // Per-type additional fields described in FORMS.md
60
+ # },
61
+ # ]
62
+ def get_field_info(reader: PdfReader):
63
+ fields = reader.get_fields()
64
+
65
+ field_info_by_id = {}
66
+ possible_radio_names = set()
67
+
68
+ for field_id, field in fields.items():
69
+ # Skip if this is a container field with children, except that it might be
70
+ # a parent group for radio button options.
71
+ if field.get("/Kids"):
72
+ if field.get("/FT") == "/Btn":
73
+ possible_radio_names.add(field_id)
74
+ continue
75
+ field_info_by_id[field_id] = make_field_dict(field, field_id)
76
+
77
+ # Bounding rects are stored in annotations in page objects.
78
+
79
+ # Radio button options have a separate annotation for each choice;
80
+ # all choices have the same field name.
81
+ # See https://westhealth.github.io/exploring-fillable-forms-with-pdfrw.html
82
+ radio_fields_by_id = {}
83
+
84
+ for page_index, page in enumerate(reader.pages):
85
+ annotations = page.get('/Annots', [])
86
+ for ann in annotations:
87
+ field_id = get_full_annotation_field_id(ann)
88
+ if field_id in field_info_by_id:
89
+ field_info_by_id[field_id]["page"] = page_index + 1
90
+ field_info_by_id[field_id]["rect"] = ann.get('/Rect')
91
+ elif field_id in possible_radio_names:
92
+ try:
93
+ # ann['/AP']['/N'] should have two items. One of them is '/Off',
94
+ # the other is the active value.
95
+ on_values = [v for v in ann["/AP"]["/N"] if v != "/Off"]
96
+ except KeyError:
97
+ continue
98
+ if len(on_values) == 1:
99
+ rect = ann.get("/Rect")
100
+ if field_id not in radio_fields_by_id:
101
+ radio_fields_by_id[field_id] = {
102
+ "field_id": field_id,
103
+ "type": "radio_group",
104
+ "page": page_index + 1,
105
+ "radio_options": [],
106
+ }
107
+ # Note: at least on macOS 15.7, Preview.app doesn't show selected
108
+ # radio buttons correctly. (It does if you remove the leading slash
109
+ # from the value, but that causes them not to appear correctly in
110
+ # Chrome/Firefox/Acrobat/etc).
111
+ radio_fields_by_id[field_id]["radio_options"].append({
112
+ "value": on_values[0],
113
+ "rect": rect,
114
+ })
115
+
116
+ # Some PDFs have form field definitions without corresponding annotations,
117
+ # so we can't tell where they are. Ignore these fields for now.
118
+ fields_with_location = []
119
+ for field_info in field_info_by_id.values():
120
+ if "page" in field_info:
121
+ fields_with_location.append(field_info)
122
+ else:
123
+ print(f"Unable to determine location for field id: {field_info.get('field_id')}, ignoring")
124
+
125
+ # Sort by page number, then Y position (flipped in PDF coordinate system), then X.
126
+ def sort_key(f):
127
+ if "radio_options" in f:
128
+ rect = f["radio_options"][0]["rect"] or [0, 0, 0, 0]
129
+ else:
130
+ rect = f.get("rect") or [0, 0, 0, 0]
131
+ adjusted_position = [-rect[1], rect[0]]
132
+ return [f.get("page"), adjusted_position]
133
+
134
+ sorted_fields = fields_with_location + list(radio_fields_by_id.values())
135
+ sorted_fields.sort(key=sort_key)
136
+
137
+ return sorted_fields
138
+
139
+
140
+ def write_field_info(pdf_path: str, json_output_path: str):
141
+ reader = PdfReader(pdf_path)
142
+ field_info = get_field_info(reader)
143
+ with open(json_output_path, "w") as f:
144
+ json.dump(field_info, f, indent=2)
145
+ print(f"Wrote {len(field_info)} fields to {json_output_path}")
146
+
147
+
148
+ if __name__ == "__main__":
149
+ if len(sys.argv) != 3:
150
+ print("Usage: extract_form_field_info.py [input pdf] [output json]")
151
+ sys.exit(1)
152
+ write_field_info(sys.argv[1], sys.argv[2])
@@ -0,0 +1,114 @@
1
+ import json
2
+ import sys
3
+
4
+ from pypdf import PdfReader, PdfWriter
5
+
6
+ from extract_form_field_info import get_field_info
7
+
8
+
9
+ # Fills fillable form fields in a PDF. See FORMS.md.
10
+
11
+
12
+ def fill_pdf_fields(input_pdf_path: str, fields_json_path: str, output_pdf_path: str):
13
+ with open(fields_json_path) as f:
14
+ fields = json.load(f)
15
+ # Group by page number.
16
+ fields_by_page = {}
17
+ for field in fields:
18
+ if "value" in field:
19
+ field_id = field["field_id"]
20
+ page = field["page"]
21
+ if page not in fields_by_page:
22
+ fields_by_page[page] = {}
23
+ fields_by_page[page][field_id] = field["value"]
24
+
25
+ reader = PdfReader(input_pdf_path)
26
+
27
+ has_error = False
28
+ field_info = get_field_info(reader)
29
+ fields_by_ids = {f["field_id"]: f for f in field_info}
30
+ for field in fields:
31
+ existing_field = fields_by_ids.get(field["field_id"])
32
+ if not existing_field:
33
+ has_error = True
34
+ print(f"ERROR: `{field['field_id']}` is not a valid field ID")
35
+ elif field["page"] != existing_field["page"]:
36
+ has_error = True
37
+ print(f"ERROR: Incorrect page number for `{field['field_id']}` (got {field['page']}, expected {existing_field['page']})")
38
+ else:
39
+ if "value" in field:
40
+ err = validation_error_for_field_value(existing_field, field["value"])
41
+ if err:
42
+ print(err)
43
+ has_error = True
44
+ if has_error:
45
+ sys.exit(1)
46
+
47
+ writer = PdfWriter(clone_from=reader)
48
+ for page, field_values in fields_by_page.items():
49
+ writer.update_page_form_field_values(writer.pages[page - 1], field_values, auto_regenerate=False)
50
+
51
+ # This seems to be necessary for many PDF viewers to format the form values correctly.
52
+ # It may cause the viewer to show a "save changes" dialog even if the user doesn't make any changes.
53
+ writer.set_need_appearances_writer(True)
54
+
55
+ with open(output_pdf_path, "wb") as f:
56
+ writer.write(f)
57
+
58
+
59
+ def validation_error_for_field_value(field_info, field_value):
60
+ field_type = field_info["type"]
61
+ field_id = field_info["field_id"]
62
+ if field_type == "checkbox":
63
+ checked_val = field_info["checked_value"]
64
+ unchecked_val = field_info["unchecked_value"]
65
+ if field_value != checked_val and field_value != unchecked_val:
66
+ return f'ERROR: Invalid value "{field_value}" for checkbox field "{field_id}". The checked value is "{checked_val}" and the unchecked value is "{unchecked_val}"'
67
+ elif field_type == "radio_group":
68
+ option_values = [opt["value"] for opt in field_info["radio_options"]]
69
+ if field_value not in option_values:
70
+ return f'ERROR: Invalid value "{field_value}" for radio group field "{field_id}". Valid values are: {option_values}'
71
+ elif field_type == "choice":
72
+ choice_values = [opt["value"] for opt in field_info["choice_options"]]
73
+ if field_value not in choice_values:
74
+ return f'ERROR: Invalid value "{field_value}" for choice field "{field_id}". Valid values are: {choice_values}'
75
+ return None
76
+
77
+
78
+ # pypdf (at least version 5.7.0) has a bug when setting the value for a selection list field.
79
+ # In _writer.py around line 966:
80
+ #
81
+ # if field.get(FA.FT, "/Tx") == "/Ch" and field_flags & FA.FfBits.Combo == 0:
82
+ # txt = "\n".join(annotation.get_inherited(FA.Opt, []))
83
+ #
84
+ # The problem is that for selection lists, `get_inherited` returns a list of two-element lists like
85
+ # [["value1", "Text 1"], ["value2", "Text 2"], ...]
86
+ # This causes `join` to throw a TypeError because it expects an iterable of strings.
87
+ # The horrible workaround is to patch `get_inherited` to return a list of the value strings.
88
+ # We call the original method and adjust the return value only if the argument to `get_inherited`
89
+ # is `FA.Opt` and if the return value is a list of two-element lists.
90
+ def monkeypatch_pydpf_method():
91
+ from pypdf.generic import DictionaryObject
92
+ from pypdf.constants import FieldDictionaryAttributes
93
+
94
+ original_get_inherited = DictionaryObject.get_inherited
95
+
96
+ def patched_get_inherited(self, key: str, default = None):
97
+ result = original_get_inherited(self, key, default)
98
+ if key == FieldDictionaryAttributes.Opt:
99
+ if isinstance(result, list) and all(isinstance(v, list) and len(v) == 2 for v in result):
100
+ result = [r[0] for r in result]
101
+ return result
102
+
103
+ DictionaryObject.get_inherited = patched_get_inherited
104
+
105
+
106
+ if __name__ == "__main__":
107
+ if len(sys.argv) != 4:
108
+ print("Usage: fill_fillable_fields.py [input pdf] [field_values.json] [output pdf]")
109
+ sys.exit(1)
110
+ monkeypatch_pydpf_method()
111
+ input_pdf = sys.argv[1]
112
+ fields_json = sys.argv[2]
113
+ output_pdf = sys.argv[3]
114
+ fill_pdf_fields(input_pdf, fields_json, output_pdf)
@@ -0,0 +1,108 @@
1
+ import json
2
+ import sys
3
+
4
+ from pypdf import PdfReader, PdfWriter
5
+ from pypdf.annotations import FreeText
6
+
7
+
8
+ # Fills a PDF by adding text annotations defined in `fields.json`. See FORMS.md.
9
+
10
+
11
+ def transform_coordinates(bbox, image_width, image_height, pdf_width, pdf_height):
12
+ """Transform bounding box from image coordinates to PDF coordinates"""
13
+ # Image coordinates: origin at top-left, y increases downward
14
+ # PDF coordinates: origin at bottom-left, y increases upward
15
+ x_scale = pdf_width / image_width
16
+ y_scale = pdf_height / image_height
17
+
18
+ left = bbox[0] * x_scale
19
+ right = bbox[2] * x_scale
20
+
21
+ # Flip Y coordinates for PDF
22
+ top = pdf_height - (bbox[1] * y_scale)
23
+ bottom = pdf_height - (bbox[3] * y_scale)
24
+
25
+ return left, bottom, right, top
26
+
27
+
28
+ def fill_pdf_form(input_pdf_path, fields_json_path, output_pdf_path):
29
+ """Fill the PDF form with data from fields.json"""
30
+
31
+ # `fields.json` format described in FORMS.md.
32
+ with open(fields_json_path, "r") as f:
33
+ fields_data = json.load(f)
34
+
35
+ # Open the PDF
36
+ reader = PdfReader(input_pdf_path)
37
+ writer = PdfWriter()
38
+
39
+ # Copy all pages to writer
40
+ writer.append(reader)
41
+
42
+ # Get PDF dimensions for each page
43
+ pdf_dimensions = {}
44
+ for i, page in enumerate(reader.pages):
45
+ mediabox = page.mediabox
46
+ pdf_dimensions[i + 1] = [mediabox.width, mediabox.height]
47
+
48
+ # Process each form field
49
+ annotations = []
50
+ for field in fields_data["form_fields"]:
51
+ page_num = field["page_number"]
52
+
53
+ # Get page dimensions and transform coordinates.
54
+ page_info = next(p for p in fields_data["pages"] if p["page_number"] == page_num)
55
+ image_width = page_info["image_width"]
56
+ image_height = page_info["image_height"]
57
+ pdf_width, pdf_height = pdf_dimensions[page_num]
58
+
59
+ transformed_entry_box = transform_coordinates(
60
+ field["entry_bounding_box"],
61
+ image_width, image_height,
62
+ pdf_width, pdf_height
63
+ )
64
+
65
+ # Skip empty fields
66
+ if "entry_text" not in field or "text" not in field["entry_text"]:
67
+ continue
68
+ entry_text = field["entry_text"]
69
+ text = entry_text["text"]
70
+ if not text:
71
+ continue
72
+
73
+ font_name = entry_text.get("font", "Arial")
74
+ font_size = str(entry_text.get("font_size", 14)) + "pt"
75
+ font_color = entry_text.get("font_color", "000000")
76
+
77
+ # Font size/color seems to not work reliably across viewers:
78
+ # https://github.com/py-pdf/pypdf/issues/2084
79
+ annotation = FreeText(
80
+ text=text,
81
+ rect=transformed_entry_box,
82
+ font=font_name,
83
+ font_size=font_size,
84
+ font_color=font_color,
85
+ border_color=None,
86
+ background_color=None,
87
+ )
88
+ annotations.append(annotation)
89
+ # page_number is 0-based for pypdf
90
+ writer.add_annotation(page_number=page_num - 1, annotation=annotation)
91
+
92
+ # Save the filled PDF
93
+ with open(output_pdf_path, "wb") as output:
94
+ writer.write(output)
95
+
96
+ print(f"Successfully filled PDF form and saved to {output_pdf_path}")
97
+ print(f"Added {len(annotations)} text annotations")
98
+
99
+
100
+ if __name__ == "__main__":
101
+ if len(sys.argv) != 4:
102
+ print("Usage: fill_pdf_form_with_annotations.py [input pdf] [fields.json] [output pdf]")
103
+ sys.exit(1)
104
+ input_pdf = sys.argv[1]
105
+ fields_json = sys.argv[2]
106
+ output_pdf = sys.argv[3]
107
+
108
+ fill_pdf_form(input_pdf, fields_json, output_pdf)
@@ -0,0 +1,122 @@
1
+ ---
2
+ name: photo-studio
3
+ description: >
4
+ Local AI photo generation and editing using FLUX.2 Klein 4B, Z-Image Turbo, and Ollama Gemma4.
5
+ Use when the user wants to generate or edit images locally (no API cost, no rate limits).
6
+ Models at I:/AI-Models/. Script at G:/Projects/Kolbo.AI/github/training-loras/scripts/photo-studio.py
7
+ Keywords: generate image, edit image, flux klein, z-image turbo, local diffusion, photo studio, gemma4
8
+ ---
9
+
10
+ # Photo Studio — Local AI Image Generation & Editing
11
+
12
+ ## Infrastructure
13
+
14
+ | Component | Path |
15
+ |-----------|------|
16
+ | Script | `G:/Projects/Kolbo.AI/github/training-loras/scripts/photo-studio.py` |
17
+ | Python venv | `G:/Projects/Kolbo.AI/github/ai-toolkit/venv/Scripts/python.exe` |
18
+ | FLUX.2 Klein 4B | `I:/AI-Models/flux2-klein-4b/` |
19
+ | Z-Image Turbo | `I:/AI-Models/z-image-turbo/` |
20
+ | Z-Image Adapter | `I:/AI-Models/z-image-turbo-adapter/zimage_turbo_training_adapter_v2.safetensors` |
21
+ | LLM / Vision | Ollama Gemma4 (runs locally at `http://localhost:11434`) |
22
+
23
+ ## How to Run
24
+
25
+ Always use the ai-toolkit venv (has Flux2KleinPipeline + ZImagePipeline + ollama package):
26
+
27
+ ```bash
28
+ "G:/Projects/Kolbo.AI/github/ai-toolkit/venv/Scripts/python.exe" \
29
+ "G:/Projects/Kolbo.AI/github/training-loras/scripts/photo-studio.py" \
30
+ [args...]
31
+ ```
32
+
33
+ ## CLI Reference
34
+
35
+ | Flag | Default | Description |
36
+ |------|---------|-------------|
37
+ | `--prompt "..."` | — | Text prompt |
38
+ | `--image path.jpg` | — | Input image (FLUX editing only) |
39
+ | `--model flux\|zimage` | `flux` | Model to use |
40
+ | `--output result.jpg` | `output_<ts>.jpg` | Output path |
41
+ | `--width N` | 1152 | Width in pixels |
42
+ | `--height N` | 2048 | Height in pixels |
43
+ | `--steps N` | 20 | Inference steps |
44
+ | `--cfg N` | 3.5 | Guidance scale |
45
+ | `--seed N` | random | Deterministic seed |
46
+ | `--analyze` | off | Analyze `--image` with Gemma4, use as base description |
47
+ | `--enhance` | off | Enhance `--prompt` with Gemma4 before generating |
48
+ | `--adapter` | off | Load Z-Image Turbo adapter (zimage only) |
49
+
50
+ ## Common Recipes
51
+
52
+ ### Text-to-image (portrait)
53
+ ```bash
54
+ python photo-studio.py \
55
+ --prompt "full-body front view, woman in designer dress, cinematic lighting" \
56
+ --model flux --width 1152 --height 2048
57
+ ```
58
+
59
+ ### Edit existing image
60
+ ```bash
61
+ python photo-studio.py \
62
+ --image input.jpg \
63
+ --prompt "wide full-body view of the subject, cinematic" \
64
+ --model flux --width 1152 --height 2048
65
+ ```
66
+
67
+ ### Analyze image and generate variation
68
+ ```bash
69
+ python photo-studio.py \
70
+ --image char.jpg --analyze \
71
+ --prompt "standing upright, full body" \
72
+ --model flux
73
+ ```
74
+
75
+ ### Auto-enhance a short prompt then generate
76
+ ```bash
77
+ python photo-studio.py \
78
+ --prompt "street fashion guy" --enhance \
79
+ --model zimage --width 1152 --height 2048
80
+ ```
81
+
82
+ ### Z-Image with adapter (MIRAGE-style)
83
+ ```bash
84
+ python photo-studio.py \
85
+ --prompt "cinematic full-body portrait, editorial" \
86
+ --model zimage --adapter --width 1152 --height 1536 --cfg 4.0
87
+ ```
88
+
89
+ ## Model Notes
90
+
91
+ ### FLUX.2 Klein 4B (`--model flux`)
92
+ - Class: `Flux2KleinPipeline` (diffusers)
93
+ - Supports both text-to-image AND image editing via `image` param
94
+ - Good default: `--steps 20 --cfg 3.5`
95
+ - ~13GB VRAM needed
96
+
97
+ ### Z-Image Turbo (`--model zimage`)
98
+ - Class: `ZImagePipeline` (diffusers), uses Qwen3 text encoder
99
+ - Text-to-image ONLY (no image editing)
100
+ - **8 NFEs, no CFG** — distilled model, per official README. More steps = waste, CFG > 0 = wrong
101
+ - Default: `--steps 8 --cfg 0.0 --width 1152 --height 2048` (~30s per image)
102
+ - Add `--adapter` to load the v2 training adapter
103
+
104
+ ### Ollama Gemma4 (vision + LLM)
105
+ - Used for `--analyze` (describe input image) and `--enhance` (expand prompt)
106
+ - Runs locally, no API key, no rate limits
107
+ - Model: `gemma4` (9.6GB, multimodal)
108
+ - Ollama auto-starts on Windows boot
109
+
110
+ ## When to use which model
111
+
112
+ | Task | Model |
113
+ |------|-------|
114
+ | Edit an existing image | `flux` |
115
+ | Character body panel generation | `flux` |
116
+ | MIRAGE-style portraits | `zimage --adapter` |
117
+ | Quick text-to-image | `flux` or `zimage` |
118
+ | Portrait + face reference | `flux --image face.jpg` |
119
+
120
+ ## Prompt Tips (Gemma4 is the default prompter)
121
+
122
+ When the user gives a short/vague prompt, always use `--enhance` to let Gemma4 expand it. For image editing, pair `--analyze --enhance` to get the best context from the source image.
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 2,
3
+ "name": "pptx",
4
+ "owner": "tfriedel",
5
+ "repo": "claude-office-skills",
6
+ "path": "public/pptx",
7
+ "branch": "main",
8
+ "sha": "6629017e20c2eeea08cdaa427892f5b5699c58b1",
9
+ "source": "manual"
10
+ }