opencode-windows-scheduler 1.5.4 → 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 +65 -5
- package/CROSS_PLATFORM.md +107 -71
- package/README.md +72 -25
- package/ROADMAP-STRATEGY.md +6 -0
- package/ROADMAP.md +116 -85
- 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/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 -2
- package/dist/core/ps-wrapper.d.ts.map +1 -1
- package/dist/core/ps-wrapper.js +293 -96
- 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 +9 -3
- package/dist/core/triage-chain.d.ts.map +1 -1
- package/dist/core/triage-chain.js +15 -5
- 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.map +1 -1
- package/dist/core/triage-rules.js +22 -0
- package/dist/core/triage-shadow.d.ts +54 -10
- package/dist/core/triage-shadow.d.ts.map +1 -1
- package/dist/core/triage-shadow.js +138 -26
- 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.js +1 -1
- 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 +41 -3
- package/dist/index.d.ts +40 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +345 -71
- 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 +287 -16
- 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 +145 -8
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +81 -6
- 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 +89 -5
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +143 -23
- 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 +40 -22
- 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 +125 -48
- package/docs/FEATURES.zh.md +655 -0
- package/docs/LOCAL-AI.md +114 -16
- package/docs/README.ru.md +18 -13
- 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/gui-experimental.cjs +8 -8
- package/locales/en.json +54 -1
- package/locales/ru.json +54 -1
- package/locales/zh.json +780 -0
- package/package.json +24 -7
- package/scripts/check-zh-locale.mjs +218 -0
- package/scripts/run-tests.mjs +236 -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 +1 -1
- 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/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 +300 -96
- 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 +15 -6
- package/src/core/triage-compare.ts +277 -0
- package/src/core/triage-rules.ts +23 -0
- package/src/core/triage-shadow.ts +176 -32
- package/src/core/triage-worker.ts +344 -0
- package/src/core/triage.ts +1 -1
- 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 +5070 -4761
- package/src/history.ts +7 -3
- package/src/i18n.ts +55 -4
- package/src/index.ts +432 -74
- package/src/integrations.ts +50 -6
- package/src/notifications.ts +465 -18
- package/src/profiles.ts +21 -3
- package/src/rpc.ts +86 -6
- package/src/server.ts +135 -16
- package/src/settings.ts +305 -46
- package/src/task-transfer.ts +10 -3
- package/src/types.ts +24 -5
- package/src/workspaces.ts +22 -0
- package/dist/gui-experimental.cjs +0 -1
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"
|
|
@@ -71,7 +70,8 @@
|
|
|
71
70
|
"bench:local": "node scripts/bench-local.mjs",
|
|
72
71
|
"prepare": "npm run build",
|
|
73
72
|
"prepublishOnly": "npm run build && npm run build:gui",
|
|
74
|
-
"
|
|
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",
|
|
75
75
|
"test:sqlite": "node test-sqlite.mjs",
|
|
76
76
|
"test:crash": "node test-crash-recovery.mjs",
|
|
77
77
|
"test:workspaces": "node test-workspaces.mjs",
|
|
@@ -85,10 +85,13 @@
|
|
|
85
85
|
"test:schedule-v2": "node test-schedule-v2.mjs",
|
|
86
86
|
"test:notifications-v2": "node test-notifications-v2.mjs",
|
|
87
87
|
"test:notifications-v3": "node test-notifications-v3.mjs",
|
|
88
|
+
"test:settings": "node test-settings.mjs",
|
|
88
89
|
"test:triage": "node test-triage.mjs",
|
|
89
90
|
"test:triage-rules": "node test-triage-rules.mjs",
|
|
90
91
|
"test:triage-chain": "node test-triage-chain.mjs",
|
|
91
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",
|
|
92
95
|
"test:local-ai": "node test-local-ai.mjs",
|
|
93
96
|
"test:secrets": "node test-secrets.mjs",
|
|
94
97
|
"test:audit": "node test-audit.mjs",
|
|
@@ -109,9 +112,23 @@
|
|
|
109
112
|
"test:glob": "node test-glob.mjs",
|
|
110
113
|
"test:git-trigger": "node test-git-trigger.mjs",
|
|
111
114
|
"test:window-v3": "node test-window-v3.mjs",
|
|
115
|
+
"test:self-analysis": "node test-self-analysis.mjs",
|
|
112
116
|
"test:i18n": "node test-i18n.mjs",
|
|
113
117
|
"test:gui-bundle": "node test-gui-bundle.mjs",
|
|
114
|
-
"test:
|
|
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"
|
|
115
132
|
},
|
|
116
133
|
"dependencies": {
|
|
117
134
|
"@opencode/plugin": "^2.2.7",
|
|
@@ -123,7 +140,7 @@
|
|
|
123
140
|
"devDependencies": {
|
|
124
141
|
"@opentui/core": ">=0.8.1",
|
|
125
142
|
"@opentui/solid": ">=0.8.1",
|
|
126
|
-
"@types/node": "^
|
|
143
|
+
"@types/node": "^22.0.0",
|
|
127
144
|
"solid-js": "^1.9.0",
|
|
128
145
|
"typescript": "^5.9.3",
|
|
129
146
|
"vite": "^7.0.0",
|
|
@@ -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-эвристика.");
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Параллельный прогон того же набора сюит, что `npm test`.
|
|
3
|
+
*
|
|
4
|
+
* Читает `scripts.test` из package.json, разбивает цепочку по `&&` и запускает
|
|
5
|
+
* наборы пулом воркеров. Последовательный `npm test` остаётся как есть — он
|
|
6
|
+
* нужен для воспроизводимости и отладки.
|
|
7
|
+
*
|
|
8
|
+
* Запуск:
|
|
9
|
+
* node scripts/run-tests.mjs
|
|
10
|
+
* node scripts/run-tests.mjs --concurrency=2
|
|
11
|
+
* node scripts/run-tests.mjs --locale=en
|
|
12
|
+
* node scripts/run-tests.mjs --only=dashboard
|
|
13
|
+
*/
|
|
14
|
+
import fs from "node:fs";
|
|
15
|
+
import os from "node:os";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
import { spawn } from "node:child_process";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
|
|
20
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
21
|
+
|
|
22
|
+
function parseArgs(argv) {
|
|
23
|
+
const options = {
|
|
24
|
+
concurrency: Math.max(1, Math.min(8, os.cpus().length || 4)),
|
|
25
|
+
locale: null,
|
|
26
|
+
only: null,
|
|
27
|
+
timeoutMs: 15 * 60 * 1000,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
for (const arg of argv) {
|
|
31
|
+
if (arg === "--serial") options.concurrency = 1;
|
|
32
|
+
else if (arg.startsWith("--concurrency=")) {
|
|
33
|
+
const value = Number(arg.slice("--concurrency=".length));
|
|
34
|
+
if (!Number.isInteger(value) || value < 1) {
|
|
35
|
+
console.error(`Некорректная конкурентность: ${arg}`);
|
|
36
|
+
process.exit(2);
|
|
37
|
+
}
|
|
38
|
+
options.concurrency = Math.min(8, value);
|
|
39
|
+
} else if (arg.startsWith("--locale=")) {
|
|
40
|
+
options.locale = arg.slice("--locale=".length);
|
|
41
|
+
if (!["ru", "en", "zh"].includes(options.locale)) {
|
|
42
|
+
console.error(`Неизвестная локаль: ${options.locale}. Ожидается ru, en или zh.`);
|
|
43
|
+
process.exit(2);
|
|
44
|
+
}
|
|
45
|
+
} else if (arg.startsWith("--only=")) {
|
|
46
|
+
options.only = arg.slice("--only=".length);
|
|
47
|
+
} else if (arg.startsWith("--timeout=")) {
|
|
48
|
+
const seconds = Number(arg.slice("--timeout=".length));
|
|
49
|
+
if (!Number.isFinite(seconds) || seconds <= 0) {
|
|
50
|
+
console.error(`Некорректный таймаут: ${arg}`);
|
|
51
|
+
process.exit(2);
|
|
52
|
+
}
|
|
53
|
+
options.timeoutMs = seconds * 1000;
|
|
54
|
+
} else if (arg === "--help" || arg === "-h") {
|
|
55
|
+
console.log(
|
|
56
|
+
[
|
|
57
|
+
"node scripts/run-tests.mjs [--concurrency=N] [--serial] [--locale=ru|en|zh]",
|
|
58
|
+
" [--only=substring] [--timeout=seconds]",
|
|
59
|
+
].join("\n")
|
|
60
|
+
);
|
|
61
|
+
process.exit(0);
|
|
62
|
+
} else {
|
|
63
|
+
console.error(`Неизвестный аргумент: ${arg}`);
|
|
64
|
+
process.exit(2);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return options;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const options = parseArgs(process.argv.slice(2));
|
|
72
|
+
|
|
73
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
74
|
+
let suites = pkg.scripts.test
|
|
75
|
+
.split("&&")
|
|
76
|
+
.map((part) => part.trim().replace(/^node\s+/, ""))
|
|
77
|
+
.filter(Boolean);
|
|
78
|
+
|
|
79
|
+
if (options.only) {
|
|
80
|
+
suites = suites.filter((suite) => suite.includes(options.only));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (suites.length === 0) {
|
|
84
|
+
console.error("Не найдено ни одного набора для запуска.");
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const total = suites.length;
|
|
89
|
+
const results = new Array(total);
|
|
90
|
+
let completed = 0;
|
|
91
|
+
let failed = 0;
|
|
92
|
+
|
|
93
|
+
const startedAt = Date.now();
|
|
94
|
+
|
|
95
|
+
function formatDuration(ms) {
|
|
96
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function runSuite(suite, index) {
|
|
100
|
+
return new Promise((resolve) => {
|
|
101
|
+
const suiteStartedAt = Date.now();
|
|
102
|
+
const child = spawn(process.execPath, [suite], {
|
|
103
|
+
cwd: root,
|
|
104
|
+
env: {
|
|
105
|
+
...process.env,
|
|
106
|
+
...(options.locale ? { OPENCODE_SCHEDULER_LOCALE: options.locale } : {}),
|
|
107
|
+
},
|
|
108
|
+
windowsHide: true,
|
|
109
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
let stdout = "";
|
|
113
|
+
let stderr = "";
|
|
114
|
+
let timedOut = false;
|
|
115
|
+
|
|
116
|
+
child.stdout.on("data", (chunk) => {
|
|
117
|
+
stdout += chunk.toString();
|
|
118
|
+
});
|
|
119
|
+
child.stderr.on("data", (chunk) => {
|
|
120
|
+
stderr += chunk.toString();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const timer = setTimeout(() => {
|
|
124
|
+
timedOut = true;
|
|
125
|
+
child.kill("SIGKILL");
|
|
126
|
+
}, options.timeoutMs);
|
|
127
|
+
|
|
128
|
+
child.on("error", (error) => {
|
|
129
|
+
clearTimeout(timer);
|
|
130
|
+
const result = {
|
|
131
|
+
suite,
|
|
132
|
+
index,
|
|
133
|
+
ok: false,
|
|
134
|
+
code: null,
|
|
135
|
+
durationMs: Date.now() - suiteStartedAt,
|
|
136
|
+
stdout,
|
|
137
|
+
stderr: `${stderr}\n${error instanceof Error ? error.message : String(error)}`,
|
|
138
|
+
timedOut,
|
|
139
|
+
};
|
|
140
|
+
finish(result);
|
|
141
|
+
resolve(result);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
child.on("close", (code) => {
|
|
145
|
+
clearTimeout(timer);
|
|
146
|
+
const result = {
|
|
147
|
+
suite,
|
|
148
|
+
index,
|
|
149
|
+
ok: code === 0 && !timedOut,
|
|
150
|
+
code,
|
|
151
|
+
durationMs: Date.now() - suiteStartedAt,
|
|
152
|
+
stdout,
|
|
153
|
+
stderr,
|
|
154
|
+
timedOut,
|
|
155
|
+
};
|
|
156
|
+
finish(result);
|
|
157
|
+
resolve(result);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function finish(result) {
|
|
163
|
+
results[result.index] = result;
|
|
164
|
+
completed++;
|
|
165
|
+
if (!result.ok) failed++;
|
|
166
|
+
|
|
167
|
+
const status = result.ok ? "OK " : result.timedOut ? "TIME" : "FAIL";
|
|
168
|
+
console.log(
|
|
169
|
+
`[${String(completed).padStart(3)}/${total}] ${status} ${result.suite} (${formatDuration(
|
|
170
|
+
result.durationMs
|
|
171
|
+
)})`
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
if (!result.ok) {
|
|
175
|
+
const output = `${result.stdout}${result.stderr}`.trim();
|
|
176
|
+
if (output) {
|
|
177
|
+
console.error(`--- вывод ${result.suite} ---`);
|
|
178
|
+
console.error(output);
|
|
179
|
+
console.error(`--- конец ${result.suite} ---`);
|
|
180
|
+
}
|
|
181
|
+
if (result.timedOut) {
|
|
182
|
+
console.error(`Таймаут ${formatDuration(options.timeoutMs)}: ${result.suite}`);
|
|
183
|
+
}
|
|
184
|
+
// GitHub Actions: логи job недоступны анонимно, поэтому дублируем хвост
|
|
185
|
+
// вывода в аннотацию. Она читается через публичный check-runs API.
|
|
186
|
+
if (process.env.GITHUB_ACTIONS === "true") {
|
|
187
|
+
const escape = (value) =>
|
|
188
|
+
value.replace(/%/g, "%25").replace(/\r/g, "").replace(/\n/g, "%0A");
|
|
189
|
+
const tail = output.split(/\r?\n/).slice(-20).join("\n");
|
|
190
|
+
const detail = `${result.timedOut ? "timeout " : ""}${tail}`.slice(0, 4000);
|
|
191
|
+
console.log(`::error title=${escape(result.suite)}::${escape(detail)}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async function main() {
|
|
197
|
+
console.log(
|
|
198
|
+
`Параллельный прогон: ${total} наборов, конкурентность ${options.concurrency}${
|
|
199
|
+
options.locale ? `, локаль ${options.locale}` : ""
|
|
200
|
+
}`
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
let nextIndex = 0;
|
|
204
|
+
const workers = Array.from({ length: Math.min(options.concurrency, total) }, async () => {
|
|
205
|
+
while (true) {
|
|
206
|
+
const index = nextIndex++;
|
|
207
|
+
if (index >= total) return;
|
|
208
|
+
await runSuite(suites[index], index);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
await Promise.all(workers);
|
|
213
|
+
|
|
214
|
+
const durationMs = Date.now() - startedAt;
|
|
215
|
+
const failedSuites = results.filter((result) => !result.ok);
|
|
216
|
+
|
|
217
|
+
console.log("");
|
|
218
|
+
console.log(
|
|
219
|
+
`Итого: ${total - failedSuites.length}/${total} наборов за ${formatDuration(durationMs)}`
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
if (failedSuites.length > 0) {
|
|
223
|
+
console.error("Провалены:");
|
|
224
|
+
for (const result of failedSuites) {
|
|
225
|
+
console.error(` - ${result.suite}${result.timedOut ? " (таймаут)" : ""}`);
|
|
226
|
+
}
|
|
227
|
+
process.exit(1);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
process.exit(0);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
main().catch((error) => {
|
|
234
|
+
console.error(error);
|
|
235
|
+
process.exit(1);
|
|
236
|
+
});
|
package/scripts/test-locale.mjs
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Прогоняет тот же набор сюит, что `npm test`, с заданной локалью.
|
|
3
3
|
*
|
|
4
4
|
* Локаль задаётся переменной `OPENCODE_SCHEDULER_LOCALE`, которую читает
|
|
5
|
-
* `src/i18n.ts` при загрузке: так один и тот же код проверяется в ru и
|
|
5
|
+
* `src/i18n.ts` при загрузке: так один и тот же код проверяется в ru, en и zh
|
|
6
6
|
* без правки settings.json.
|
|
7
7
|
*
|
|
8
8
|
* Запуск: node scripts/test-locale.mjs en
|
|
9
|
+
* Локали: ru (по умолчанию), en, zh.
|
|
9
10
|
*/
|
|
10
11
|
import fs from "node:fs";
|
|
11
12
|
import path from "node:path";
|
|
@@ -15,8 +16,8 @@ import { fileURLToPath } from "node:url";
|
|
|
15
16
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
16
17
|
const locale = process.argv[2] ?? "en";
|
|
17
18
|
|
|
18
|
-
if (locale !== "ru" && locale !== "en") {
|
|
19
|
-
console.error(`Неизвестная локаль: ${locale}. Ожидается ru или
|
|
19
|
+
if (locale !== "ru" && locale !== "en" && locale !== "zh") {
|
|
20
|
+
console.error(`Неизвестная локаль: ${locale}. Ожидается ru, en или zh.`);
|
|
20
21
|
process.exit(2);
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -55,8 +55,11 @@ is genuinely ambiguous, tell it to stop and write the question into the report.
|
|
|
55
55
|
|
|
56
56
|
## 4. Safety defaults
|
|
57
57
|
|
|
58
|
-
- **Least privilege**:
|
|
59
|
-
not be allowed to `write` or run
|
|
58
|
+
- **Least privilege**: the default `hybrid` policy already denies `shell` and `question`; keep it
|
|
59
|
+
that way. Read-only monitoring jobs should not be allowed to `write` or run shell. Do not ask
|
|
60
|
+
for `shell` just to run `git commit`, a build or tests — put those in `qualityGate`/`afterScript`,
|
|
61
|
+
which the wrapper runs outside the agent. If a job truly needs shell, list `shell` in
|
|
62
|
+
`allowedTools` (or set `legacyShell: true` for a migrated task) and explain why.
|
|
60
63
|
- **Timeout**: always set `timeoutSeconds` for jobs that call networks or models. Default
|
|
61
64
|
timeouts are a safety net, not a plan.
|
|
62
65
|
- **Quality Gate**: pass `qualityGate` whenever a machine-checkable success criterion exists
|
|
@@ -146,7 +149,7 @@ Before saying the job is done, confirm:
|
|
|
146
149
|
- [ ] Trigger type matches the need (cron / file / MCP event).
|
|
147
150
|
- [ ] Prompt states goal, scope, constraints, verification and output.
|
|
148
151
|
- [ ] `timeoutSeconds` set; `qualityGate` set when checkable.
|
|
149
|
-
- [ ] `allowedTools` / `deniedTools` follow least privilege.
|
|
152
|
+
- [ ] `allowedTools` / `deniedTools` follow least privilege; shell is absent unless justified.
|
|
150
153
|
- [ ] Matrix: workspaces correct, concurrency capped, failure mode justified.
|
|
151
154
|
- [ ] `dry_run` reviewed.
|
|
152
155
|
- [ ] One successful `run_task_now` with clean `get_history`.
|
|
@@ -133,7 +133,7 @@ then verify with the benchmark and the shadow report before enforcing.
|
|
|
133
133
|
"mode": "auto",
|
|
134
134
|
"baseUrl": "http://127.0.0.1:11434",
|
|
135
135
|
"model": "qwen3:4b",
|
|
136
|
-
"timeoutMs":
|
|
136
|
+
"timeoutMs": 60000,
|
|
137
137
|
"fallback": "rules",
|
|
138
138
|
"confidenceThreshold": 0.6,
|
|
139
139
|
"shadow": { "enabled": true, "days": 14 }
|
package/src/core/analytics.ts
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
* Чистые функции без БД и HTTP: дашборд и RPC отдают JSON, экспорт — CSV.
|
|
5
5
|
* Так агрегаты легко тестировать без запуска сервера.
|
|
6
6
|
*/
|
|
7
|
+
import {
|
|
8
|
+
computeSavings,
|
|
9
|
+
type SavingsRecord,
|
|
10
|
+
type SavingsReport,
|
|
11
|
+
} from "./savings.js";
|
|
7
12
|
|
|
8
13
|
/** Оценка стоимости, если запись истории не содержит costUsd. */
|
|
9
14
|
export const ESTIMATED_COST_PER_1K_TOKENS_USD = 0.003;
|
|
@@ -102,6 +107,8 @@ export interface AnalyticsReport {
|
|
|
102
107
|
byModel: ModelAnalyticsRow[];
|
|
103
108
|
/** Топ ошибок по частоте (Спринт 20). */
|
|
104
109
|
errors: ErrorAnalyticsRow[];
|
|
110
|
+
/** Оценка экономии по контрфактике (Спринт 31.6). */
|
|
111
|
+
savings: SavingsReport;
|
|
105
112
|
sources: {
|
|
106
113
|
historyRecords: number;
|
|
107
114
|
/** Сколько записей попало в окно. */
|
|
@@ -198,6 +205,7 @@ export function buildAnalytics(
|
|
|
198
205
|
let durationsSum = 0;
|
|
199
206
|
let durationsCount = 0;
|
|
200
207
|
let recordsInWindow = 0;
|
|
208
|
+
const windowRecords: SavingsRecord[] = [];
|
|
201
209
|
|
|
202
210
|
for (const record of records) {
|
|
203
211
|
const date = recordDate(record);
|
|
@@ -212,6 +220,7 @@ export function buildAnalytics(
|
|
|
212
220
|
const status = String(record.status ?? "");
|
|
213
221
|
// Незавершённые запуски не участвуют в аналитике: их ещё нельзя оценить.
|
|
214
222
|
if (status === "running") continue;
|
|
223
|
+
windowRecords.push(record);
|
|
215
224
|
const duration = toNumber(record.durationMs);
|
|
216
225
|
|
|
217
226
|
bucket.total += 1;
|
|
@@ -358,6 +367,7 @@ export function buildAnalytics(
|
|
|
358
367
|
errors: [...byError.values()]
|
|
359
368
|
.sort((a, b) => b.count - a.count || a.message.localeCompare(b.message))
|
|
360
369
|
.slice(0, topLimit),
|
|
370
|
+
savings: computeSavings(windowRecords, { topLimit }),
|
|
361
371
|
sources: {
|
|
362
372
|
historyRecords: records.length,
|
|
363
373
|
recordsInWindow,
|