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,100 @@
1
+ // Sync the built dev plugin into the CLI's plugin cache so the running zcode CLI
2
+ // (which loads plugins from ~/.zcode/cli/plugins/cache/..., NOT from this repo)
3
+ // picks up skill / MCP / manifest changes without a manual copy.
4
+ //
5
+ // This closes the last hop of the sync chain:
6
+ // zcode-cua repo --sync:skill/sync:mcp--> dev plugin (here) --sync:cache--> CLI cache
7
+ //
8
+ // The cache dir name (e.g. 0.1.31) is just an install-time cache key; copying newer
9
+ // content (plugin.json says 0.2.0) on top of it is tolerated by the CLI and is exactly
10
+ // what makes a dev skill/MCP edit go live. Run after `pnpm sync:skill` (+ `pnpm build`
11
+ // when the MCP wrapper or skill changed).
12
+ //
13
+ // Usage:
14
+ // node scripts/sync-cache.mjs # auto-resolve cache path from marketplace.json
15
+ // node scripts/sync-cache.mjs <cacheDir> # explicit cache dir
16
+ import { cp, mkdir, readFile, readdir, stat } from "node:fs/promises";
17
+ import { existsSync } from "node:fs";
18
+ import { dirname, join, resolve } from "node:path";
19
+ import { fileURLToPath, pathToFileURL } from "node:url";
20
+ import { homedir } from "node:os";
21
+ import { stageSharpIntoBundledAgents } from "../../../../../packages/desktop/scripts/sharp-package-assets.mjs";
22
+
23
+ const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
24
+
25
+ const devPlugin = packageRoot;
26
+ // Build artifacts that constitute an installed plugin in the cache.
27
+ const ENTRIES = ["skills", "dist", ".zcode-plugin", "package.json"];
28
+
29
+ /**
30
+ * Resolve the CLI cache dir for zcode-cua. Prefer the cachePath declared in the
31
+ * zcode-plugins-official marketplace.json; fall back to the single version dir under
32
+ * the cache root. Throws if neither yields an existing dir (plugin not installed).
33
+ */
34
+ async function resolveCacheDir() {
35
+ if (process.argv[2]) return resolve(process.argv[2]);
36
+ const marketplace = join(
37
+ homedir(),
38
+ ".zcode/cli/plugins/marketplaces/zcode-plugins-official/marketplace.json",
39
+ );
40
+ try {
41
+ const text = await readFile(marketplace, "utf8");
42
+ const parsed = JSON.parse(text);
43
+ const entry = (parsed.plugins ?? parsed.items ?? []).find(
44
+ (p) => p?.name === "zcode-cua" && p?.cachePath,
45
+ );
46
+ if (entry?.cachePath && existsSync(entry.cachePath)) return entry.cachePath;
47
+ } catch {
48
+ // marketplace.json missing/unreadable — fall through to glob.
49
+ }
50
+ const cacheRoot = join(homedir(), ".zcode/cli/plugins/cache/zcode-plugins-official/zcode-cua");
51
+ if (existsSync(cacheRoot)) {
52
+ const dirs = await readdir(cacheRoot);
53
+ if (dirs.length === 1) return join(cacheRoot, dirs[0]);
54
+ if (dirs.length > 1) {
55
+ // Pick the newest by mtime — the most recently installed version.
56
+ let newest = null;
57
+ for (const d of dirs) {
58
+ const s = await stat(join(cacheRoot, d));
59
+ if (!newest || s.mtimeMs > newest.mtimeMs) newest = { d, mtimeMs: s.mtimeMs };
60
+ }
61
+ if (newest) return join(cacheRoot, newest.d);
62
+ }
63
+ }
64
+ throw new Error(
65
+ `Could not resolve the zcode-cua CLI cache dir. The plugin does not appear to be ` +
66
+ `installed — run it once from the zcode UI/TUI to install, then re-run sync:cache. ` +
67
+ `(looked in marketplace.json and ${cacheRoot})`,
68
+ );
69
+ }
70
+
71
+ const cacheDir = await resolveCacheDir();
72
+ await mkdir(cacheDir, { recursive: true });
73
+
74
+ const copied = [];
75
+ for (const entry of ENTRIES) {
76
+ const src = join(devPlugin, entry);
77
+ if (!existsSync(src)) continue; // e.g. dist/ before first build
78
+ const dest = join(cacheDir, entry);
79
+ // cp with recursive + force replacement; file/dir both handled.
80
+ await cp(pathToFileURL(src), pathToFileURL(dest), { recursive: true, force: true });
81
+ copied.push(entry);
82
+ }
83
+
84
+ // Bug 根因:开发态 CLI 实际从 ~/.zcode/cli/plugins/cache 启动 MCP,
85
+ // 只同步 dist 会让 externalized sharp 仍从一个隔离目录解析,导致 screenshot/zoom
86
+ // 在源码和 Helper 都正确时依旧报 MODULE_NOT_FOUND。与产品打包共用同一个 staging
87
+ // 函数,把当前平台的 JS/native 运行时放在插件自身 node_modules,避免两条链路漂移。
88
+ stageSharpIntoBundledAgents({
89
+ desktopPackageRoot: resolve(packageRoot, "../../../../packages/desktop"),
90
+ glmDir: cacheDir,
91
+ targetPlatform: { os: process.platform, arch: process.arch },
92
+ });
93
+ copied.push("node_modules/sharp runtime");
94
+
95
+ console.log(`sync:cache → ${cacheDir}`);
96
+ console.log(` copied: ${copied.join(", ") || "(nothing)"}`);
97
+ console.log(
98
+ ` note: the cache dir name is an install-time key and may lag the plugin.json ` +
99
+ `version inside — that is expected and does not affect loading.`,
100
+ );
@@ -0,0 +1,115 @@
1
+ import { createHash } from "node:crypto";
2
+ import { execFile as execFileCallback } from "node:child_process";
3
+ import { copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
4
+ import { dirname, resolve } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { promisify } from "node:util";
7
+
8
+ const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
9
+ const workspacePath = resolve(packageRoot, "../../../../pnpm-workspace.yaml");
10
+ const execFile = promisify(execFileCallback);
11
+ const defaultRepositoryRoot = resolve(packageRoot, "../../../../../zcode-cua");
12
+ const repositoryRoot = resolve(
13
+ process.argv[2] ?? process.env.ZCODE_CUA_REPO ?? defaultRepositoryRoot,
14
+ );
15
+ const sourceSkill = resolve(repositoryRoot, "plugin/skills/zcode-computer-use/SKILL.md");
16
+ const sourceManifest = resolve(repositoryRoot, "plugin/.zcode-plugin/plugin.json");
17
+ const targetSkill = resolve(packageRoot, "skills/zcode-computer-use/SKILL.md");
18
+ const provenancePath = resolve(packageRoot, "upstream.json");
19
+ // 修复:bundled wrapper 的 plugin.json / package.json 之前各自维护 0.1.0,
20
+ // 与实际 zcode-cua MCP server 版本割裂(UI 展示、缓存路径、marketplace 条目都对不上)。
21
+ // 这里把上游 manifest 的 version 作为单一真相源,回写到 bundled wrapper,避免再次漂移。
22
+ const bundledManifestPath = resolve(packageRoot, ".zcode-plugin", "plugin.json");
23
+ const bundledPackageJsonPath = resolve(packageRoot, "package.json");
24
+
25
+ const [skillBytes, manifestText, workspaceText, revision, sourceStatus] = await Promise.all([
26
+ readFile(sourceSkill),
27
+ readFile(sourceManifest, "utf8"),
28
+ readFile(workspacePath, "utf8"),
29
+ execFile("git", ["-C", repositoryRoot, "rev-parse", "HEAD"], {
30
+ encoding: "utf8",
31
+ }),
32
+ execFile(
33
+ "git",
34
+ [
35
+ "-C",
36
+ repositoryRoot,
37
+ "status",
38
+ "--porcelain",
39
+ "--untracked-files=all",
40
+ "--",
41
+ "plugin/skills/zcode-computer-use/SKILL.md",
42
+ "plugin/.zcode-plugin/plugin.json",
43
+ ],
44
+ { encoding: "utf8" },
45
+ ),
46
+ ]);
47
+ const upstreamCommit = revision.stdout.trim();
48
+ // 不记录本地 worktree 的临时分支名;不可变 commit 同时是可重放的 ref。
49
+ const upstreamRef = upstreamCommit;
50
+ const pins = [
51
+ ...workspaceText.matchAll(
52
+ /^\s+"@zcode\/zcode-cua":\s+"git\+https:\/\/dev\.aminer\.cn\/codegeex\/zcode-cua\.git#([0-9a-f]{40})"\s*$/gmu,
53
+ ),
54
+ ].map((match) => match[1]);
55
+ if (pins.length !== 1) {
56
+ throw new Error("The canonical zcode-cua catalog entry must pin one full producer commit");
57
+ }
58
+ if (!/^[0-9a-f]{40}$/u.test(upstreamCommit) || upstreamCommit !== pins[0]) {
59
+ throw new Error(
60
+ `Refusing to sync Skill from ${upstreamCommit || "unknown"}; catalog pins ${pins[0]}`,
61
+ );
62
+ }
63
+ if (!/^(?!.*\.\.)(?!\/)(?!.*\/$)[A-Za-z0-9._/-]+$/u.test(upstreamRef)) {
64
+ throw new Error(`Refusing to record invalid producer ref ${upstreamRef || "HEAD"}`);
65
+ }
66
+ if (sourceStatus.stdout.trim() !== "") {
67
+ throw new Error("Refusing to sync Skill or plugin manifest from uncommitted producer content");
68
+ }
69
+ const manifest = JSON.parse(manifestText);
70
+ if (manifest.name !== "zcode-cua" || typeof manifest.version !== "string") {
71
+ throw new Error(`Invalid zcode-cua plugin manifest at ${sourceManifest}`);
72
+ }
73
+
74
+ /**
75
+ * Patch a JSON file's top-level `version` field in place, preserving key order and
76
+ * 2-space indentation + trailing newline. Only rewrites when the value actually changes,
77
+ * so a no-op sync leaves the working tree clean.
78
+ */
79
+ async function syncVersionField(filePath, version) {
80
+ const text = await readFile(filePath, "utf8");
81
+ const parsed = JSON.parse(text);
82
+ if (parsed.version === version) return false;
83
+ parsed.version = version;
84
+ await writeFile(filePath, `${JSON.stringify(parsed, null, 2)}\n`);
85
+ return true;
86
+ }
87
+
88
+ // 重命名后目标目录可能尚不存在(skills/<name>/),copyFile 不会自动建目录,先确保它存在。
89
+ await mkdir(dirname(targetSkill), { recursive: true });
90
+ await copyFile(sourceSkill, targetSkill);
91
+ await writeFile(
92
+ provenancePath,
93
+ `${JSON.stringify(
94
+ {
95
+ repository: "https://dev.aminer.cn/codegeex/zcode-cua.git",
96
+ ref: upstreamRef,
97
+ commit: upstreamCommit,
98
+ skillPath: "plugin/skills/zcode-computer-use/SKILL.md",
99
+ skillSha256: createHash("sha256").update(skillBytes).digest("hex"),
100
+ },
101
+ null,
102
+ 2,
103
+ )}\n`,
104
+ );
105
+
106
+ const manifestUpdated = await syncVersionField(bundledManifestPath, manifest.version);
107
+ const packageJsonUpdated = await syncVersionField(bundledPackageJsonPath, manifest.version);
108
+
109
+ console.log(`Synced zcode-computer-use skill from zcode-cua ${manifest.version}`);
110
+ if (manifestUpdated || packageJsonUpdated) {
111
+ console.log(
112
+ `Aligned bundled wrapper version to ${manifest.version} ` +
113
+ `(plugin.json${manifestUpdated ? " updated" : ""}, package.json${packageJsonUpdated ? " updated" : ""})`,
114
+ );
115
+ }
@@ -0,0 +1,172 @@
1
+ ---
2
+ name: zcode-computer-use
3
+ description: Main-agent-only desktop control through accessibility-first semantic actions with visual pixel fallback only when accessibility cannot reach the target.
4
+ ---
5
+
6
+ # ZCode Computer Use
7
+
8
+ Main agent only. Never delegate Computer Use to a subagent.
9
+
10
+ ## Core loop
11
+
12
+ Observe once, act once, then verify.
13
+
14
+ 1. If readiness is unknown, call `request_access` once.
15
+ 2. `list_apps` shows running apps only. If the user names an app that is absent,
16
+ use `open_application` once with the original user-provided name: copy it character-for-character,
17
+ including its script, case, spaces, punctuation, and suffixes such as `app`.
18
+ For example, use `{"name":"网易云音乐app"}`, not `{"name":"网易云音乐"}`;
19
+ use `{"name":"日历"}`, not `{"name":"Calendar"}`.
20
+ Do not translate, localize, normalize, shorten, or remove a suffix. Do not retry names,
21
+ operate Finder/Spotlight, use shell commands to discover it, or substitute a different running app.
22
+ 3. Call `get_app_state`. Start with the accessibility tree and no screenshot.
23
+ 4. If the target has an accessibility element, use an element action. This is the primary path because it is semantic, precise, background-safe, and does not steal the user's focus.
24
+ 5. Only when accessibility cannot locate or express the target, request a window
25
+ screenshot or full screenshot and use a frame-bound coordinate action.
26
+ 6. Let actions return the default receipt only. Use `return_state="compact"` or
27
+ call `get_app_state` only when the next step needs fresh UI state.
28
+
29
+ Do not run both the accessibility and visual workflows for the same action.
30
+ Do not activate or focus an app merely to make a semantic action work.
31
+ Honor tool capabilities and fail-closed results.
32
+
33
+ Tool failures are reported without a producer-side permission classifier. Read
34
+ the original message before choosing recovery. Call `request_access` once only
35
+ when the failure explicitly names Accessibility or Screen Recording; do not
36
+ infer macOS permission loss from a generic `permission_denied`, foreground,
37
+ focus-policy, UIPI, or capability failure. If delivery is `possibly_sent`,
38
+ observe the application state and never replay the same action automatically.
39
+ If `request_access` reports Accessibility as `denied`/`stale` or Screen Recording
40
+ as `denied`, tell the user that authorization is required and end the current
41
+ turn. Do not call another Computer Use action, retry `request_access`, or promise
42
+ that the interrupted action will continue automatically after authorization.
43
+
44
+ ## Choose the target
45
+
46
+ There are two authoritative target forms:
47
+
48
+ - Element: `{"type":"element","state_id":"<state_id>","index":<index>}`
49
+ - Coordinate: `{"type":"coordinate","x":<x>,"y":<y>}`
50
+
51
+ Use an element target whenever the observed accessibility tree contains the
52
+ target. Use only an action advertised by the element.
53
+ Never translate image pixels into an element target.
54
+
55
+ Use a coordinate target only for a point chosen from the latest returned image.
56
+ Submit only `x` and `y`. Do not attach an `app_ref`, `state_id`, coordinate-space
57
+ name, or extra transform to it. An optional explicit `frame_id` exists only for
58
+ backward compatibility; never invent one.
59
+
60
+ ### Frame-bound coordinates
61
+
62
+ Choose `x` and `y` only by looking at the current returned raster.
63
+ Submit those integers unchanged; CUA binds the current raster internally.
64
+ CUA owns every transform from the returned raster to native dispatch.
65
+
66
+ When visual fallback begins, discard coordinate-like numbers from earlier text or accessibility results.
67
+ They are not part of the visual task.
68
+
69
+ Act directly on the current raster when the target is clear.
70
+ Do not call `zoom` routinely.
71
+ Zoom is not part of the normal flow.
72
+ Use `zoom` only when the target is too small or ambiguous to select confidently.
73
+ For a Zoom result, choose the point in that returned child raster and submit only its pixels.
74
+
75
+ ## Action strategy
76
+
77
+ - Accessibility element action is always preferred. It avoids focus changes and
78
+ real-pointer movement.
79
+ - `strategy="a11y"` requires an accessibility action and fails closed otherwise.
80
+ - For a coordinate target, `strategy="auto"` may use an actionable accessibility
81
+ hit first and otherwise follows the tool's declared fallback behavior.
82
+ - `strategy="event"` forces the raw coordinate path on tools that expose it. Use
83
+ it only when accessibility cannot perform the intended action or the task
84
+ explicitly requires visual pixel interaction.
85
+
86
+ On macOS, verified app/window-scoped raw dispatch is designed not to move the
87
+ real cursor or steal focus. Linux and Windows may require the target window to
88
+ be foreground for raw input. Never bypass a stale-frame, changed-owner,
89
+ occlusion, permission, or capability refusal.
90
+
91
+ A coordinate refusal may report that windows covering the point were skipped, or
92
+ name an owner other than the app you expected. Those windows are invisible
93
+ overlays belonging to the user's environment. Raise the window you meant to act on
94
+ with `open_application(activate=true)`, observe again, and retry. Do not move,
95
+ resize, or close the reported windows.
96
+
97
+ ### macOS file panels
98
+
99
+ For an `open_panel` / `save_panel` exact-path workflow, background app-scoped
100
+ keyboard receipts may be accepted without executing the AppKit command. Use this
101
+ single recovery sequence:
102
+
103
+ 1. Observe the panel and keep its `pid`, `bundle_id`, and fresh `actual_window_id`.
104
+ 2. Call `open_application` with those three fields and `activate=true`.
105
+ 3. Observe the same panel again, then send Cmd+Shift+G with `strategy=event` and
106
+ that exact panel window id.
107
+ 4. Observe by `pid` / `bundle_id` **without the old panel `window_id`**, so CUA
108
+ returns the newly focused `attached_dialog`. Pin its fresh `actual_window_id`
109
+ for the path `type(strategy=event)` and Enter.
110
+
111
+ `key` and `type` never activate implicitly. If they return `foreground_required`
112
+ with `action_sent=false`, repeat the confirmed activation and fresh observation;
113
+ do not retry the same key blindly. Ordinary windows and popovers do not receive
114
+ this activation exception.
115
+
116
+ For every ordinary launch or application activation, omit `window_id`. Never
117
+ invent a window id or use a placeholder such as `1`. If `bundle_id` or `pid` is
118
+ known, pass that canonical identity without a translated or guessed `name`.
119
+
120
+ ## Text and keyboard
121
+
122
+ Prefer `set_value` for editable elements. It is semantic and background-safe.
123
+ Use `select_text` and `perform_action` for element capabilities exposed by the
124
+ current state.
125
+
126
+ Never send targetless `type` or `key`; scope them with an element target or
127
+ `app_ref` as allowed by the tool schema. Preserve a returned `window_id` in
128
+ `app_ref` so the runtime can verify and retain window scope.
129
+ macOS uses `cmd`; Linux and Windows use `ctrl`.
130
+ Use `hold_key` for a duration; use `key` for a normal chord or repeated presses.
131
+
132
+ Platform app references:
133
+
134
+ - macOS: prefer `bundle_id`, otherwise `pid`.
135
+ - Windows: use AUMID in `bundle_id` for packaged apps; otherwise `name` or `pid`.
136
+ - Linux: use `name` or `pid`; do not invent a bundle id.
137
+
138
+ ## Outcome and retry safety
139
+
140
+ `action_sent=true` means the action may already have happened. Never blindly
141
+ replay it. When `action_sent=false`, re-observe with `get_app_state`, choose a
142
+ fresh target from the new state, and issue a new action only if it is still
143
+ needed. Never replay the same stale action call.
144
+
145
+ The default action result is an `action_receipt`, not a UI observation. Old
146
+ `state_id` values used by a sent element write are consumed after dispatch; call
147
+ `get_app_state` before another element write or whenever the next step depends
148
+ on current UI state. A changed tree is not by itself proof that this action
149
+ caused the change; verify with the app state or an external task oracle when it
150
+ matters.
151
+
152
+ Call `stop_computer_control` to stop the active control session. Do not continue
153
+ after the kill switch, denied access, or a non-retryable readiness result.
154
+
155
+ ## Tool surface
156
+
157
+ Tool schemas are authoritative for arguments and supported strategies. The 30
158
+ tools are grouped as follows:
159
+
160
+ - Observe and resolve: `list_apps`, `open_application`, `list_windows`,
161
+ `get_app_state`, `screenshot`, `zoom`, `list_displays`, `switch_display`,
162
+ `cursor_position`
163
+ - Pointer: `left_click`, `double_click`, `triple_click`, `right_click`,
164
+ `middle_click`, `scroll`, `left_click_drag`, `mouse_move`, `left_mouse_down`,
165
+ `left_mouse_up`
166
+ - Text and keyboard: `type`, `set_value`, `select_text`, `key`, `hold_key`
167
+ - Semantic: `perform_action`
168
+ - Runtime: `request_access`, `stop_computer_control`, `wait`, `read_clipboard`,
169
+ `write_clipboard`
170
+
171
+ Do not infer unsupported arguments from this guide. Read the live tool schema,
172
+ prefer the accessibility path, and use screenshot pixels only as the fallback.