@farazirfan/costar-server-executor 1.7.37 → 1.7.39

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 (253) hide show
  1. package/dist/agent/agent.d.ts +90 -0
  2. package/dist/agent/agent.d.ts.map +1 -1
  3. package/dist/agent/agent.js +606 -0
  4. package/dist/agent/agent.js.map +1 -1
  5. package/dist/agent/pi-embedded-runner/run.d.ts.map +1 -1
  6. package/dist/agent/pi-embedded-runner/run.js +2 -1
  7. package/dist/agent/pi-embedded-runner/run.js.map +1 -1
  8. package/dist/agent/pi-embedded-runner/system-prompt.d.ts.map +1 -1
  9. package/dist/agent/pi-embedded-runner/system-prompt.js +16 -37
  10. package/dist/agent/pi-embedded-runner/system-prompt.js.map +1 -1
  11. package/dist/agent/pi-embedded-runner/tools.d.ts +4 -1
  12. package/dist/agent/pi-embedded-runner/tools.d.ts.map +1 -1
  13. package/dist/agent/pi-embedded-runner/tools.js +3 -1
  14. package/dist/agent/pi-embedded-runner/tools.js.map +1 -1
  15. package/dist/agent/pi-embedded-runner/types.d.ts +4 -0
  16. package/dist/agent/pi-embedded-runner/types.d.ts.map +1 -1
  17. package/dist/cli/env-loader.d.ts.map +1 -1
  18. package/dist/cli/env-loader.js +1 -0
  19. package/dist/cli/env-loader.js.map +1 -1
  20. package/dist/cli/setup.js +2 -2
  21. package/dist/cli/setup.js.map +1 -1
  22. package/dist/cron/normalize.d.ts +31 -0
  23. package/dist/cron/normalize.d.ts.map +1 -0
  24. package/dist/cron/normalize.js +211 -0
  25. package/dist/cron/normalize.js.map +1 -0
  26. package/dist/cron/scheduler.d.ts +33 -3
  27. package/dist/cron/scheduler.d.ts.map +1 -1
  28. package/dist/cron/scheduler.js +253 -48
  29. package/dist/cron/scheduler.js.map +1 -1
  30. package/dist/heartbeat/runner.d.ts +27 -12
  31. package/dist/heartbeat/runner.d.ts.map +1 -1
  32. package/dist/heartbeat/runner.js +82 -104
  33. package/dist/heartbeat/runner.js.map +1 -1
  34. package/dist/infra/heartbeat-events-filter.d.ts +29 -0
  35. package/dist/infra/heartbeat-events-filter.d.ts.map +1 -0
  36. package/dist/infra/heartbeat-events-filter.js +80 -0
  37. package/dist/infra/heartbeat-events-filter.js.map +1 -0
  38. package/dist/infra/index.d.ts +9 -0
  39. package/dist/infra/index.d.ts.map +1 -0
  40. package/dist/infra/index.js +9 -0
  41. package/dist/infra/index.js.map +1 -0
  42. package/dist/infra/system-events.d.ts +58 -2
  43. package/dist/infra/system-events.d.ts.map +1 -1
  44. package/dist/infra/system-events.js +80 -14
  45. package/dist/infra/system-events.js.map +1 -1
  46. package/dist/server.d.ts.map +1 -1
  47. package/dist/server.js +6 -1
  48. package/dist/server.js.map +1 -1
  49. package/dist/services/platform-keys.d.ts +19 -0
  50. package/dist/services/platform-keys.d.ts.map +1 -0
  51. package/dist/services/platform-keys.js +74 -0
  52. package/dist/services/platform-keys.js.map +1 -0
  53. package/dist/subagent/registry.d.ts +96 -0
  54. package/dist/subagent/registry.d.ts.map +1 -0
  55. package/dist/subagent/registry.js +180 -0
  56. package/dist/subagent/registry.js.map +1 -0
  57. package/dist/tools/complete-turn.d.ts +2 -2
  58. package/dist/tools/complete-turn.js +10 -10
  59. package/dist/tools/complete-turn.js.map +1 -1
  60. package/dist/tools/contacts.d.ts +13 -0
  61. package/dist/tools/contacts.d.ts.map +1 -0
  62. package/dist/tools/contacts.js +80 -0
  63. package/dist/tools/contacts.js.map +1 -0
  64. package/dist/tools/cron.d.ts +17 -2
  65. package/dist/tools/cron.d.ts.map +1 -1
  66. package/dist/tools/cron.js +117 -35
  67. package/dist/tools/cron.js.map +1 -1
  68. package/dist/tools/google-maps.d.ts +6 -6
  69. package/dist/tools/google-maps.d.ts.map +1 -1
  70. package/dist/tools/google-maps.js +207 -262
  71. package/dist/tools/google-maps.js.map +1 -1
  72. package/dist/tools/index.d.ts +17 -7
  73. package/dist/tools/index.d.ts.map +1 -1
  74. package/dist/tools/index.js +40 -9
  75. package/dist/tools/index.js.map +1 -1
  76. package/dist/tools/phone-call.d.ts +11 -0
  77. package/dist/tools/phone-call.d.ts.map +1 -0
  78. package/dist/tools/phone-call.js +151 -0
  79. package/dist/tools/phone-call.js.map +1 -0
  80. package/dist/tools/sessions-spawn.d.ts +33 -0
  81. package/dist/tools/sessions-spawn.d.ts.map +1 -0
  82. package/dist/tools/sessions-spawn.js +164 -0
  83. package/dist/tools/sessions-spawn.js.map +1 -0
  84. package/dist/tools/spotify.d.ts +12 -0
  85. package/dist/tools/spotify.d.ts.map +1 -0
  86. package/dist/tools/spotify.js +251 -0
  87. package/dist/tools/spotify.js.map +1 -0
  88. package/dist/tools/subagents.d.ts +23 -0
  89. package/dist/tools/subagents.d.ts.map +1 -0
  90. package/dist/tools/subagents.js +209 -0
  91. package/dist/tools/subagents.js.map +1 -0
  92. package/dist/tools/whatsapp.d.ts +13 -0
  93. package/dist/tools/whatsapp.d.ts.map +1 -0
  94. package/dist/tools/whatsapp.js +215 -0
  95. package/dist/tools/whatsapp.js.map +1 -0
  96. package/dist/tools/youtube.d.ts +12 -0
  97. package/dist/tools/youtube.d.ts.map +1 -0
  98. package/dist/tools/youtube.js +218 -0
  99. package/dist/tools/youtube.js.map +1 -0
  100. package/dist/utils/asterizk-auth.d.ts +43 -0
  101. package/dist/utils/asterizk-auth.d.ts.map +1 -0
  102. package/dist/utils/asterizk-auth.js +125 -0
  103. package/dist/utils/asterizk-auth.js.map +1 -0
  104. package/dist/web-server.d.ts.map +1 -1
  105. package/dist/web-server.js +132 -0
  106. package/dist/web-server.js.map +1 -1
  107. package/dist/workspace/index.d.ts +3 -4
  108. package/dist/workspace/index.d.ts.map +1 -1
  109. package/dist/workspace/index.js +3 -4
  110. package/dist/workspace/index.js.map +1 -1
  111. package/dist/workspace/templates.d.ts +8 -7
  112. package/dist/workspace/templates.d.ts.map +1 -1
  113. package/dist/workspace/templates.js +18 -127
  114. package/dist/workspace/templates.js.map +1 -1
  115. package/dist/workspace/workspace.d.ts +2 -4
  116. package/dist/workspace/workspace.d.ts.map +1 -1
  117. package/dist/workspace/workspace.js +7 -16
  118. package/dist/workspace/workspace.js.map +1 -1
  119. package/package.json +1 -1
  120. package/public/index.html +231 -0
  121. package/skills/docx/SKILL.md +468 -0
  122. package/skills/docx/scripts/__init__.py +1 -0
  123. package/skills/docx/scripts/accept_changes.py +181 -0
  124. package/skills/docx/scripts/comment.py +347 -0
  125. package/skills/docx/scripts/helpers/__init__.py +0 -0
  126. package/skills/docx/scripts/helpers/merge_runs.py +231 -0
  127. package/skills/docx/scripts/helpers/simplify_redlines.py +240 -0
  128. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  129. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  130. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  131. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  132. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  133. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  134. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  135. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  136. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  137. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  138. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  139. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  140. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  141. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  142. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  143. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  144. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  145. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  146. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  147. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  148. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  149. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  150. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  151. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  152. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  153. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  154. package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  155. package/skills/docx/scripts/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  156. package/skills/docx/scripts/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  157. package/skills/docx/scripts/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  158. package/skills/docx/scripts/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  159. package/skills/docx/scripts/ooxml/schemas/mce/mc.xsd +75 -0
  160. package/skills/docx/scripts/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
  161. package/skills/docx/scripts/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
  162. package/skills/docx/scripts/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
  163. package/skills/docx/scripts/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
  164. package/skills/docx/scripts/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
  165. package/skills/docx/scripts/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  166. package/skills/docx/scripts/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
  167. package/skills/docx/scripts/ooxml/scripts/pack.py +159 -0
  168. package/skills/docx/scripts/ooxml/scripts/unpack.py +29 -0
  169. package/skills/docx/scripts/ooxml/scripts/validate.py +106 -0
  170. package/skills/docx/scripts/ooxml/scripts/validation/__init__.py +15 -0
  171. package/skills/docx/scripts/ooxml/scripts/validation/base.py +1023 -0
  172. package/skills/docx/scripts/ooxml/scripts/validation/docx.py +519 -0
  173. package/skills/docx/scripts/ooxml/scripts/validation/pptx.py +315 -0
  174. package/skills/docx/scripts/ooxml/scripts/validation/redlining.py +284 -0
  175. package/skills/docx/scripts/pack.py +166 -0
  176. package/skills/docx/scripts/templates/comments.xml +3 -0
  177. package/skills/docx/scripts/templates/commentsExtended.xml +3 -0
  178. package/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
  179. package/skills/docx/scripts/templates/commentsIds.xml +3 -0
  180. package/skills/docx/scripts/templates/people.xml +3 -0
  181. package/skills/docx/scripts/unpack.py +134 -0
  182. package/skills/longform-video-generation/SKILL.md +298 -0
  183. package/skills/longform-video-generation/references/advanced_techniques.md +474 -0
  184. package/skills/longform-video-generation/references/google_api_guide.md +288 -0
  185. package/skills/longform-video-generation/scripts/video_generator.py +579 -0
  186. package/skills/pdf/FORMS.md +305 -0
  187. package/skills/pdf/REFERENCE.md +612 -0
  188. package/skills/pdf/SKILL.md +293 -0
  189. package/skills/pdf/scripts/check_bounding_boxes.py +70 -0
  190. package/skills/pdf/scripts/check_fillable_fields.py +12 -0
  191. package/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
  192. package/skills/pdf/scripts/create_validation_image.py +41 -0
  193. package/skills/pdf/scripts/extract_form_field_info.py +152 -0
  194. package/skills/pdf/scripts/extract_form_structure.py +124 -0
  195. package/skills/pdf/scripts/fill_fillable_fields.py +116 -0
  196. package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +136 -0
  197. package/skills/pptx/SKILL.md +171 -0
  198. package/skills/pptx/editing.md +205 -0
  199. package/skills/pptx/pptxgenjs.md +377 -0
  200. package/skills/pptx/scripts/add_slide.py +225 -0
  201. package/skills/pptx/scripts/clean.py +309 -0
  202. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  203. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  204. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  205. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  206. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  207. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  208. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  209. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  210. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  211. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  212. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  213. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  214. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  215. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  216. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  217. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  218. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  219. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  220. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  221. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  222. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  223. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  224. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  225. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  226. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  227. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  228. package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  229. package/skills/pptx/scripts/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  230. package/skills/pptx/scripts/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  231. package/skills/pptx/scripts/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  232. package/skills/pptx/scripts/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  233. package/skills/pptx/scripts/ooxml/schemas/mce/mc.xsd +75 -0
  234. package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
  235. package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
  236. package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
  237. package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
  238. package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
  239. package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  240. package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
  241. package/skills/pptx/scripts/ooxml/scripts/pack.py +159 -0
  242. package/skills/pptx/scripts/ooxml/scripts/unpack.py +29 -0
  243. package/skills/pptx/scripts/ooxml/scripts/validate.py +106 -0
  244. package/skills/pptx/scripts/ooxml/scripts/validation/__init__.py +15 -0
  245. package/skills/pptx/scripts/ooxml/scripts/validation/base.py +1023 -0
  246. package/skills/pptx/scripts/ooxml/scripts/validation/docx.py +519 -0
  247. package/skills/pptx/scripts/ooxml/scripts/validation/pptx.py +315 -0
  248. package/skills/pptx/scripts/ooxml/scripts/validation/redlining.py +284 -0
  249. package/skills/pptx/scripts/pack.py +168 -0
  250. package/skills/pptx/scripts/thumbnail.py +318 -0
  251. package/skills/pptx/scripts/unpack.py +86 -0
  252. package/skills/xlsx/SKILL.md +291 -0
  253. package/skills/xlsx/recalc.py +247 -0
@@ -0,0 +1,291 @@
1
+ ---
2
+ name: xlsx
3
+ description: "Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When you need to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas"
4
+ ---
5
+
6
+ # Requirements for Outputs
7
+
8
+ ## All Excel files
9
+
10
+ ### Professional Font
11
+ - Use a consistent, professional font (e.g., Arial, Times New Roman) for all deliverables unless otherwise instructed by the user
12
+
13
+ ### Zero Formula Errors
14
+ - Every Excel model MUST be delivered with ZERO formula errors (#REF!, #DIV/0!, #VALUE!, #N/A, #NAME?)
15
+
16
+ ### Preserve Existing Templates (when updating templates)
17
+ - Study and EXACTLY match existing format, style, and conventions when modifying files
18
+ - Never impose standardized formatting on files with established patterns
19
+ - Existing template conventions ALWAYS override these guidelines
20
+
21
+ ## Financial models
22
+
23
+ ### Color Coding Standards
24
+ Unless otherwise stated by the user or existing template
25
+
26
+ #### Industry-Standard Color Conventions
27
+ - **Blue text (RGB: 0,0,255)**: Hardcoded inputs, and numbers users will change for scenarios
28
+ - **Black text (RGB: 0,0,0)**: ALL formulas and calculations
29
+ - **Green text (RGB: 0,128,0)**: Links pulling from other worksheets within same workbook
30
+ - **Red text (RGB: 255,0,0)**: External links to other files
31
+ - **Yellow background (RGB: 255,255,0)**: Key assumptions needing attention or cells that need to be updated
32
+
33
+ ### Number Formatting Standards
34
+
35
+ #### Required Format Rules
36
+ - **Years**: Format as text strings (e.g., "2024" not "2,024")
37
+ - **Currency**: Use $#,##0 format; ALWAYS specify units in headers ("Revenue ($mm)")
38
+ - **Zeros**: Use number formatting to make all zeros "-", including percentages (e.g., "$#,##0;($#,##0);-")
39
+ - **Percentages**: Default to 0.0% format (one decimal)
40
+ - **Multiples**: Format as 0.0x for valuation multiples (EV/EBITDA, P/E)
41
+ - **Negative numbers**: Use parentheses (123) not minus -123
42
+
43
+ ### Formula Construction Rules
44
+
45
+ #### Assumptions Placement
46
+ - Place ALL assumptions (growth rates, margins, multiples, etc.) in separate assumption cells
47
+ - Use cell references instead of hardcoded values in formulas
48
+ - Example: Use =B5*(1+$B$6) instead of =B5*1.05
49
+
50
+ #### Formula Error Prevention
51
+ - Verify all cell references are correct
52
+ - Check for off-by-one errors in ranges
53
+ - Ensure consistent formulas across all projection periods
54
+ - Test with edge cases (zero values, negative numbers)
55
+ - Verify no unintended circular references
56
+
57
+ #### Documentation Requirements for Hardcodes
58
+ - Comment or in cells beside (if end of table). Format: "Source: [System/Document], [Date], [Specific Reference], [URL if applicable]"
59
+ - Examples:
60
+ - "Source: Company 10-K, FY2024, Page 45, Revenue Note, [SEC EDGAR URL]"
61
+ - "Source: Company 10-Q, Q2 2025, Exhibit 99.1, [SEC EDGAR URL]"
62
+ - "Source: Bloomberg Terminal, 8/15/2025, AAPL US Equity"
63
+ - "Source: FactSet, 8/20/2025, Consensus Estimates Screen"
64
+
65
+ # XLSX creation, editing, and analysis
66
+
67
+ ## Overview
68
+
69
+ A user may ask you to create, edit, or analyze the contents of an .xlsx file. You have different tools and workflows available for different tasks.
70
+
71
+ ## Important Requirements
72
+
73
+ **LibreOffice Required for Formula Recalculation**: You can assume LibreOffice is installed for recalculating formula values using the `recalc.py` script. The script automatically configures LibreOffice on first run
74
+
75
+ ## Reading and analyzing data
76
+
77
+ ### Data analysis with pandas
78
+ For data analysis, visualization, and basic operations, use **pandas** which provides powerful data manipulation capabilities:
79
+
80
+ ```python
81
+ import pandas as pd
82
+
83
+ # Read Excel
84
+ df = pd.read_excel('file.xlsx') # Default: first sheet
85
+ all_sheets = pd.read_excel('file.xlsx', sheet_name=None) # All sheets as dict
86
+
87
+ # Analyze
88
+ df.head() # Preview data
89
+ df.info() # Column info
90
+ df.describe() # Statistics
91
+
92
+ # Write Excel
93
+ df.to_excel('output.xlsx', index=False)
94
+ ```
95
+
96
+ ## Excel File Workflows
97
+
98
+ ## CRITICAL: Use Formulas, Not Hardcoded Values
99
+
100
+ **Always use Excel formulas instead of calculating values in Python and hardcoding them.** This ensures the spreadsheet remains dynamic and updateable.
101
+
102
+ ### ❌ WRONG - Hardcoding Calculated Values
103
+ ```python
104
+ # Bad: Calculating in Python and hardcoding result
105
+ total = df['Sales'].sum()
106
+ sheet['B10'] = total # Hardcodes 5000
107
+
108
+ # Bad: Computing growth rate in Python
109
+ growth = (df.iloc[-1]['Revenue'] - df.iloc[0]['Revenue']) / df.iloc[0]['Revenue']
110
+ sheet['C5'] = growth # Hardcodes 0.15
111
+
112
+ # Bad: Python calculation for average
113
+ avg = sum(values) / len(values)
114
+ sheet['D20'] = avg # Hardcodes 42.5
115
+ ```
116
+
117
+ ### ✅ CORRECT - Using Excel Formulas
118
+ ```python
119
+ # Good: Let Excel calculate the sum
120
+ sheet['B10'] = '=SUM(B2:B9)'
121
+
122
+ # Good: Growth rate as Excel formula
123
+ sheet['C5'] = '=(C4-C2)/C2'
124
+
125
+ # Good: Average using Excel function
126
+ sheet['D20'] = '=AVERAGE(D2:D19)'
127
+ ```
128
+
129
+ This applies to ALL calculations - totals, percentages, ratios, differences, etc. The spreadsheet should be able to recalculate when source data changes.
130
+
131
+ ## Common Workflow
132
+ 1. **Choose tool**: pandas for data, openpyxl for formulas/formatting
133
+ 2. **Create/Load**: Create new workbook or load existing file
134
+ 3. **Modify**: Add/edit data, formulas, and formatting
135
+ 4. **Save**: Write to file
136
+ 5. **Recalculate formulas (MANDATORY IF USING FORMULAS)**: Use the recalc.py script
137
+ ```bash
138
+ python recalc.py output.xlsx
139
+ ```
140
+ 6. **Verify and fix any errors**:
141
+ - The script returns JSON with error details
142
+ - If `status` is `errors_found`, check `error_summary` for specific error types and locations
143
+ - Fix the identified errors and recalculate again
144
+ - Common errors to fix:
145
+ - `#REF!`: Invalid cell references
146
+ - `#DIV/0!`: Division by zero
147
+ - `#VALUE!`: Wrong data type in formula
148
+ - `#NAME?`: Unrecognized formula name
149
+
150
+ ### Creating new Excel files
151
+
152
+ ```python
153
+ # Using openpyxl for formulas and formatting
154
+ from openpyxl import Workbook
155
+ from openpyxl.styles import Font, PatternFill, Alignment
156
+
157
+ wb = Workbook()
158
+ sheet = wb.active
159
+
160
+ # Add data
161
+ sheet['A1'] = 'Hello'
162
+ sheet['B1'] = 'World'
163
+ sheet.append(['Row', 'of', 'data'])
164
+
165
+ # Add formula
166
+ sheet['B2'] = '=SUM(A1:A10)'
167
+
168
+ # Formatting
169
+ sheet['A1'].font = Font(bold=True, color='FF0000')
170
+ sheet['A1'].fill = PatternFill('solid', start_color='FFFF00')
171
+ sheet['A1'].alignment = Alignment(horizontal='center')
172
+
173
+ # Column width
174
+ sheet.column_dimensions['A'].width = 20
175
+
176
+ wb.save('output.xlsx')
177
+ ```
178
+
179
+ ### Editing existing Excel files
180
+
181
+ ```python
182
+ # Using openpyxl to preserve formulas and formatting
183
+ from openpyxl import load_workbook
184
+
185
+ # Load existing file
186
+ wb = load_workbook('existing.xlsx')
187
+ sheet = wb.active # or wb['SheetName'] for specific sheet
188
+
189
+ # Working with multiple sheets
190
+ for sheet_name in wb.sheetnames:
191
+ sheet = wb[sheet_name]
192
+ print(f"Sheet: {sheet_name}")
193
+
194
+ # Modify cells
195
+ sheet['A1'] = 'New Value'
196
+ sheet.insert_rows(2) # Insert row at position 2
197
+ sheet.delete_cols(3) # Delete column 3
198
+
199
+ # Add new sheet
200
+ new_sheet = wb.create_sheet('NewSheet')
201
+ new_sheet['A1'] = 'Data'
202
+
203
+ wb.save('modified.xlsx')
204
+ ```
205
+
206
+ ## Recalculating formulas
207
+
208
+ Excel files created or modified by openpyxl contain formulas as strings but not calculated values. Use the provided `recalc.py` script to recalculate formulas:
209
+
210
+ ```bash
211
+ python recalc.py <excel_file> [timeout_seconds]
212
+ ```
213
+
214
+ Example:
215
+ ```bash
216
+ python recalc.py output.xlsx 30
217
+ ```
218
+
219
+ The script:
220
+ - Automatically sets up LibreOffice macro on first run
221
+ - Recalculates all formulas in all sheets
222
+ - Scans ALL cells for Excel errors (#REF!, #DIV/0!, etc.)
223
+ - Returns JSON with detailed error locations and counts
224
+ - Works on both Linux and macOS
225
+
226
+ ## Formula Verification Checklist
227
+
228
+ Quick checks to ensure formulas work correctly:
229
+
230
+ ### Essential Verification
231
+ - [ ] **Test 2-3 sample references**: Verify they pull correct values before building full model
232
+ - [ ] **Column mapping**: Confirm Excel columns match (e.g., column 64 = BL, not BK)
233
+ - [ ] **Row offset**: Remember Excel rows are 1-indexed (DataFrame row 5 = Excel row 6)
234
+
235
+ ### Common Pitfalls
236
+ - [ ] **NaN handling**: Check for null values with `pd.notna()`
237
+ - [ ] **Far-right columns**: FY data often in columns 50+
238
+ - [ ] **Multiple matches**: Search all occurrences, not just first
239
+ - [ ] **Division by zero**: Check denominators before using `/` in formulas (#DIV/0!)
240
+ - [ ] **Wrong references**: Verify all cell references point to intended cells (#REF!)
241
+ - [ ] **Cross-sheet references**: Use correct format (Sheet1!A1) for linking sheets
242
+
243
+ ### Formula Testing Strategy
244
+ - [ ] **Start small**: Test formulas on 2-3 cells before applying broadly
245
+ - [ ] **Verify dependencies**: Check all cells referenced in formulas exist
246
+ - [ ] **Test edge cases**: Include zero, negative, and very large values
247
+
248
+ ### Interpreting recalc.py Output
249
+ The script returns JSON with error details:
250
+ ```json
251
+ {
252
+ "status": "success", // or "errors_found"
253
+ "total_errors": 0, // Total error count
254
+ "total_formulas": 42, // Number of formulas in file
255
+ "error_summary": { // Only present if errors found
256
+ "#REF!": {
257
+ "count": 2,
258
+ "locations": ["Sheet1!B5", "Sheet1!C10"]
259
+ }
260
+ }
261
+ }
262
+ ```
263
+
264
+ ## Best Practices
265
+
266
+ ### Library Selection
267
+ - **pandas**: Best for data analysis, bulk operations, and simple data export
268
+ - **openpyxl**: Best for complex formatting, formulas, and Excel-specific features
269
+
270
+ ### Working with openpyxl
271
+ - Cell indices are 1-based (row=1, column=1 refers to cell A1)
272
+ - Use `data_only=True` to read calculated values: `load_workbook('file.xlsx', data_only=True)`
273
+ - **Warning**: If opened with `data_only=True` and saved, formulas are replaced with values and permanently lost
274
+ - For large files: Use `read_only=True` for reading or `write_only=True` for writing
275
+ - Formulas are preserved but not evaluated - use recalc.py to update values
276
+
277
+ ### Working with pandas
278
+ - Specify data types to avoid inference issues: `pd.read_excel('file.xlsx', dtype={'id': str})`
279
+ - For large files, read specific columns: `pd.read_excel('file.xlsx', usecols=['A', 'C', 'E'])`
280
+ - Handle dates properly: `pd.read_excel('file.xlsx', parse_dates=['date_column'])`
281
+
282
+ ## Code Style Guidelines
283
+ **IMPORTANT**: When generating Python code for Excel operations:
284
+ - Write minimal, concise Python code without unnecessary comments
285
+ - Avoid verbose variable names and redundant operations
286
+ - Avoid unnecessary print statements
287
+
288
+ **For Excel files themselves**:
289
+ - Add comments to cells with complex formulas or important assumptions
290
+ - Document data sources for hardcoded values
291
+ - Include notes for key calculations and model sections
@@ -0,0 +1,247 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Excel Formula Recalculation Script
4
+ Recalculates all formulas in an Excel file using LibreOffice
5
+ """
6
+
7
+ import json
8
+ import os
9
+ import platform
10
+ import subprocess
11
+ import sys
12
+ import time
13
+ from pathlib import Path
14
+
15
+ from openpyxl import load_workbook
16
+
17
+ # Platform-specific LibreOffice macro directory
18
+ MACRO_DIR_MACOS = "~/Library/Application Support/LibreOffice/4/user/basic/Standard"
19
+ MACRO_DIR_LINUX = "~/.config/libreoffice/4/user/basic/Standard"
20
+ MACRO_FILENAME = "Module1.xba"
21
+
22
+ # LibreOffice Basic macro for recalculation
23
+ RECALCULATE_MACRO = """<?xml version="1.0" encoding="UTF-8"?>
24
+ <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
25
+ <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">
26
+ Sub RecalculateAndSave()
27
+ ThisComponent.calculateAll()
28
+ ThisComponent.store()
29
+ ThisComponent.close(True)
30
+ End Sub
31
+ </script:module>"""
32
+
33
+
34
+ def ensure_xvfb_running():
35
+ """Ensure Xvfb is running on display :99 for headless Linux environments"""
36
+ # Only needed in headless Linux environments (no DISPLAY set)
37
+ if platform.system() != "Linux" or os.environ.get("DISPLAY"):
38
+ return
39
+
40
+ # Check if Xvfb is already running on :99
41
+ try:
42
+ result = subprocess.run(
43
+ ["pgrep", "-f", "Xvfb.*:99"], capture_output=True, text=True
44
+ )
45
+ if result.returncode == 0 and result.stdout.strip():
46
+ os.environ["DISPLAY"] = ":99"
47
+ return
48
+ except FileNotFoundError:
49
+ pass
50
+
51
+ # Start Xvfb (leave it running for subsequent calls)
52
+ try:
53
+ subprocess.Popen(
54
+ ["Xvfb", ":99", "-screen", "0", "1024x768x24"],
55
+ stdout=subprocess.DEVNULL,
56
+ stderr=subprocess.DEVNULL,
57
+ )
58
+ except FileNotFoundError:
59
+ raise RuntimeError("Xvfb not found - install with: apt-get install xvfb")
60
+
61
+ os.environ["DISPLAY"] = ":99"
62
+
63
+ # Wait for Xvfb to be ready (poll socket file)
64
+ socket_path = "/tmp/.X11-unix/X99"
65
+ for _ in range(20): # Up to 2 seconds
66
+ if os.path.exists(socket_path):
67
+ return
68
+ time.sleep(0.1)
69
+ raise RuntimeError("Xvfb started but socket not ready")
70
+
71
+
72
+ def has_gtimeout():
73
+ """Check if gtimeout is available on macOS"""
74
+ try:
75
+ subprocess.run(
76
+ ["gtimeout", "--version"], capture_output=True, timeout=1, check=False
77
+ )
78
+ return True
79
+ except (FileNotFoundError, subprocess.TimeoutExpired):
80
+ return False
81
+
82
+
83
+ def setup_libreoffice_macro():
84
+ """Setup LibreOffice macro for recalculation if not already configured"""
85
+ macro_dir = os.path.expanduser(
86
+ MACRO_DIR_MACOS if platform.system() == "Darwin" else MACRO_DIR_LINUX
87
+ )
88
+ macro_file = os.path.join(macro_dir, MACRO_FILENAME)
89
+
90
+ # Check if macro already exists
91
+ if (
92
+ os.path.exists(macro_file)
93
+ and "RecalculateAndSave" in Path(macro_file).read_text()
94
+ ):
95
+ return True
96
+
97
+ # Create macro directory if needed
98
+ if not os.path.exists(macro_dir):
99
+ subprocess.run(
100
+ ["soffice", "--headless", "--terminate_after_init"],
101
+ capture_output=True,
102
+ timeout=10,
103
+ )
104
+ os.makedirs(macro_dir, exist_ok=True)
105
+
106
+ # Write macro file
107
+ try:
108
+ Path(macro_file).write_text(RECALCULATE_MACRO)
109
+ return True
110
+ except Exception:
111
+ return False
112
+
113
+
114
+ def recalc(filename, timeout=30):
115
+ """
116
+ Recalculate formulas in Excel file and report any errors
117
+
118
+ Args:
119
+ filename: Path to Excel file
120
+ timeout: Maximum time to wait for recalculation (seconds)
121
+
122
+ Returns:
123
+ dict with error locations and counts
124
+ """
125
+ if not Path(filename).exists():
126
+ return {"error": f"File {filename} does not exist"}
127
+
128
+ abs_path = str(Path(filename).absolute())
129
+
130
+ if not setup_libreoffice_macro():
131
+ return {"error": "Failed to setup LibreOffice macro"}
132
+
133
+ # Ensure Xvfb is running for headless Unix environments
134
+ ensure_xvfb_running()
135
+
136
+ cmd = [
137
+ "soffice",
138
+ "--headless",
139
+ "--norestore",
140
+ "vnd.sun.star.script:Standard.Module1.RecalculateAndSave?language=Basic&location=application",
141
+ abs_path,
142
+ ]
143
+
144
+ # Wrap command with timeout utility if available
145
+ if platform.system() == "Linux":
146
+ cmd = ["timeout", str(timeout)] + cmd
147
+ elif platform.system() == "Darwin" and has_gtimeout():
148
+ cmd = ["gtimeout", str(timeout)] + cmd
149
+
150
+ result = subprocess.run(cmd, capture_output=True, text=True)
151
+
152
+ if result.returncode != 0 and result.returncode != 124: # 124 is timeout exit code
153
+ error_msg = result.stderr or "Unknown error during recalculation"
154
+ if "Module1" in error_msg or "RecalculateAndSave" not in error_msg:
155
+ return {"error": "LibreOffice macro not configured properly"}
156
+ return {"error": error_msg}
157
+
158
+ # Check for Excel errors in the recalculated file - scan ALL cells
159
+ try:
160
+ wb = load_workbook(filename, data_only=True)
161
+
162
+ excel_errors = [
163
+ "#VALUE!",
164
+ "#DIV/0!",
165
+ "#REF!",
166
+ "#NAME?",
167
+ "#NULL!",
168
+ "#NUM!",
169
+ "#N/A",
170
+ ]
171
+ error_details = {err: [] for err in excel_errors}
172
+ total_errors = 0
173
+
174
+ for sheet_name in wb.sheetnames:
175
+ ws = wb[sheet_name]
176
+ # Check ALL rows and columns - no limits
177
+ for row in ws.iter_rows():
178
+ for cell in row:
179
+ if cell.value is not None and isinstance(cell.value, str):
180
+ for err in excel_errors:
181
+ if err in cell.value:
182
+ location = f"{sheet_name}!{cell.coordinate}"
183
+ error_details[err].append(location)
184
+ total_errors += 1
185
+ break
186
+
187
+ wb.close()
188
+
189
+ # Build result summary
190
+ result = {
191
+ "status": "success" if total_errors == 0 else "errors_found",
192
+ "total_errors": total_errors,
193
+ "error_summary": {},
194
+ }
195
+
196
+ # Add non-empty error categories
197
+ for err_type, locations in error_details.items():
198
+ if locations:
199
+ result["error_summary"][err_type] = {
200
+ "count": len(locations),
201
+ "locations": locations[:20], # Show up to 20 locations
202
+ }
203
+
204
+ # Add formula count for context - also check ALL cells
205
+ wb_formulas = load_workbook(filename, data_only=False)
206
+ formula_count = 0
207
+ for sheet_name in wb_formulas.sheetnames:
208
+ ws = wb_formulas[sheet_name]
209
+ for row in ws.iter_rows():
210
+ for cell in row:
211
+ if (
212
+ cell.value
213
+ and isinstance(cell.value, str)
214
+ and cell.value.startswith("=")
215
+ ):
216
+ formula_count += 1
217
+ wb_formulas.close()
218
+
219
+ result["total_formulas"] = formula_count
220
+
221
+ return result
222
+
223
+ except Exception as e:
224
+ return {"error": str(e)}
225
+
226
+
227
+ def main():
228
+ if len(sys.argv) < 2:
229
+ print("Usage: python recalc.py <excel_file> [timeout_seconds]")
230
+ print("\nRecalculates all formulas in an Excel file using LibreOffice")
231
+ print("\nReturns JSON with error details:")
232
+ print(" - status: 'success' or 'errors_found'")
233
+ print(" - total_errors: Total number of Excel errors found")
234
+ print(" - total_formulas: Number of formulas in the file")
235
+ print(" - error_summary: Breakdown by error type with locations")
236
+ print(" - #VALUE!, #DIV/0!, #REF!, #NAME?, #NULL!, #NUM!, #N/A")
237
+ sys.exit(1)
238
+
239
+ filename = sys.argv[1]
240
+ timeout = int(sys.argv[2]) if len(sys.argv) > 2 else 30
241
+
242
+ result = recalc(filename, timeout)
243
+ print(json.dumps(result, indent=2))
244
+
245
+
246
+ if __name__ == "__main__":
247
+ main()