@nguyenphp/antigravity-marketing 1.0.18 → 1.0.19

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 (127) hide show
  1. package/README.md +186 -78
  2. package/package.json +4 -3
  3. package/templates/.agent/skills/marketing-report-expert/SKILL.md +70 -0
  4. package/templates/.agent/skills/minimax-docx/LICENSE +21 -0
  5. package/templates/.agent/skills/minimax-docx/SKILL.md +274 -0
  6. package/templates/.agent/skills/minimax-docx/assets/styles/academic_styles.xml +250 -0
  7. package/templates/.agent/skills/minimax-docx/assets/styles/corporate_styles.xml +284 -0
  8. package/templates/.agent/skills/minimax-docx/assets/styles/default_styles.xml +449 -0
  9. package/templates/.agent/skills/minimax-docx/assets/xsd/aesthetic-rules.xsd +470 -0
  10. package/templates/.agent/skills/minimax-docx/assets/xsd/business-rules.xsd +130 -0
  11. package/templates/.agent/skills/minimax-docx/assets/xsd/common-types.xsd +159 -0
  12. package/templates/.agent/skills/minimax-docx/assets/xsd/wml-subset.xsd +589 -0
  13. package/templates/.agent/skills/minimax-docx/references/cjk_typography.md +357 -0
  14. package/templates/.agent/skills/minimax-docx/references/cjk_university_template_guide.md +184 -0
  15. package/templates/.agent/skills/minimax-docx/references/comments_guide.md +191 -0
  16. package/templates/.agent/skills/minimax-docx/references/design_good_bad_examples.md +829 -0
  17. package/templates/.agent/skills/minimax-docx/references/design_principles.md +819 -0
  18. package/templates/.agent/skills/minimax-docx/references/openxml_element_order.md +308 -0
  19. package/templates/.agent/skills/minimax-docx/references/openxml_encyclopedia_part1.md +4061 -0
  20. package/templates/.agent/skills/minimax-docx/references/openxml_encyclopedia_part2.md +2820 -0
  21. package/templates/.agent/skills/minimax-docx/references/openxml_encyclopedia_part3.md +3381 -0
  22. package/templates/.agent/skills/minimax-docx/references/openxml_namespaces.md +82 -0
  23. package/templates/.agent/skills/minimax-docx/references/openxml_units.md +72 -0
  24. package/templates/.agent/skills/minimax-docx/references/scenario_a_create.md +284 -0
  25. package/templates/.agent/skills/minimax-docx/references/scenario_b_edit_content.md +295 -0
  26. package/templates/.agent/skills/minimax-docx/references/scenario_c_apply_template.md +456 -0
  27. package/templates/.agent/skills/minimax-docx/references/track_changes_guide.md +200 -0
  28. package/templates/.agent/skills/minimax-docx/references/troubleshooting.md +506 -0
  29. package/templates/.agent/skills/minimax-docx/references/typography_guide.md +294 -0
  30. package/templates/.agent/skills/minimax-docx/references/xsd_validation_guide.md +158 -0
  31. package/templates/.agent/skills/minimax-docx/scripts/doc_to_docx.sh +40 -0
  32. package/templates/.agent/skills/minimax-docx/scripts/docx_preview.sh +37 -0
  33. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Cli/MiniMaxAIDocx.Cli.csproj +19 -0
  34. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Cli/Program.cs +18 -0
  35. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/AnalyzeCommand.cs +147 -0
  36. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/ApplyTemplateCommand.cs +322 -0
  37. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/CreateCommand.cs +324 -0
  38. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/DiffCommand.cs +155 -0
  39. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/EditContentCommand.cs +487 -0
  40. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/FixOrderCommand.cs +108 -0
  41. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/MergeRunsCommand.cs +122 -0
  42. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Commands/ValidateCommand.cs +107 -0
  43. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/MiniMaxAIDocx.Core.csproj +15 -0
  44. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/CommentSynchronizer.cs +169 -0
  45. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/ElementOrder.cs +80 -0
  46. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/NamespaceConstants.cs +42 -0
  47. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/RunMerger.cs +81 -0
  48. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/StyleAnalyzer.cs +81 -0
  49. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/TrackChangesHelper.cs +99 -0
  50. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/OpenXml/UnitConverter.cs +23 -0
  51. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples.cs +1832 -0
  52. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples_Batch1.cs +910 -0
  53. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples_Batch2.cs +999 -0
  54. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples_Batch3.cs +1048 -0
  55. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/AestheticRecipeSamples_Batch4.cs +1038 -0
  56. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/CharacterFormattingSamples.cs +1020 -0
  57. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/DocumentCreationSamples.cs +1121 -0
  58. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/FieldAndTocSamples.cs +624 -0
  59. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/FootnoteAndCommentSamples.cs +675 -0
  60. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/HeaderFooterSamples.cs +838 -0
  61. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/ImageSamples.cs +917 -0
  62. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/ListAndNumberingSamples.cs +826 -0
  63. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/ParagraphFormattingSamples.cs +1199 -0
  64. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/StyleSystemSamples.cs +1487 -0
  65. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/TableSamples.cs +1163 -0
  66. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Samples/TrackChangesSamples.cs +595 -0
  67. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Typography/CjkHelper.cs +39 -0
  68. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Typography/FontDefaults.cs +24 -0
  69. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Typography/PageSizes.cs +20 -0
  70. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Validation/BusinessRuleValidator.cs +224 -0
  71. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Validation/GateCheckValidator.cs +148 -0
  72. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Validation/ValidationResult.cs +23 -0
  73. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.Core/Validation/XsdValidator.cs +69 -0
  74. package/templates/.agent/skills/minimax-docx/scripts/dotnet/MiniMaxAIDocx.slnx +4 -0
  75. package/templates/.agent/skills/minimax-docx/scripts/env_check.sh +196 -0
  76. package/templates/.agent/skills/minimax-docx/scripts/setup.ps1 +274 -0
  77. package/templates/.agent/skills/minimax-docx/scripts/setup.sh +504 -0
  78. package/templates/.agent/skills/minimax-multimodal-toolkit/SKILL.md +359 -0
  79. package/templates/.agent/skills/minimax-pdf/README.md +222 -0
  80. package/templates/.agent/skills/minimax-pdf/SKILL.md +201 -0
  81. package/templates/.agent/skills/minimax-pdf/design/design.md +381 -0
  82. package/templates/.agent/skills/minimax-pdf/scripts/cover.py +1579 -0
  83. package/templates/.agent/skills/minimax-pdf/scripts/fill_inspect.py +200 -0
  84. package/templates/.agent/skills/minimax-pdf/scripts/fill_write.py +242 -0
  85. package/templates/.agent/skills/minimax-pdf/scripts/make.sh +491 -0
  86. package/templates/.agent/skills/minimax-pdf/scripts/merge.py +112 -0
  87. package/templates/.agent/skills/minimax-pdf/scripts/palette.py +559 -0
  88. package/templates/.agent/skills/minimax-pdf/scripts/reformat_parse.py +374 -0
  89. package/templates/.agent/skills/minimax-pdf/scripts/render_body.py +1055 -0
  90. package/templates/.agent/skills/minimax-pdf/scripts/render_cover.cjs +111 -0
  91. package/templates/.agent/skills/minimax-xlsx/SKILL.md +138 -0
  92. package/templates/.agent/skills/minimax-xlsx/references/create.md +691 -0
  93. package/templates/.agent/skills/minimax-xlsx/references/edit.md +684 -0
  94. package/templates/.agent/skills/minimax-xlsx/references/fix.md +37 -0
  95. package/templates/.agent/skills/minimax-xlsx/references/format.md +768 -0
  96. package/templates/.agent/skills/minimax-xlsx/references/ooxml-cheatsheet.md +231 -0
  97. package/templates/.agent/skills/minimax-xlsx/references/read-analyze.md +97 -0
  98. package/templates/.agent/skills/minimax-xlsx/references/validate.md +772 -0
  99. package/templates/.agent/skills/minimax-xlsx/scripts/formula_check.py +422 -0
  100. package/templates/.agent/skills/minimax-xlsx/scripts/libreoffice_recalc.py +248 -0
  101. package/templates/.agent/skills/minimax-xlsx/scripts/shared_strings_builder.py +163 -0
  102. package/templates/.agent/skills/minimax-xlsx/scripts/style_audit.py +575 -0
  103. package/templates/.agent/skills/minimax-xlsx/scripts/xlsx_add_column.py +395 -0
  104. package/templates/.agent/skills/minimax-xlsx/scripts/xlsx_insert_row.py +274 -0
  105. package/templates/.agent/skills/minimax-xlsx/scripts/xlsx_pack.py +87 -0
  106. package/templates/.agent/skills/minimax-xlsx/scripts/xlsx_reader.py +362 -0
  107. package/templates/.agent/skills/minimax-xlsx/scripts/xlsx_shift_rows.py +396 -0
  108. package/templates/.agent/skills/minimax-xlsx/scripts/xlsx_unpack.py +130 -0
  109. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/[Content_Types].xml +9 -0
  110. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/_rels/.rels +6 -0
  111. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/xl/_rels/workbook.xml.rels +19 -0
  112. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/xl/sharedStrings.xml +33 -0
  113. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/xl/styles.xml +160 -0
  114. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/xl/workbook.xml +30 -0
  115. package/templates/.agent/skills/minimax-xlsx/templates/minimal_xlsx/xl/worksheets/sheet1.xml +70 -0
  116. package/templates/.agent/skills/pptx-generator/SKILL.md +249 -0
  117. package/templates/.agent/skills/pptx-generator/references/design-system.md +392 -0
  118. package/templates/.agent/skills/pptx-generator/references/editing.md +162 -0
  119. package/templates/.agent/skills/pptx-generator/references/pitfalls.md +112 -0
  120. package/templates/.agent/skills/pptx-generator/references/pptxgenjs.md +420 -0
  121. package/templates/.agent/skills/pptx-generator/references/slide-types.md +413 -0
  122. package/templates/.agent/skills/tutorial-video-expert/SKILL.md +88 -0
  123. package/templates/.agent/skills/ui-ux-pro-max/SKILL.md +170 -585
  124. package/templates/.agent/skills/vision-analysis/SKILL.md +174 -0
  125. package/templates/.agent/workflows/analyze.md +3 -0
  126. package/templates/.agent/workflows/brand-report.md +44 -0
  127. package/templates/.agent/workflows/report.md +49 -0
@@ -0,0 +1,504 @@
1
+ #!/usr/bin/env bash
2
+ # minimax-docx Environment Setup & Initialization Script
3
+ # Supports: macOS (Homebrew), Linux (apt/dnf/pacman), WSL
4
+ # License: MIT
5
+ set -euo pipefail
6
+
7
+ # Force English output for dotnet CLI
8
+ export DOTNET_CLI_UI_LANGUAGE=en
9
+
10
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11
+ PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
12
+ DOTNET_DIR="$SCRIPT_DIR/dotnet"
13
+ LOG_FILE="$PROJECT_DIR/.setup.log"
14
+
15
+ # --- Colors ---
16
+ RED='\033[0;31m'
17
+ GREEN='\033[0;32m'
18
+ YELLOW='\033[1;33m'
19
+ BLUE='\033[0;34m'
20
+ NC='\033[0m'
21
+
22
+ log() { echo -e "${GREEN}[OK]${NC} $*"; }
23
+ warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
24
+ fail() { echo -e "${RED}[FAIL]${NC} $*"; }
25
+ info() { echo -e "${BLUE}[INFO]${NC} $*"; }
26
+ step() { echo -e "\n${BLUE}=== $* ===${NC}"; }
27
+
28
+ # --- Detect OS & Package Manager ---
29
+ detect_platform() {
30
+ OS="unknown"
31
+ PKG_MGR="unknown"
32
+ ARCH="$(uname -m)"
33
+
34
+ case "$(uname -s)" in
35
+ Darwin)
36
+ OS="macos"
37
+ if command -v brew &>/dev/null; then
38
+ PKG_MGR="brew"
39
+ else
40
+ PKG_MGR="none"
41
+ fi
42
+ ;;
43
+ Linux)
44
+ OS="linux"
45
+ if [ -f /etc/os-release ]; then
46
+ . /etc/os-release
47
+ case "$ID" in
48
+ ubuntu|debian|linuxmint|pop)
49
+ PKG_MGR="apt"
50
+ ;;
51
+ fedora|rhel|centos|rocky|alma)
52
+ PKG_MGR="dnf"
53
+ ;;
54
+ arch|manjaro|endeavouros)
55
+ PKG_MGR="pacman"
56
+ ;;
57
+ opensuse*|sles)
58
+ PKG_MGR="zypper"
59
+ ;;
60
+ alpine)
61
+ PKG_MGR="apk"
62
+ ;;
63
+ *)
64
+ PKG_MGR="unknown"
65
+ ;;
66
+ esac
67
+ fi
68
+ # Detect WSL
69
+ if grep -qi microsoft /proc/version 2>/dev/null; then
70
+ OS="wsl"
71
+ fi
72
+ ;;
73
+ MINGW*|MSYS*|CYGWIN*)
74
+ OS="windows-git-bash"
75
+ PKG_MGR="none"
76
+ ;;
77
+ esac
78
+
79
+ echo "Platform: $OS ($ARCH), Package Manager: $PKG_MGR"
80
+ }
81
+
82
+ # --- .NET SDK Installation ---
83
+ install_dotnet() {
84
+ step "Checking .NET SDK"
85
+
86
+ if command -v dotnet &>/dev/null; then
87
+ local ver
88
+ ver=$(dotnet --version 2>/dev/null || echo "0")
89
+ local major="${ver%%.*}"
90
+ if [ "$major" -ge 8 ] 2>/dev/null; then
91
+ log "dotnet $ver already installed (>= 8.0 OK)"
92
+ return 0
93
+ else
94
+ warn "dotnet $ver found but < 8.0, upgrading..."
95
+ fi
96
+ fi
97
+
98
+ info "Installing .NET SDK..."
99
+ case "$PKG_MGR" in
100
+ brew)
101
+ brew install --cask dotnet-sdk
102
+ ;;
103
+ apt)
104
+ # Microsoft package repo for Ubuntu/Debian
105
+ if ! dpkg -l dotnet-sdk-8.0 &>/dev/null 2>&1; then
106
+ info "Adding Microsoft package repository..."
107
+ sudo apt-get update -qq
108
+ sudo apt-get install -y -qq wget apt-transport-https
109
+ wget -q "https://dot.net/v1/dotnet-install.sh" -O /tmp/dotnet-install.sh
110
+ chmod +x /tmp/dotnet-install.sh
111
+ /tmp/dotnet-install.sh --channel 8.0 --install-dir "$HOME/.dotnet"
112
+ export PATH="$HOME/.dotnet:$PATH"
113
+ echo 'export PATH="$HOME/.dotnet:$PATH"' >> "$HOME/.bashrc"
114
+ fi
115
+ ;;
116
+ dnf)
117
+ sudo dnf install -y dotnet-sdk-8.0
118
+ ;;
119
+ pacman)
120
+ sudo pacman -S --noconfirm dotnet-sdk
121
+ ;;
122
+ zypper)
123
+ sudo zypper install -y dotnet-sdk-8.0
124
+ ;;
125
+ apk)
126
+ apk add --no-cache dotnet8-sdk
127
+ ;;
128
+ none)
129
+ if [ "$OS" = "windows-git-bash" ]; then
130
+ fail "On Windows, install .NET SDK from: https://dotnet.microsoft.com/download"
131
+ fail "Then restart your terminal and re-run this script."
132
+ return 1
133
+ fi
134
+ # Fallback: use Microsoft install script
135
+ info "Using Microsoft install script..."
136
+ wget -q "https://dot.net/v1/dotnet-install.sh" -O /tmp/dotnet-install.sh || \
137
+ curl -sSL "https://dot.net/v1/dotnet-install.sh" -o /tmp/dotnet-install.sh
138
+ chmod +x /tmp/dotnet-install.sh
139
+ /tmp/dotnet-install.sh --channel 8.0 --install-dir "$HOME/.dotnet"
140
+ export PATH="$HOME/.dotnet:$PATH"
141
+ echo 'export PATH="$HOME/.dotnet:$PATH"' >> "$HOME/.bashrc"
142
+ ;;
143
+ *)
144
+ warn "Unknown package manager. Install .NET SDK manually: https://dotnet.microsoft.com/download"
145
+ return 1
146
+ ;;
147
+ esac
148
+
149
+ # Verify
150
+ if command -v dotnet &>/dev/null; then
151
+ log "dotnet $(dotnet --version) installed"
152
+ else
153
+ fail "dotnet installation failed. Install manually: https://dotnet.microsoft.com/download"
154
+ return 1
155
+ fi
156
+ }
157
+
158
+ # --- Pandoc Installation (Optional) ---
159
+ install_pandoc() {
160
+ step "Checking pandoc (optional: content preview)"
161
+
162
+ if command -v pandoc &>/dev/null; then
163
+ log "pandoc $(pandoc --version | head -1 | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?') already installed"
164
+ return 0
165
+ fi
166
+
167
+ info "Installing pandoc..."
168
+ case "$PKG_MGR" in
169
+ brew) brew install pandoc ;;
170
+ apt) sudo apt-get install -y -qq pandoc ;;
171
+ dnf) sudo dnf install -y pandoc ;;
172
+ pacman) sudo pacman -S --noconfirm pandoc ;;
173
+ zypper) sudo zypper install -y pandoc ;;
174
+ apk) apk add --no-cache pandoc ;;
175
+ *)
176
+ warn "Cannot auto-install pandoc. Install manually: https://pandoc.org/installing.html"
177
+ return 0
178
+ ;;
179
+ esac
180
+
181
+ if command -v pandoc &>/dev/null; then
182
+ log "pandoc installed"
183
+ else
184
+ warn "pandoc installation failed (optional, will degrade gracefully)"
185
+ fi
186
+ }
187
+
188
+ # --- LibreOffice Installation (Optional) ---
189
+ install_soffice() {
190
+ step "Checking LibreOffice/soffice (optional: .doc conversion)"
191
+
192
+ if command -v soffice &>/dev/null; then
193
+ log "soffice already installed"
194
+ return 0
195
+ fi
196
+
197
+ # Also check common install paths
198
+ local soffice_paths=(
199
+ "/usr/bin/soffice"
200
+ "/usr/local/bin/soffice"
201
+ "/opt/libreoffice/program/soffice"
202
+ "/snap/bin/libreoffice"
203
+ "/Applications/LibreOffice.app/Contents/MacOS/soffice"
204
+ )
205
+ for p in "${soffice_paths[@]}"; do
206
+ if [ -x "$p" ]; then
207
+ log "soffice found at $p"
208
+ if [ "$OS" = "macos" ] && [ "$p" = "/Applications/LibreOffice.app/Contents/MacOS/soffice" ]; then
209
+ info "Tip: Add to PATH: ln -s '$p' /usr/local/bin/soffice"
210
+ fi
211
+ return 0
212
+ fi
213
+ done
214
+
215
+ info "Installing LibreOffice (this may take a while)..."
216
+ case "$PKG_MGR" in
217
+ brew) brew install --cask libreoffice ;;
218
+ apt) sudo apt-get install -y -qq libreoffice-core ;;
219
+ dnf) sudo dnf install -y libreoffice-core ;;
220
+ pacman) sudo pacman -S --noconfirm libreoffice-still ;;
221
+ zypper) sudo zypper install -y libreoffice ;;
222
+ apk) apk add --no-cache libreoffice ;;
223
+ *)
224
+ warn "Cannot auto-install LibreOffice. Install manually: https://www.libreoffice.org/download/"
225
+ return 0
226
+ ;;
227
+ esac
228
+
229
+ if command -v soffice &>/dev/null; then
230
+ log "soffice installed"
231
+ else
232
+ warn "soffice not found after install (optional, .doc conversion unavailable)"
233
+ fi
234
+ }
235
+
236
+ # --- zip/unzip ---
237
+ install_zip_tools() {
238
+ step "Checking zip/unzip"
239
+
240
+ local need_zip=false need_unzip=false
241
+ command -v zip &>/dev/null && log "zip already installed" || need_zip=true
242
+ command -v unzip &>/dev/null && log "unzip already installed" || need_unzip=true
243
+
244
+ if ! $need_zip && ! $need_unzip; then
245
+ return 0
246
+ fi
247
+
248
+ info "Installing zip/unzip..."
249
+ case "$PKG_MGR" in
250
+ brew) brew install zip unzip 2>/dev/null || true ;;
251
+ apt) sudo apt-get install -y -qq zip unzip ;;
252
+ dnf) sudo dnf install -y zip unzip ;;
253
+ pacman) sudo pacman -S --noconfirm zip unzip ;;
254
+ zypper) sudo zypper install -y zip unzip ;;
255
+ apk) apk add --no-cache zip unzip ;;
256
+ *) warn "Install zip/unzip manually (optional, .NET handles DOCX natively)" ;;
257
+ esac
258
+ }
259
+
260
+ # --- .NET Project Build ---
261
+ build_project() {
262
+ step "Building minimax-docx .NET project"
263
+
264
+ if [ ! -d "$DOTNET_DIR" ]; then
265
+ fail "Dotnet project directory not found: $DOTNET_DIR"
266
+ return 1
267
+ fi
268
+
269
+ cd "$DOTNET_DIR"
270
+
271
+ info "Restoring NuGet packages..."
272
+ if ! dotnet restore --verbosity quiet 2>>"$LOG_FILE"; then
273
+ fail "NuGet restore failed. Check network and $LOG_FILE for details."
274
+ fail "Common causes:"
275
+ fail " - No internet access (NuGet needs to download packages)"
276
+ fail " - Corporate proxy blocking nuget.org"
277
+ fail " - Disk space insufficient"
278
+ echo ""
279
+ fail "Try manually: cd $DOTNET_DIR && dotnet restore --verbosity detailed"
280
+ return 1
281
+ fi
282
+ log "NuGet packages restored"
283
+
284
+ info "Building project..."
285
+ if ! dotnet build --verbosity quiet --no-restore 2>>"$LOG_FILE"; then
286
+ fail "Build failed. Check $LOG_FILE for details."
287
+ fail "Try manually: cd $DOTNET_DIR && dotnet build --verbosity normal"
288
+ return 1
289
+ fi
290
+ log "Project built successfully"
291
+
292
+ cd "$PROJECT_DIR"
293
+ }
294
+
295
+ # --- Shell Script Permissions ---
296
+ fix_permissions() {
297
+ step "Setting script permissions"
298
+
299
+ local scripts=(
300
+ "$SCRIPT_DIR/env_check.sh"
301
+ "$SCRIPT_DIR/docx_preview.sh"
302
+ "$SCRIPT_DIR/doc_to_docx.sh"
303
+ "$SCRIPT_DIR/setup.sh"
304
+ )
305
+
306
+ for s in "${scripts[@]}"; do
307
+ if [ -f "$s" ]; then
308
+ chmod +x "$s"
309
+ log "chmod +x $(basename "$s")"
310
+ fi
311
+ done
312
+ }
313
+
314
+ # --- NuGet Proxy / Certificate Issues (Corporate Environments) ---
315
+ check_nuget_config() {
316
+ step "Checking NuGet configuration"
317
+
318
+ local nuget_config="$HOME/.nuget/NuGet/NuGet.Config"
319
+ if [ -f "$nuget_config" ]; then
320
+ log "NuGet config exists: $nuget_config"
321
+ else
322
+ info "No custom NuGet config found (using defaults)"
323
+ fi
324
+
325
+ # Test NuGet connectivity
326
+ if dotnet nuget list source 2>/dev/null | grep -q "nuget.org"; then
327
+ log "nuget.org source is configured"
328
+ else
329
+ warn "nuget.org not in sources. Adding..."
330
+ dotnet nuget add source "https://api.nuget.org/v3/index.json" --name "nuget.org" 2>/dev/null || true
331
+ fi
332
+ }
333
+
334
+ # --- Locale / Encoding Check ---
335
+ check_locale() {
336
+ step "Checking locale and encoding"
337
+
338
+ local current_lang="${LANG:-not set}"
339
+ local current_lc="${LC_ALL:-not set}"
340
+
341
+ if echo "$current_lang" | grep -qi "utf-8\|utf8"; then
342
+ log "Locale supports UTF-8: LANG=$current_lang"
343
+ else
344
+ warn "Locale may not support UTF-8: LANG=$current_lang"
345
+ warn "CJK document processing requires UTF-8. Set: export LANG=en_US.UTF-8"
346
+ if [ "$OS" = "linux" ] || [ "$OS" = "wsl" ]; then
347
+ info "To fix permanently: sudo locale-gen en_US.UTF-8 && sudo update-locale LANG=en_US.UTF-8"
348
+ fi
349
+ fi
350
+ }
351
+
352
+ # --- Font Check (for CJK and professional documents) ---
353
+ check_fonts() {
354
+ step "Checking fonts for document rendering"
355
+
356
+ if [ "$OS" = "macos" ]; then
357
+ # macOS has good CJK support built-in
358
+ log "macOS: built-in CJK font support (PingFang, Hiragino, Apple SD Gothic)"
359
+ log "macOS: built-in Western fonts (Helvetica, Times, Calibri via Office)"
360
+ if [ -d "/Applications/Microsoft Word.app" ] || [ -d "/Applications/Microsoft Office" ]; then
361
+ log "Microsoft Office fonts available (Calibri, Cambria, etc.)"
362
+ else
363
+ warn "Microsoft Office not installed — Calibri/Cambria fonts may be missing"
364
+ info "Documents will render with fallback fonts on this machine"
365
+ info "Recipients with Office installed will see correct fonts"
366
+ fi
367
+ elif [ "$OS" = "linux" ] || [ "$OS" = "wsl" ]; then
368
+ # Check for key font packages
369
+ local missing_fonts=()
370
+
371
+ if ! fc-list 2>/dev/null | grep -qi "liberation\|times new roman\|calibri"; then
372
+ missing_fonts+=("Western: liberation-fonts or msttcorefonts")
373
+ fi
374
+
375
+ if ! fc-list 2>/dev/null | grep -qi "noto.*cjk\|wqy\|simsun\|pingfang"; then
376
+ missing_fonts+=("CJK: noto-fonts-cjk or wqy-microhei")
377
+ fi
378
+
379
+ if [ ${#missing_fonts[@]} -eq 0 ]; then
380
+ log "Font support looks good"
381
+ else
382
+ warn "Missing fonts may affect document rendering:"
383
+ for f in "${missing_fonts[@]}"; do
384
+ warn " - $f"
385
+ done
386
+ info "Install fonts:"
387
+ case "$PKG_MGR" in
388
+ apt)
389
+ info " sudo apt-get install -y fonts-liberation fonts-noto-cjk"
390
+ info " # For MS core fonts: sudo apt-get install -y ttf-mscorefonts-installer"
391
+ ;;
392
+ dnf)
393
+ info " sudo dnf install -y liberation-fonts google-noto-sans-cjk-fonts"
394
+ ;;
395
+ pacman)
396
+ info " sudo pacman -S ttf-liberation noto-fonts-cjk"
397
+ ;;
398
+ *)
399
+ info " Install Liberation Fonts and Noto CJK fonts for your distribution"
400
+ ;;
401
+ esac
402
+ fi
403
+ fi
404
+ }
405
+
406
+ # --- Verification Run ---
407
+ verify_installation() {
408
+ step "Verification Test"
409
+
410
+ local test_output="/tmp/minimax-docx-setup-test-$$.docx"
411
+
412
+ info "Creating a test document..."
413
+ if cd "$DOTNET_DIR" && dotnet run --project MiniMaxAIDocx.Cli -- create \
414
+ --type report --output "$test_output" --title "Setup Test" 2>>"$LOG_FILE"; then
415
+ log "Test document created: $test_output"
416
+
417
+ # Try preview
418
+ if command -v pandoc &>/dev/null; then
419
+ local preview
420
+ preview=$(pandoc -f docx -t plain "$test_output" 2>/dev/null | head -5)
421
+ if [ -n "$preview" ]; then
422
+ log "Preview working: \"$preview\""
423
+ fi
424
+ fi
425
+
426
+ # Cleanup
427
+ rm -f "$test_output"
428
+ log "Test passed — minimax-docx is ready to use!"
429
+ else
430
+ fail "Test document creation failed. Check $LOG_FILE for details."
431
+ return 1
432
+ fi
433
+
434
+ cd "$PROJECT_DIR"
435
+ }
436
+
437
+ # --- Summary ---
438
+ print_summary() {
439
+ step "Setup Complete"
440
+
441
+ echo ""
442
+ echo " Environment: $OS ($ARCH)"
443
+ echo " .NET SDK: $(dotnet --version 2>/dev/null || echo 'NOT FOUND')"
444
+ echo " pandoc: $(pandoc --version 2>/dev/null | head -1 | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' || echo 'not installed (optional)')"
445
+ echo " soffice: $(soffice --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' || echo 'not installed (optional)')"
446
+ echo " Project: $DOTNET_DIR"
447
+ echo ""
448
+ echo " Usage:"
449
+ echo " dotnet run --project $DOTNET_DIR/MiniMaxAIDocx.Cli -- create --type report --output my_report.docx"
450
+ echo " bash $SCRIPT_DIR/env_check.sh # Quick environment check"
451
+ echo ""
452
+ echo " Log file: $LOG_FILE"
453
+ }
454
+
455
+ # --- Main ---
456
+ main() {
457
+ echo "============================================"
458
+ echo " minimax-docx Setup & Initialization"
459
+ echo " $(date '+%Y-%m-%d %H:%M:%S')"
460
+ echo "============================================"
461
+
462
+ : > "$LOG_FILE" # Clear log
463
+
464
+ detect_platform
465
+
466
+ # Parse arguments
467
+ local SKIP_OPTIONAL=false
468
+ local SKIP_VERIFY=false
469
+ for arg in "$@"; do
470
+ case "$arg" in
471
+ --minimal) SKIP_OPTIONAL=true ;;
472
+ --skip-verify) SKIP_VERIFY=true ;;
473
+ --help|-h)
474
+ echo "Usage: setup.sh [options]"
475
+ echo " --minimal Only install critical dependencies (skip pandoc, soffice, fonts)"
476
+ echo " --skip-verify Skip the verification test at the end"
477
+ echo " --help Show this help"
478
+ exit 0
479
+ ;;
480
+ esac
481
+ done
482
+
483
+ install_dotnet
484
+ install_zip_tools
485
+
486
+ if ! $SKIP_OPTIONAL; then
487
+ install_pandoc
488
+ install_soffice
489
+ check_fonts
490
+ fi
491
+
492
+ check_locale
493
+ check_nuget_config
494
+ fix_permissions
495
+ build_project
496
+
497
+ if ! $SKIP_VERIFY; then
498
+ verify_installation
499
+ fi
500
+
501
+ print_summary
502
+ }
503
+
504
+ main "$@"