zcode-app-cli 3.3.5-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +642 -0
  3. package/bin/zcode.js +848 -0
  4. package/config.example.json +110 -0
  5. package/package.json +81 -0
  6. package/vendor/.node-bundle-meta.json +6 -0
  7. package/vendor/extraction.json +11 -0
  8. package/vendor/node_modules/@zcode/tui/dist/index.js +161875 -0
  9. package/vendor/node_modules/@zcode/tui/package.json +14 -0
  10. package/vendor/packages/android-emulator-plugin/.mcp.json +19 -0
  11. package/vendor/packages/android-emulator-plugin/.zcode-plugin/plugin.json +63 -0
  12. package/vendor/packages/android-emulator-plugin/README.md +134 -0
  13. package/vendor/packages/android-emulator-plugin/commands/android-dev.md +11 -0
  14. package/vendor/packages/android-emulator-plugin/dist/lib/path.d.ts +4 -0
  15. package/vendor/packages/android-emulator-plugin/dist/lib/path.js +17 -0
  16. package/vendor/packages/android-emulator-plugin/dist/lib/result.d.ts +5 -0
  17. package/vendor/packages/android-emulator-plugin/dist/lib/result.js +22 -0
  18. package/vendor/packages/android-emulator-plugin/dist/lib/run.d.ts +18 -0
  19. package/vendor/packages/android-emulator-plugin/dist/lib/run.js +99 -0
  20. package/vendor/packages/android-emulator-plugin/dist/mcp/server.d.ts +3 -0
  21. package/vendor/packages/android-emulator-plugin/dist/mcp/server.js +47607 -0
  22. package/vendor/packages/android-emulator-plugin/dist/providers/app.d.ts +39 -0
  23. package/vendor/packages/android-emulator-plugin/dist/providers/app.js +50 -0
  24. package/vendor/packages/android-emulator-plugin/dist/providers/avd.d.ts +37 -0
  25. package/vendor/packages/android-emulator-plugin/dist/providers/avd.js +185 -0
  26. package/vendor/packages/android-emulator-plugin/dist/providers/build.d.ts +68 -0
  27. package/vendor/packages/android-emulator-plugin/dist/providers/build.js +131 -0
  28. package/vendor/packages/android-emulator-plugin/dist/providers/config.d.ts +7 -0
  29. package/vendor/packages/android-emulator-plugin/dist/providers/config.js +29 -0
  30. package/vendor/packages/android-emulator-plugin/dist/providers/device.d.ts +20 -0
  31. package/vendor/packages/android-emulator-plugin/dist/providers/device.js +91 -0
  32. package/vendor/packages/android-emulator-plugin/dist/providers/logs.d.ts +15 -0
  33. package/vendor/packages/android-emulator-plugin/dist/providers/logs.js +31 -0
  34. package/vendor/packages/android-emulator-plugin/dist/providers/preflight.d.ts +15 -0
  35. package/vendor/packages/android-emulator-plugin/dist/providers/preflight.js +123 -0
  36. package/vendor/packages/android-emulator-plugin/dist/providers/project-template.d.ts +13 -0
  37. package/vendor/packages/android-emulator-plugin/dist/providers/project-template.js +211 -0
  38. package/vendor/packages/android-emulator-plugin/dist/providers/project.d.ts +33 -0
  39. package/vendor/packages/android-emulator-plugin/dist/providers/project.js +195 -0
  40. package/vendor/packages/android-emulator-plugin/dist/providers/screenshot.d.ts +14 -0
  41. package/vendor/packages/android-emulator-plugin/dist/providers/screenshot.js +73 -0
  42. package/vendor/packages/android-emulator-plugin/dist/providers/sdk.d.ts +14 -0
  43. package/vendor/packages/android-emulator-plugin/dist/providers/sdk.js +185 -0
  44. package/vendor/packages/android-emulator-plugin/dist/providers/ui.d.ts +92 -0
  45. package/vendor/packages/android-emulator-plugin/dist/providers/ui.js +146 -0
  46. package/vendor/packages/android-emulator-plugin/hooks/hooks.json +3 -0
  47. package/vendor/packages/android-emulator-plugin/package.json +35 -0
  48. package/vendor/packages/android-emulator-plugin/skills/android-dev/INSTALL_ENVIRONMENT.md +357 -0
  49. package/vendor/packages/android-emulator-plugin/skills/android-dev/SKILL.md +73 -0
  50. package/vendor/packages/android-emulator-plugin/templates/compose-app/README.md +5 -0
  51. package/vendor/packages/document-skills-plugin/.zcode-plugin/plugin.json +8 -0
  52. package/vendor/packages/document-skills-plugin/package.json +8 -0
  53. package/vendor/packages/document-skills-plugin/skills/docx/LICENSE.txt +13 -0
  54. package/vendor/packages/document-skills-plugin/skills/docx/SKILL.md +201 -0
  55. package/vendor/packages/document-skills-plugin/skills/docx/references/chart-templates.md +386 -0
  56. package/vendor/packages/document-skills-plugin/skills/docx/references/common-rules.md +419 -0
  57. package/vendor/packages/document-skills-plugin/skills/docx/references/decorations.md +537 -0
  58. package/vendor/packages/document-skills-plugin/skills/docx/references/design-system.md +1797 -0
  59. package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-advanced.md +257 -0
  60. package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-core.md +332 -0
  61. package/vendor/packages/document-skills-plugin/skills/docx/references/faq.md +323 -0
  62. package/vendor/packages/document-skills-plugin/skills/docx/references/math-formulas.md +276 -0
  63. package/vendor/packages/document-skills-plugin/skills/docx/references/ooxml.md +222 -0
  64. package/vendor/packages/document-skills-plugin/skills/docx/references/toc.md +264 -0
  65. package/vendor/packages/document-skills-plugin/skills/docx/routes/comment.md +88 -0
  66. package/vendor/packages/document-skills-plugin/skills/docx/routes/create.md +207 -0
  67. package/vendor/packages/document-skills-plugin/skills/docx/routes/edit.md +115 -0
  68. package/vendor/packages/document-skills-plugin/skills/docx/routes/format.md +120 -0
  69. package/vendor/packages/document-skills-plugin/skills/docx/routes/read.md +114 -0
  70. package/vendor/packages/document-skills-plugin/skills/docx/scenes/academic.md +783 -0
  71. package/vendor/packages/document-skills-plugin/skills/docx/scenes/contract.md +463 -0
  72. package/vendor/packages/document-skills-plugin/skills/docx/scenes/copywriting.md +139 -0
  73. package/vendor/packages/document-skills-plugin/skills/docx/scenes/exam.md +698 -0
  74. package/vendor/packages/document-skills-plugin/skills/docx/scenes/official-doc.md +411 -0
  75. package/vendor/packages/document-skills-plugin/skills/docx/scenes/report.md +340 -0
  76. package/vendor/packages/document-skills-plugin/skills/docx/scenes/resume.md +534 -0
  77. package/vendor/packages/document-skills-plugin/skills/docx/scripts/__init__.py +1 -0
  78. package/vendor/packages/document-skills-plugin/skills/docx/scripts/add_toc_placeholders.py +749 -0
  79. package/vendor/packages/document-skills-plugin/skills/docx/scripts/document.py +1333 -0
  80. package/vendor/packages/document-skills-plugin/skills/docx/scripts/postcheck.py +807 -0
  81. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/comments.xml +3 -0
  82. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsExtended.xml +3 -0
  83. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
  84. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsIds.xml +3 -0
  85. package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/people.xml +3 -0
  86. package/vendor/packages/document-skills-plugin/skills/docx/scripts/utilities.py +374 -0
  87. package/vendor/packages/document-skills-plugin/skills/docx/setup.sh +177 -0
  88. package/vendor/packages/document-skills-plugin/skills/pdf/LICENSE.txt +13 -0
  89. package/vendor/packages/document-skills-plugin/skills/pdf/SKILL.md +919 -0
  90. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/academic.md +1058 -0
  91. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/creative.md +770 -0
  92. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/poster.md +702 -0
  93. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process-advanced.md +284 -0
  94. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process.md +319 -0
  95. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/report.md +1659 -0
  96. package/vendor/packages/document-skills-plugin/skills/pdf/configs/components.md +153 -0
  97. package/vendor/packages/document-skills-plugin/skills/pdf/configs/fonts.md +93 -0
  98. package/vendor/packages/document-skills-plugin/skills/pdf/configs/visual_framework.md +263 -0
  99. package/vendor/packages/document-skills-plugin/skills/pdf/references/resume-academic.tex +130 -0
  100. package/vendor/packages/document-skills-plugin/skills/pdf/references/resume-altacv.tex +190 -0
  101. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/cover_validate.js +367 -0
  102. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/design_engine.py +2816 -0
  103. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2pdf-next.js +754 -0
  104. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2poster.js +256 -0
  105. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf.py +2959 -0
  106. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf_qa.py +901 -0
  107. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/poster_validate.py +1337 -0
  108. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/setup.sh +269 -0
  109. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/toc_validate.py +2075 -0
  110. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/charts.md +320 -0
  111. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover-backgrounds.md +384 -0
  112. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover.md +1442 -0
  113. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/fill-engine.md +527 -0
  114. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/geometry.md +142 -0
  115. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/overflow.md +630 -0
  116. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/pagination.md +367 -0
  117. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/palette.md +217 -0
  118. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/typography.md +20 -0
  119. package/vendor/packages/ios-simulator-plugin/.mcp.json +15 -0
  120. package/vendor/packages/ios-simulator-plugin/.zcode-plugin/plugin.json +34 -0
  121. package/vendor/packages/ios-simulator-plugin/README.md +111 -0
  122. package/vendor/packages/ios-simulator-plugin/commands/ios-dev.md +11 -0
  123. package/vendor/packages/ios-simulator-plugin/dist/lib/path.d.ts +4 -0
  124. package/vendor/packages/ios-simulator-plugin/dist/lib/path.js +18 -0
  125. package/vendor/packages/ios-simulator-plugin/dist/lib/result.d.ts +5 -0
  126. package/vendor/packages/ios-simulator-plugin/dist/lib/result.js +20 -0
  127. package/vendor/packages/ios-simulator-plugin/dist/lib/run.d.ts +17 -0
  128. package/vendor/packages/ios-simulator-plugin/dist/lib/run.js +83 -0
  129. package/vendor/packages/ios-simulator-plugin/dist/mcp/server.d.ts +3 -0
  130. package/vendor/packages/ios-simulator-plugin/dist/mcp/server.js +46833 -0
  131. package/vendor/packages/ios-simulator-plugin/dist/providers/build.d.ts +112 -0
  132. package/vendor/packages/ios-simulator-plugin/dist/providers/build.js +99 -0
  133. package/vendor/packages/ios-simulator-plugin/dist/providers/logs.d.ts +21 -0
  134. package/vendor/packages/ios-simulator-plugin/dist/providers/logs.js +26 -0
  135. package/vendor/packages/ios-simulator-plugin/dist/providers/preflight.d.ts +12 -0
  136. package/vendor/packages/ios-simulator-plugin/dist/providers/preflight.js +62 -0
  137. package/vendor/packages/ios-simulator-plugin/dist/providers/project.d.ts +35 -0
  138. package/vendor/packages/ios-simulator-plugin/dist/providers/project.js +288 -0
  139. package/vendor/packages/ios-simulator-plugin/dist/providers/screenshot.d.ts +22 -0
  140. package/vendor/packages/ios-simulator-plugin/dist/providers/screenshot.js +30 -0
  141. package/vendor/packages/ios-simulator-plugin/dist/providers/sim.d.ts +60 -0
  142. package/vendor/packages/ios-simulator-plugin/dist/providers/sim.js +116 -0
  143. package/vendor/packages/ios-simulator-plugin/dist/providers/ui.d.ts +57 -0
  144. package/vendor/packages/ios-simulator-plugin/dist/providers/ui.js +67 -0
  145. package/vendor/packages/ios-simulator-plugin/hooks/hooks.json +3 -0
  146. package/vendor/packages/ios-simulator-plugin/package.json +35 -0
  147. package/vendor/packages/ios-simulator-plugin/skills/ios-dev/SKILL.md +45 -0
  148. package/vendor/packages/ios-simulator-plugin/templates/swiftui-app/README.md +5 -0
  149. package/vendor/packages/restore-legacy-sessions-plugin/.zcode-plugin/plugin.json +9 -0
  150. package/vendor/packages/restore-legacy-sessions-plugin/README.md +35 -0
  151. package/vendor/packages/restore-legacy-sessions-plugin/commands/restore-legacy-sessions.md +11 -0
  152. package/vendor/packages/restore-legacy-sessions-plugin/package.json +8 -0
  153. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/SKILL.md +92 -0
  154. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/restore-conversation.mjs +648 -0
  155. package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/scan-legacy-sessions.mjs +422 -0
  156. package/vendor/packages/skill-creator-plugin/.zcode-plugin/plugin.json +8 -0
  157. package/vendor/packages/skill-creator-plugin/package.json +8 -0
  158. package/vendor/packages/skill-creator-plugin/skills/skill-creator/SKILL.md +159 -0
  159. package/vendor/packages/zcode-guide-plugin/.zcode-plugin/plugin.json +8 -0
  160. package/vendor/packages/zcode-guide-plugin/README.md +22 -0
  161. package/vendor/packages/zcode-guide-plugin/package.json +8 -0
  162. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-commands/SKILL.md +66 -0
  163. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-hooks/SKILL.md +66 -0
  164. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-mcp/SKILL.md +97 -0
  165. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-plugins/SKILL.md +59 -0
  166. package/vendor/packages/zcode-guide-plugin/skills/diagnosing-skills/SKILL.md +61 -0
  167. package/vendor/packages/zcode-guide-plugin/skills/zcode-configuration-guide/SKILL.md +99 -0
  168. package/vendor/zcode.cjs +2926 -0
  169. package/zcode-runtime.lock.json +8 -0
@@ -0,0 +1,357 @@
1
+ # Android Environment Setup
2
+
3
+ Use this procedure only when `android_preflight` reports that the Android development environment is not ready.
4
+
5
+ The goal is to make the environment ready with deterministic shell commands, then return to MCP tools. Do not call removed setup tools such as `android_ensure_environment`.
6
+
7
+ ## Configurable Defaults
8
+
9
+ The plugin manifest exposes the Android SDK path, default AVD, JDK major version,
10
+ Android API level, build-tools version, and system image variant/ABI as user
11
+ config. ZCode/OpenCLI passes those values to the MCP server as `ANDROID_PLUGIN_*`
12
+ environment variables, and `android_preflight` reports the effective defaults.
13
+
14
+ Use those configured values instead of inventing versions. The documented fallback defaults are:
15
+
16
+ - `ANDROID_PLUGIN_JDK_MAJOR=17`
17
+ - `ANDROID_PLUGIN_API_LEVEL=35`
18
+ - `ANDROID_PLUGIN_BUILD_TOOLS_VERSION=35.0.0`
19
+ - `ANDROID_PLUGIN_SYSTEM_IMAGE_VARIANT=default`
20
+ - `ANDROID_PLUGIN_SYSTEM_IMAGE_ABI=` for host-based auto selection
21
+
22
+ The Windows PowerShell setup commands also accept these shell environment
23
+ overrides when you run them directly; they are not plugin user config and are
24
+ not injected into the MCP server:
25
+
26
+ - `ANDROID_PLUGIN_DEFAULT_PROFILE=medium_phone`
27
+ - `ANDROID_PLUGIN_WINDOWS_JDK_WINGET_PACKAGE=EclipseAdoptium.Temurin.17.JDK`
28
+
29
+ ## Guardrails
30
+
31
+ - Use explicit long timeouts for install commands, normally 10-30 minutes.
32
+ - Do not run `brew`, `sdkmanager`, `avdmanager`, or PowerShell installers in the background.
33
+ - Do not pipe long installer output through `tail` only; preserve logs when useful.
34
+ - If a command asks for a password, administrator permission, or license acceptance, stop and ask the user to complete or approve that step.
35
+ - After each setup phase, re-run `android_preflight` and continue from the latest result.
36
+
37
+ ## Quick Fix: Gradle Not Found
38
+
39
+ If `android_preflight` only reports `Gradle` as `not found`, do not reinstall the Android SDK. Install Gradle, then re-run `android_preflight`.
40
+
41
+ macOS:
42
+
43
+ ```bash
44
+ brew list gradle >/dev/null 2>&1 || brew install gradle
45
+ gradle -v
46
+ ```
47
+
48
+ Windows PowerShell:
49
+
50
+ ```powershell
51
+ winget install --id Gradle.Gradle --exact --source winget --accept-source-agreements --accept-package-agreements --silent
52
+ gradle -v
53
+ ```
54
+
55
+ If a project already has `gradlew` or `gradlew.bat`, global Gradle is not required for that project. Generated projects initially need global Gradle so `android_build_app` can create the wrapper.
56
+
57
+ ## macOS
58
+
59
+ ### Detect Current State
60
+
61
+ ```bash
62
+ JDK_MAJOR="${ANDROID_PLUGIN_JDK_MAJOR:-17}"
63
+ uname -s
64
+ command -v brew || true
65
+ /usr/libexec/java_home -V 2>&1 || true
66
+ test -x "/opt/homebrew/opt/openjdk@$JDK_MAJOR/libexec/openjdk.jdk/Contents/Home/bin/java" && "/opt/homebrew/opt/openjdk@$JDK_MAJOR/libexec/openjdk.jdk/Contents/Home/bin/java" -version
67
+ command -v gradle || true
68
+ command -v sdkmanager || true
69
+ command -v adb || true
70
+ command -v emulator || true
71
+ echo "ANDROID_HOME=$ANDROID_HOME"
72
+ echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"
73
+ ```
74
+
75
+ ### Install JDK
76
+
77
+ Prefer the Homebrew formula. It is more reliable for headless setup than the JDK cask, and the plugin can inject its `JAVA_HOME` into child processes.
78
+
79
+ Homebrew `openjdk@<major>` is keg-only. That means `java` and `/usr/libexec/java_home` may still fail until `JAVA_HOME`/`PATH` are set, or until the optional system symlink is created.
80
+
81
+ ```bash
82
+ JDK_MAJOR="${ANDROID_PLUGIN_JDK_MAJOR:-17}"
83
+ brew list "openjdk@$JDK_MAJOR" >/dev/null 2>&1 || brew install "openjdk@$JDK_MAJOR"
84
+ export JAVA_HOME="/opt/homebrew/opt/openjdk@$JDK_MAJOR/libexec/openjdk.jdk/Contents/Home"
85
+ export PATH="$JAVA_HOME/bin:/opt/homebrew/bin:$PATH"
86
+ java -version
87
+ ```
88
+
89
+ If the user wants Java visible to `/usr/libexec/java_home`, ask before running the privileged symlink:
90
+
91
+ ```bash
92
+ JDK_MAJOR="${ANDROID_PLUGIN_JDK_MAJOR:-17}"
93
+ sudo ln -sfn "/opt/homebrew/opt/openjdk@$JDK_MAJOR/libexec/openjdk.jdk" "/Library/Java/JavaVirtualMachines/openjdk-$JDK_MAJOR.jdk"
94
+ ```
95
+
96
+ Only write shell startup files after user confirmation:
97
+
98
+ ```bash
99
+ JDK_MAJOR="${ANDROID_PLUGIN_JDK_MAJOR:-17}"
100
+ printf '\nexport JAVA_HOME=/opt/homebrew/opt/openjdk@%s/libexec/openjdk.jdk/Contents/Home\nexport PATH="$JAVA_HOME/bin:$PATH"\n' "$JDK_MAJOR" >> ~/.zshrc
101
+ ```
102
+
103
+ ### Install Gradle
104
+
105
+ Generated projects prefer `./gradlew`. If it is missing, `android_build_app` can generate a wrapper when `gradle` is available.
106
+
107
+ ```bash
108
+ brew list gradle >/dev/null 2>&1 || brew install gradle
109
+ ```
110
+
111
+ ### Install Android Command-Line Tools
112
+
113
+ ```bash
114
+ brew list --cask android-commandlinetools >/dev/null 2>&1 || brew install --cask android-commandlinetools
115
+ ```
116
+
117
+ Use the plugin SDK path if configured; otherwise use the Homebrew cask location:
118
+
119
+ ```bash
120
+ JDK_MAJOR="${ANDROID_PLUGIN_JDK_MAJOR:-17}"
121
+ export ANDROID_HOME="${ANDROID_PLUGIN_SDK_PATH:-/opt/homebrew/share/android-commandlinetools}"
122
+ export ANDROID_SDK_ROOT="$ANDROID_HOME"
123
+ export JAVA_HOME="/opt/homebrew/opt/openjdk@$JDK_MAJOR/libexec/openjdk.jdk/Contents/Home"
124
+ export PATH="$JAVA_HOME/bin:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:/opt/homebrew/bin:$PATH"
125
+ sdkmanager --version
126
+ ```
127
+
128
+ ### Install SDK Packages
129
+
130
+ Default to the smaller `default` system image. Use `google_apis` only when the app needs Google APIs.
131
+
132
+ Image variants trade size for capabilities:
133
+
134
+ - `default`: smaller, enough for normal build/run testing.
135
+ - `google_apis`: larger, use when Google APIs are required.
136
+ - `google_apis_playstore`: largest, use only when Play Store services are required.
137
+
138
+ ```bash
139
+ ANDROID_API_LEVEL="${ANDROID_PLUGIN_API_LEVEL:-35}"
140
+ ANDROID_BUILD_TOOLS_VERSION="${ANDROID_PLUGIN_BUILD_TOOLS_VERSION:-35.0.0}"
141
+ SYSTEM_IMAGE_VARIANT="${ANDROID_PLUGIN_SYSTEM_IMAGE_VARIANT:-default}"
142
+ if [ -n "${ANDROID_PLUGIN_SYSTEM_IMAGE_ABI:-}" ]; then
143
+ SYSTEM_IMAGE_ABI="$ANDROID_PLUGIN_SYSTEM_IMAGE_ABI"
144
+ elif [ "$(uname -m)" = "arm64" ]; then
145
+ SYSTEM_IMAGE_ABI="arm64-v8a"
146
+ else
147
+ SYSTEM_IMAGE_ABI="x86_64"
148
+ fi
149
+ SYSTEM_IMAGE="system-images;android-$ANDROID_API_LEVEL;$SYSTEM_IMAGE_VARIANT;$SYSTEM_IMAGE_ABI"
150
+
151
+ sdkmanager --sdk_root="$ANDROID_HOME" --install \
152
+ "cmdline-tools;latest" \
153
+ "platform-tools" \
154
+ "emulator" \
155
+ "platforms;android-$ANDROID_API_LEVEL" \
156
+ "build-tools;$ANDROID_BUILD_TOOLS_VERSION" \
157
+ "$SYSTEM_IMAGE"
158
+ ```
159
+
160
+ If the system image download times out, retry the exact command with a longer timeout and keep the output log. Avoid launching a second `sdkmanager` for the same package while the first one is still running.
161
+
162
+ If SDK licenses block installation, ask the user to approve license handling before running:
163
+
164
+ ```bash
165
+ sdkmanager --sdk_root="$ANDROID_HOME" --licenses
166
+ ```
167
+
168
+ ### Create AVD
169
+
170
+ Only create an AVD when no ready USB device is available and the user needs a
171
+ new emulator target.
172
+
173
+ ```bash
174
+ AVD_NAME="${ANDROID_PLUGIN_DEFAULT_AVD:-medium_phone}"
175
+ DEVICE_PROFILE="${ANDROID_PLUGIN_DEFAULT_PROFILE:-medium_phone}"
176
+
177
+ avdmanager create avd \
178
+ --name "$AVD_NAME" \
179
+ --package "$SYSTEM_IMAGE" \
180
+ --device "$DEVICE_PROFILE"
181
+ ```
182
+
183
+ If the AVD already exists, do not delete it unless the user explicitly confirms.
184
+
185
+ ## Windows PowerShell
186
+
187
+ Run these commands step by step. They install the configured JDK and Android
188
+ Studio with `winget`, then use the Android SDK tools that Android Studio
189
+ installs. Keep the setup visible for review.
190
+
191
+ ### Detect Current State
192
+
193
+ ```powershell
194
+ $PSVersionTable.PSVersion
195
+ where.exe java 2>$null
196
+ where.exe gradle 2>$null
197
+ where.exe sdkmanager 2>$null
198
+ where.exe adb 2>$null
199
+ where.exe emulator 2>$null
200
+ Write-Output "ANDROID_HOME=$env:ANDROID_HOME"
201
+ Write-Output "ANDROID_SDK_ROOT=$env:ANDROID_SDK_ROOT"
202
+ ```
203
+
204
+ ### Install JDK, Gradle, and Android Studio
205
+
206
+ ```powershell
207
+ $JdkPackage = if ($env:ANDROID_PLUGIN_WINDOWS_JDK_WINGET_PACKAGE) { $env:ANDROID_PLUGIN_WINDOWS_JDK_WINGET_PACKAGE } else { "EclipseAdoptium.Temurin.17.JDK" }
208
+ winget install --id "$JdkPackage" --exact --source winget --accept-source-agreements --accept-package-agreements --silent
209
+ winget install --id Gradle.Gradle --exact --source winget --accept-source-agreements --accept-package-agreements --silent
210
+ winget install --id Google.AndroidStudio --exact --source winget --accept-source-agreements --accept-package-agreements
211
+ ```
212
+
213
+ ### Confirm Android Command-Line Tools
214
+
215
+ Use Android Studio SDK Manager to install Android SDK Command-line Tools,
216
+ Android SDK Platform-Tools, Android Emulator, the configured Android platform,
217
+ build tools, and a system image. Avoid direct zip URLs here so the guide does
218
+ not need to maintain Google command-line tools package identifiers.
219
+
220
+ ```powershell
221
+ $SdkRoot = if ($env:ANDROID_PLUGIN_SDK_PATH) { $env:ANDROID_PLUGIN_SDK_PATH } else { "$env:LOCALAPPDATA\Android\Sdk" }
222
+ $SdkManager = Join-Path $SdkRoot "cmdline-tools\latest\bin\sdkmanager.bat"
223
+ if (-not (Test-Path $SdkManager)) {
224
+ throw "Install Android SDK Command-line Tools from Android Studio SDK Manager, then rerun android_preflight."
225
+ }
226
+ ```
227
+
228
+ Configure the current session:
229
+
230
+ ```powershell
231
+ $env:ANDROID_HOME = $SdkRoot
232
+ $env:ANDROID_SDK_ROOT = $SdkRoot
233
+ $JdkMajor = if ($env:ANDROID_PLUGIN_JDK_MAJOR) { $env:ANDROID_PLUGIN_JDK_MAJOR } else { "17" }
234
+ $JavaHome = Get-ChildItem "$env:ProgramFiles\Eclipse Adoptium" -Directory -Filter "jdk-$JdkMajor*" |
235
+ Sort-Object LastWriteTime -Descending |
236
+ Select-Object -First 1
237
+ $env:JAVA_HOME = $JavaHome.FullName
238
+ $env:Path = "$env:JAVA_HOME\bin;$env:ANDROID_HOME\platform-tools;$env:ANDROID_HOME\emulator;$env:ANDROID_HOME\cmdline-tools\latest\bin;$env:Path"
239
+ ```
240
+
241
+ Persist user-level environment variables when the user wants future terminals to inherit them:
242
+
243
+ ```powershell
244
+ [Environment]::SetEnvironmentVariable("ANDROID_HOME", $env:ANDROID_HOME, "User")
245
+ [Environment]::SetEnvironmentVariable("ANDROID_SDK_ROOT", $env:ANDROID_HOME, "User")
246
+ [Environment]::SetEnvironmentVariable("JAVA_HOME", $env:JAVA_HOME, "User")
247
+ ```
248
+
249
+ Install SDK packages:
250
+
251
+ Default to the smaller `default` system image.
252
+
253
+ ```powershell
254
+ $AndroidApiLevel = if ($env:ANDROID_PLUGIN_API_LEVEL) { $env:ANDROID_PLUGIN_API_LEVEL } else { "35" }
255
+ $BuildToolsVersion = if ($env:ANDROID_PLUGIN_BUILD_TOOLS_VERSION) { $env:ANDROID_PLUGIN_BUILD_TOOLS_VERSION } else { "35.0.0" }
256
+ $SystemImageVariant = if ($env:ANDROID_PLUGIN_SYSTEM_IMAGE_VARIANT) { $env:ANDROID_PLUGIN_SYSTEM_IMAGE_VARIANT } else { "default" }
257
+ $Abi = if ($env:ANDROID_PLUGIN_SYSTEM_IMAGE_ABI) { $env:ANDROID_PLUGIN_SYSTEM_IMAGE_ABI } elseif ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64-v8a" } else { "x86_64" }
258
+ $SystemImage = "system-images;android-$AndroidApiLevel;$SystemImageVariant;$Abi"
259
+
260
+ sdkmanager.bat --sdk_root="$env:ANDROID_HOME" --install `
261
+ "cmdline-tools;latest" `
262
+ "platform-tools" `
263
+ "emulator" `
264
+ "platforms;android-$AndroidApiLevel" `
265
+ "build-tools;$BuildToolsVersion" `
266
+ "$SystemImage"
267
+ ```
268
+
269
+ If SDK licenses block installation, ask the user to approve license handling before running:
270
+
271
+ ```powershell
272
+ sdkmanager.bat --sdk_root="$env:ANDROID_HOME" --licenses
273
+ ```
274
+
275
+ Create an AVD:
276
+
277
+ Only create an AVD when no ready USB device is available and the user needs a
278
+ new emulator target.
279
+
280
+ ```powershell
281
+ $AvdName = if ($env:ANDROID_PLUGIN_DEFAULT_AVD) { $env:ANDROID_PLUGIN_DEFAULT_AVD } else { "medium_phone" }
282
+ $DeviceProfile = if ($env:ANDROID_PLUGIN_DEFAULT_PROFILE) { $env:ANDROID_PLUGIN_DEFAULT_PROFILE } else { "medium_phone" }
283
+
284
+ avdmanager.bat create avd `
285
+ --name "$AvdName" `
286
+ --package "$SystemImage" `
287
+ --device "$DeviceProfile"
288
+ ```
289
+
290
+ ### Windows Emulator Acceleration
291
+
292
+ The command-line flow can install the SDK and create an AVD, but Windows emulator acceleration may still require user or administrator action.
293
+
294
+ Check acceleration:
295
+
296
+ ```powershell
297
+ emulator.exe -accel-check
298
+ ```
299
+
300
+ If acceleration or drivers are missing:
301
+
302
+ - Ask the user to enable CPU virtualization in BIOS/UEFI if it is disabled.
303
+ - Prefer enabling Windows Hypervisor Platform / WHPX when available.
304
+ - If the emulator driver still needs setup, install Android Studio and ask the user to finish Device Manager or driver prompts:
305
+
306
+ ```powershell
307
+ winget install --id Google.AndroidStudio --exact --source winget --accept-source-agreements --accept-package-agreements
308
+ ```
309
+
310
+ ## Project Configuration
311
+
312
+ Generated projects include `gradle.properties` and create `local.properties` when the plugin can detect the SDK root. If you need to repair an existing Android Gradle root manually:
313
+
314
+ Create `gradle.properties` when AndroidX or Compose dependencies are present:
315
+
316
+ ```properties
317
+ android.useAndroidX=true
318
+ android.nonTransitiveRClass=true
319
+ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
320
+ ```
321
+
322
+ macOS:
323
+
324
+ ```bash
325
+ printf 'sdk.dir=%s\n' "$ANDROID_HOME" > local.properties
326
+ ```
327
+
328
+ Windows PowerShell:
329
+
330
+ ```powershell
331
+ $SdkDir = $env:ANDROID_HOME -replace '\\', '/'
332
+ "sdk.dir=$SdkDir" | Set-Content local.properties
333
+ ```
334
+
335
+ If the Gradle wrapper is missing and Gradle is installed:
336
+
337
+ macOS:
338
+
339
+ ```bash
340
+ gradle wrapper --gradle-version 8.9
341
+ ```
342
+
343
+ Windows PowerShell:
344
+
345
+ ```powershell
346
+ gradle wrapper --gradle-version 8.9
347
+ ```
348
+
349
+ ## Final Verification
350
+
351
+ Re-run `android_preflight`. Continue when the host OS, SDK root, `adb`,
352
+ `sdkmanager`, Java, Gradle, and at least one Android target path are ready. A
353
+ ready USB device satisfies target readiness without an AVD. For emulator
354
+ workflows, also require `emulator`, `avdmanager`, at least one AVD, and on
355
+ Windows a passing `Emulator acceleration` check before starting the emulator. It
356
+ is acceptable for `ADB devices` to show zero devices before an emulator is
357
+ started.
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: android-dev
3
+ description: Build, run, inspect, and lightly automate Android apps with the android-emulator MCP tools.
4
+ ---
5
+
6
+ # Android Dev
7
+
8
+ Use this skill when the user wants you to create, modify, build, run, debug, screenshot, or inspect an Android app in the desktop Android Emulator or on a USB-connected Android device.
9
+
10
+ ## ZCode Tool Names
11
+
12
+ This skill assumes the MCP server is configured in zcode as `android_emulator`. In zcode, MCP tools are exposed to the model as `mcp__android_emulator__<tool>`.
13
+
14
+ If the server is configured with a different name, use the corresponding visible `mcp__<server>__...` tool names from the active zcode tool list.
15
+
16
+ ## Default Workflow
17
+
18
+ 1. Call `mcp__android_emulator__android_preflight` first.
19
+ - If the required environment is not ready, follow `INSTALL_ENVIRONMENT.md` before continuing. Missing emulator-only checks do not block a selected ready USB device target.
20
+ - Environment setup is done with the fixed macOS shell or Windows PowerShell procedure in that file; do not improvise unrelated install commands.
21
+ - Do not accept Android SDK licenses, enter passwords, wipe emulator data, or delete AVDs on the user's behalf. Stop and ask the user for those cases.
22
+ 2. Discover the project with `mcp__android_emulator__android_discover_project`.
23
+ - If no Android project exists and the user wants a new app, call `mcp__android_emulator__android_create_app`.
24
+ - Prefer editing Kotlin/Compose files directly after project creation.
25
+ - `mcp__android_emulator__android_create_app` refuses to overwrite generated files by default; only pass `overwrite: true` after explicit user confirmation.
26
+ - Read `warnings` in the discovery result before building and repair missing `gradle.properties`, `local.properties`, or Gradle wrapper issues.
27
+ 3. Build and launch with `mcp__android_emulator__android_build_and_run`.
28
+ - Pass `module`, `variant`, or `applicationId` when discovery is ambiguous.
29
+ - Use a selected `serial` when the user wants a specific USB device or emulator. Use `mcp__android_emulator__android_start_emulator` only when a new GUI emulator is needed, then pass its returned `serial` to follow-up tools.
30
+ - Read the returned `output` first for compile errors; use the returned log path only when more detail is needed.
31
+ 4. Verify the app visually with `mcp__android_emulator__android_screenshot`.
32
+ 5. For runtime checks, use `mcp__android_emulator__android_open_url`, `mcp__android_emulator__android_launch_app`, `mcp__android_emulator__android_terminate_app`, and `mcp__android_emulator__android_logs`.
33
+ 6. For UI automation, call `mcp__android_emulator__android_ui_status` first.
34
+ - Prefer `mcp__android_emulator__android_ui_describe` or `mcp__android_emulator__android_ui_resolve` before tapping coordinates.
35
+ - `mcp__android_emulator__android_ui_tap`, `mcp__android_emulator__android_ui_swipe`, `mcp__android_emulator__android_ui_type_text`, and `mcp__android_emulator__android_ui_keyevent` use ADB/UI Automator based backends.
36
+ - If UI automation is unavailable, continue with build/run/screenshot checks and say UI automation is unavailable.
37
+
38
+ ## Tool Notes
39
+
40
+ - This MVP intentionally uses Android Emulator's own desktop window for rendering. Do not create or expect a custom emulator window.
41
+ - `mcp__android_emulator__android_preflight` is a pure diagnostic check. Use `INSTALL_ENVIRONMENT.md` for guided environment setup when it reports missing dependencies.
42
+ - The target MCP tools accept `serial` for a specific USB device or emulator and `avd` for the fallback emulator to start only when no target is ready. `mcp__android_emulator__android_start_emulator` starts a new GUI emulator and does not reuse existing targets.
43
+ - Keep emulator interactions through MCP tools instead of raw `adb`/`emulator` commands unless a tool does not cover the operation.
44
+ - `mcp__android_emulator__android_create_app` generates a minimal Kotlin + Jetpack Compose app suitable for model-driven iteration.
45
+ - `mcp__android_emulator__android_build_app` only builds. `mcp__android_emulator__android_build_and_run` builds, reuses the selected Android target by serial or starts a GUI emulator when needed, installs, and launches the app.
46
+ - Android SDK path, default AVD, API level, build-tools version, system image variant/ABI, and JDK major version come from plugin user config and are exposed to the MCP server as `ANDROID_PLUGIN_*` environment variables.
47
+
48
+ ## Project Requirements
49
+
50
+ When creating or repairing a project manually, make sure these files exist before building:
51
+
52
+ - `settings.gradle` or `settings.gradle.kts`
53
+ - root `build.gradle` or `build.gradle.kts`
54
+ - `app/build.gradle` or `app/build.gradle.kts`
55
+ - `gradle.properties` with `android.useAndroidX=true`
56
+ - `local.properties` with `sdk.dir=<Android SDK path>` when the SDK is not otherwise discoverable
57
+ - a Gradle wrapper (`gradlew` / `gradlew.bat`) or `gradle` available on `PATH`
58
+
59
+ ## Build Troubleshooting
60
+
61
+ - If Gradle reports `android.useAndroidX property is not enabled`, create or update `gradle.properties` with `android.useAndroidX=true`.
62
+ - If `android_preflight` reports `Gradle` as `not found`, follow the quick Gradle fix in `INSTALL_ENVIRONMENT.md`; do not reinstall the Android SDK when Gradle is the only missing check.
63
+ - If `android_preflight` reports no AVDs but a USB device is ready, continue by passing that device `serial` to target tools.
64
+ - If Gradle cannot find the Android SDK, create `local.properties` in the Android Gradle root with `sdk.dir=<Android SDK path>`.
65
+ - If `./gradlew` or `gradlew.bat` is missing, install Gradle and run `gradle wrapper --gradle-version 8.9`, or let `android_build_app` attempt wrapper generation when `gradle` is available.
66
+ - If `sdkmanager` or `avdmanager` cannot find Java after installing Homebrew `openjdk@<configured JDK major>`, export the matching `JAVA_HOME` from `INSTALL_ENVIRONMENT.md` and retry. Use the optional symlink step only after user confirmation.
67
+ - On Windows, if SDK package installation fails because Android SDK licenses are not accepted, ask the user for explicit approval before running `sdkmanager.bat --licenses`, then retry the same package installation command.
68
+ - On Windows, if emulator acceleration is unavailable, ask the user to enable virtualization/WHPX or finish Android Emulator driver setup in Android Studio Device Manager, then rerun `android_preflight`.
69
+ - If system image downloads time out, prefer the `default` image first and retry the exact `sdkmanager --install` command with a longer timeout before switching to larger `google_apis` images.
70
+
71
+ ## Extension Point
72
+
73
+ The Android backend is deliberately isolated. P0 uses Android SDK tools, ADB/UI Automator, and Gradle. Future backends can map the same public operations to Android Studio semantic tools, a UI Automator helper APK, Appium/uiautomator2, or another automation bridge without changing the skill workflow.
@@ -0,0 +1,5 @@
1
+ # Compose App Template
2
+
3
+ The Android plugin generates its minimal Kotlin + Jetpack Compose project from TypeScript templates in `src/providers/project.ts`.
4
+
5
+ This directory is reserved for larger template assets if the generated project grows beyond inline templates.
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "document-skills",
3
+ "version": "0.1.0",
4
+ "description": "Built-in DOCX and PDF document production skills for ZCode.",
5
+ "author": { "name": "Z.ai" },
6
+ "license": "Proprietary",
7
+ "skills": "skills"
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/package.json",
3
+ "name": "@zcode/document-skills-plugin",
4
+ "version": "0.1.0",
5
+ "private": true,
6
+ "license": "SEE LICENSE IN skills/docx/LICENSE.txt",
7
+ "description": "Built-in DOCX and PDF document production skills published as an official ZCode plugin."
8
+ }
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2026 Z.ai All rights reserved.
2
+
3
+ Permission is granted for personal, educational, and non-commercial use only.
4
+
5
+ Commercial use is strictly prohibited without prior written permission from the author.
6
+
7
+ Unauthorized copying, modification, or distribution of the software for commercial purposes is prohibited.
8
+
9
+ The author reserves the right to make the final determination of what constitutes "commercial use".
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
12
+
13
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY ARISING FROM THE USE OF THE SOFTWARE.
@@ -0,0 +1,201 @@
1
+ ---
2
+ name: docx
3
+ metadata:
4
+ author: Z.AI
5
+ version: "1.0"
6
+ description: "Complete DOCX document creation, editing, and analysis capabilities with support for revisions, comments, formatting preservation, and text extraction. Use for creating new documents, modifying content, handling revisions, adding comments, or other professional Word document tasks."
7
+ license: Proprietary. LICENSE.txt has complete terms
8
+ ---
9
+
10
+ # DOCX Creation, Editing, and Analysis
11
+
12
+ ## Quick Setup
13
+
14
+ ```bash
15
+ bash "$SKILL_DIR/setup.sh" # Interactive environment check + install
16
+ ```
17
+
18
+ ## Overview
19
+
20
+ A .docx file is a ZIP archive containing XML files. This skill provides tools for creating, editing, reading, and reviewing Word documents.
21
+
22
+ ## Quick Route — Read This First
23
+
24
+ **Step 1**: Determine task type → load the corresponding route file
25
+ **Step 2**: Determine business scene → load the corresponding scene file (if applicable)
26
+ **Step 3**: Load `references/design-system.md` for cover recipes, palettes, and chart colors
27
+ **Step 4**: Load `references/common-rules.md` for shared layout, font, and quality rules
28
+ **Step 5**: Execute per route instructions
29
+ **Step 6**: Run the post-generation checklist
30
+
31
+ ⚠️ **MANDATORY — Cover Recipe Enforcement (Step 3):**
32
+ When creating a document that needs a cover page, you MUST use one of the 7 validated cover recipes (R1–R7) from `design-system.md`. **Free-form cover code is FORBIDDEN.** The recipe provides the wrapper table, background, layout structure, border settings, and spacing — do not reinvent any of these.
33
+
34
+ Workflow: (1) Call `selectCoverRecipe(docType, industry)` to get recipe + palette → (2) Use the corresponding `buildCoverRX()` function code from `design-system.md` → (3) Pass your `config` (title, subtitle, metaLines, etc.) into the recipe builder. If you skip this and write cover code from scratch, the cover WILL have compatibility issues (blank pages in MS Office, missing borders, overflow, etc.).
35
+
36
+ ### Script Path Setup (MANDATORY before any script call)
37
+
38
+ All CLI tools live in `scripts/` relative to this skill's directory. Before calling any script, resolve the absolute path once:
39
+
40
+ ```bash
41
+ DOCX_SCRIPTS="<skill_directory>/scripts" # ← parent directory of this SKILL.md
42
+
43
+ # Then all commands use $DOCX_SCRIPTS:
44
+ python3 "$DOCX_SCRIPTS/postcheck.py" output.docx
45
+ python3 "$DOCX_SCRIPTS/add_toc_placeholders.py" output.docx --auto
46
+ ```
47
+
48
+ **For Python imports** (when generation code needs to import skill modules):
49
+
50
+ ```python
51
+ import sys, os
52
+ DOCX_SCRIPTS = os.path.join("<skill_directory>", "scripts")
53
+ if DOCX_SCRIPTS not in sys.path:
54
+ sys.path.insert(0, DOCX_SCRIPTS)
55
+ ```
56
+
57
+ **⚠️ NEVER use bare `python3 scripts/...`** — it only works if cwd happens to be the skill directory. Always use the absolute `$DOCX_SCRIPTS` path.
58
+
59
+ ### Task Router
60
+
61
+ | User Intent | Route | Files to Load |
62
+ |-------------|-------|---------------|
63
+ | Create/write/generate (no attachment) | **Create** | `routes/create.md` + `references/docx-js-core.md` |
64
+ | Edit/modify/revise (has attachment) | **Edit** | `routes/edit.md` + `references/ooxml.md` |
65
+ | Format/layout/font/margin | **Format** | `routes/format.md` |
66
+ | Comment/annotate/review | **Comment** | `routes/comment.md` |
67
+ | Read/analyze/extract | **Read** | `routes/read.md` |
68
+
69
+ ### Scene Router (Optional — load after route)
70
+
71
+ | User Keywords | Scene | File |
72
+ |---------------|-------|------|
73
+ | thesis, academic, research, paper, dissertation, abstract, journal | Academic | `scenes/academic.md` |
74
+ | report, analysis, experiment, testing, survey, review, summary, proposal, feasibility, competitor, industry, operations | Report | `scenes/report.md` |
75
+ | contract, agreement, terms, transfer, NDA, confidential, framework, cooperation, service terms, user agreement, procurement | Contract | `scenes/contract.md` |
76
+ | resume, CV, job application | Resume | `scenes/resume.md` |
77
+ | exam, test, quiz, paper (exam context), lesson plan | Exam | `scenes/exam.md` |
78
+ | official document, notice, letter, reply, minutes, red header, government, issuance | Official | `scenes/official-doc.md` |
79
+ | broadcast script, product copy, livestream, speech, presentation script, video script | Copywriting | `scenes/copywriting.md` |
80
+ | plan, proposal (if not report context) | Report | `scenes/report.md` |
81
+ | policy, regulation, standard, management rules | Official | `scenes/official-doc.md` |
82
+
83
+ **If no scene matches**, use default design rules from `references/design-system.md` and `references/common-rules.md`.
84
+
85
+ ## Formatting Standards (Always Apply)
86
+
87
+ → See `references/common-rules.md` for full font profiles, spacing, indent, and layout rules.
88
+
89
+ **Key rules (quick reference):**
90
+ - **Line spacing**: 1.3x (`line: 312`) — MANDATORY. Exceptions: resume 1.15x, official doc 28pt fixed, copywriting `400`, contract 1.5x
91
+ - **CJK body**: Justified + 2-char indent (`firstLine: 480` SimSun / `420` YaHei)
92
+ - **Tables**: `margins` set, `ShadingType.CLEAR`, `tableHeader: true`, `cantSplit: true`, title `keepNext: true`
93
+ - **Images**: `type` parameter required, preserve aspect ratio via `image-size`, PageBreak inside Paragraph
94
+ - **Full-page Table row**: `rule: "exact"` with 1200 twips safety margin
95
+
96
+ ## Unit Quick Reference
97
+
98
+ | Unit | Value |
99
+ |------|-------|
100
+ | 1 cm | 567 twips |
101
+ | 1 inch | 1440 twips |
102
+ | 1 pt | 20 half-points |
103
+ | A4 | 11906 × 16838 twips |
104
+
105
+ For Chinese font size table and common margins, see `references/common-rules.md`.
106
+
107
+ ## Post-Generation — Two-Layer Verification
108
+
109
+ ### Layer 1: Manual Checklist (self-check during generation)
110
+
111
+ #### Basic Format
112
+ - [ ] Line spacing is 1.3x (`line: 312`) or scene-specific override
113
+ - [ ] CJK body has 2-char indent (`firstLine: 480` or `420`)
114
+ - [ ] Tables have margins set
115
+ - [ ] Images preserve aspect ratio via `image-size` — NEVER hardcode both width and height
116
+ - [ ] PageBreak inside Paragraph
117
+ - [ ] ShadingType uses CLEAR
118
+ - [ ] Each numbered list uses unique `reference`
119
+ - [ ] **⚠️ CRITICAL — Quotation marks in JS strings properly escaped.** Chinese curly quotes (`""` `''`) MUST use Unicode escapes (`\u201c` `\u201d` `\u2018` `\u2019`); straight quotes (`"` `'`) use `\"` `\'` or alternate delimiters. **This is the #1 most common code generation bug.** Chinese text frequently contains `""` for emphasis or proper nouns (e.g., "双11", "前低后高", "618") — every occurrence MUST be escaped. Failure to escape produces JS syntax errors that silently break document generation.
120
+ - [ ] ImageRun includes `type` parameter
121
+ - [ ] Header/footer present (unless scene says otherwise)
122
+
123
+ #### Heading Styles
124
+ - [ ] All body chapter headings use `heading: HeadingLevel.HEADING_X` (never simulate with bold + large font)
125
+ - [ ] Cover title may skip Heading style (not in TOC), but body headings MUST use Heading style
126
+
127
+ #### Page Break & Blank Page Prevention
128
+ - [ ] Cover/content in separate sections
129
+ - [ ] Three rules to prevent blank pages:
130
+ - ① When using section(NEXT_PAGE), previous section must NOT end with PageBreak (double break = blank page)
131
+ - ② PageBreak paragraph SHOULD contain visible text — **exception**: section-ending empty para + PageBreak is allowed (normal section separator, e.g., after cover page)
132
+ - ③ No more than 3 consecutive empty paragraphs
133
+ - [ ] Full-page Table row height uses `rule: "exact"` (never `"atLeast"` for tall tables)
134
+ - [ ] No unwanted blank pages (check each section ending)
135
+
136
+ #### TOC
137
+ → See `references/toc.md` for the complete TOC reference and checklist.
138
+ - [ ] If TOC title exists → `TableOfContents` element must be present
139
+ - [ ] **⚠️ MANDATORY PageBreak after TableOfContents** — a Paragraph containing PageBreak MUST immediately follow the `TableOfContents` element; without it, TOC and body content will render on the same page. This is the #1 TOC formatting failure — never omit it
140
+ - [ ] `add_toc_placeholders.py --auto` runs after generation; exit code = 0
141
+ - [ ] **TOC MUST be in its own section** — body section sets `page: { pageNumbers: { start: 1, formatType: NumberFormat.DECIMAL } }` so page numbers start from the first body page, not from the TOC pages
142
+ - [ ] **Page number API nesting** — `pageNumbers` MUST be inside `page: {}`, NOT at properties top level (see toc.md § Page Number API)
143
+ - [ ] **3-section page numbering** — Cover (no page#) → Front matter (Roman i,ii,iii, start=1) → Body (Arabic 1,2,3, start=1)
144
+ - [ ] **Post-process footers** — Roman section footer instrText must contain `PAGE \* ROMAN \* MERGEFORMAT`; Arabic section `PAGE \* arabic \* MERGEFORMAT` (WPS ignores pgNumType fmt). **⚠️ NEVER use `\* decimal` in instrText** — `decimal` is a docx-js API enum value (`NumberFormat.DECIMAL`), NOT a valid Word field format switch; using it causes page numbers to render as "1decimal", "2decimal". The correct Word field switch for Arabic numerals is `\* arabic`.
145
+ - [ ] **Remove empty pgNumType** — Post-process to strip `<w:pgNumType/>` from cover section (docx-js emits empty element that confuses WPS)
146
+ - [ ] **⚠️ TOC Refresh Hint MANDATORY** — between `TableOfContents` element and the PageBreak, MUST add an italic gray note paragraph telling users to right-click TOC → "Update Field" to refresh page numbers (see toc.md § TOC Refresh Hint)
147
+
148
+ #### Table Cross-Page
149
+ - [ ] Header rows: `tableHeader: true`
150
+ - [ ] All rows: `cantSplit: true`
151
+ - [ ] Title paragraph: `keepNext: true`
152
+
153
+ #### Cover
154
+ - [ ] **Cover MUST use a validated recipe (R1–R7)** from `design-system.md` — free-form cover code is forbidden
155
+ - [ ] Cover recipe matches document type (per `selectCoverRecipe()` in `design-system.md`)
156
+ - [ ] Cover uses the 16838 outer wrapper table with `allNoBorders` (all recipes provide this)
157
+ - [ ] Cover title uses `calcTitleLayout()` — never hardcoded font size above 40pt
158
+ - [ ] Cover spacing uses `calcCoverSpacing()` — never hardcoded large spacing values
159
+ - [ ] Cover content does not overflow (total height ≤ 15638 twips, Table uses `rule: "exact"`)
160
+ - [ ] Every TextRun on dark/colored background has explicit `color` set (Rule 9 — never rely on default black)
161
+ - [ ] Cover section has no trailing PageBreak or empty paragraphs
162
+ - [ ] Title lines split at semantic boundaries (no mid-word breaks, no single-char orphan lines)
163
+ - [ ] No text-character decorative lines (`───`, `━━━`) — use paragraph borders only
164
+
165
+ ### Layer 2: Automated Post-Check Script
166
+
167
+ ```bash
168
+ python3 "$DOCX_SCRIPTS/postcheck.py" output.docx
169
+ ```
170
+
171
+ Automatically checks 14 business rules: blank pages, **cover overflow (font size/spacing/trailing content)**, line spacing consistency, table margins, table cross-page control (cantSplit/tblHeader), image overflow, image aspect ratio distortion, font fallback, CJK indent, heading hierarchy, ShadingType misuse, TOC quality, document cleanliness (placeholder text/Markdown/HTML residuals), report content quality (abstract presence/heading specificity/vague conclusion detection).
172
+
173
+ ⚠️ **After generating any document, MUST run postcheck.py and fix all ❌ errors.**
174
+
175
+ ## Math Formulas
176
+
177
+ Formula input uses **LaTeX syntax**, internally converted to docx-js Math objects.
178
+
179
+ - **Basic formulas** (fractions, sub/superscript, roots, summation) → docx-js Math components
180
+ - **Complex formulas** (3+ nesting, matrices, piecewise functions) → matplotlib PNG fallback
181
+
182
+ See `references/math-formulas.md`.
183
+
184
+ ## Charts
185
+
186
+ Default: **matplotlib template library** generates PNG for embedding.
187
+
188
+ 6 ready-to-use templates: bar, line, pie, box, radar, heatmap.
189
+ Colors auto-derived from document palette.accent for style consistency.
190
+ Default palette: Morandi low-saturation (see design-system.md).
191
+
192
+ See `references/chart-templates.md`.
193
+
194
+ ## Dependencies
195
+
196
+ - **pandoc**: Text extraction
197
+ - **docx**: `bun add docx` or `npm install docx` (creating)
198
+ - **LibreOffice**: PDF conversion, .doc support
199
+ - **Poppler**: PDF to image (`pdftoppm`)
200
+ - **defusedxml**: Secure XML parsing
201
+ - **python-docx**: Simple comment operations