zcode-app-cli 3.8.1-15 → 3.9.1-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.
- package/bin/zcode.js +92 -47
- package/package.json +2 -2
- package/vendor/extraction.json +131 -5
- package/vendor/node_modules/@zcode/tui/dist/index.js +35 -4
- package/vendor/packages/browser-use-plugin/.zcode-plugin/plugin.json +1 -1
- package/vendor/packages/browser-use-plugin/dist/mcp/server.js +12880 -10408
- package/vendor/packages/browser-use-plugin/package.json +1 -1
- package/vendor/packages/document-skills-plugin/.mcp.json +13 -0
- package/vendor/packages/document-skills-plugin/.zcode-plugin/plugin.json +19 -6
- package/vendor/packages/document-skills-plugin/package.json +3 -3
- package/vendor/packages/document-skills-plugin/skills/docx/SKILL.md +6 -2
- package/vendor/packages/document-skills-plugin/skills/docx/env_setup/env_check.sh +0 -0
- package/vendor/packages/document-skills-plugin/skills/docx/env_setup/setup_mac_linux.sh +0 -0
- package/vendor/packages/document-skills-plugin/skills/docx/setup.sh +0 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/SKILL.md +39 -20
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/academic.md +39 -47
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/creative.md +11 -3
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/poster.md +3 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process.md +3 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/report.md +41 -62
- package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/env_check.sh +23 -15
- package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup.md +37 -19
- package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup_mac_linux.sh +0 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/env_setup/setup_windows.ps1 +17 -19
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/cover_render.py +487 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2poster.js +43 -11
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf.py +145 -50
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/setup.sh +23 -21
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover-backgrounds.md +1 -1
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover.md +139 -1347
- package/vendor/packages/document-skills-plugin/skills/pptx/LICENSE.txt +13 -0
- package/vendor/packages/document-skills-plugin/skills/pptx/SKILL.md +146 -179
- package/vendor/packages/document-skills-plugin/skills/xlsx/SKILL.md +6 -2
- package/vendor/packages/document-skills-plugin/skills/xlsx/env_setup/env_check.sh +0 -0
- package/vendor/packages/document-skills-plugin/skills/xlsx/env_setup/setup_mac_linux.sh +0 -0
- package/vendor/packages/document-skills-plugin/skills/xlsx/setup.sh +0 -0
- package/vendor/packages/zcode-cua-plugin/.zcode-plugin/plugin.json +19 -0
- package/vendor/packages/zcode-cua-plugin/dist/mcp/server.js +68498 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/@img/colour/color.cjs +1596 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/@img/colour/index.cjs +1 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/@img/colour/package.json +58 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/lib/glib-2.0/include/glibconfig.h +221 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/lib/index.js +1 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.8.17.3 +0 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/package.json +42 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-libvips-linux-x64/versions.json +30 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-linux-x64/LICENSE +191 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64.node +0 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/@img/sharp-linux-x64/package.json +46 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/LICENSE +201 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/lib/detect-libc.js +313 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/lib/elf.js +39 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/lib/filesystem.js +51 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/lib/process.js +24 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/detect-libc/package.json +44 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/LICENSE +15 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/bin/semver.js +191 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/classes/comparator.js +143 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/classes/index.js +7 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/classes/range.js +557 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/classes/semver.js +333 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/clean.js +8 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/cmp.js +54 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/coerce.js +62 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/compare-build.js +9 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/compare-loose.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/compare.js +7 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/diff.js +60 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/eq.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/gt.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/gte.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/inc.js +21 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/lt.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/lte.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/major.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/minor.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/neq.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/parse.js +18 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/patch.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/prerelease.js +8 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/rcompare.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/rsort.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/satisfies.js +12 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/sort.js +5 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/functions/valid.js +8 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/index.js +91 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/constants.js +37 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/debug.js +11 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/identifiers.js +29 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/lrucache.js +42 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/parse-options.js +17 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/internal/re.js +223 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/package.json +78 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/preload.js +4 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/range.bnf +16 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/gtr.js +6 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/intersects.js +9 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/ltr.js +6 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/min-version.js +63 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/outside.js +82 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/simplify.js +49 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/subset.js +249 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/to-comparators.js +10 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/semver/ranges/valid.js +13 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/LICENSE +191 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/install/build.js +38 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/install/check.js +14 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/channel.js +177 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/colour.js +195 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/composite.js +212 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/constructor.js +499 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/index.js +16 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/input.js +809 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/is.js +143 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/libvips.js +207 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/operation.js +1016 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/output.js +1666 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/resize.js +595 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/sharp.js +121 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/lib/utility.js +291 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/package.json +202 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/binding.gyp +298 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/common.cc +1130 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/common.h +402 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/metadata.cc +346 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/metadata.h +90 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/operations.cc +499 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/operations.h +137 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/pipeline.cc +1814 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/pipeline.h +408 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/sharp.cc +43 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/stats.cc +186 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/stats.h +62 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/utilities.cc +288 -0
- package/vendor/packages/zcode-cua-plugin/node_modules/sharp/src/utilities.h +22 -0
- package/vendor/packages/zcode-cua-plugin/package.json +31 -0
- package/vendor/packages/zcode-cua-plugin/scripts/build-mcp.mjs +58 -0
- package/vendor/packages/zcode-cua-plugin/scripts/bump-zcode-cua-producer.mjs +291 -0
- package/vendor/packages/zcode-cua-plugin/scripts/check-cua-baseline.mjs +155 -0
- package/vendor/packages/zcode-cua-plugin/scripts/check-version-coherence.mjs +478 -0
- package/vendor/packages/zcode-cua-plugin/scripts/sync-cache.mjs +100 -0
- package/vendor/packages/zcode-cua-plugin/scripts/sync-skill-from-zcode-cua.mjs +115 -0
- package/vendor/packages/zcode-cua-plugin/skills/zcode-computer-use/SKILL.md +129 -0
- package/vendor/zcode.cjs +752 -743
- package/zcode-runtime.lock.json +3 -3
- package/vendor/packages/document-skills-plugin/skills/pptx/assets/font_list.txt +0 -80
- 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,129 @@
|
|
|
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. Resolve the app with `list_apps`; use `open_application` only when needed.
|
|
16
|
+
3. Call `get_app_state`. Start with the accessibility tree and no screenshot.
|
|
17
|
+
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.
|
|
18
|
+
5. Only when accessibility cannot locate or express the target, request a window
|
|
19
|
+
screenshot or full screenshot and use a frame-bound coordinate action.
|
|
20
|
+
6. Prefer `return_state="compact"` when the action supports it. Otherwise observe
|
|
21
|
+
again only when verification is required.
|
|
22
|
+
|
|
23
|
+
Do not run both the accessibility and visual workflows for the same action.
|
|
24
|
+
Do not activate or focus an app merely to make a semantic action work.
|
|
25
|
+
Honor tool capabilities and fail-closed results.
|
|
26
|
+
|
|
27
|
+
## Choose the target
|
|
28
|
+
|
|
29
|
+
There are two authoritative target forms:
|
|
30
|
+
|
|
31
|
+
- Element: `{"type":"element","state_id":"<state_id>","index":<index>}`
|
|
32
|
+
- Coordinate: `{"type":"coordinate","x":<x>,"y":<y>}`
|
|
33
|
+
|
|
34
|
+
Use an element target whenever the observed accessibility tree contains the
|
|
35
|
+
target. Use only an action advertised by the element.
|
|
36
|
+
Never translate image pixels into an element target.
|
|
37
|
+
|
|
38
|
+
Use a coordinate target only for a point chosen from the latest returned image.
|
|
39
|
+
Submit only `x` and `y`. Do not attach an `app_ref`, `state_id`, coordinate-space
|
|
40
|
+
name, or extra transform to it. An optional explicit `frame_id` exists only for
|
|
41
|
+
backward compatibility; never invent one.
|
|
42
|
+
|
|
43
|
+
### Frame-bound coordinates
|
|
44
|
+
|
|
45
|
+
Choose `x` and `y` only by looking at the current returned raster.
|
|
46
|
+
Submit those integers unchanged; CUA binds the current raster internally.
|
|
47
|
+
CUA owns every transform from the returned raster to native dispatch.
|
|
48
|
+
|
|
49
|
+
When visual fallback begins, discard coordinate-like numbers from earlier text or accessibility results.
|
|
50
|
+
They are not part of the visual task.
|
|
51
|
+
|
|
52
|
+
Act directly on the current raster when the target is clear.
|
|
53
|
+
Do not call `zoom` routinely.
|
|
54
|
+
Zoom is not part of the normal flow.
|
|
55
|
+
Use `zoom` only when the target is too small or ambiguous to select confidently.
|
|
56
|
+
For a Zoom result, choose the point in that returned child raster and submit only its pixels.
|
|
57
|
+
|
|
58
|
+
## Action strategy
|
|
59
|
+
|
|
60
|
+
- Accessibility element action is always preferred. It avoids focus changes and
|
|
61
|
+
real-pointer movement.
|
|
62
|
+
- `strategy="a11y"` requires an accessibility action and fails closed otherwise.
|
|
63
|
+
- For a coordinate target, `strategy="auto"` may use an actionable accessibility
|
|
64
|
+
hit first and otherwise follows the tool's declared fallback behavior.
|
|
65
|
+
- `strategy="event"` forces the raw coordinate path on tools that expose it. Use
|
|
66
|
+
it only when accessibility cannot perform the intended action or the task
|
|
67
|
+
explicitly requires visual pixel interaction.
|
|
68
|
+
|
|
69
|
+
On macOS, verified app/window-scoped raw dispatch is designed not to move the
|
|
70
|
+
real cursor or steal focus. Linux and Windows may require the target window to
|
|
71
|
+
be foreground for raw input. Never bypass a stale-frame, changed-owner,
|
|
72
|
+
occlusion, permission, or capability refusal.
|
|
73
|
+
|
|
74
|
+
A coordinate refusal may report that windows covering the point were skipped, or
|
|
75
|
+
name an owner other than the app you expected. Those windows are invisible
|
|
76
|
+
overlays belonging to the user's environment. Raise the window you meant to act on
|
|
77
|
+
with `open_application(activate=true, confirm_focus_steal=true)`, observe again,
|
|
78
|
+
and retry. Do not move, resize, or close the reported windows.
|
|
79
|
+
|
|
80
|
+
## Text and keyboard
|
|
81
|
+
|
|
82
|
+
Prefer `set_value` for editable elements. It is semantic and background-safe.
|
|
83
|
+
Use `select_text` and `perform_action` for element capabilities exposed by the
|
|
84
|
+
current state.
|
|
85
|
+
|
|
86
|
+
Never send targetless `type` or `key`; scope them with an element target or
|
|
87
|
+
`app_ref` as allowed by the tool schema. Preserve a returned `window_id` in
|
|
88
|
+
`app_ref` so the runtime can verify and retain window scope.
|
|
89
|
+
macOS uses `cmd`; Linux and Windows use `ctrl`.
|
|
90
|
+
Use `hold_key` for a duration; use `key` for a normal chord or repeated presses.
|
|
91
|
+
|
|
92
|
+
Platform app references:
|
|
93
|
+
|
|
94
|
+
- macOS: prefer `bundle_id`, otherwise `pid`.
|
|
95
|
+
- Windows: use AUMID in `bundle_id` for packaged apps; otherwise `name` or `pid`.
|
|
96
|
+
- Linux: use `name` or `pid`; do not invent a bundle id.
|
|
97
|
+
|
|
98
|
+
## Outcome and retry safety
|
|
99
|
+
|
|
100
|
+
`action_sent=true` means the action may already have happened. Never blindly
|
|
101
|
+
replay it. Retry a non-idempotent action only when `action_sent=false`.
|
|
102
|
+
|
|
103
|
+
Use returned post-state or a fresh `get_app_state` to verify the result. Old
|
|
104
|
+
`state_id` values become stale after an element write. When
|
|
105
|
+
`state_sync_status="refresh_required"`, call `get_app_state` before another
|
|
106
|
+
element write. A changed tree is not by itself proof that this action caused the
|
|
107
|
+
change; prefer target-specific verification fields when present.
|
|
108
|
+
|
|
109
|
+
Call `stop_computer_control` to stop the active control session. Do not continue
|
|
110
|
+
after the kill switch, denied access, or a non-retryable readiness result.
|
|
111
|
+
|
|
112
|
+
## Tool surface
|
|
113
|
+
|
|
114
|
+
Tool schemas are authoritative for arguments and supported strategies. The 30
|
|
115
|
+
tools are grouped as follows:
|
|
116
|
+
|
|
117
|
+
- Observe and resolve: `list_apps`, `open_application`, `list_windows`,
|
|
118
|
+
`get_app_state`, `screenshot`, `zoom`, `list_displays`, `switch_display`,
|
|
119
|
+
`cursor_position`
|
|
120
|
+
- Pointer: `left_click`, `double_click`, `triple_click`, `right_click`,
|
|
121
|
+
`middle_click`, `scroll`, `left_click_drag`, `mouse_move`, `left_mouse_down`,
|
|
122
|
+
`left_mouse_up`
|
|
123
|
+
- Text and keyboard: `type`, `set_value`, `select_text`, `key`, `hold_key`
|
|
124
|
+
- Semantic: `perform_action`
|
|
125
|
+
- Runtime: `request_access`, `stop_computer_control`, `wait`, `read_clipboard`,
|
|
126
|
+
`write_clipboard`
|
|
127
|
+
|
|
128
|
+
Do not infer unsupported arguments from this guide. Read the live tool schema,
|
|
129
|
+
prefer the accessibility path, and use screenshot pixels only as the fallback.
|