Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

ci: reject CJK ideographs in changed files

jeffreyaaf71eecbce1
diff --git a/scripts/ci/check-repository-gate.sh b/scripts/ci/check-repository-gate.sh
index 5bfe1275..811ec189 100755
--- a/scripts/ci/check-repository-gate.sh
+++ b/scripts/ci/check-repository-gate.sh
@@ -40,6 +40,7 @@ pnpm env:inventory:check
# Skill versions are immutable and never reformatted.
prettier_files=()
eslint_files=()
+changed_files=()
while IFS= read -r -d '' file; do
[[ "$file" =~ ^skills/builtin/[^/]+/[^/]+/ ]] && continue
[[ -f "$file" ]] || continue
@@ -51,6 +52,7 @@ while IFS= read -r -d '' file; do
case "$file" in
*.cjs | *.cts | *.js | *.jsx | *.mjs | *.mts | *.ts | *.tsx) eslint_files+=("$file") ;;
esac
+ changed_files+=("$file")
done < <(git -c core.quotePath=false diff -z --name-only --no-renames --diff-filter=ACMRT "$base" "$head_sha")
if ((${#prettier_files[@]} > 0)); then
pnpm exec prettier --check "${prettier_files[@]}"
@@ -59,4 +61,12 @@ if ((${#eslint_files[@]} > 0)); then
pnpm exec eslint "${eslint_files[@]}"
fi
+# The repository is English-only. Only CJK ideographs are rejected, so tests
+# may still use kana, Hangul, and full-width punctuation as unspaced scripts.
+if ((${#changed_files[@]} > 0)) &&
+ LC_ALL=C git grep -nIP '(*UTF)[\x{3400}-\x{4DBF}\x{4E00}-\x{9FFF}\x{F900}-\x{FAFF}]' -- "${changed_files[@]}"; then
+ echo "Changed files contain Chinese characters; the repository is English-only (see AGENTS.md)." >&2
+ exit 1
+fi
+
make check-scripts-fast check-docs
diff --git a/scripts/ci/check-repository-gate.test.ts b/scripts/ci/check-repository-gate.test.ts
index e8662672..ef7871e6 100644
--- a/scripts/ci/check-repository-gate.test.ts
+++ b/scripts/ci/check-repository-gate.test.ts
@@ -20,6 +20,7 @@ const cleanEnv = Object.fromEntries(
interface GateOptions {
changedPath?: string;
+ changedContent?: string;
// Delete this base file in the head commit.
deletedPath?: string;
// Pass a target branch that moved past the merge base, as a local run does.
@@ -57,7 +58,10 @@ function runGate(options: GateOptions = {}) {
if (options.deletedPath) git("rm", "-q", options.deletedPath);
const changed = options.changedPath ?? "apps/web/src/example.ts";
mkdirSync(join(root, changed, ".."), { recursive: true });
- writeFileSync(join(root, changed), "export {};\n");
+ writeFileSync(
+ join(root, changed),
+ options.changedContent ?? "export {};\n",
+ );
git("add", ".");
git("commit", "-q", "-m", "head");
const head = git("rev-parse", "HEAD");
@@ -137,6 +141,23 @@ describe("local repository gate", { timeout: 60_000 }, () => {
]);
});
+ it("rejects changed files with CJK ideographs and allows kana", () => {
+ const ideographs = runGate({
+ changedContent: 'export const greeting = "\u4f60\u597d";\n',
+ });
+ expect(ideographs.status).not.toBe(0);
+ expect(ideographs.stderr).toContain("English-only");
+ expect(ideographs.commands).not.toContain(
+ "make check-scripts-fast check-docs",
+ );
+
+ const kana = runGate({
+ changedContent:
+ 'export const sample = "\u3072\u3089\u304c\u306a\u3002";\n',
+ });
+ expect(kana.status).toBe(0);
+ });
+
it("formats and lints only existing changed files outside published Skill versions", () => {
const skill = runGate({
changedPath: "skills/builtin/example/1.0.0/scripts/run.js",