@brookmind/ai-toolkit 1.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 (105) hide show
  1. package/README.md +54 -0
  2. package/agents/code-reviewer.md +30 -0
  3. package/bin/cli.js +5 -0
  4. package/mcps/context7/.claude-plugin +1 -0
  5. package/mcps/context7/README.md +1 -0
  6. package/mcps/context7/server.json +1 -0
  7. package/mcps/expo-mcp/README.md +33 -0
  8. package/mcps/expo-mcp/package.json +30 -0
  9. package/mcps/figma-mcp/.mcp.json +12 -0
  10. package/mcps/figma-mcp/README.md +554 -0
  11. package/mcps/figma-mcp/server.json +17 -0
  12. package/mcps/figma-mcp/skills/code-connect-components +1 -0
  13. package/mcps/figma-mcp/skills/create-design-system-rules +1 -0
  14. package/mcps/figma-mcp/skills/implement-design +1 -0
  15. package/mcps/pg-aiguide/.claude-plugin +1 -0
  16. package/mcps/pg-aiguide/CLAUDE.md +21 -0
  17. package/mcps/pg-aiguide/README.md +275 -0
  18. package/mcps/pg-aiguide/skills/design-postgres-tables +1 -0
  19. package/mcps/pg-aiguide/skills/find-hypertable-candidates +1 -0
  20. package/mcps/pg-aiguide/skills/migrate-postgres-tables-to-hypertables +1 -0
  21. package/mcps/pg-aiguide/skills/setup-timescaledb-hypertables +1 -0
  22. package/mcps/pg-aiguide/skills.yaml +4 -0
  23. package/package.json +42 -0
  24. package/skills/cloudflare-cli/SKILL.md +151 -0
  25. package/skills/docx/LICENSE.txt +30 -0
  26. package/skills/docx/SKILL.md +197 -0
  27. package/skills/docx/docx-js.md +350 -0
  28. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  29. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  30. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  31. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  32. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  33. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  34. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  35. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  36. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  37. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  38. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  39. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  40. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  41. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  42. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  43. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  44. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  45. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  46. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  47. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  48. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  49. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  50. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  51. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  52. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  53. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  54. package/skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  55. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  56. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  57. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  58. package/skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  59. package/skills/docx/ooxml/schemas/mce/mc.xsd +75 -0
  60. package/skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
  61. package/skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
  62. package/skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
  63. package/skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
  64. package/skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
  65. package/skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  66. package/skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
  67. package/skills/docx/ooxml/scripts/pack.py +159 -0
  68. package/skills/docx/ooxml/scripts/unpack.py +29 -0
  69. package/skills/docx/ooxml/scripts/validate.py +69 -0
  70. package/skills/docx/ooxml/scripts/validation/__init__.py +15 -0
  71. package/skills/docx/ooxml/scripts/validation/base.py +951 -0
  72. package/skills/docx/ooxml/scripts/validation/docx.py +274 -0
  73. package/skills/docx/ooxml/scripts/validation/pptx.py +315 -0
  74. package/skills/docx/ooxml/scripts/validation/redlining.py +279 -0
  75. package/skills/docx/ooxml.md +610 -0
  76. package/skills/docx/scripts/__init__.py +1 -0
  77. package/skills/docx/scripts/document.py +1276 -0
  78. package/skills/docx/scripts/templates/comments.xml +3 -0
  79. package/skills/docx/scripts/templates/commentsExtended.xml +3 -0
  80. package/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
  81. package/skills/docx/scripts/templates/commentsIds.xml +3 -0
  82. package/skills/docx/scripts/templates/people.xml +3 -0
  83. package/skills/docx/scripts/utilities.py +374 -0
  84. package/skills/github-cli/SKILL.md +125 -0
  85. package/skills/pdf/LICENSE.txt +30 -0
  86. package/skills/pdf/SKILL.md +294 -0
  87. package/skills/pdf/forms.md +205 -0
  88. package/skills/pdf/reference.md +612 -0
  89. package/skills/pdf/scripts/check_bounding_boxes.py +70 -0
  90. package/skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
  91. package/skills/pdf/scripts/check_fillable_fields.py +12 -0
  92. package/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
  93. package/skills/pdf/scripts/create_validation_image.py +41 -0
  94. package/skills/pdf/scripts/extract_form_field_info.py +152 -0
  95. package/skills/pdf/scripts/fill_fillable_fields.py +114 -0
  96. package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
  97. package/skills/skill-creator/LICENSE.txt +202 -0
  98. package/skills/skill-creator/SKILL.md +209 -0
  99. package/skills/skill-creator/scripts/init_skill.py +303 -0
  100. package/skills/skill-creator/scripts/package_skill.py +110 -0
  101. package/skills/skill-creator/scripts/quick_validate.py +65 -0
  102. package/skills/xlsx/LICENSE.txt +30 -0
  103. package/skills/xlsx/SKILL.md +289 -0
  104. package/skills/xlsx/recalc.py +178 -0
  105. package/src/index.js +181 -0
@@ -0,0 +1,289 @@
1
+ ---
2
+ name: xlsx
3
+ description: "Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs 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
+ license: Proprietary. LICENSE.txt has complete terms
5
+ ---
6
+
7
+ # Requirements for Outputs
8
+
9
+ ## All Excel files
10
+
11
+ ### Zero Formula Errors
12
+ - Every Excel model MUST be delivered with ZERO formula errors (#REF!, #DIV/0!, #VALUE!, #N/A, #NAME?)
13
+
14
+ ### Preserve Existing Templates (when updating templates)
15
+ - Study and EXACTLY match existing format, style, and conventions when modifying files
16
+ - Never impose standardized formatting on files with established patterns
17
+ - Existing template conventions ALWAYS override these guidelines
18
+
19
+ ## Financial models
20
+
21
+ ### Color Coding Standards
22
+ Unless otherwise stated by the user or existing template
23
+
24
+ #### Industry-Standard Color Conventions
25
+ - **Blue text (RGB: 0,0,255)**: Hardcoded inputs, and numbers users will change for scenarios
26
+ - **Black text (RGB: 0,0,0)**: ALL formulas and calculations
27
+ - **Green text (RGB: 0,128,0)**: Links pulling from other worksheets within same workbook
28
+ - **Red text (RGB: 255,0,0)**: External links to other files
29
+ - **Yellow background (RGB: 255,255,0)**: Key assumptions needing attention or cells that need to be updated
30
+
31
+ ### Number Formatting Standards
32
+
33
+ #### Required Format Rules
34
+ - **Years**: Format as text strings (e.g., "2024" not "2,024")
35
+ - **Currency**: Use $#,##0 format; ALWAYS specify units in headers ("Revenue ($mm)")
36
+ - **Zeros**: Use number formatting to make all zeros "-", including percentages (e.g., "$#,##0;($#,##0);-")
37
+ - **Percentages**: Default to 0.0% format (one decimal)
38
+ - **Multiples**: Format as 0.0x for valuation multiples (EV/EBITDA, P/E)
39
+ - **Negative numbers**: Use parentheses (123) not minus -123
40
+
41
+ ### Formula Construction Rules
42
+
43
+ #### Assumptions Placement
44
+ - Place ALL assumptions (growth rates, margins, multiples, etc.) in separate assumption cells
45
+ - Use cell references instead of hardcoded values in formulas
46
+ - Example: Use =B5*(1+$B$6) instead of =B5*1.05
47
+
48
+ #### Formula Error Prevention
49
+ - Verify all cell references are correct
50
+ - Check for off-by-one errors in ranges
51
+ - Ensure consistent formulas across all projection periods
52
+ - Test with edge cases (zero values, negative numbers)
53
+ - Verify no unintended circular references
54
+
55
+ #### Documentation Requirements for Hardcodes
56
+ - Comment or in cells beside (if end of table). Format: "Source: [System/Document], [Date], [Specific Reference], [URL if applicable]"
57
+ - Examples:
58
+ - "Source: Company 10-K, FY2024, Page 45, Revenue Note, [SEC EDGAR URL]"
59
+ - "Source: Company 10-Q, Q2 2025, Exhibit 99.1, [SEC EDGAR URL]"
60
+ - "Source: Bloomberg Terminal, 8/15/2025, AAPL US Equity"
61
+ - "Source: FactSet, 8/20/2025, Consensus Estimates Screen"
62
+
63
+ # XLSX creation, editing, and analysis
64
+
65
+ ## Overview
66
+
67
+ 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.
68
+
69
+ ## Important Requirements
70
+
71
+ **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
72
+
73
+ ## Reading and analyzing data
74
+
75
+ ### Data analysis with pandas
76
+ For data analysis, visualization, and basic operations, use **pandas** which provides powerful data manipulation capabilities:
77
+
78
+ ```python
79
+ import pandas as pd
80
+
81
+ # Read Excel
82
+ df = pd.read_excel('file.xlsx') # Default: first sheet
83
+ all_sheets = pd.read_excel('file.xlsx', sheet_name=None) # All sheets as dict
84
+
85
+ # Analyze
86
+ df.head() # Preview data
87
+ df.info() # Column info
88
+ df.describe() # Statistics
89
+
90
+ # Write Excel
91
+ df.to_excel('output.xlsx', index=False)
92
+ ```
93
+
94
+ ## Excel File Workflows
95
+
96
+ ## CRITICAL: Use Formulas, Not Hardcoded Values
97
+
98
+ **Always use Excel formulas instead of calculating values in Python and hardcoding them.** This ensures the spreadsheet remains dynamic and updateable.
99
+
100
+ ### ❌ WRONG - Hardcoding Calculated Values
101
+ ```python
102
+ # Bad: Calculating in Python and hardcoding result
103
+ total = df['Sales'].sum()
104
+ sheet['B10'] = total # Hardcodes 5000
105
+
106
+ # Bad: Computing growth rate in Python
107
+ growth = (df.iloc[-1]['Revenue'] - df.iloc[0]['Revenue']) / df.iloc[0]['Revenue']
108
+ sheet['C5'] = growth # Hardcodes 0.15
109
+
110
+ # Bad: Python calculation for average
111
+ avg = sum(values) / len(values)
112
+ sheet['D20'] = avg # Hardcodes 42.5
113
+ ```
114
+
115
+ ### ✅ CORRECT - Using Excel Formulas
116
+ ```python
117
+ # Good: Let Excel calculate the sum
118
+ sheet['B10'] = '=SUM(B2:B9)'
119
+
120
+ # Good: Growth rate as Excel formula
121
+ sheet['C5'] = '=(C4-C2)/C2'
122
+
123
+ # Good: Average using Excel function
124
+ sheet['D20'] = '=AVERAGE(D2:D19)'
125
+ ```
126
+
127
+ This applies to ALL calculations - totals, percentages, ratios, differences, etc. The spreadsheet should be able to recalculate when source data changes.
128
+
129
+ ## Common Workflow
130
+ 1. **Choose tool**: pandas for data, openpyxl for formulas/formatting
131
+ 2. **Create/Load**: Create new workbook or load existing file
132
+ 3. **Modify**: Add/edit data, formulas, and formatting
133
+ 4. **Save**: Write to file
134
+ 5. **Recalculate formulas (MANDATORY IF USING FORMULAS)**: Use the recalc.py script
135
+ ```bash
136
+ python recalc.py output.xlsx
137
+ ```
138
+ 6. **Verify and fix any errors**:
139
+ - The script returns JSON with error details
140
+ - If `status` is `errors_found`, check `error_summary` for specific error types and locations
141
+ - Fix the identified errors and recalculate again
142
+ - Common errors to fix:
143
+ - `#REF!`: Invalid cell references
144
+ - `#DIV/0!`: Division by zero
145
+ - `#VALUE!`: Wrong data type in formula
146
+ - `#NAME?`: Unrecognized formula name
147
+
148
+ ### Creating new Excel files
149
+
150
+ ```python
151
+ # Using openpyxl for formulas and formatting
152
+ from openpyxl import Workbook
153
+ from openpyxl.styles import Font, PatternFill, Alignment
154
+
155
+ wb = Workbook()
156
+ sheet = wb.active
157
+
158
+ # Add data
159
+ sheet['A1'] = 'Hello'
160
+ sheet['B1'] = 'World'
161
+ sheet.append(['Row', 'of', 'data'])
162
+
163
+ # Add formula
164
+ sheet['B2'] = '=SUM(A1:A10)'
165
+
166
+ # Formatting
167
+ sheet['A1'].font = Font(bold=True, color='FF0000')
168
+ sheet['A1'].fill = PatternFill('solid', start_color='FFFF00')
169
+ sheet['A1'].alignment = Alignment(horizontal='center')
170
+
171
+ # Column width
172
+ sheet.column_dimensions['A'].width = 20
173
+
174
+ wb.save('output.xlsx')
175
+ ```
176
+
177
+ ### Editing existing Excel files
178
+
179
+ ```python
180
+ # Using openpyxl to preserve formulas and formatting
181
+ from openpyxl import load_workbook
182
+
183
+ # Load existing file
184
+ wb = load_workbook('existing.xlsx')
185
+ sheet = wb.active # or wb['SheetName'] for specific sheet
186
+
187
+ # Working with multiple sheets
188
+ for sheet_name in wb.sheetnames:
189
+ sheet = wb[sheet_name]
190
+ print(f"Sheet: {sheet_name}")
191
+
192
+ # Modify cells
193
+ sheet['A1'] = 'New Value'
194
+ sheet.insert_rows(2) # Insert row at position 2
195
+ sheet.delete_cols(3) # Delete column 3
196
+
197
+ # Add new sheet
198
+ new_sheet = wb.create_sheet('NewSheet')
199
+ new_sheet['A1'] = 'Data'
200
+
201
+ wb.save('modified.xlsx')
202
+ ```
203
+
204
+ ## Recalculating formulas
205
+
206
+ Excel files created or modified by openpyxl contain formulas as strings but not calculated values. Use the provided `recalc.py` script to recalculate formulas:
207
+
208
+ ```bash
209
+ python recalc.py <excel_file> [timeout_seconds]
210
+ ```
211
+
212
+ Example:
213
+ ```bash
214
+ python recalc.py output.xlsx 30
215
+ ```
216
+
217
+ The script:
218
+ - Automatically sets up LibreOffice macro on first run
219
+ - Recalculates all formulas in all sheets
220
+ - Scans ALL cells for Excel errors (#REF!, #DIV/0!, etc.)
221
+ - Returns JSON with detailed error locations and counts
222
+ - Works on both Linux and macOS
223
+
224
+ ## Formula Verification Checklist
225
+
226
+ Quick checks to ensure formulas work correctly:
227
+
228
+ ### Essential Verification
229
+ - [ ] **Test 2-3 sample references**: Verify they pull correct values before building full model
230
+ - [ ] **Column mapping**: Confirm Excel columns match (e.g., column 64 = BL, not BK)
231
+ - [ ] **Row offset**: Remember Excel rows are 1-indexed (DataFrame row 5 = Excel row 6)
232
+
233
+ ### Common Pitfalls
234
+ - [ ] **NaN handling**: Check for null values with `pd.notna()`
235
+ - [ ] **Far-right columns**: FY data often in columns 50+
236
+ - [ ] **Multiple matches**: Search all occurrences, not just first
237
+ - [ ] **Division by zero**: Check denominators before using `/` in formulas (#DIV/0!)
238
+ - [ ] **Wrong references**: Verify all cell references point to intended cells (#REF!)
239
+ - [ ] **Cross-sheet references**: Use correct format (Sheet1!A1) for linking sheets
240
+
241
+ ### Formula Testing Strategy
242
+ - [ ] **Start small**: Test formulas on 2-3 cells before applying broadly
243
+ - [ ] **Verify dependencies**: Check all cells referenced in formulas exist
244
+ - [ ] **Test edge cases**: Include zero, negative, and very large values
245
+
246
+ ### Interpreting recalc.py Output
247
+ The script returns JSON with error details:
248
+ ```json
249
+ {
250
+ "status": "success", // or "errors_found"
251
+ "total_errors": 0, // Total error count
252
+ "total_formulas": 42, // Number of formulas in file
253
+ "error_summary": { // Only present if errors found
254
+ "#REF!": {
255
+ "count": 2,
256
+ "locations": ["Sheet1!B5", "Sheet1!C10"]
257
+ }
258
+ }
259
+ }
260
+ ```
261
+
262
+ ## Best Practices
263
+
264
+ ### Library Selection
265
+ - **pandas**: Best for data analysis, bulk operations, and simple data export
266
+ - **openpyxl**: Best for complex formatting, formulas, and Excel-specific features
267
+
268
+ ### Working with openpyxl
269
+ - Cell indices are 1-based (row=1, column=1 refers to cell A1)
270
+ - Use `data_only=True` to read calculated values: `load_workbook('file.xlsx', data_only=True)`
271
+ - **Warning**: If opened with `data_only=True` and saved, formulas are replaced with values and permanently lost
272
+ - For large files: Use `read_only=True` for reading or `write_only=True` for writing
273
+ - Formulas are preserved but not evaluated - use recalc.py to update values
274
+
275
+ ### Working with pandas
276
+ - Specify data types to avoid inference issues: `pd.read_excel('file.xlsx', dtype={'id': str})`
277
+ - For large files, read specific columns: `pd.read_excel('file.xlsx', usecols=['A', 'C', 'E'])`
278
+ - Handle dates properly: `pd.read_excel('file.xlsx', parse_dates=['date_column'])`
279
+
280
+ ## Code Style Guidelines
281
+ **IMPORTANT**: When generating Python code for Excel operations:
282
+ - Write minimal, concise Python code without unnecessary comments
283
+ - Avoid verbose variable names and redundant operations
284
+ - Avoid unnecessary print statements
285
+
286
+ **For Excel files themselves**:
287
+ - Add comments to cells with complex formulas or important assumptions
288
+ - Document data sources for hardcoded values
289
+ - Include notes for key calculations and model sections
@@ -0,0 +1,178 @@
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 sys
9
+ import subprocess
10
+ import os
11
+ import platform
12
+ from pathlib import Path
13
+ from openpyxl import load_workbook
14
+
15
+
16
+ def setup_libreoffice_macro():
17
+ """Setup LibreOffice macro for recalculation if not already configured"""
18
+ if platform.system() == 'Darwin':
19
+ macro_dir = os.path.expanduser('~/Library/Application Support/LibreOffice/4/user/basic/Standard')
20
+ else:
21
+ macro_dir = os.path.expanduser('~/.config/libreoffice/4/user/basic/Standard')
22
+
23
+ macro_file = os.path.join(macro_dir, 'Module1.xba')
24
+
25
+ if os.path.exists(macro_file):
26
+ with open(macro_file, 'r') as f:
27
+ if 'RecalculateAndSave' in f.read():
28
+ return True
29
+
30
+ if not os.path.exists(macro_dir):
31
+ subprocess.run(['soffice', '--headless', '--terminate_after_init'],
32
+ capture_output=True, timeout=10)
33
+ os.makedirs(macro_dir, exist_ok=True)
34
+
35
+ macro_content = '''<?xml version="1.0" encoding="UTF-8"?>
36
+ <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
37
+ <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">
38
+ Sub RecalculateAndSave()
39
+ ThisComponent.calculateAll()
40
+ ThisComponent.store()
41
+ ThisComponent.close(True)
42
+ End Sub
43
+ </script:module>'''
44
+
45
+ try:
46
+ with open(macro_file, 'w') as f:
47
+ f.write(macro_content)
48
+ return True
49
+ except Exception:
50
+ return False
51
+
52
+
53
+ def recalc(filename, timeout=30):
54
+ """
55
+ Recalculate formulas in Excel file and report any errors
56
+
57
+ Args:
58
+ filename: Path to Excel file
59
+ timeout: Maximum time to wait for recalculation (seconds)
60
+
61
+ Returns:
62
+ dict with error locations and counts
63
+ """
64
+ if not Path(filename).exists():
65
+ return {'error': f'File {filename} does not exist'}
66
+
67
+ abs_path = str(Path(filename).absolute())
68
+
69
+ if not setup_libreoffice_macro():
70
+ return {'error': 'Failed to setup LibreOffice macro'}
71
+
72
+ cmd = [
73
+ 'soffice', '--headless', '--norestore',
74
+ 'vnd.sun.star.script:Standard.Module1.RecalculateAndSave?language=Basic&location=application',
75
+ abs_path
76
+ ]
77
+
78
+ # Handle timeout command differences between Linux and macOS
79
+ if platform.system() != 'Windows':
80
+ timeout_cmd = 'timeout' if platform.system() == 'Linux' else None
81
+ if platform.system() == 'Darwin':
82
+ # Check if gtimeout is available on macOS
83
+ try:
84
+ subprocess.run(['gtimeout', '--version'], capture_output=True, timeout=1, check=False)
85
+ timeout_cmd = 'gtimeout'
86
+ except (FileNotFoundError, subprocess.TimeoutExpired):
87
+ pass
88
+
89
+ if timeout_cmd:
90
+ cmd = [timeout_cmd, str(timeout)] + cmd
91
+
92
+ result = subprocess.run(cmd, capture_output=True, text=True)
93
+
94
+ if result.returncode != 0 and result.returncode != 124: # 124 is timeout exit code
95
+ error_msg = result.stderr or 'Unknown error during recalculation'
96
+ if 'Module1' in error_msg or 'RecalculateAndSave' not in error_msg:
97
+ return {'error': 'LibreOffice macro not configured properly'}
98
+ else:
99
+ return {'error': error_msg}
100
+
101
+ # Check for Excel errors in the recalculated file - scan ALL cells
102
+ try:
103
+ wb = load_workbook(filename, data_only=True)
104
+
105
+ excel_errors = ['#VALUE!', '#DIV/0!', '#REF!', '#NAME?', '#NULL!', '#NUM!', '#N/A']
106
+ error_details = {err: [] for err in excel_errors}
107
+ total_errors = 0
108
+
109
+ for sheet_name in wb.sheetnames:
110
+ ws = wb[sheet_name]
111
+ # Check ALL rows and columns - no limits
112
+ for row in ws.iter_rows():
113
+ for cell in row:
114
+ if cell.value is not None and isinstance(cell.value, str):
115
+ for err in excel_errors:
116
+ if err in cell.value:
117
+ location = f"{sheet_name}!{cell.coordinate}"
118
+ error_details[err].append(location)
119
+ total_errors += 1
120
+ break
121
+
122
+ wb.close()
123
+
124
+ # Build result summary
125
+ result = {
126
+ 'status': 'success' if total_errors == 0 else 'errors_found',
127
+ 'total_errors': total_errors,
128
+ 'error_summary': {}
129
+ }
130
+
131
+ # Add non-empty error categories
132
+ for err_type, locations in error_details.items():
133
+ if locations:
134
+ result['error_summary'][err_type] = {
135
+ 'count': len(locations),
136
+ 'locations': locations[:20] # Show up to 20 locations
137
+ }
138
+
139
+ # Add formula count for context - also check ALL cells
140
+ wb_formulas = load_workbook(filename, data_only=False)
141
+ formula_count = 0
142
+ for sheet_name in wb_formulas.sheetnames:
143
+ ws = wb_formulas[sheet_name]
144
+ for row in ws.iter_rows():
145
+ for cell in row:
146
+ if cell.value and isinstance(cell.value, str) and cell.value.startswith('='):
147
+ formula_count += 1
148
+ wb_formulas.close()
149
+
150
+ result['total_formulas'] = formula_count
151
+
152
+ return result
153
+
154
+ except Exception as e:
155
+ return {'error': str(e)}
156
+
157
+
158
+ def main():
159
+ if len(sys.argv) < 2:
160
+ print("Usage: python recalc.py <excel_file> [timeout_seconds]")
161
+ print("\nRecalculates all formulas in an Excel file using LibreOffice")
162
+ print("\nReturns JSON with error details:")
163
+ print(" - status: 'success' or 'errors_found'")
164
+ print(" - total_errors: Total number of Excel errors found")
165
+ print(" - total_formulas: Number of formulas in the file")
166
+ print(" - error_summary: Breakdown by error type with locations")
167
+ print(" - #VALUE!, #DIV/0!, #REF!, #NAME?, #NULL!, #NUM!, #N/A")
168
+ sys.exit(1)
169
+
170
+ filename = sys.argv[1]
171
+ timeout = int(sys.argv[2]) if len(sys.argv) > 2 else 30
172
+
173
+ result = recalc(filename, timeout)
174
+ print(json.dumps(result, indent=2))
175
+
176
+
177
+ if __name__ == '__main__':
178
+ main()
package/src/index.js ADDED
@@ -0,0 +1,181 @@
1
+ import { select, checkbox, confirm } from '@inquirer/prompts';
2
+ import chalk from 'chalk';
3
+ import ora from 'ora';
4
+ import { readdir, cp, mkdir } from 'fs/promises';
5
+ import { existsSync } from 'fs';
6
+ import { join, dirname } from 'path';
7
+ import { fileURLToPath } from 'url';
8
+ import { homedir } from 'os';
9
+
10
+ const __dirname = dirname(fileURLToPath(import.meta.url));
11
+ const ROOT_DIR = join(__dirname, '..');
12
+
13
+ async function getDirectories(path) {
14
+ try {
15
+ const entries = await readdir(path, { withFileTypes: true });
16
+ return entries.filter(e => e.isDirectory()).map(e => e.name);
17
+ } catch {
18
+ return [];
19
+ }
20
+ }
21
+
22
+ async function getFiles(path, extension) {
23
+ try {
24
+ const entries = await readdir(path, { withFileTypes: true });
25
+ return entries
26
+ .filter(e => e.isFile() && e.name.endsWith(extension))
27
+ .map(e => e.name.replace(extension, ''));
28
+ } catch {
29
+ return [];
30
+ }
31
+ }
32
+
33
+ export async function run() {
34
+ console.clear();
35
+
36
+ // Header
37
+ console.log('');
38
+ console.log(chalk.magenta('╔═══════════════════════════════════════════════════╗'));
39
+ console.log(chalk.magenta('║ ║'));
40
+ console.log(chalk.magenta('║') + chalk.white.bold(' CKW AI Toolkit Installer ') + chalk.magenta('║'));
41
+ console.log(chalk.magenta('║ ║'));
42
+ console.log(chalk.magenta('╚═══════════════════════════════════════════════════╝'));
43
+ console.log('');
44
+
45
+ // Get available items
46
+ const agents = await getFiles(join(ROOT_DIR, 'agents'), '.md');
47
+ const skills = await getDirectories(join(ROOT_DIR, 'skills'));
48
+ const mcps = await getDirectories(join(ROOT_DIR, 'mcps'));
49
+
50
+ // Step 1: Platform
51
+ console.log(chalk.cyan('Step 1/4: Platform'));
52
+ const platform = await select({
53
+ message: 'Where do you want to install?',
54
+ choices: [
55
+ { name: 'Claude Code', value: 'claude' },
56
+ { name: 'OpenCode', value: 'opencode' },
57
+ { name: 'Both', value: 'both' }
58
+ ]
59
+ });
60
+
61
+ // Step 2: Agents
62
+ console.log('');
63
+ console.log(chalk.cyan('Step 2/4: Agents'));
64
+ const selectedAgents = agents.length > 0
65
+ ? await checkbox({
66
+ message: 'Select agents to install',
67
+ choices: agents.map(a => ({ name: a, value: a }))
68
+ })
69
+ : [];
70
+
71
+ // Step 3: Skills
72
+ console.log('');
73
+ console.log(chalk.cyan('Step 3/4: Skills'));
74
+ const selectedSkills = skills.length > 0
75
+ ? await checkbox({
76
+ message: 'Select skills to install',
77
+ choices: skills.map(s => ({ name: s, value: s }))
78
+ })
79
+ : [];
80
+
81
+ // Step 4: MCPs
82
+ console.log('');
83
+ console.log(chalk.cyan('Step 4/4: MCPs'));
84
+ const selectedMcps = mcps.length > 0
85
+ ? await checkbox({
86
+ message: 'Select MCPs to install',
87
+ choices: mcps.map(m => ({ name: m, value: m }))
88
+ })
89
+ : [];
90
+
91
+ // Summary
92
+ console.log('');
93
+ console.log(chalk.yellow('Summary'));
94
+ console.log('');
95
+ console.log(` Platform: ${chalk.white(platform)}`);
96
+ console.log(` Agents: ${chalk.white(selectedAgents.length > 0 ? selectedAgents.join(', ') : 'none')}`);
97
+ console.log(` Skills: ${chalk.white(selectedSkills.length > 0 ? selectedSkills.join(', ') : 'none')}`);
98
+ console.log(` MCPs: ${chalk.white(selectedMcps.length > 0 ? selectedMcps.join(', ') : 'none')}`);
99
+ console.log('');
100
+
101
+ const proceed = await confirm({ message: 'Proceed with installation?' });
102
+
103
+ if (!proceed) {
104
+ console.log(chalk.yellow('Installation cancelled.'));
105
+ return;
106
+ }
107
+
108
+ // Installation
109
+ console.log('');
110
+ const spinner = ora('Installing...').start();
111
+
112
+ const home = homedir();
113
+
114
+ async function installClaude() {
115
+ const claudeDir = join(home, '.claude');
116
+ const agentsDir = join(claudeDir, 'agents');
117
+ const skillsDir = join(claudeDir, 'skills');
118
+
119
+ await mkdir(agentsDir, { recursive: true });
120
+ await mkdir(skillsDir, { recursive: true });
121
+
122
+ for (const agent of selectedAgents) {
123
+ const src = join(ROOT_DIR, 'agents', `${agent}.md`);
124
+ const dest = join(agentsDir, `${agent}.md`);
125
+ await cp(src, dest);
126
+ }
127
+
128
+ for (const skill of selectedSkills) {
129
+ const src = join(ROOT_DIR, 'skills', skill);
130
+ const dest = join(skillsDir, skill);
131
+ await cp(src, dest, { recursive: true });
132
+ }
133
+ }
134
+
135
+ async function installOpencode() {
136
+ const opencodeDir = join(home, '.config', 'opencode');
137
+ const agentsDir = join(opencodeDir, 'agent');
138
+ const commandsDir = join(opencodeDir, 'command');
139
+
140
+ await mkdir(agentsDir, { recursive: true });
141
+ await mkdir(commandsDir, { recursive: true });
142
+
143
+ for (const agent of selectedAgents) {
144
+ const src = join(ROOT_DIR, 'agents', `${agent}.md`);
145
+ const dest = join(agentsDir, `${agent}.md`);
146
+ await cp(src, dest);
147
+ }
148
+ }
149
+
150
+ try {
151
+ if (platform === 'claude' || platform === 'both') {
152
+ await installClaude();
153
+ }
154
+ if (platform === 'opencode' || platform === 'both') {
155
+ await installOpencode();
156
+ }
157
+
158
+ spinner.succeed('Installation complete!');
159
+ } catch (error) {
160
+ spinner.fail('Installation failed');
161
+ console.error(chalk.red(error.message));
162
+ return;
163
+ }
164
+
165
+ // Done
166
+ console.log('');
167
+ console.log(chalk.green('╔═══════════════════════════════════════════════════╗'));
168
+ console.log(chalk.green('║') + chalk.white.bold(' ✓ Installation Complete! ') + chalk.green('║'));
169
+ console.log(chalk.green('╚═══════════════════════════════════════════════════╝'));
170
+
171
+ if (selectedMcps.length > 0) {
172
+ console.log('');
173
+ console.log(chalk.yellow('MCP Setup Instructions:'));
174
+ console.log('');
175
+ for (const mcp of selectedMcps) {
176
+ console.log(` → ${chalk.cyan(`mcps/${mcp}/README.md`)}`);
177
+ }
178
+ }
179
+
180
+ console.log('');
181
+ }