mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-25 18:16:32 +00:00
* feat(autocomplete): add zh-CN descriptions for zip, unzip, make, nano Cover 32 missing Fig descriptions, generate zh-TW, add batch coverage tests, and record source and semantic checks. * fix(autocomplete): correct zip, unzip, and make semantics Limit zip -9 to the compression level, warn that unzip -0 is a suspect upstream option, and describe make -N as the Apple/NeXT compatibility extension. * fix(autocomplete): simplify unzip -0 warning and correct NeXT note Keep the -O gbk version caveat in the research record and describe Next/NeXT as a capitalization difference. * feat(autocomplete): complete remaining common command descriptions Add 177 zh-CN descriptions for python, python3, node, vim, sort, awk, and sed; generate zh-TW, cover the batch with real Fig specs, and record one deferred shared node key. * fix(autocomplete): correct sed n and sort parallel semantics Add the automatic-print condition to sed n, remove the universal CPU default from sort --parallel, and remove duplicated adopted-entry sections from the source record. * fix: repair macOS terminal setup and align autocomplete details - Read OSC 7 setup payloads through base64 stdin so BSD/macOS works - Keep the FIDO askpass socket path within the Unix sun_path limit - Align autocomplete descriptions in a shared fixed column - Fix an invalid optional-parameter declaration and lint warnings - Harden macOS-sensitive OSC 7, SFTP, temp-dir and privacy tests * feat(autocomplete): add zh-CN descriptions for file and text utilities Cover ln, stat, wc, cut, uniq, tee and xargs with 70 localized descriptions. Add coverage and localization tests, preload the new common specs, and record the upstream wc/xargs wording corrections. * fix(autocomplete): keep popup scrollbars draggable Panel mousedown handlers no longer preventDefault across the whole box, so the right-side detail scrollbar and the suggestion list scrollbar can be dragged while padding clicks still preserve terminal focus. * fix(autocomplete): keep detail panel open while selecting text Delay row hover clearing so the pointer can move into the right-side detail panel, and allow native text selection there without stealing terminal focus on ordinary padding clicks.
156 lines
3.5 KiB
JavaScript
156 lines
3.5 KiB
JavaScript
/**
|
|
* List description strings for the common-command autocomplete overlay that
|
|
* have no zh-CN entry. Maintenance aid for @withfig/autocomplete updates.
|
|
* Not a CI check: always exits 0.
|
|
*
|
|
* Usage: node scripts/list-untranslated-autocomplete-descriptions.mjs
|
|
*
|
|
* Local specs in electron/specs win over the bundled Fig file, matching
|
|
* electron/main/registerBridges.cjs. `docker compose` descriptions come from
|
|
* the docker spec; docker-compose.js covers the standalone command.
|
|
*/
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { pathToFileURL, fileURLToPath } from "node:url";
|
|
|
|
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
const dictionaryPath = path.join(
|
|
rootDir,
|
|
"components/terminal/autocomplete/descriptions.zh-CN.json",
|
|
);
|
|
|
|
/** Commands covered by the zh-CN description overlay. */
|
|
const COVERED_COMMANDS = [
|
|
"git",
|
|
"docker",
|
|
"docker-compose",
|
|
"kubectl",
|
|
"npm",
|
|
"pnpm",
|
|
"yarn",
|
|
"pip",
|
|
"pip3",
|
|
"systemctl",
|
|
"journalctl",
|
|
"ls",
|
|
"cd",
|
|
"cp",
|
|
"mv",
|
|
"rm",
|
|
"ln",
|
|
"mkdir",
|
|
"chmod",
|
|
"chown",
|
|
"stat",
|
|
"wc",
|
|
"cut",
|
|
"uniq",
|
|
"tee",
|
|
"xargs",
|
|
"tar",
|
|
"ssh",
|
|
"scp",
|
|
"rsync",
|
|
"curl",
|
|
"wget",
|
|
"grep",
|
|
"find",
|
|
"ps",
|
|
"kill",
|
|
"top",
|
|
"apt",
|
|
"yum",
|
|
"dnf",
|
|
"brew",
|
|
"sudo",
|
|
"touch",
|
|
"zip",
|
|
"unzip",
|
|
"make",
|
|
"nano",
|
|
"python",
|
|
"python3",
|
|
"node",
|
|
"vim",
|
|
"sort",
|
|
"awk",
|
|
"sed",
|
|
"cat",
|
|
"tail",
|
|
"head",
|
|
"less",
|
|
"df",
|
|
"du",
|
|
"ip",
|
|
"ping",
|
|
"netstat",
|
|
"ss",
|
|
];
|
|
|
|
function collectDescriptions(node, out, seen) {
|
|
if (!node || typeof node !== "object") return;
|
|
if (seen.has(node)) return;
|
|
seen.add(node);
|
|
if (typeof node.description === "string" && node.description.trim()) {
|
|
out.add(node.description);
|
|
}
|
|
for (const value of Object.values(node)) {
|
|
if (Array.isArray(value)) {
|
|
for (const item of value) collectDescriptions(item, out, seen);
|
|
} else if (value && typeof value === "object") {
|
|
collectDescriptions(value, out, seen);
|
|
}
|
|
}
|
|
}
|
|
|
|
function resolveSpecFile(commandName) {
|
|
const localFile = path.join(rootDir, "electron/specs", `${commandName}.js`);
|
|
if (fs.existsSync(localFile)) return localFile;
|
|
const figFile = path.join(
|
|
rootDir,
|
|
"node_modules/@withfig/autocomplete/build",
|
|
`${commandName}.js`,
|
|
);
|
|
if (fs.existsSync(figFile)) return figFile;
|
|
return null;
|
|
}
|
|
|
|
const dictionary = fs.existsSync(dictionaryPath)
|
|
? JSON.parse(fs.readFileSync(dictionaryPath, "utf8"))
|
|
: {};
|
|
const missing = [];
|
|
const missingSpecs = [];
|
|
|
|
for (const commandName of COVERED_COMMANDS) {
|
|
const specFile = resolveSpecFile(commandName);
|
|
if (!specFile) {
|
|
missingSpecs.push(commandName);
|
|
continue;
|
|
}
|
|
const mod = await import(pathToFileURL(specFile).href);
|
|
const raw = mod.default?.default ?? mod.default ?? null;
|
|
if (!raw) {
|
|
missingSpecs.push(commandName);
|
|
continue;
|
|
}
|
|
const spec = JSON.parse(JSON.stringify(raw));
|
|
const descriptions = new Set();
|
|
collectDescriptions(spec, descriptions, new WeakSet());
|
|
for (const description of descriptions) {
|
|
if (typeof dictionary[description] !== "string" || dictionary[description].length === 0) {
|
|
missing.push({ commandName, description });
|
|
}
|
|
}
|
|
}
|
|
|
|
if (missingSpecs.length > 0) {
|
|
console.log(`NO_SPEC ${missingSpecs.join(" ")}`);
|
|
}
|
|
const seen = new Set();
|
|
for (const entry of missing) {
|
|
if (seen.has(entry.description)) continue;
|
|
seen.add(entry.description);
|
|
console.log(`MISSING ${entry.commandName} ${JSON.stringify(entry.description)}`);
|
|
}
|
|
console.log(`Untranslated description strings: ${seen.size}`);
|