opencode-windows-scheduler 1.5.2 → 1.5.5
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/CHANGELOG.md +107 -2
- package/CROSS_PLATFORM.md +107 -71
- package/LICENSE +21 -21
- package/README.md +74 -26
- package/ROADMAP-STRATEGY.md +11 -4
- package/ROADMAP.md +322 -112
- package/dist/core/analytics.d.ts +3 -0
- package/dist/core/analytics.d.ts.map +1 -1
- package/dist/core/analytics.js +4 -0
- package/dist/core/audit.d.ts +2 -1
- package/dist/core/audit.d.ts.map +1 -1
- package/dist/core/audit.js +32 -1
- package/dist/core/cron-to-schtasks.d.ts.map +1 -1
- package/dist/core/cron-to-schtasks.js +21 -4
- package/dist/core/file-watcher.d.ts.map +1 -1
- package/dist/core/file-watcher.js +16 -1
- package/dist/core/git-trigger.d.ts +4 -2
- package/dist/core/git-trigger.d.ts.map +1 -1
- package/dist/core/git-trigger.js +34 -16
- package/dist/core/local-ai.d.ts +52 -0
- package/dist/core/local-ai.d.ts.map +1 -0
- package/dist/core/local-ai.js +119 -0
- package/dist/core/lock.d.ts +14 -0
- package/dist/core/lock.d.ts.map +1 -1
- package/dist/core/lock.js +81 -4
- package/dist/core/matrix.d.ts.map +1 -1
- package/dist/core/matrix.js +3 -2
- package/dist/core/native-notify.d.ts.map +1 -1
- package/dist/core/native-notify.js +3 -0
- package/dist/core/one-shot.d.ts +7 -1
- package/dist/core/one-shot.d.ts.map +1 -1
- package/dist/core/one-shot.js +15 -2
- package/dist/core/permissions.d.ts +69 -0
- package/dist/core/permissions.d.ts.map +1 -0
- package/dist/core/permissions.js +143 -0
- package/dist/core/ps-wrapper.d.ts +9 -30
- package/dist/core/ps-wrapper.d.ts.map +1 -1
- package/dist/core/ps-wrapper.js +477 -108
- package/dist/core/record-history.d.ts +11 -0
- package/dist/core/record-history.d.ts.map +1 -1
- package/dist/core/record-history.js +106 -4
- package/dist/core/savings.d.ts +70 -0
- package/dist/core/savings.d.ts.map +1 -0
- package/dist/core/savings.js +87 -0
- package/dist/core/schedule-gate.js +7 -3
- package/dist/core/schedule-v2.js +1 -1
- package/dist/core/scheduler/index.d.ts +13 -1
- package/dist/core/scheduler/index.d.ts.map +1 -1
- package/dist/core/scheduler/index.js +35 -4
- package/dist/core/scheduler/linux.d.ts +4 -1
- package/dist/core/scheduler/linux.d.ts.map +1 -1
- package/dist/core/scheduler/linux.js +53 -20
- package/dist/core/scheduler/mac.d.ts +2 -1
- package/dist/core/scheduler/mac.d.ts.map +1 -1
- package/dist/core/scheduler/mac.js +24 -6
- package/dist/core/scheduler/posix.d.ts +1 -1
- package/dist/core/scheduler/posix.d.ts.map +1 -1
- package/dist/core/scheduler/posix.js +2 -2
- package/dist/core/scheduler/registry.d.ts +3 -2
- package/dist/core/scheduler/registry.d.ts.map +1 -1
- package/dist/core/scheduler/registry.js +6 -5
- package/dist/core/scheduler/windows.d.ts +49 -1
- package/dist/core/scheduler/windows.d.ts.map +1 -1
- package/dist/core/scheduler/windows.js +219 -34
- package/dist/core/secrets.d.ts +5 -3
- package/dist/core/secrets.d.ts.map +1 -1
- package/dist/core/secrets.js +86 -8
- package/dist/core/self-analysis.d.ts +117 -0
- package/dist/core/self-analysis.d.ts.map +1 -0
- package/dist/core/self-analysis.js +539 -0
- package/dist/core/session.d.ts +11 -3
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +34 -5
- package/dist/core/shutdown.d.ts +26 -0
- package/dist/core/shutdown.d.ts.map +1 -0
- package/dist/core/shutdown.js +49 -0
- package/dist/core/summary.d.ts +69 -0
- package/dist/core/summary.d.ts.map +1 -0
- package/dist/core/summary.js +250 -0
- package/dist/core/telegram.d.ts +10 -0
- package/dist/core/telegram.d.ts.map +1 -1
- package/dist/core/telegram.js +228 -47
- package/dist/core/triage-chain.d.ts +40 -0
- package/dist/core/triage-chain.d.ts.map +1 -0
- package/dist/core/triage-chain.js +80 -0
- package/dist/core/triage-compare.d.ts +68 -0
- package/dist/core/triage-compare.d.ts.map +1 -0
- package/dist/core/triage-compare.js +184 -0
- package/dist/core/triage-rules.d.ts +23 -0
- package/dist/core/triage-rules.d.ts.map +1 -0
- package/dist/core/triage-rules.js +196 -0
- package/dist/core/triage-shadow.d.ts +91 -0
- package/dist/core/triage-shadow.d.ts.map +1 -0
- package/dist/core/triage-shadow.js +160 -0
- package/dist/core/triage-worker.d.ts +55 -0
- package/dist/core/triage-worker.d.ts.map +1 -0
- package/dist/core/triage-worker.js +314 -0
- package/dist/core/triage.d.ts +76 -0
- package/dist/core/triage.d.ts.map +1 -0
- package/dist/core/triage.js +271 -0
- package/dist/core/watch-paths.d.ts +6 -0
- package/dist/core/watch-paths.d.ts.map +1 -0
- package/dist/core/watch-paths.js +62 -0
- package/dist/core/wrappers/bash.d.ts +15 -3
- package/dist/core/wrappers/bash.d.ts.map +1 -1
- package/dist/core/wrappers/bash.js +153 -120
- package/dist/db/history-repo.d.ts +1 -1
- package/dist/db/history-repo.d.ts.map +1 -1
- package/dist/db/history-repo.js +29 -14
- package/dist/db/schema.d.ts +1 -1
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +31 -0
- package/dist/history.d.ts +2 -2
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +3 -3
- package/dist/i18n.d.ts +25 -2
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +75 -10
- package/dist/index.d.ts +66 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +527 -68
- package/dist/integrations.d.ts +9 -1
- package/dist/integrations.d.ts.map +1 -1
- package/dist/integrations.js +34 -6
- package/dist/notifications.d.ts +30 -2
- package/dist/notifications.d.ts.map +1 -1
- package/dist/notifications.js +289 -10
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.d.ts.map +1 -1
- package/dist/profiles.js +21 -3
- package/dist/rpc.d.ts +401 -5
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +138 -5
- package/dist/server.d.ts +20 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +136 -14
- package/dist/settings.d.ts +167 -3
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +322 -3
- package/dist/task-transfer.d.ts +8 -1
- package/dist/task-transfer.d.ts.map +1 -1
- package/dist/task-transfer.js +2 -2
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +23 -5
- package/dist/workspaces.d.ts +9 -0
- package/dist/workspaces.d.ts.map +1 -1
- package/dist/workspaces.js +25 -0
- package/docs/ARCHITECTURE.md +48 -28
- package/docs/CONCEPT.md +230 -0
- package/docs/CROSS_PLATFORM.ru.md +150 -0
- package/docs/CROSS_PLATFORM.zh.md +146 -0
- package/docs/FAQ.md +52 -0
- package/docs/FAQ.ru.md +53 -0
- package/docs/FAQ.zh.md +43 -0
- package/docs/FEATURES.md +141 -44
- package/docs/FEATURES.zh.md +655 -0
- package/docs/LOCAL-AI.md +300 -0
- package/docs/MIGRATION.md +17 -0
- package/docs/README.ru.md +22 -16
- package/docs/README.zh.md +286 -0
- package/docs/SAVINGS.md +61 -0
- package/docs/SAVINGS.ru.md +60 -0
- package/docs/SAVINGS.zh.md +52 -0
- package/docs/ZH-LOCALE-PLAN.md +324 -0
- package/docs/spikes/local-model-structured-output.md +81 -0
- package/docs/spikes/ollama-qwen3-4b-smoke.json +28 -0
- package/docs/spikes/ollama-qwen3-4b.json +163 -0
- package/gui-experimental.cjs +8 -8
- package/locales/en.json +85 -0
- package/locales/ru.json +85 -0
- package/locales/zh.json +780 -0
- package/package.json +31 -7
- package/scripts/bench-local.mjs +321 -0
- package/scripts/check-zh-locale.mjs +218 -0
- package/scripts/run-tests.mjs +236 -0
- package/scripts/spike-local-structured.mjs +182 -0
- package/scripts/test-locale.mjs +4 -3
- package/skills/scheduled-job-best-practices/SKILL.md +6 -3
- package/skills/scheduled-job-best-practices/references/recipes.md +40 -0
- package/src/core/analytics.ts +10 -0
- package/src/core/audit.ts +39 -1
- package/src/core/cron-to-schtasks.ts +23 -4
- package/src/core/file-watcher.ts +20 -1
- package/src/core/git-trigger.ts +34 -16
- package/src/core/local-ai.ts +173 -0
- package/src/core/lock.ts +88 -3
- package/src/core/matrix.ts +5 -1
- package/src/core/native-notify.ts +3 -0
- package/src/core/one-shot.ts +18 -2
- package/src/core/permissions.ts +200 -0
- package/src/core/ps-wrapper.ts +492 -108
- package/src/core/record-history.ts +111 -4
- package/src/core/savings.ts +150 -0
- package/src/core/schedule-gate.ts +9 -3
- package/src/core/schedule-v2.ts +1 -1
- package/src/core/scheduler/index.ts +41 -3
- package/src/core/scheduler/linux.ts +67 -22
- package/src/core/scheduler/mac.ts +24 -7
- package/src/core/scheduler/posix.ts +2 -2
- package/src/core/scheduler/registry.ts +7 -5
- package/src/core/scheduler/windows.ts +237 -32
- package/src/core/secrets.ts +101 -7
- package/src/core/self-analysis.ts +744 -0
- package/src/core/session.ts +40 -5
- package/src/core/shutdown.ts +69 -0
- package/src/core/summary.ts +318 -0
- package/src/core/telegram.ts +266 -55
- package/src/core/triage-chain.ts +125 -0
- package/src/core/triage-compare.ts +277 -0
- package/src/core/triage-rules.ts +238 -0
- package/src/core/triage-shadow.ts +240 -0
- package/src/core/triage-worker.ts +344 -0
- package/src/core/triage.ts +366 -0
- package/src/core/watch-paths.ts +70 -0
- package/src/core/wrappers/bash.ts +181 -138
- package/src/db/history-repo.ts +31 -18
- package/src/db/schema.ts +31 -0
- package/src/gui.tsx +551 -14
- package/src/history.ts +7 -3
- package/src/i18n.ts +87 -13
- package/src/index.ts +649 -71
- package/src/integrations.ts +50 -6
- package/src/notifications.ts +468 -5
- package/src/profiles.ts +21 -3
- package/src/rpc.ts +143 -5
- package/src/server.ts +135 -16
- package/src/settings.ts +582 -5
- package/src/task-transfer.ts +10 -3
- package/src/types.ts +24 -5
- package/src/workspaces.ts +22 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-windows-scheduler",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"description": "OpenCode v2 plugin for scheduling and orchestrating AI agent jobs: cron, one-shot runs, DAG pipelines, matrix builds, quality gates, SQLite history, metrics and a local web dashboard. Windows, macOS and Linux. Free and open source (MIT).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "opencode-windows-scheduler contributors",
|
|
@@ -38,8 +38,7 @@
|
|
|
38
38
|
"types": "dist/index.d.ts",
|
|
39
39
|
"type": "module",
|
|
40
40
|
"exports": {
|
|
41
|
-
".": "./
|
|
42
|
-
"./tui": "./src/tui.tsx",
|
|
41
|
+
".": "./dist/index.js",
|
|
43
42
|
"./gui-experimental": "./gui-experimental.cjs"
|
|
44
43
|
},
|
|
45
44
|
"files": [
|
|
@@ -59,7 +58,7 @@
|
|
|
59
58
|
"ROADMAP-STRATEGY.md"
|
|
60
59
|
],
|
|
61
60
|
"engines": {
|
|
62
|
-
"node": ">=
|
|
61
|
+
"node": ">=22.22.0"
|
|
63
62
|
},
|
|
64
63
|
"publishConfig": {
|
|
65
64
|
"access": "public"
|
|
@@ -68,9 +67,11 @@
|
|
|
68
67
|
"build": "tsc",
|
|
69
68
|
"build:gui": "vite build",
|
|
70
69
|
"demo": "node scripts/demo-dashboard.mjs",
|
|
70
|
+
"bench:local": "node scripts/bench-local.mjs",
|
|
71
71
|
"prepare": "npm run build",
|
|
72
72
|
"prepublishOnly": "npm run build && npm run build:gui",
|
|
73
|
-
"
|
|
73
|
+
"pretest": "npm run build",
|
|
74
|
+
"test": "node test-sqlite.mjs && node test-crash-recovery.mjs && node test-workspaces.mjs && node test-role-scoped.mjs && node test-permissions-policy.mjs && node test-dry-run.mjs && node test-matrix.mjs && node test-matrix-lifecycle.mjs && node test-matrix-sync.mjs && node test-retention.mjs && node test-metrics.mjs && node test-savings.mjs && node test-schedule-v2.mjs && node test-notifications-v2.mjs && node test-notifications-dedup.mjs && node test-notifications-embedding.mjs && node test-notifications-summary.mjs && node test-settings.mjs && node test-notifications-v3.mjs && node test-triage.mjs && node test-triage-rules.mjs && node test-triage-compare.mjs && node test-triage-chain.mjs && node test-triage-shadow.mjs && node test-triage-audit.mjs && node test-triage-async.mjs && node test-local-ai.mjs && node test-secrets.mjs && node test-audit.mjs && node test-profiles.mjs && node test-env.mjs && node test-agent-tools.mjs && node test-skill.mjs && node test-integrations.mjs && node test-one-shot.mjs && node test-session-continuity.mjs && node test-task-status.mjs && node test-jobs-view.mjs && node test-dag.mjs && node test-dashboard.mjs && node test-dashboard-trust.mjs && node test-dashboard-dag.mjs && node test-dashboard-json.mjs && node test-docs.mjs && node test-glob.mjs && node test-git-trigger.mjs && node test-window-v3.mjs && node test-i18n.mjs && node test-gui-bundle.mjs && node test-stale-lock.mjs && node test-task-name-limit.mjs && node test-task-name-limit-profile.mjs && node test-delete-profile.mjs && node test-execution-hardening.mjs && node test-path-safety.mjs && node test-watch-paths.mjs && node test-windows-oem.mjs && node test-schtasks-errors.mjs && node test-shutdown.mjs && node test-usage-from-log.mjs && node test-posix-e2e.mjs",
|
|
74
75
|
"test:sqlite": "node test-sqlite.mjs",
|
|
75
76
|
"test:crash": "node test-crash-recovery.mjs",
|
|
76
77
|
"test:workspaces": "node test-workspaces.mjs",
|
|
@@ -84,6 +85,14 @@
|
|
|
84
85
|
"test:schedule-v2": "node test-schedule-v2.mjs",
|
|
85
86
|
"test:notifications-v2": "node test-notifications-v2.mjs",
|
|
86
87
|
"test:notifications-v3": "node test-notifications-v3.mjs",
|
|
88
|
+
"test:settings": "node test-settings.mjs",
|
|
89
|
+
"test:triage": "node test-triage.mjs",
|
|
90
|
+
"test:triage-rules": "node test-triage-rules.mjs",
|
|
91
|
+
"test:triage-chain": "node test-triage-chain.mjs",
|
|
92
|
+
"test:triage-shadow": "node test-triage-shadow.mjs",
|
|
93
|
+
"test:triage-audit": "node test-triage-audit.mjs",
|
|
94
|
+
"test:triage-async": "node test-triage-async.mjs",
|
|
95
|
+
"test:local-ai": "node test-local-ai.mjs",
|
|
87
96
|
"test:secrets": "node test-secrets.mjs",
|
|
88
97
|
"test:audit": "node test-audit.mjs",
|
|
89
98
|
"test:profiles": "node test-profiles.mjs",
|
|
@@ -103,8 +112,23 @@
|
|
|
103
112
|
"test:glob": "node test-glob.mjs",
|
|
104
113
|
"test:git-trigger": "node test-git-trigger.mjs",
|
|
105
114
|
"test:window-v3": "node test-window-v3.mjs",
|
|
115
|
+
"test:self-analysis": "node test-self-analysis.mjs",
|
|
106
116
|
"test:i18n": "node test-i18n.mjs",
|
|
107
|
-
|
|
117
|
+
"test:gui-bundle": "node test-gui-bundle.mjs",
|
|
118
|
+
"test:stale-lock": "node test-stale-lock.mjs",
|
|
119
|
+
"test:task-name-limit": "node test-task-name-limit.mjs && node test-task-name-limit-profile.mjs",
|
|
120
|
+
"test:delete-profile": "node test-delete-profile.mjs",
|
|
121
|
+
"test:windows-oem": "node test-windows-oem.mjs",
|
|
122
|
+
"test:schtasks-errors": "node test-schtasks-errors.mjs",
|
|
123
|
+
"test:shutdown": "node test-shutdown.mjs",
|
|
124
|
+
"test:usage-from-log": "node test-usage-from-log.mjs",
|
|
125
|
+
"test:posix-e2e": "node test-posix-e2e.mjs",
|
|
126
|
+
"test:watch-paths": "node test-watch-paths.mjs",
|
|
127
|
+
"test:en": "node scripts/test-locale.mjs en",
|
|
128
|
+
"test:zh": "node scripts/test-locale.mjs zh",
|
|
129
|
+
"test:parallel": "node scripts/run-tests.mjs",
|
|
130
|
+
"test:parallel:en": "node scripts/run-tests.mjs --locale=en",
|
|
131
|
+
"test:parallel:zh": "node scripts/run-tests.mjs --locale=zh"
|
|
108
132
|
},
|
|
109
133
|
"dependencies": {
|
|
110
134
|
"@opencode/plugin": "^2.2.7",
|
|
@@ -116,7 +140,7 @@
|
|
|
116
140
|
"devDependencies": {
|
|
117
141
|
"@opentui/core": ">=0.8.1",
|
|
118
142
|
"@opentui/solid": ">=0.8.1",
|
|
119
|
-
"@types/node": "^
|
|
143
|
+
"@types/node": "^22.0.0",
|
|
120
144
|
"solid-js": "^1.9.0",
|
|
121
145
|
"typescript": "^5.9.3",
|
|
122
146
|
"vite": "^7.0.0",
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Бенчмарк локальной модели для триажа уведомлений (Спринт 30.8).
|
|
3
|
+
*
|
|
4
|
+
* Запуск:
|
|
5
|
+
* node scripts/bench-local.mjs --model qwen3:4b --runs 3
|
|
6
|
+
*
|
|
7
|
+
* Скрипт не входит в `npm test`: он требует запущенную Ollama и скачанную
|
|
8
|
+
* модель. Цель — измерить скорость (tok/s), латентность и долю схемо-валидных
|
|
9
|
+
* ответов, подобрать тир по объёму RAM и выдать версионированный JSON,
|
|
10
|
+
* пригодный для краудсорсинга (`--out`).
|
|
11
|
+
*
|
|
12
|
+
* Без Ollama скрипт не падает молча: он печатает понятную ошибку и всё равно
|
|
13
|
+
* формирует валидный JSON с `available: false`, чтобы замер можно было
|
|
14
|
+
* приложить к отчёту.
|
|
15
|
+
*/
|
|
16
|
+
import fs from "node:fs";
|
|
17
|
+
import os from "node:os";
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
|
|
20
|
+
const SCHEMA_VERSION = "1";
|
|
21
|
+
|
|
22
|
+
const DEFAULTS = {
|
|
23
|
+
baseUrl: "http://127.0.0.1:11434",
|
|
24
|
+
model: "qwen3:4b",
|
|
25
|
+
runs: 3,
|
|
26
|
+
timeoutMs: 120000,
|
|
27
|
+
out: "",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function parseArgs(argv) {
|
|
31
|
+
const args = { ...DEFAULTS };
|
|
32
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
33
|
+
const key = argv[i];
|
|
34
|
+
const value = argv[i + 1];
|
|
35
|
+
if (key === "--base-url") args.baseUrl = value;
|
|
36
|
+
else if (key === "--model") args.model = value;
|
|
37
|
+
else if (key === "--runs") args.runs = Number(value);
|
|
38
|
+
else if (key === "--timeout") args.timeoutMs = Number(value);
|
|
39
|
+
else if (key === "--out") args.out = value;
|
|
40
|
+
else if (key === "--help" || key === "-h") {
|
|
41
|
+
console.log(
|
|
42
|
+
"node scripts/bench-local.mjs [--model qwen3:4b] [--runs 3] [--base-url URL] [--timeout MS] [--out FILE]"
|
|
43
|
+
);
|
|
44
|
+
process.exit(0);
|
|
45
|
+
} else {
|
|
46
|
+
console.error(`Неизвестный аргумент: ${key}`);
|
|
47
|
+
process.exit(2);
|
|
48
|
+
}
|
|
49
|
+
i += 1;
|
|
50
|
+
}
|
|
51
|
+
if (!Number.isInteger(args.runs) || args.runs < 1 || args.runs > 50) {
|
|
52
|
+
console.error("--runs должен быть целым числом от 1 до 50.");
|
|
53
|
+
process.exit(2);
|
|
54
|
+
}
|
|
55
|
+
if (!Number.isInteger(args.timeoutMs) || args.timeoutMs < 1000 || args.timeoutMs > 600000) {
|
|
56
|
+
console.error("--timeout должен быть целым числом от 1000 до 600000 мс.");
|
|
57
|
+
process.exit(2);
|
|
58
|
+
}
|
|
59
|
+
return args;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const schema = {
|
|
63
|
+
type: "object",
|
|
64
|
+
properties: {
|
|
65
|
+
category: { type: "string", enum: ["quality", "timeout", "permission", "network", "unknown"] },
|
|
66
|
+
severity: { type: "string", enum: ["low", "medium", "high"] },
|
|
67
|
+
confidence: { type: "number", minimum: 0, maximum: 1 },
|
|
68
|
+
reason: { type: "string" },
|
|
69
|
+
},
|
|
70
|
+
required: ["category", "severity", "confidence", "reason"],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const prompt = `Ты классифицируешь уведомление планировщика задач.
|
|
74
|
+
Верни только JSON без markdown и пояснений по схеме:
|
|
75
|
+
{"category":"quality|timeout|permission|network|unknown","severity":"low|medium|high","confidence":0..1,"reason":"кратко"}
|
|
76
|
+
|
|
77
|
+
Уведомление:
|
|
78
|
+
Задача "nightly-tests" упала за 2.3s. Quality Gate вернул код 1: 3 теста не прошли в auth-модуле.`;
|
|
79
|
+
|
|
80
|
+
function validate(value) {
|
|
81
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return "not an object";
|
|
82
|
+
for (const key of schema.required) {
|
|
83
|
+
if (!(key in value)) return `missing ${key}`;
|
|
84
|
+
}
|
|
85
|
+
if (!schema.properties.category.enum.includes(value.category)) return "bad category";
|
|
86
|
+
if (!schema.properties.severity.enum.includes(value.severity)) return "bad severity";
|
|
87
|
+
if (typeof value.confidence !== "number" || value.confidence < 0 || value.confidence > 1) return "bad confidence";
|
|
88
|
+
if (typeof value.reason !== "string" || value.reason.trim() === "") return "bad reason";
|
|
89
|
+
return "";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Тир по объёму RAM: рекомендация модели и причина выбора. */
|
|
93
|
+
function pickTier(ramGb) {
|
|
94
|
+
if (ramGb < 8) {
|
|
95
|
+
return {
|
|
96
|
+
id: "rules-only",
|
|
97
|
+
recommendedModel: "qwen3:0.6b",
|
|
98
|
+
reason: `RAM ${ramGb} ГБ: локальная модель не помещается с запасом — работают только правила.`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (ramGb < 15) {
|
|
102
|
+
return {
|
|
103
|
+
id: "light",
|
|
104
|
+
recommendedModel: "qwen3:1.7b",
|
|
105
|
+
reason: `RAM ${ramGb} ГБ: хватает на маленькую модель, ожидайте скромную точность.`,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (ramGb < 30) {
|
|
109
|
+
return {
|
|
110
|
+
id: "balanced",
|
|
111
|
+
recommendedModel: "qwen3:4b",
|
|
112
|
+
reason: `RAM ${ramGb} ГБ: рекомендуемый тир для триажа — qwen3:4b на CPU.`,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
id: "max",
|
|
117
|
+
recommendedModel: "qwen3:8b",
|
|
118
|
+
reason: `RAM ${ramGb} ГБ: можно позволить модель крупнее для лучшей точности.`,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function round(value, digits = 2) {
|
|
123
|
+
return Number.isFinite(value) ? Number(value.toFixed(digits)) : null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function percentile(sorted, fraction) {
|
|
127
|
+
if (sorted.length === 0) return null;
|
|
128
|
+
return sorted[Math.max(0, Math.ceil(sorted.length * fraction) - 1)];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function machineInfo() {
|
|
132
|
+
const cpus = os.cpus();
|
|
133
|
+
return {
|
|
134
|
+
platform: os.platform(),
|
|
135
|
+
osRelease: os.release(),
|
|
136
|
+
arch: os.arch(),
|
|
137
|
+
cpu: cpus.length > 0 ? cpus[0].model.trim() : "unknown",
|
|
138
|
+
cpuCount: cpus.length,
|
|
139
|
+
ramGb: round(os.totalmem() / 1024 ** 3, 1),
|
|
140
|
+
nodeVersion: process.version,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function loadModel(baseUrl, model) {
|
|
145
|
+
const response = await fetch(`${baseUrl}/api/tags`, { signal: AbortSignal.timeout(10000) });
|
|
146
|
+
if (!response.ok) throw new Error(`/api/tags: HTTP ${response.status}`);
|
|
147
|
+
const data = await response.json();
|
|
148
|
+
const names = (data.models ?? []).map((item) => item.name);
|
|
149
|
+
if (names.length === 0) {
|
|
150
|
+
throw new Error(`Ollama запущена, но моделей нет: выполните "ollama pull ${model}"`);
|
|
151
|
+
}
|
|
152
|
+
if (!names.some((name) => name === model || name === `${model}:latest`)) {
|
|
153
|
+
throw new Error(`Модель "${model}" не найдена. Доступны: ${names.join(", ")}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Один прогон: латентность, счётчики токенов и валидность схемы. */
|
|
158
|
+
async function runOnce(args, index) {
|
|
159
|
+
const started = Date.now();
|
|
160
|
+
const body = {
|
|
161
|
+
model: args.model,
|
|
162
|
+
messages: [{ role: "user", content: prompt }],
|
|
163
|
+
stream: false,
|
|
164
|
+
format: schema,
|
|
165
|
+
options: { temperature: 0, seed: index + 1 },
|
|
166
|
+
};
|
|
167
|
+
let response;
|
|
168
|
+
try {
|
|
169
|
+
response = await fetch(`${args.baseUrl}/api/chat`, {
|
|
170
|
+
method: "POST",
|
|
171
|
+
headers: { "content-type": "application/json" },
|
|
172
|
+
body: JSON.stringify(body),
|
|
173
|
+
signal: AbortSignal.timeout(args.timeoutMs),
|
|
174
|
+
});
|
|
175
|
+
} catch (error) {
|
|
176
|
+
return {
|
|
177
|
+
run: index + 1,
|
|
178
|
+
ok: false,
|
|
179
|
+
jsonValid: false,
|
|
180
|
+
schemaValid: false,
|
|
181
|
+
latencyMs: Date.now() - started,
|
|
182
|
+
evalCount: null,
|
|
183
|
+
evalMs: null,
|
|
184
|
+
tokPerSec: null,
|
|
185
|
+
error: error instanceof Error ? error.message : String(error),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const latencyMs = Date.now() - started;
|
|
189
|
+
if (!response.ok) {
|
|
190
|
+
return { run: index + 1, ok: false, jsonValid: false, schemaValid: false, latencyMs, evalCount: null, evalMs: null, tokPerSec: null, error: `HTTP ${response.status}` };
|
|
191
|
+
}
|
|
192
|
+
const data = await response.json();
|
|
193
|
+
const content = data?.message?.content ?? "";
|
|
194
|
+
const evalCount = typeof data?.eval_count === "number" ? data.eval_count : null;
|
|
195
|
+
const evalNs = typeof data?.eval_duration === "number" ? data.eval_duration : null;
|
|
196
|
+
const evalMs = evalNs !== null ? Math.round(evalNs / 1e6) : null;
|
|
197
|
+
const tokPerSec = evalCount !== null && evalNs !== null && evalNs > 0 ? (evalCount / evalNs) * 1e9 : null;
|
|
198
|
+
|
|
199
|
+
let parsed;
|
|
200
|
+
try {
|
|
201
|
+
parsed = JSON.parse(content);
|
|
202
|
+
} catch {
|
|
203
|
+
return { run: index + 1, ok: false, jsonValid: false, schemaValid: false, latencyMs, evalCount, evalMs, tokPerSec, content, error: "invalid JSON" };
|
|
204
|
+
}
|
|
205
|
+
const error = validate(parsed);
|
|
206
|
+
return {
|
|
207
|
+
run: index + 1,
|
|
208
|
+
ok: !error,
|
|
209
|
+
jsonValid: true,
|
|
210
|
+
schemaValid: !error,
|
|
211
|
+
latencyMs,
|
|
212
|
+
evalCount,
|
|
213
|
+
evalMs,
|
|
214
|
+
tokPerSec: round(tokPerSec),
|
|
215
|
+
content,
|
|
216
|
+
parsed,
|
|
217
|
+
error,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function buildReport({ args, machine, tier, available, error, results }) {
|
|
222
|
+
const completed = results.filter((item) => item.schemaValid);
|
|
223
|
+
const validRuns = results.filter((item) => item.jsonValid);
|
|
224
|
+
const latencies = results.map((item) => item.latencyMs).sort((a, b) => a - b);
|
|
225
|
+
const throughput = results
|
|
226
|
+
.map((item) => item.tokPerSec)
|
|
227
|
+
.filter((value) => typeof value === "number")
|
|
228
|
+
.sort((a, b) => a - b);
|
|
229
|
+
const avg = (values) => (values.length === 0 ? null : values.reduce((sum, value) => sum + value, 0) / values.length);
|
|
230
|
+
|
|
231
|
+
return {
|
|
232
|
+
schemaVersion: SCHEMA_VERSION,
|
|
233
|
+
generatedAt: new Date().toISOString(),
|
|
234
|
+
available,
|
|
235
|
+
error: error ?? null,
|
|
236
|
+
machine,
|
|
237
|
+
tier,
|
|
238
|
+
baseUrl: args.baseUrl,
|
|
239
|
+
model: args.model,
|
|
240
|
+
runs: args.runs,
|
|
241
|
+
metrics: {
|
|
242
|
+
schemaValid: completed.length,
|
|
243
|
+
schemaValidRate: results.length === 0 ? 0 : round(completed.length / results.length, 2),
|
|
244
|
+
jsonValid: validRuns.length,
|
|
245
|
+
jsonValidRate: results.length === 0 ? 0 : round(validRuns.length / results.length, 2),
|
|
246
|
+
avgLatencyMs: latencies.length === 0 ? null : Math.round(avg(latencies)),
|
|
247
|
+
p95LatencyMs: percentile(latencies, 0.95),
|
|
248
|
+
avgTokPerSec: throughput.length === 0 ? null : round(avg(throughput), 1),
|
|
249
|
+
p95TokPerSec: percentile(throughput, 0.95) === null ? null : round(percentile(throughput, 0.95), 1),
|
|
250
|
+
},
|
|
251
|
+
notes: [
|
|
252
|
+
"tok/s считается по eval_count / eval_duration из ответа Ollama /api/chat.",
|
|
253
|
+
"Тир подобран по объёму RAM; модель можно переопределить флагом --model.",
|
|
254
|
+
"Формат версионирован (schemaVersion) для краудсорсинга замеров.",
|
|
255
|
+
],
|
|
256
|
+
results,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const args = parseArgs(process.argv.slice(2));
|
|
261
|
+
const machine = machineInfo();
|
|
262
|
+
const tier = pickTier(machine.ramGb);
|
|
263
|
+
|
|
264
|
+
let available = true;
|
|
265
|
+
let availabilityError = null;
|
|
266
|
+
try {
|
|
267
|
+
await loadModel(args.baseUrl, args.model);
|
|
268
|
+
} catch (error) {
|
|
269
|
+
available = false;
|
|
270
|
+
availabilityError = error instanceof Error ? error.message : String(error);
|
|
271
|
+
console.error(`Не удалось подключиться к Ollama: ${availabilityError}`);
|
|
272
|
+
console.error(`Бенчмарк заблокирован: установите Ollama, выполните "ollama serve" и "ollama pull ${args.model}".`);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const results = [];
|
|
276
|
+
if (available) {
|
|
277
|
+
for (let i = 0; i < args.runs; i += 1) {
|
|
278
|
+
const result = await runOnce(args, i);
|
|
279
|
+
results.push(result);
|
|
280
|
+
const mark = result.schemaValid ? "OK" : "FAIL";
|
|
281
|
+
console.log(
|
|
282
|
+
`${result.run}/${args.runs} ${mark} ${result.latencyMs}ms${result.tokPerSec ? ` ${result.tokPerSec} tok/s` : ""}${result.error ? ` — ${result.error}` : ""}`
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const report = buildReport({ args, machine, tier, available, error: availabilityError, results });
|
|
288
|
+
|
|
289
|
+
console.log("");
|
|
290
|
+
console.log(`Машина: ${machine.cpu} × ${machine.cpuCount}, ${machine.ramGb} ГБ RAM, ${machine.platform}/${machine.arch}`);
|
|
291
|
+
console.log(`Тир: ${tier.id} → рекомендуется ${tier.recommendedModel}`);
|
|
292
|
+
console.log(tier.reason);
|
|
293
|
+
if (available) {
|
|
294
|
+
console.log(
|
|
295
|
+
`Схема: ${report.metrics.schemaValid}/${args.runs} (${Math.round(report.metrics.schemaValidRate * 100)}%); JSON: ${report.metrics.jsonValid}/${args.runs}`
|
|
296
|
+
);
|
|
297
|
+
const speed = report.metrics.avgTokPerSec === null ? "n/a" : `${report.metrics.avgTokPerSec} tok/s`;
|
|
298
|
+
console.log(`Латентность: avg ${report.metrics.avgLatencyMs}ms, p95 ${report.metrics.p95LatencyMs}ms; скорость: ${speed}`);
|
|
299
|
+
if (report.metrics.schemaValidRate >= 0.9) {
|
|
300
|
+
console.log("Вывод: модель подходит для триажа, валидацию схемы всё равно оставить.");
|
|
301
|
+
} else if (report.metrics.schemaValidRate >= 0.7) {
|
|
302
|
+
console.log("Вывод: нужен один retry и fallback на правила.");
|
|
303
|
+
} else {
|
|
304
|
+
console.log("Вывод: модель не подходит для критичных вердиктов — только правила или модель крупнее.");
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
console.log("Вывод: замер не выполнен, JSON всё равно сформирован для отчёта.");
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (args.out) {
|
|
311
|
+
const target = path.resolve(args.out);
|
|
312
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
313
|
+
fs.writeFileSync(target, `${JSON.stringify(report, null, 2)}\n`, "utf8");
|
|
314
|
+
console.log(`Результат: ${target}`);
|
|
315
|
+
} else {
|
|
316
|
+
console.log("");
|
|
317
|
+
console.log(JSON.stringify(report, null, 2));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (!available) process.exit(2);
|
|
321
|
+
process.exit(report.metrics.schemaValidRate >= 0.7 ? 0 : 1);
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Валидация locales/zh.json по паритету с locales/en.json.
|
|
3
|
+
*
|
|
4
|
+
* Проверяет:
|
|
5
|
+
* 1. Все ключи en.json присутствуют в zh.json (и нет лишних).
|
|
6
|
+
* 2. Набор плейсхолдеров {name} совпадает с en.json по каждому ключу.
|
|
7
|
+
* 3. Плюральные ключи содержат только ветку `other` (для zh категорий one/few/many нет).
|
|
8
|
+
* 4. Значения не пустые.
|
|
9
|
+
* 5. Значения содержат китайские иероглифы (CJK), за исключением белого списка
|
|
10
|
+
* токенов, которые не переводятся (cron, JSON, SQLite, MCP, DAG, HMAC, URL,
|
|
11
|
+
* ID, GUI, OpenCode, Telegram, Ollama, glob, имена инструментов, ${secret:NAME},
|
|
12
|
+
* латинские числа, знаки препинания, плейсхолдеры).
|
|
13
|
+
*
|
|
14
|
+
* Запуск: node scripts/check-zh-locale.mjs
|
|
15
|
+
*/
|
|
16
|
+
import fs from "node:fs";
|
|
17
|
+
import path from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
|
|
20
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
21
|
+
const en = JSON.parse(fs.readFileSync(path.join(root, "locales", "en.json"), "utf8"));
|
|
22
|
+
const zh = JSON.parse(fs.readFileSync(path.join(root, "locales", "zh.json"), "utf8"));
|
|
23
|
+
|
|
24
|
+
const errors = [];
|
|
25
|
+
const warnings = [];
|
|
26
|
+
|
|
27
|
+
const enKeys = Object.keys(en).sort();
|
|
28
|
+
const zhKeys = Object.keys(zh).sort();
|
|
29
|
+
|
|
30
|
+
// 1. Паритет ключей
|
|
31
|
+
const missingInZh = enKeys.filter((k) => !(k in zh));
|
|
32
|
+
const extraInZh = zhKeys.filter((k) => !(k in en));
|
|
33
|
+
if (missingInZh.length > 0) {
|
|
34
|
+
errors.push(`Ключи отсутствуют в zh.json (${missingInZh.length}): ${missingInZh.join(", ")}`);
|
|
35
|
+
}
|
|
36
|
+
if (extraInZh.length > 0) {
|
|
37
|
+
errors.push(`Лишние ключи в zh.json (${extraInZh.length}): ${extraInZh.join(", ")}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Плейсхолдеры: {name} или {{name}} — извлекаем имя без скобок
|
|
41
|
+
const placeholderRe = /\{\{?([a-zA-Z_][a-zA-Z0-9_.]*)\}?\}/g;
|
|
42
|
+
const placeholders = (s) => {
|
|
43
|
+
const out = new Set();
|
|
44
|
+
let m;
|
|
45
|
+
while ((m = placeholderRe.exec(s))) out.add(m[1]);
|
|
46
|
+
return [...out].sort();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Плюральные ключи (в en содержат {count, plural, …})
|
|
50
|
+
const pluralKeys = [];
|
|
51
|
+
for (const k of enKeys) {
|
|
52
|
+
if (String(en[k]).includes(", plural,")) pluralKeys.push(k);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Токены, которые не переводятся и могут остаться латиницей (белый список для CJK-эвристики)
|
|
56
|
+
const untranslatedTokens = [
|
|
57
|
+
"cron", "json", "sqlite", "mcp", "dag", "hmac", "url", "id", "gui", "opencode",
|
|
58
|
+
"telegram", "ollama", "glob", "webhook", "llm", "rpc", "ssh", "http", "https",
|
|
59
|
+
"api", "sdk", "cli", "ui", "diy", "ai", "os", "iso", "tls", "utf", "bot",
|
|
60
|
+
"token", "chat", "channel", "secret", "env", "path", "file", "dir", "cmd",
|
|
61
|
+
"run", "task", "job", "matrix", "profile", "schedule", "shadow", "triage",
|
|
62
|
+
"trigger", "hook", "history", "audit", "log", "logs", "template", "templates",
|
|
63
|
+
"prompt", "prompts", "preset", "presets", "model", "models", "provider",
|
|
64
|
+
"baseurl", "base url", "threshold", "confidence", "timeout", "fallback",
|
|
65
|
+
"concurrency", "concurrent", "workspace", "workspaces", "clone", "clones",
|
|
66
|
+
"aggregator", "status", "success", "error", "warning", "warn", "message", "info", "debug",
|
|
67
|
+
"daily", "weekly", "monthly", "hourly", "minute", "second", "ms", "sec", "s",
|
|
68
|
+
"tok", "tokens", "cost", "rate", "limit", "limits", "offset", "page", "pages",
|
|
69
|
+
"total", "count", "done", "pending", "failed", "skipped", "running", "paused",
|
|
70
|
+
"resumed", "stopped", "cancelled", "deleted", "created", "updated", "restored",
|
|
71
|
+
"rollback", "orphans", "orphan", "parent", "child", "children", "branch",
|
|
72
|
+
"commit", "scheduler", "git", "push", "pull", "merge", "diff", "repo", "repository", "head", "master",
|
|
73
|
+
"main", "origin", "remote", "local", "global", "system", "user", "admin", "root",
|
|
74
|
+
"true", "false", "null", "undefined", "none", "all", "any", "every", "each",
|
|
75
|
+
"some", "no", "not", "is", "are", "was", "were", "be", "been", "being", "have",
|
|
76
|
+
"has", "had", "do", "does", "did", "will", "would", "could", "should", "may",
|
|
77
|
+
"might", "can", "must", "shall", "need", "dare", "ought", "used", "use", "using",
|
|
78
|
+
"used", "uses", "get", "got", "gets", "getting", "set", "sets", "setting",
|
|
79
|
+
"let", "lets", "make", "makes", "making", "made", "take", "takes", "taking",
|
|
80
|
+
"took", "taken", "give", "gives", "giving", "gave", "given", "go", "goes",
|
|
81
|
+
"going", "went", "gone", "come", "comes", "coming", "came", "come", "see",
|
|
82
|
+
"sees", "seeing", "saw", "seen", "know", "knows", "knowing", "knew", "known",
|
|
83
|
+
"think", "thinks", "thinking", "thought", "want", "wants", "wanting", "wanted",
|
|
84
|
+
"need", "needs", "needing", "needed", "like", "likes", "liking", "liked",
|
|
85
|
+
"love", "loves", "loving", "loved", "hate", "hates", "hating", "hated",
|
|
86
|
+
"wait", "waits", "waiting", "waited", "start", "starts", "starting", "started",
|
|
87
|
+
"stop", "stops", "stopping", "stopped", "run", "runs", "running", "ran",
|
|
88
|
+
"work", "works", "working", "worked", "play", "plays", "playing", "played",
|
|
89
|
+
"live", "lives", "living", "lived", "feel", "feels", "feeling", "felt",
|
|
90
|
+
"leave", "leaves", "leaving", "left", "put", "puts", "putting", "send", "sends",
|
|
91
|
+
"sending", "sent", "say", "says", "saying", "said", "tell", "tells", "telling",
|
|
92
|
+
"told", "ask", "asks", "asking", "asked", "answer", "answers", "answering",
|
|
93
|
+
"answered", "call", "calls", "calling", "called", "try", "tries", "trying",
|
|
94
|
+
"tried", "turn", "turns", "turning", "turned", "keep", "keeps", "keeping",
|
|
95
|
+
"kept", "hold", "holds", "holding", "held", "bring", "brings", "bringing",
|
|
96
|
+
"brought", "buy", "buys", "buying", "bought", "sell", "sells", "selling",
|
|
97
|
+
"sold", "pay", "pays", "paying", "paid", "cost", "costs", "costing", "cut",
|
|
98
|
+
"cuts", "cutting", "hit", "hits", "hitting", "hurt", "hurts", "hurting",
|
|
99
|
+
"read", "reads", "reading", "write", "writes", "writing", "wrote", "written",
|
|
100
|
+
"draw", "draws", "drawing", "drew", "drawn", "drive", "drives", "driving",
|
|
101
|
+
"drove", "driven", "break", "breaks", "breaking", "broke", "broken", "speak",
|
|
102
|
+
"speaks", "speaking", "spoke", "spoken", "wake", "wakes", "waking", "woke",
|
|
103
|
+
"woken", "choose", "chooses", "choosing", "chose", "chosen", "close", "closes",
|
|
104
|
+
"closing", "closed", "open", "opens", "opening", "opened", "find", "finds",
|
|
105
|
+
"finding", "found", "lose", "loses", "losing", "lost", "meet", "meets",
|
|
106
|
+
"meeting", "met", "teach", "teaches", "teaching", "taught", "learn", "learns",
|
|
107
|
+
"learning", "learned", "understand", "understands", "understanding",
|
|
108
|
+
"understood", "win", "wins", "winning", "won", "fly", "flies", "flying",
|
|
109
|
+
"flew", "flown", "fall", "falls", "falling", "fell", "fallen", "swim", "swims",
|
|
110
|
+
"swimming", "swam", "swum", "shake", "shakes", "shaking", "shook", "shaken",
|
|
111
|
+
"steal", "steals", "stealing", "stole", "stolen", "spend", "spends", "spending",
|
|
112
|
+
"spent", "stand", "stands", "standing", "stood", "swear", "swears", "swearing",
|
|
113
|
+
"swore", "sworn", "throw", "throws", "throwing", "threw", "thrown", "catch",
|
|
114
|
+
"catches", "catching", "caught", "teach", "teaches", "teaching", "taught",
|
|
115
|
+
"sleep", "sleeps", "sleeping", "slept", "dream", "dreams", "dreaming", "dreamt",
|
|
116
|
+
"ring", "rings", "ringing", "rang", "rung", "rise", "rises", "rising", "rose",
|
|
117
|
+
"risen", "sit", "sits", "sitting", "sat", "slay", "slays", "slaying", "slew",
|
|
118
|
+
"slain", "spin", "spins", "spinning", "spun", "spit", "spits", "spitting",
|
|
119
|
+
"spit", "split", "splits", "splitting", "spread", "spreads", "spreading",
|
|
120
|
+
"cut", "cuts", "cutting", "hit", "hits", "hitting", "let", "lets", "letting",
|
|
121
|
+
"put", "puts", "putting", "quit", "quits", "quitting", "set", "sets", "setting",
|
|
122
|
+
"shut", "shuts", "shutting", "split", "splits", "splitting", "spread",
|
|
123
|
+
"spreads", "spreading", "thrust", "thrusts", "thrusting", "broadcast",
|
|
124
|
+
"broadcasts", "broadcasting", "cost", "costs", "costing", "hit", "hits",
|
|
125
|
+
"hitting", "hurt", "hurts", "hurting", "let", "lets", "letting", "put",
|
|
126
|
+
"puts", "putting", "quit", "quits", "quitting", "read", "reads", "reading",
|
|
127
|
+
"set", "sets", "setting", "shut", "shuts", "shutting", "split", "splits",
|
|
128
|
+
"splitting", "spread", "spreads", "spreading", "thrust", "thrusts",
|
|
129
|
+
"thrusting", "upset", "upsets", "upsetting", "wet", "wets", "wetting",
|
|
130
|
+
"wind", "winds", "winding", "wound", "withdraw", "withdraws", "withdrawing",
|
|
131
|
+
"withdrew", "withdrawn",
|
|
132
|
+
// спецзначения / плейсхолдеры
|
|
133
|
+
"{count}", "{schedule}", "{timezone}", "{path}", "{task}", "{name}", "{error}",
|
|
134
|
+
"{branch}", "{pattern}", "{commit}", "{files}", "{filter}", "{server}", "{event}",
|
|
135
|
+
"{reason}", "{runAt}", "{nextOpenAt}", "{when}", "{scope}", "{visible}", "{total}",
|
|
136
|
+
"{success}", "{visible}", "{model}", "{latency}", "{ms}", "{days}", "{count}",
|
|
137
|
+
"{seconds}", "{where}", "{filter}", "{warnings}", "{fields}", "{list}", "{verb}",
|
|
138
|
+
"{until}", "{date}", "{affected}", "{started}", "{clone}", "{workspace}", "{parent}",
|
|
139
|
+
"{matrix}", "{channels}", "{errors}", "{byAge}", "{byCount}", "{kept}", "{deleted}",
|
|
140
|
+
"{rate}", "{period}", "{message}", "{min}", "{max}", "{step}", "{raw}", "{value}",
|
|
141
|
+
"{field}", "{operator}", "{tokens}", "{cost}", "{duration}", "{startedAt}",
|
|
142
|
+
"{warnings}", "{warnings}", "{port}", "{id}", "{action}", "{session}",
|
|
143
|
+
"{scheduler}", "{until}", "{minutes}", "{hours}", "{session}", "{warnings}",
|
|
144
|
+
"{session}", "{warnings}",
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
// Регулярное выражение для обнаружения любого китайского/японского/корейского иероглифа
|
|
148
|
+
const cjkRe = /[\u4e00-\u9fff\u3400-\u4dbf\u3040-\u309f\u30a0-\u30ff\uf900-\ufaff]/;
|
|
149
|
+
|
|
150
|
+
// 2. Плейсхолдеры + 3. только other + 4. непустые + 5. CJK-эвристика
|
|
151
|
+
for (const k of enKeys) {
|
|
152
|
+
const e = String(en[k]);
|
|
153
|
+
const z = String(zh[k] ?? "");
|
|
154
|
+
|
|
155
|
+
// 4. не пусто
|
|
156
|
+
if (!z.trim()) {
|
|
157
|
+
errors.push(`${k}: пустое значение в zh.json`);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// 2. плейсхолдеры совпадают
|
|
162
|
+
const enPh = placeholders(e);
|
|
163
|
+
const zhPh = placeholders(z);
|
|
164
|
+
if (enPh.join(",") !== zhPh.join(",")) {
|
|
165
|
+
errors.push(`${k}: плейсхолдеры не совпадают (en: [${enPh.join(",")}], zh: [${zhPh.join(",")}])`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// 3. плюральные ключи — только other
|
|
169
|
+
if (e.includes(", plural,")) {
|
|
170
|
+
if (!z.includes("{count, plural, other {")) {
|
|
171
|
+
errors.push(`${k}: плюральный ключ должен содержать только ветку other`);
|
|
172
|
+
}
|
|
173
|
+
if (/\bone\b|\bfew\b|\bmany\b/.test(z)) {
|
|
174
|
+
errors.push(`${k}: плюральный ключ содержит не-zh категорию (one/few/many)`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// 5. CJK-эвристика: значение должно содержать хотя бы один иероглиф,
|
|
179
|
+
// если после вычёта белого списка токенов остаётся хоть что-то переводящее
|
|
180
|
+
if (cjkRe.test(z)) continue; // есть иероглифы — ок
|
|
181
|
+
|
|
182
|
+
// Проверим, не состоит ли строка только из "непереводимых" токенов/чисел/пунктуации/плейсхолдеров
|
|
183
|
+
let normalized = z;
|
|
184
|
+
for (const tok of untranslatedTokens) {
|
|
185
|
+
normalized = normalized.replace(new RegExp(tok, "gi"), " ");
|
|
186
|
+
}
|
|
187
|
+
// убрать числа, знаки препинания, пробелы, плейсхолдеры
|
|
188
|
+
normalized = normalized
|
|
189
|
+
.replace(/\d+/g, " ")
|
|
190
|
+
.replace(/[{}\[\]().,:;!?·•—–-]+/g, " ")
|
|
191
|
+
.replace(/\s+/g, " ")
|
|
192
|
+
.trim();
|
|
193
|
+
|
|
194
|
+
if (normalized.length > 0) {
|
|
195
|
+
warnings.push(`${k}: нет китайских иероглифов (осталось: "${normalized}")`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Итог
|
|
200
|
+
let failed = false;
|
|
201
|
+
if (errors.length > 0) {
|
|
202
|
+
failed = true;
|
|
203
|
+
console.error("ОШИБКИ валидации zh.json:");
|
|
204
|
+
for (const e of errors) console.error(` ✗ ${e}`);
|
|
205
|
+
}
|
|
206
|
+
if (warnings.length > 0) {
|
|
207
|
+
console.warn(`\nВНИМАНИЕ (${warnings.length}):`);
|
|
208
|
+
for (const w of warnings) console.warn(` ! ${w}`);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
console.log(`\nКлючей en: ${enKeys.length}, zh: ${zhKeys.length}`);
|
|
212
|
+
console.log(`Плюральных ключей: ${pluralKeys.length}`);
|
|
213
|
+
console.log(`Ошибок: ${errors.length}, предупреждений: ${warnings.length}`);
|
|
214
|
+
|
|
215
|
+
if (failed) {
|
|
216
|
+
process.exit(1);
|
|
217
|
+
}
|
|
218
|
+
console.log("\n✓ zh.json прошёл валидацию: паритет ключей, плейсхолдеры, только other, непустые, CJK-эвристика.");
|