zcode-app-cli 3.8.1-15 → 3.9.2-16

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 (154) hide show
  1. package/bin/zcode.js +109 -47
  2. package/config.example.json +14 -0
  3. package/package.json +2 -2
  4. package/vendor/extraction.json +131 -5
  5. package/vendor/node_modules/@zcode/tui/dist/index.js +52 -4
  6. package/vendor/packages/browser-use-plugin/.zcode-plugin/plugin.json +1 -1
  7. package/vendor/packages/browser-use-plugin/dist/mcp/server.js +12862 -10414
  8. package/vendor/packages/browser-use-plugin/docs/api.json +5 -0
  9. package/vendor/packages/browser-use-plugin/docs/overview.md +3 -0
  10. package/vendor/packages/browser-use-plugin/package.json +1 -1
  11. package/vendor/packages/browser-use-plugin/scripts/browser-client.mjs +63 -7
  12. package/vendor/packages/browser-use-plugin/skills/control-browser/SKILL.md +4 -1
  13. package/vendor/packages/document-skills-plugin/.mcp.json +13 -0
  14. package/vendor/packages/document-skills-plugin/.zcode-plugin/plugin.json +19 -6
  15. package/vendor/packages/document-skills-plugin/package.json +3 -3
  16. package/vendor/packages/document-skills-plugin/skills/docx/SKILL.md +6 -2
  17. package/vendor/packages/document-skills-plugin/skills/docx/env_setup/env_check.sh +0 -0
  18. package/vendor/packages/document-skills-plugin/skills/docx/env_setup/setup_mac_linux.sh +0 -0
  19. package/vendor/packages/document-skills-plugin/skills/docx/setup.sh +0 -0
  20. package/vendor/packages/document-skills-plugin/skills/pdf/SKILL.md +39 -20
  21. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/academic.md +39 -47
  22. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/creative.md +11 -3
  23. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/poster.md +3 -0
  24. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process.md +3 -0
  25. package/vendor/packages/document-skills-plugin/skills/pdf/briefs/report.md +41 -62
  26. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/env_check.sh +23 -15
  27. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup.md +37 -19
  28. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup_mac_linux.sh +0 -0
  29. package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup_windows.ps1 +17 -19
  30. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/cover_render.py +487 -0
  31. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2poster.js +43 -11
  32. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf.py +145 -50
  33. package/vendor/packages/document-skills-plugin/skills/pdf/scripts/setup.sh +23 -21
  34. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover-backgrounds.md +1 -1
  35. package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover.md +139 -1347
  36. package/vendor/packages/document-skills-plugin/skills/pptx/LICENSE.txt +13 -0
  37. package/vendor/packages/document-skills-plugin/skills/pptx/SKILL.md +149 -180
  38. package/vendor/packages/document-skills-plugin/skills/xlsx/SKILL.md +6 -2
  39. package/vendor/packages/document-skills-plugin/skills/xlsx/env_setup/env_check.sh +0 -0
  40. package/vendor/packages/document-skills-plugin/skills/xlsx/env_setup/setup_mac_linux.sh +0 -0
  41. package/vendor/packages/document-skills-plugin/skills/xlsx/setup.sh +0 -0
  42. package/vendor/packages/zcode-cua-plugin/.zcode-plugin/plugin.json +19 -0
  43. package/vendor/packages/zcode-cua-plugin/dist/mcp/server.js +68048 -0
  44. package/vendor/packages/zcode-cua-plugin/node_modules/@img/colour/color.cjs +1596 -0
  45. package/vendor/packages/zcode-cua-plugin/node_modules/@img/colour/index.cjs +1 -0
  46. package/vendor/packages/zcode-cua-plugin/node_modules/@img/colour/package.json +58 -0
  47. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/lib/glib-2.0/include/glibconfig.h +221 -0
  48. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/lib/index.js +1 -0
  49. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.8.17.3 +0 -0
  50. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/package.json +42 -0
  51. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/versions.json +30 -0
  52. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-linux-x64/LICENSE +191 -0
  53. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64.node +0 -0
  54. package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-linux-x64/package.json +46 -0
  55. package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/LICENSE +201 -0
  56. package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/lib/detect-libc.js +313 -0
  57. package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/lib/elf.js +39 -0
  58. package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/lib/filesystem.js +51 -0
  59. package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/lib/process.js +24 -0
  60. package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/package.json +44 -0
  61. package/vendor/packages/zcode-cua-plugin/node_modules/semver/LICENSE +15 -0
  62. package/vendor/packages/zcode-cua-plugin/node_modules/semver/bin/semver.js +191 -0
  63. package/vendor/packages/zcode-cua-plugin/node_modules/semver/classes/comparator.js +143 -0
  64. package/vendor/packages/zcode-cua-plugin/node_modules/semver/classes/index.js +7 -0
  65. package/vendor/packages/zcode-cua-plugin/node_modules/semver/classes/range.js +557 -0
  66. package/vendor/packages/zcode-cua-plugin/node_modules/semver/classes/semver.js +333 -0
  67. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/clean.js +8 -0
  68. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/cmp.js +54 -0
  69. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/coerce.js +62 -0
  70. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/compare-build.js +9 -0
  71. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/compare-loose.js +5 -0
  72. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/compare.js +7 -0
  73. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/diff.js +60 -0
  74. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/eq.js +5 -0
  75. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/gt.js +5 -0
  76. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/gte.js +5 -0
  77. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/inc.js +21 -0
  78. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/lt.js +5 -0
  79. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/lte.js +5 -0
  80. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/major.js +5 -0
  81. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/minor.js +5 -0
  82. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/neq.js +5 -0
  83. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/parse.js +18 -0
  84. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/patch.js +5 -0
  85. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/prerelease.js +8 -0
  86. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/rcompare.js +5 -0
  87. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/rsort.js +5 -0
  88. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/satisfies.js +12 -0
  89. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/sort.js +5 -0
  90. package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/valid.js +8 -0
  91. package/vendor/packages/zcode-cua-plugin/node_modules/semver/index.js +91 -0
  92. package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/constants.js +37 -0
  93. package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/debug.js +11 -0
  94. package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/identifiers.js +29 -0
  95. package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/lrucache.js +42 -0
  96. package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/parse-options.js +17 -0
  97. package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/re.js +223 -0
  98. package/vendor/packages/zcode-cua-plugin/node_modules/semver/package.json +78 -0
  99. package/vendor/packages/zcode-cua-plugin/node_modules/semver/preload.js +4 -0
  100. package/vendor/packages/zcode-cua-plugin/node_modules/semver/range.bnf +16 -0
  101. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/gtr.js +6 -0
  102. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/intersects.js +9 -0
  103. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/ltr.js +6 -0
  104. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/max-satisfying.js +27 -0
  105. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/min-satisfying.js +26 -0
  106. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/min-version.js +63 -0
  107. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/outside.js +82 -0
  108. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/simplify.js +49 -0
  109. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/subset.js +249 -0
  110. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/to-comparators.js +10 -0
  111. package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/valid.js +13 -0
  112. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/LICENSE +191 -0
  113. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/install/build.js +38 -0
  114. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/install/check.js +14 -0
  115. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/channel.js +177 -0
  116. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/colour.js +195 -0
  117. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/composite.js +212 -0
  118. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/constructor.js +499 -0
  119. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/index.js +16 -0
  120. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/input.js +809 -0
  121. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/is.js +143 -0
  122. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/libvips.js +207 -0
  123. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/operation.js +1016 -0
  124. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/output.js +1666 -0
  125. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/resize.js +595 -0
  126. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/sharp.js +121 -0
  127. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/utility.js +291 -0
  128. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/package.json +202 -0
  129. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/binding.gyp +298 -0
  130. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/common.cc +1130 -0
  131. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/common.h +402 -0
  132. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/metadata.cc +346 -0
  133. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/metadata.h +90 -0
  134. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/operations.cc +499 -0
  135. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/operations.h +137 -0
  136. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/pipeline.cc +1814 -0
  137. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/pipeline.h +408 -0
  138. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/sharp.cc +43 -0
  139. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/stats.cc +186 -0
  140. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/stats.h +62 -0
  141. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/utilities.cc +288 -0
  142. package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/utilities.h +22 -0
  143. package/vendor/packages/zcode-cua-plugin/package.json +31 -0
  144. package/vendor/packages/zcode-cua-plugin/scripts/build-mcp.mjs +58 -0
  145. package/vendor/packages/zcode-cua-plugin/scripts/bump-zcode-cua-producer.mjs +291 -0
  146. package/vendor/packages/zcode-cua-plugin/scripts/check-cua-baseline.mjs +155 -0
  147. package/vendor/packages/zcode-cua-plugin/scripts/check-version-coherence.mjs +478 -0
  148. package/vendor/packages/zcode-cua-plugin/scripts/sync-cache.mjs +100 -0
  149. package/vendor/packages/zcode-cua-plugin/scripts/sync-skill-from-zcode-cua.mjs +115 -0
  150. package/vendor/packages/zcode-cua-plugin/skills/zcode-computer-use/SKILL.md +172 -0
  151. package/vendor/zcode.cjs +748 -740
  152. package/zcode-runtime.lock.json +3 -3
  153. package/vendor/packages/document-skills-plugin/skills/pptx/assets/font_list.txt +0 -80
  154. package/vendor/packages/document-skills-plugin/skills/pptx/scripts/general_judge.py +0 -529
@@ -0,0 +1,288 @@
1
+ /*!
2
+ Copyright 2013 Lovell Fuller and others.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ #include <cmath>
7
+ #include <cstdio>
8
+ #include <string>
9
+
10
+ #include <napi.h>
11
+ #include <vips/vips8>
12
+ #include <vips/vector.h>
13
+
14
+ #include "./common.h"
15
+ #include "./operations.h"
16
+ #include "./utilities.h"
17
+
18
+ /*
19
+ Get and set cache limits
20
+ */
21
+ Napi::Value cache(const Napi::CallbackInfo& info) {
22
+ Napi::Env env = info.Env();
23
+
24
+ // Set memory limit
25
+ if (info[size_t(0)].IsNumber()) {
26
+ vips_cache_set_max_mem(info[size_t(0)].As<Napi::Number>().Int32Value() * 1048576);
27
+ }
28
+ // Set file limit
29
+ if (info[size_t(1)].IsNumber()) {
30
+ vips_cache_set_max_files(info[size_t(1)].As<Napi::Number>().Int32Value());
31
+ }
32
+ // Set items limit
33
+ if (info[size_t(2)].IsNumber()) {
34
+ vips_cache_set_max(info[size_t(2)].As<Napi::Number>().Int32Value());
35
+ }
36
+
37
+ // Get memory stats
38
+ Napi::Object memory = Napi::Object::New(env);
39
+ memory.Set("current", round(vips_tracked_get_mem() / 1048576));
40
+ memory.Set("high", round(vips_tracked_get_mem_highwater() / 1048576));
41
+ memory.Set("max", round(vips_cache_get_max_mem() / 1048576));
42
+ // Get file stats
43
+ Napi::Object files = Napi::Object::New(env);
44
+ files.Set("current", vips_tracked_get_files());
45
+ files.Set("max", vips_cache_get_max_files());
46
+
47
+ // Get item stats
48
+ Napi::Object items = Napi::Object::New(env);
49
+ items.Set("current", vips_cache_get_size());
50
+ items.Set("max", vips_cache_get_max());
51
+
52
+ Napi::Object cache = Napi::Object::New(env);
53
+ cache.Set("memory", memory);
54
+ cache.Set("files", files);
55
+ cache.Set("items", items);
56
+ return cache;
57
+ }
58
+
59
+ /*
60
+ Get and set size of thread pool
61
+ */
62
+ Napi::Value concurrency(const Napi::CallbackInfo& info) {
63
+ // Set concurrency
64
+ if (info[size_t(0)].IsNumber()) {
65
+ vips_concurrency_set(info[size_t(0)].As<Napi::Number>().Int32Value());
66
+ }
67
+ // Get concurrency
68
+ return Napi::Number::New(info.Env(), vips_concurrency_get());
69
+ }
70
+
71
+ /*
72
+ Get internal counters (queued tasks, processing tasks)
73
+ */
74
+ Napi::Value counters(const Napi::CallbackInfo& info) {
75
+ Napi::Object counters = Napi::Object::New(info.Env());
76
+ counters.Set("queue", static_cast<int>(sharp::counterQueue));
77
+ counters.Set("process", static_cast<int>(sharp::counterProcess));
78
+ return counters;
79
+ }
80
+
81
+ /*
82
+ Get and set use of SIMD vector unit instructions
83
+ */
84
+ Napi::Value simd(const Napi::CallbackInfo& info) {
85
+ // Set state
86
+ if (info[size_t(0)].IsBoolean()) {
87
+ vips_vector_set_enabled(info[size_t(0)].As<Napi::Boolean>().Value());
88
+ }
89
+ // Get state
90
+ return Napi::Boolean::New(info.Env(), vips_vector_isenabled());
91
+ }
92
+
93
+ /*
94
+ Get libvips version
95
+ */
96
+ Napi::Value libvipsVersion(const Napi::CallbackInfo& info) {
97
+ Napi::Env env = info.Env();
98
+ Napi::Object version = Napi::Object::New(env);
99
+
100
+ char semver[9];
101
+ std::snprintf(semver, sizeof(semver), "%d.%d.%d", vips_version(0), vips_version(1), vips_version(2));
102
+ version.Set("semver", Napi::String::New(env, semver));
103
+ #ifdef SHARP_USE_GLOBAL_LIBVIPS
104
+ version.Set("isGlobal", Napi::Boolean::New(env, true));
105
+ #else
106
+ version.Set("isGlobal", Napi::Boolean::New(env, false));
107
+ #endif
108
+ #ifdef __EMSCRIPTEN__
109
+ version.Set("isWasm", Napi::Boolean::New(env, true));
110
+ #else
111
+ version.Set("isWasm", Napi::Boolean::New(env, false));
112
+ #endif
113
+ return version;
114
+ }
115
+
116
+ /*
117
+ Get available input/output file/buffer/stream formats
118
+ */
119
+ Napi::Value format(const Napi::CallbackInfo& info) {
120
+ Napi::Env env = info.Env();
121
+ Napi::Object format = Napi::Object::New(env);
122
+ for (std::string const f : {
123
+ "jpeg", "png", "webp", "tiff", "magick", "openslide", "dz",
124
+ "ppm", "fits", "gif", "svg", "heif", "pdf", "vips", "jp2k", "jxl", "rad", "dcraw"
125
+ }) {
126
+ // Input
127
+ const VipsObjectClass *oc = vips_class_find("VipsOperation", (f + "load").c_str());
128
+ Napi::Boolean hasInputFile = Napi::Boolean::New(env, oc);
129
+ Napi::Boolean hasInputBuffer =
130
+ Napi::Boolean::New(env, vips_type_find("VipsOperation", (f + "load_buffer").c_str()));
131
+ Napi::Object input = Napi::Object::New(env);
132
+ input.Set("file", hasInputFile);
133
+ input.Set("buffer", hasInputBuffer);
134
+ input.Set("stream", hasInputBuffer);
135
+ if (hasInputFile) {
136
+ const VipsForeignClass *fc = VIPS_FOREIGN_CLASS(oc);
137
+ if (fc->suffs) {
138
+ Napi::Array fileSuffix = Napi::Array::New(env);
139
+ const char **suffix = fc->suffs;
140
+ for (int i = 0; *suffix; i++, suffix++) {
141
+ fileSuffix.Set(i, Napi::String::New(env, *suffix));
142
+ }
143
+ input.Set("fileSuffix", fileSuffix);
144
+ }
145
+ }
146
+ // Output
147
+ Napi::Boolean hasOutputFile =
148
+ Napi::Boolean::New(env, vips_type_find("VipsOperation", (f + "save").c_str()));
149
+ Napi::Boolean hasOutputBuffer =
150
+ Napi::Boolean::New(env, vips_type_find("VipsOperation", (f + "save_buffer").c_str()));
151
+ Napi::Object output = Napi::Object::New(env);
152
+ output.Set("file", hasOutputFile);
153
+ output.Set("buffer", hasOutputBuffer);
154
+ output.Set("stream", hasOutputBuffer);
155
+ // Other attributes
156
+ Napi::Object container = Napi::Object::New(env);
157
+ container.Set("id", f);
158
+ container.Set("input", input);
159
+ container.Set("output", output);
160
+ // Add to set of formats
161
+ format.Set(f, container);
162
+ }
163
+
164
+ // Raw, uncompressed data
165
+ Napi::Boolean supported = Napi::Boolean::New(env, true);
166
+ Napi::Boolean unsupported = Napi::Boolean::New(env, false);
167
+ Napi::Object rawInput = Napi::Object::New(env);
168
+ rawInput.Set("file", unsupported);
169
+ rawInput.Set("buffer", supported);
170
+ rawInput.Set("stream", supported);
171
+ Napi::Object rawOutput = Napi::Object::New(env);
172
+ rawOutput.Set("file", unsupported);
173
+ rawOutput.Set("buffer", supported);
174
+ rawOutput.Set("stream", supported);
175
+ Napi::Object raw = Napi::Object::New(env);
176
+ raw.Set("id", "raw");
177
+ raw.Set("input", rawInput);
178
+ raw.Set("output", rawOutput);
179
+ format.Set("raw", raw);
180
+
181
+ return format;
182
+ }
183
+
184
+ /*
185
+ (Un)block libvips operations at runtime.
186
+ */
187
+ void block(const Napi::CallbackInfo& info) {
188
+ Napi::Array ops = info[size_t(0)].As<Napi::Array>();
189
+ bool const state = info[size_t(1)].As<Napi::Boolean>().Value();
190
+ for (unsigned int i = 0; i < ops.Length(); i++) {
191
+ vips_operation_block_set(ops.Get(i).As<Napi::String>().Utf8Value().c_str(), state);
192
+ }
193
+ }
194
+
195
+ /*
196
+ Synchronous, internal-only method used by some of the functional tests.
197
+ Calculates the maximum colour distance using the DE2000 algorithm
198
+ between two images of the same dimensions and number of channels.
199
+ */
200
+ Napi::Value _maxColourDistance(const Napi::CallbackInfo& info) {
201
+ Napi::Env env = info.Env();
202
+
203
+ // Open input files
204
+ VImage image1;
205
+ sharp::ImageType imageType1 = sharp::DetermineImageType(info[size_t(0)].As<Napi::String>().Utf8Value().data());
206
+ if (imageType1 != sharp::ImageType::UNKNOWN) {
207
+ try {
208
+ image1 = VImage::new_from_file(info[size_t(0)].As<Napi::String>().Utf8Value().c_str());
209
+ } catch (...) {
210
+ throw Napi::Error::New(env, "Input file 1 has corrupt header");
211
+ }
212
+ } else {
213
+ throw Napi::Error::New(env, "Input file 1 is of an unsupported image format");
214
+ }
215
+ VImage image2;
216
+ sharp::ImageType imageType2 = sharp::DetermineImageType(info[size_t(1)].As<Napi::String>().Utf8Value().data());
217
+ if (imageType2 != sharp::ImageType::UNKNOWN) {
218
+ try {
219
+ image2 = VImage::new_from_file(info[size_t(1)].As<Napi::String>().Utf8Value().c_str());
220
+ } catch (...) {
221
+ throw Napi::Error::New(env, "Input file 2 has corrupt header");
222
+ }
223
+ } else {
224
+ throw Napi::Error::New(env, "Input file 2 is of an unsupported image format");
225
+ }
226
+ // Ensure same number of channels
227
+ if (image1.bands() != image2.bands()) {
228
+ throw Napi::Error::New(env, "mismatchedBands");
229
+ }
230
+ // Ensure same dimensions
231
+ if (image1.width() != image2.width() || image1.height() != image2.height()) {
232
+ throw Napi::Error::New(env, "mismatchedDimensions");
233
+ }
234
+
235
+ double maxColourDistance;
236
+ try {
237
+ // Premultiply and remove alpha
238
+ if (image1.has_alpha()) {
239
+ image1 = image1.premultiply().extract_band(1, VImage::option()->set("n", image1.bands() - 1));
240
+ }
241
+ if (image2.has_alpha()) {
242
+ image2 = image2.premultiply().extract_band(1, VImage::option()->set("n", image2.bands() - 1));
243
+ }
244
+ // Calculate colour distance
245
+ maxColourDistance = image1.dE00(image2).max();
246
+ } catch (vips::VError const &err) {
247
+ throw Napi::Error::New(env, err.what());
248
+ }
249
+
250
+ // Clean up libvips' per-request data and threads
251
+ vips_error_clear();
252
+ vips_thread_shutdown();
253
+
254
+ return Napi::Number::New(env, maxColourDistance);
255
+ }
256
+
257
+ #if defined(__GNUC__)
258
+ // mallctl will be resolved by the runtime linker when jemalloc is being used
259
+ extern "C" {
260
+ int mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) __attribute__((weak));
261
+ }
262
+ Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info) {
263
+ Napi::Env env = info.Env();
264
+ return Napi::Boolean::New(env, mallctl != nullptr);
265
+ }
266
+ #else
267
+ Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info) {
268
+ Napi::Env env = info.Env();
269
+ return Napi::Boolean::New(env, false);
270
+ }
271
+ #endif
272
+
273
+ #if defined(__GNUC__) && defined(__x86_64__)
274
+ // Are SSE 4.2 intrinsics available at runtime?
275
+ Napi::Value _isUsingX64V2(const Napi::CallbackInfo& info) {
276
+ Napi::Env env = info.Env();
277
+ unsigned int eax, ebx, ecx, edx;
278
+ __asm__ __volatile__("cpuid"
279
+ : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
280
+ : "a"(1));
281
+ return Napi::Boolean::New(env, (ecx & 1U << 20) != 0);
282
+ }
283
+ #else
284
+ Napi::Value _isUsingX64V2(const Napi::CallbackInfo& info) {
285
+ Napi::Env env = info.Env();
286
+ return Napi::Boolean::New(env, false);
287
+ }
288
+ #endif
@@ -0,0 +1,22 @@
1
+ /*!
2
+ Copyright 2013 Lovell Fuller and others.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ #ifndef SRC_UTILITIES_H_
7
+ #define SRC_UTILITIES_H_
8
+
9
+ #include <napi.h>
10
+
11
+ Napi::Value cache(const Napi::CallbackInfo& info);
12
+ Napi::Value concurrency(const Napi::CallbackInfo& info);
13
+ Napi::Value counters(const Napi::CallbackInfo& info);
14
+ Napi::Value simd(const Napi::CallbackInfo& info);
15
+ Napi::Value libvipsVersion(const Napi::CallbackInfo& info);
16
+ Napi::Value format(const Napi::CallbackInfo& info);
17
+ void block(const Napi::CallbackInfo& info);
18
+ Napi::Value _maxColourDistance(const Napi::CallbackInfo& info);
19
+ Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info);
20
+ Napi::Value _isUsingX64V2(const Napi::CallbackInfo& info);
21
+
22
+ #endif // SRC_UTILITIES_H_
@@ -0,0 +1,31 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/package.json",
3
+ "name": "@zcode/zcode-cua-plugin",
4
+ "version": "0.5.12",
5
+ "private": true,
6
+ "description": "ZCode CUA plugin wrapper; its version tracks the upstream zcode-cua MCP server version (enforced by check-version-coherence.mjs against the pnpm catalog pin)",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "main": "./dist/mcp/server.js",
10
+ "types": "./src/mcp/server.ts",
11
+ "scripts": {
12
+ "build": "tsc --noEmit && node scripts/build-mcp.mjs",
13
+ "clean": "node ../../scripts/clean-dist.mjs",
14
+ "sync:skill": "node scripts/sync-skill-from-zcode-cua.mjs",
15
+ "bump:producer": "node scripts/bump-zcode-cua-producer.mjs",
16
+ "check:baseline": "node scripts/check-cua-baseline.mjs",
17
+ "sync:cache": "node scripts/sync-cache.mjs",
18
+ "version:check": "node scripts/check-version-coherence.mjs --check",
19
+ "sync:version": "node scripts/check-version-coherence.mjs",
20
+ "sync:all": "pnpm sync:skill && pnpm sync:version && pnpm build && pnpm sync:cache",
21
+ "test": "pnpm run build && node --import tsx --test tests/*.node-test.mjs && pnpm --filter @zcode/cli... build && pnpm --dir ../cli exec node --import tsx --test tests/zcode-cua-plugin-host-authority.node-test.ts",
22
+ "typecheck": "tsc --noEmit"
23
+ },
24
+ "dependencies": {
25
+ "@zcode/zcode-cua": "catalog:"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^24.0.0",
29
+ "typescript": "^5.9.0"
30
+ }
31
+ }
@@ -0,0 +1,58 @@
1
+ // Self-contained esbuild bundle for the M4 slim shell.
2
+ //
3
+ // Why this exists: `tsc` emits raw ESM that keeps `import { main } from "@zcode/zcode-cua"`
4
+ // as a bare specifier. The bundled-agent staging tree
5
+ // (packages/desktop/bundled-agents/<plat>/glm/packages/zcode-cua-plugin/) ships only the
6
+ // plugin's dist/ + package.json — no node_modules/@zcode/zcode-cua. Loading the raw tsc
7
+ // server.js there throws ERR_MODULE_NOT_FOUND for '@zcode/zcode-cua', the MCP stdio socket
8
+ // closes immediately, and the dev app shows "Connection closed / 0 tools". DEV works only
9
+ // because the workspace's hoisted node_modules/@zcode/zcode-cua is resolvable from source.
10
+ //
11
+ // Fix: bundle the slim shell so @zcode/zcode-cua (and its pure-JS deps) are inlined into a
12
+ // single dist/mcp/server.js. `sharp` stays external — it's native (.node prebuilt) and
13
+ // cannot be inlined into a JS bundle; @zcode/zcode-cua's own bundle already externalizes
14
+ // it the same way. In-repo runs resolve sharp via the hoisted root node_modules.
15
+ //
16
+ // Mirrors apps/zcode-cli/packages/android-emulator-plugin/scripts/build-mcp.mjs.
17
+
18
+ import { chmod } from "node:fs/promises";
19
+ import { resolve } from "node:path";
20
+ import { build } from "esbuild";
21
+
22
+ const packageRoot = resolve(import.meta.dirname, "..");
23
+ const serverOutputPath = resolve(packageRoot, "dist", "mcp", "server.js");
24
+
25
+ // sharp is native: esbuild cannot inline `.node` binaries into a JS bundle.
26
+ // Matches @zcode/zcode-cua/scripts/build.mjs's external list.
27
+ const external = ["sharp"];
28
+ const localRuntimePackageDir = process.env.ZCODE_CUA_RUNTIME_PACKAGE_DIR?.trim();
29
+
30
+ await build({
31
+ bundle: true,
32
+ entryPoints: [resolve(packageRoot, "src", "mcp", "server.ts")],
33
+ format: "esm",
34
+ legalComments: "none",
35
+ outfile: serverOutputPath,
36
+ platform: "node",
37
+ target: "node24",
38
+ external,
39
+ // 本地 Helper/插件联合回归必须内联同一份刚 build 的 zcode-cua。
40
+ // 未设置覆盖时,发布构建仍解析 lockfile 固定的 workspace 依赖。
41
+ ...(localRuntimePackageDir
42
+ ? {
43
+ alias: {
44
+ "@zcode/zcode-cua": resolve(localRuntimePackageDir),
45
+ },
46
+ }
47
+ : {}),
48
+ // @zcode/zcode-cua v0.4.0 ships a CJS dist; esbuild inlining it into this ESM bundle
49
+ // emits a `__require(...)` shim that throws "Dynamic require of X is not supported" because
50
+ // `require` is undefined in ESM. Define `require` via createRequire so the shim resolves to
51
+ // the real CJS loader (node builtins + any CJS deps). esbuild places the entry shebang on
52
+ // line 1 and the banner after it, so the shebang stays valid.
53
+ banner: {
54
+ js: "import { createRequire as __zcodeCreateRequire } from 'node:module';\nconst require = __zcodeCreateRequire(import.meta.url);",
55
+ },
56
+ });
57
+
58
+ await chmod(serverOutputPath, 0o755);
@@ -0,0 +1,291 @@
1
+ #!/usr/bin/env node
2
+ // 唯一的原子 producer bump 命令 —— 一次调用完成全部 producer 记录的同步更新:
3
+ // pnpm-workspace.yaml catalog(两个别名)
4
+ // pnpm-lock.yaml(通过 pnpm install)
5
+ // bundled Skill(skills/zcode-computer-use/SKILL.md)
6
+ // upstream.json(commit/ref/skillSha256 provenance)
7
+ // wrapper 版本三处记录 + 官方插件定义 + 实现契约(复用 check-version-coherence.mjs 写回)
8
+ // 成功后自动跑快速基线门禁与 skill-sync 不可变性测试自校验;--commit 直接产出单个
9
+ // chore(cua) 提交,从机制上消灭“改 catalog、更新 lock、同步 Skill/provenance、
10
+ // 改版本/契约”被拆成多个提交的漂移窗口。
11
+ //
12
+ // 背景(2026-08-20):这两条链路此前是手工分开跑的(改 catalog+install 一个提交,
13
+ // sync:skill + sync:version 另一个提交,甚至漏跑),集成分支出现 catalog=e38999b7 /
14
+ // upstream.json=0bf36086 的漂移。CI(check-cua-baseline.mjs)现在直接拒绝这种状态,
15
+ // 本脚本是唯一合法修复/升级路径。
16
+ //
17
+ // 用法:
18
+ // node scripts/bump-zcode-cua-producer.mjs # bump 到 producer origin/main
19
+ // node scripts/bump-zcode-cua-producer.mjs <ref|sha> # bump 到指定 ref/评审 SHA
20
+ // node scripts/bump-zcode-cua-producer.mjs <ref> --commit # 校验通过后直接产出单个提交
21
+ // 环境变量:ZCODE_CUA_REPO 指定 producer 本地克隆(默认同级 ../zcode-cua)。
22
+
23
+ import { createHash } from "node:crypto";
24
+ import { execFile as execFileCallback } from "node:child_process";
25
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
26
+ import { dirname, resolve } from "node:path";
27
+ import { fileURLToPath } from "node:url";
28
+ import { promisify } from "node:util";
29
+
30
+ const execFile = promisify(execFileCallback);
31
+ const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
32
+ const repoRoot = resolve(packageRoot, "../../../..");
33
+ const workspacePath = resolve(repoRoot, "pnpm-workspace.yaml");
34
+ const producerRoot = resolve(
35
+ process.env.ZCODE_CUA_REPO ?? resolve(packageRoot, "../../../../../zcode-cua"),
36
+ );
37
+ const skillPath = "plugin/skills/zcode-computer-use/SKILL.md";
38
+ const producerManifestPath = "plugin/.zcode-plugin/plugin.json";
39
+ const targetSkill = resolve(packageRoot, "skills/zcode-computer-use/SKILL.md");
40
+ const provenancePath = resolve(packageRoot, "upstream.json");
41
+ const doCommit = process.argv.includes("--commit");
42
+ const positionalArgs = process.argv.slice(2).filter((arg) => !arg.startsWith("--"));
43
+ const producerRefArg = positionalArgs[0] ?? "origin/main";
44
+
45
+ async function run(command, args, options = {}) {
46
+ const result = await execFile(command, args, {
47
+ encoding: "utf8",
48
+ maxBuffer: 64 * 1024 * 1024,
49
+ ...options,
50
+ });
51
+ return result.stdout.trim();
52
+ }
53
+
54
+ // 二进制安全的变体:git show 的文件内容必须逐字节等于 producer 对象(含末尾换行),
55
+ // 任何 trim 都会造成 sha256 与不可变性校验漂移。
56
+ async function runBuffer(command, args, options = {}) {
57
+ const result = await execFile(command, args, {
58
+ encoding: "buffer",
59
+ maxBuffer: 64 * 1024 * 1024,
60
+ ...options,
61
+ });
62
+ return Buffer.from(result.stdout);
63
+ }
64
+
65
+ async function runOrThrow(label, command, args, options = {}) {
66
+ try {
67
+ return await run(command, args, options);
68
+ } catch (error) {
69
+ throw new Error(
70
+ `${label} 失败:${error.stderr || error.stdout || error.message}`,
71
+ );
72
+ }
73
+ }
74
+
75
+ // 1) 解析 producer commit:fetch 后 rev-parse;40 位 SHA 额外要求它已存在于某个远端
76
+ // ref 上,防止把本地实验提交 pin 进产品依赖锁。
77
+ console.log(`[cua-bump] producer 仓库:${producerRoot}`);
78
+ await runOrThrow("producer git fetch", "git", [
79
+ "-C",
80
+ producerRoot,
81
+ "fetch",
82
+ "origin",
83
+ "--prune",
84
+ ]);
85
+ let producerCommit;
86
+ try {
87
+ producerCommit = await run("git", [
88
+ "-C",
89
+ producerRoot,
90
+ "rev-parse",
91
+ "--verify",
92
+ `${producerRefArg}^{commit}`,
93
+ ]);
94
+ } catch {
95
+ if (/^[0-9a-f]{40}$/u.test(producerRefArg)) {
96
+ await runOrThrow("按 SHA 精确拉取", "git", [
97
+ "-C",
98
+ producerRoot,
99
+ "fetch",
100
+ "origin",
101
+ producerRefArg,
102
+ ]);
103
+ producerCommit = producerRefArg;
104
+ } else {
105
+ throw new Error(`producer 仓库里找不到 ref:${producerRefArg}`);
106
+ }
107
+ }
108
+ if (!/^[0-9a-f]{40}$/u.test(producerCommit)) {
109
+ throw new Error(`producer commit 不是 40 位 SHA:${producerCommit}`);
110
+ }
111
+ if (/^[0-9a-f]{40}$/u.test(producerRefArg)) {
112
+ const containing = await run("git", [
113
+ "-C",
114
+ producerRoot,
115
+ "branch",
116
+ "-r",
117
+ "--contains",
118
+ producerCommit,
119
+ ]);
120
+ if (containing === "") {
121
+ throw new Error(
122
+ `${producerCommit} 不在任何远端 ref 上;先推送 producer 提交再 pin(禁止 pin 本地实验提交)`,
123
+ );
124
+ }
125
+ }
126
+ const producerSubject = await run("git", [
127
+ "-C",
128
+ producerRoot,
129
+ "log",
130
+ "-1",
131
+ "--format=%s",
132
+ producerCommit,
133
+ ]);
134
+ console.log(`[cua-bump] 目标 producer:${producerCommit}(${producerSubject})`);
135
+
136
+ // 2) 从 producer commit 的 git 对象里直接取 Skill 字节与插件 manifest 版本
137
+ // (不 checkout producer 工作区,冻结中的工作分支不受影响)。
138
+ let skillBytes;
139
+ try {
140
+ skillBytes = await runBuffer("git", [
141
+ "-C",
142
+ producerRoot,
143
+ "show",
144
+ `${producerCommit}:${skillPath}`,
145
+ ]);
146
+ } catch (error) {
147
+ throw new Error(
148
+ `读取 producer Skill 失败:${error.stderr || error.stdout || error.message}`,
149
+ );
150
+ }
151
+ const producerManifestText = await runOrThrow("读取 producer 插件 manifest", "git", [
152
+ "-C",
153
+ producerRoot,
154
+ "show",
155
+ `${producerCommit}:${producerManifestPath}`,
156
+ ]);
157
+ const producerVersion = JSON.parse(producerManifestText).version;
158
+ if (typeof producerVersion !== "string" || producerVersion.length === 0) {
159
+ throw new Error(`producer 插件 manifest 缺少合法 version:${producerManifestText}`);
160
+ }
161
+ console.log(`[cua-bump] producer 版本:${producerVersion}`);
162
+
163
+ // 3) 原子更新 catalog 两个别名(各自必须恰好一处,保持 YAML 字节布局不变)。
164
+ const aliases = ["@zcode/zcode-cua", "@zcode/zcode-cua-helper-runtime"];
165
+ let workspaceText = await readFile(workspacePath, "utf8");
166
+ for (const alias of aliases) {
167
+ const pattern = new RegExp(
168
+ `^(\\s+"${alias}":\\s+"git\\+https://dev\\.aminer\\.cn/codegeex/zcode-cua\\.git#)([0-9a-f]{40})("\\s*)$`,
169
+ "gmu",
170
+ );
171
+ const matches = [...workspaceText.matchAll(pattern)];
172
+ if (matches.length !== 1) {
173
+ throw new Error(
174
+ `pnpm-workspace.yaml catalog 里 ${alias} 必须恰好 pin 一个 40 位 commit(当前 ${matches.length} 个)`,
175
+ );
176
+ }
177
+ workspaceText = workspaceText.replace(
178
+ pattern,
179
+ `$1${producerCommit}$3`,
180
+ );
181
+ }
182
+ await writeFile(workspacePath, workspaceText);
183
+
184
+ // 4) 更新 lockfile 与 node_modules(coherence 写回要读 installed producer 契约)。
185
+ console.log("[cua-bump] 运行 pnpm install(更新 lockfile 与 installed producer)…");
186
+ await runOrThrow("pnpm install", "pnpm", ["install", "--prefer-offline"], {
187
+ cwd: repoRoot,
188
+ });
189
+
190
+ // 5) 写 bundled Skill 与 upstream.json provenance。
191
+ await mkdir(dirname(targetSkill), { recursive: true });
192
+ await writeFile(targetSkill, skillBytes);
193
+ await writeFile(
194
+ provenancePath,
195
+ `${JSON.stringify(
196
+ {
197
+ repository: "https://dev.aminer.cn/codegeex/zcode-cua.git",
198
+ ref: producerCommit,
199
+ commit: producerCommit,
200
+ skillPath,
201
+ skillSha256: createHash("sha256").update(skillBytes).digest("hex"),
202
+ },
203
+ null,
204
+ 2,
205
+ )}\n`,
206
+ );
207
+
208
+ // 6) 对齐 wrapper 版本三处记录 + 官方插件定义 + 实现契约(复用既有写回逻辑)。
209
+ console.log("[cua-bump] 对齐 wrapper 版本与实现契约…");
210
+ const coherenceOutput = await runOrThrow(
211
+ "check-version-coherence 写回",
212
+ "node",
213
+ ["scripts/check-version-coherence.mjs"],
214
+ { cwd: packageRoot },
215
+ );
216
+ console.log(coherenceOutput);
217
+
218
+ // 7) 自校验:快速基线门禁 + Skill 不可变性测试必须全绿,否则拒绝产出提交。
219
+ console.log("[cua-bump] 自校验:check-cua-baseline + skill-sync…");
220
+ await runOrThrow("check-cua-baseline", "node", [
221
+ "scripts/check-cua-baseline.mjs",
222
+ ], { cwd: packageRoot });
223
+ await runOrThrow("skill-sync node test", "node", [
224
+ "--test",
225
+ "tests/skill-sync.node-test.mjs",
226
+ ], { cwd: packageRoot });
227
+
228
+ // 8) 汇总变更并(可选)产出单个原子提交。
229
+ const commitFileSet = [
230
+ "pnpm-workspace.yaml",
231
+ "pnpm-lock.yaml",
232
+ "apps/zcode-cli/packages/zcode-cua-plugin/upstream.json",
233
+ "apps/zcode-cli/packages/zcode-cua-plugin/skills/zcode-computer-use/SKILL.md",
234
+ "apps/zcode-cli/packages/zcode-cua-plugin/package.json",
235
+ "apps/zcode-cli/packages/zcode-cua-plugin/.zcode-plugin/plugin.json",
236
+ "apps/zcode-cli/packages/bootstrap/src/app/official-plugin-definitions.ts",
237
+ "docs/superpowers/specs/2026-08-14-cua-final-raster-integrity-contract.md",
238
+ ];
239
+ // 注意不能用 trim():porcelain 每行以 "XY " 两列状态开头,未暂存改动的首列是空格,
240
+ // 整体 trim 会吃掉第一行的前导空格,把路径错切 3 个字符。
241
+ const statusOutput = await execFile(
242
+ "git",
243
+ ["-C", repoRoot, "status", "--porcelain"],
244
+ { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 },
245
+ );
246
+ const statusLines = statusOutput.stdout
247
+ .split("\n")
248
+ .filter((line) => line !== "");
249
+ const relevant = statusLines.filter((line) =>
250
+ commitFileSet.some((path) => line.slice(3).replace(/^"|"$/gu, "") === path),
251
+ );
252
+ const unexpected = statusLines.filter(
253
+ (line) =>
254
+ // 未跟踪文件不属于任何提交,不阻塞原子 bump;已跟踪文件的意外改动才阻塞。
255
+ !line.startsWith("??") &&
256
+ !commitFileSet.some((path) => line.slice(3).replace(/^"|"$/gu, "") === path),
257
+ );
258
+ console.log("[cua-bump] 本次原子变更:");
259
+ for (const line of relevant) console.log(` ${line}`);
260
+ if (unexpected.length > 0) {
261
+ console.log("[cua-bump] 工作区里的其他未提交改动(不属于本次 bump,不会被提交):");
262
+ for (const line of unexpected) console.log(` ${line}`);
263
+ }
264
+ const refLabel =
265
+ producerRefArg === "origin/main" ? "main" : producerRefArg;
266
+ const commitMessage = `chore(cua): pin producer to ${refLabel} ${producerCommit.slice(0, 9)}(${producerSubject})`;
267
+ if (!doCommit) {
268
+ console.log(`[cua-bump] 完成。建议提交信息:\n ${commitMessage}`);
269
+ console.log("[cua-bump] 加 --commit 可直接产出这个原子提交。");
270
+ process.exit(0);
271
+ }
272
+ if (unexpected.length > 0) {
273
+ throw new Error(
274
+ "工作区存在不属于本次 bump 的未提交改动;为保持原子性拒绝自动提交,请先处理它们。",
275
+ );
276
+ }
277
+ if (relevant.length === 0) {
278
+ // 幂等重跑:目标 producer 与工作区已一致(例如修复漂移后重复执行),
279
+ // 不能让 git commit 以 "nothing to commit" 报错。
280
+ console.log(`[cua-bump] 工作区已与目标 producer ${producerCommit} 一致,无需提交。`);
281
+ process.exit(0);
282
+ }
283
+ await runOrThrow("git add", "git", ["-C", repoRoot, "add", ...commitFileSet]);
284
+ await runOrThrow("git commit", "git", [
285
+ "-C",
286
+ repoRoot,
287
+ "commit",
288
+ "-m",
289
+ commitMessage,
290
+ ]);
291
+ console.log(`[cua-bump] 已提交:${commitMessage}`);