opencode-windows-scheduler 1.5.1 → 1.5.4

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/LICENSE +21 -21
  3. package/README.md +3 -2
  4. package/ROADMAP-STRATEGY.md +5 -4
  5. package/ROADMAP.md +502 -103
  6. package/dist/core/audit.d.ts +27 -0
  7. package/dist/core/audit.d.ts.map +1 -1
  8. package/dist/core/audit.js +60 -0
  9. package/dist/core/local-ai.d.ts +52 -0
  10. package/dist/core/local-ai.d.ts.map +1 -0
  11. package/dist/core/local-ai.js +119 -0
  12. package/dist/core/ps-wrapper.d.ts +2 -30
  13. package/dist/core/ps-wrapper.d.ts.map +1 -1
  14. package/dist/core/ps-wrapper.js +258 -49
  15. package/dist/core/secrets.d.ts +10 -3
  16. package/dist/core/secrets.d.ts.map +1 -1
  17. package/dist/core/secrets.js +28 -4
  18. package/dist/core/triage-chain.d.ts +34 -0
  19. package/dist/core/triage-chain.d.ts.map +1 -0
  20. package/dist/core/triage-chain.js +70 -0
  21. package/dist/core/triage-rules.d.ts +23 -0
  22. package/dist/core/triage-rules.d.ts.map +1 -0
  23. package/dist/core/triage-rules.js +174 -0
  24. package/dist/core/triage-shadow.d.ts +47 -0
  25. package/dist/core/triage-shadow.d.ts.map +1 -0
  26. package/dist/core/triage-shadow.js +48 -0
  27. package/dist/core/triage.d.ts +76 -0
  28. package/dist/core/triage.d.ts.map +1 -0
  29. package/dist/core/triage.js +271 -0
  30. package/dist/core/wrappers/bash.d.ts +1 -0
  31. package/dist/core/wrappers/bash.d.ts.map +1 -1
  32. package/dist/core/wrappers/bash.js +91 -5
  33. package/dist/gui-experimental.cjs +1 -0
  34. package/dist/i18n.d.ts.map +1 -1
  35. package/dist/i18n.js +34 -7
  36. package/dist/index.d.ts +27 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +194 -6
  39. package/dist/notifications.d.ts.map +1 -1
  40. package/dist/notifications.js +9 -1
  41. package/dist/rpc.d.ts +259 -0
  42. package/dist/rpc.d.ts.map +1 -1
  43. package/dist/rpc.js +58 -0
  44. package/dist/settings.d.ts +80 -0
  45. package/dist/settings.d.ts.map +1 -1
  46. package/dist/settings.js +199 -0
  47. package/dist/workspaces.d.ts +2 -2
  48. package/dist/workspaces.d.ts.map +1 -1
  49. package/dist/workspaces.js +6 -4
  50. package/docs/ARCHITECTURE.md +69 -10
  51. package/docs/FEATURES.md +37 -7
  52. package/docs/LOCAL-AI.md +202 -0
  53. package/docs/MIGRATION.md +17 -0
  54. package/docs/README.ru.md +5 -4
  55. package/docs/spikes/local-model-structured-output.md +81 -0
  56. package/docs/spikes/ollama-qwen3-4b-smoke.json +28 -0
  57. package/docs/spikes/ollama-qwen3-4b.json +163 -0
  58. package/gui-experimental.cjs +8 -8
  59. package/locales/en.json +32 -0
  60. package/locales/ru.json +32 -0
  61. package/package.json +9 -2
  62. package/scripts/bench-local.mjs +321 -0
  63. package/scripts/spike-local-structured.mjs +182 -0
  64. package/skills/scheduled-job-best-practices/references/recipes.md +40 -0
  65. package/src/core/audit.ts +89 -0
  66. package/src/core/local-ai.ts +173 -0
  67. package/src/core/ps-wrapper.ts +265 -48
  68. package/src/core/secrets.ts +34 -10
  69. package/src/core/triage-chain.ts +116 -0
  70. package/src/core/triage-rules.ts +215 -0
  71. package/src/core/triage-shadow.ts +96 -0
  72. package/src/core/triage.ts +366 -0
  73. package/src/core/wrappers/bash.ts +112 -5
  74. package/src/gui.tsx +4761 -4533
  75. package/src/i18n.ts +32 -9
  76. package/src/index.ts +239 -4
  77. package/src/notifications.ts +16 -0
  78. package/src/rpc.ts +58 -0
  79. package/src/settings.ts +318 -0
  80. package/src/workspaces.ts +9 -4
@@ -133,7 +133,12 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
133
133
  `SCHEDULE_DEFER_FILE=${shellQuote(scheduleGate?.deferFile ?? "")}`,
134
134
  `SCHEDULE_FORCE_FILE=${shellQuote(scheduleGate?.forceFile ?? "")}`,
135
135
  `ENV_FILE=${shellQuote(envFile ?? "")}`,
136
- "",
136
+ // Спринт 29.2: права задачи передаются в opencode через переменную окружения.
137
+ // opencode run CLI не поддерживает --allow-tool/--deny-tool, а файл
138
+ // opencode.jsonc в Workdir мог бы перезаписать проектный конфиг.
139
+ `export OPENCODE_CONFIG_CONTENT=${shellQuote(buildOpencodeConfig(allowedTools, deniedTools))}`,
140
+ 'log "[role-scoped] opencode config passed via OPENCODE_CONFIG_CONTENT"',
141
+ '',
137
142
  "# cron запускает задачи с минимальным PATH — добавляем типовые каталоги.",
138
143
  'export PATH="/opt/homebrew/bin:/usr/local/bin:$HOME/.local/bin:$HOME/.bun/bin:$PATH"',
139
144
  "",
@@ -270,9 +275,9 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
270
275
  ' ;;',
271
276
  ' esac',
272
277
  ' if [ -n "$MODEL" ]; then',
273
- ' opencode run "${SESSION_ARGS[@]}" --model "$MODEL" "$PROMPT"',
278
+ ' opencode run --auto "${SESSION_ARGS[@]}" --model "$MODEL" "$PROMPT"',
274
279
  " else",
275
- ' opencode run "${SESSION_ARGS[@]}" "$PROMPT"',
280
+ ' opencode run --auto "${SESSION_ARGS[@]}" "$PROMPT"',
276
281
  " fi",
277
282
  "}",
278
283
  "",
@@ -286,10 +291,12 @@ export function buildBashWrapperScript(options: BashWrapperOptions): string {
286
291
  ' kill "$WATCHDOG" 2>/dev/null || true',
287
292
  ' wait "$WATCHDOG" 2>/dev/null || true',
288
293
  "else",
289
- ' run_opencode >> "$LOG_FILE" 2>&1',
294
+ ' opencode run --auto "${SESSION_ARGS[@]}" "$PROMPT"',
290
295
  " EXIT_CODE=$?",
291
296
  "fi",
292
- "",
297
+ '',
298
+ '# Конфиг прав живёт только в переменной окружения — файл не создаётся.',
299
+ '',
293
300
  'if [ "$EXIT_CODE" -ne 0 ]; then',
294
301
  ' log "[scheduler] Задача \'$TASK_NAME\' завершилась с кодом $EXIT_CODE."',
295
302
  ' ERROR_MESSAGE="Код возврата $EXIT_CODE"',
@@ -380,3 +387,103 @@ export async function writeBashWrapper(
380
387
  export function bashWrapperPath(sanitizedName: string): string {
381
388
  return path.join(WRAPPER_DIR, `run-${sanitizedName}.sh`);
382
389
  }
390
+
391
+ // Спринт 29.2: генерация содержимого opencode.jsonc с правами для задачи.
392
+ // opencode run CLI (v2.2.3) не поддерживает --allow-tool/--deny-tool, поэтому
393
+ // права задаются через временный opencode.jsonc в WORKDIR.
394
+ //
395
+ // Actions OpenCode v2: read, edit, glob, grep, shell, subagent, skill, question,
396
+ // webfetch, websearch. deny для shell покрывает bash/Shell, deny для edit покрывает
397
+ // write/edit/apply_patch/remove.
398
+ //
399
+ // Политика: всё разрешено по умолчанию (как в OpenCode), deniedTools добавляют
400
+ // deny-правила, allowedTools (если задан) запрещает всё, чего нет в списке.
401
+ // Задаёт только допустимые/actions из известного набора — неизвестные игнорируются.
402
+ export function buildOpencodeConfig(
403
+ allowedTools?: string[],
404
+ deniedTools?: string[]
405
+ ): string {
406
+ const actions: Array<{ action: string; effect: "allow" | "deny" }> = [
407
+ { action: "read", effect: "allow" },
408
+ { action: "edit", effect: "allow" },
409
+ { action: "glob", effect: "allow" },
410
+ { action: "grep", effect: "allow" },
411
+ { action: "shell", effect: "allow" },
412
+ { action: "subagent", effect: "allow" },
413
+ { action: "skill", effect: "allow" },
414
+ { action: "question", effect: "allow" },
415
+ { action: "webfetch", effect: "allow" },
416
+ { action: "websearch", effect: "allow" },
417
+ ];
418
+
419
+ const deniedSet = new Set(
420
+ (deniedTools ?? [])
421
+ .map((t) => t.trim().toLowerCase())
422
+ .filter(Boolean)
423
+ );
424
+ const allowedSet = new Set(
425
+ (allowedTools ?? [])
426
+ .map((t) => t.trim().toLowerCase())
427
+ .filter(Boolean)
428
+ );
429
+
430
+ const toolToAction = new Map<string, string>([
431
+ ["read", "read"],
432
+ ["write", "edit"],
433
+ ["edit", "edit"],
434
+ ["apply_patch", "edit"],
435
+ ["remove", "edit"],
436
+ ["bash", "shell"],
437
+ ["shell", "shell"],
438
+ ["glob", "glob"],
439
+ ["grep", "grep"],
440
+ ["webfetch", "webfetch"],
441
+ ["websearch", "websearch"],
442
+ ["question", "question"],
443
+ ["subagent", "subagent"],
444
+ ["skill", "skill"],
445
+ ["WebFetch", "webfetch"],
446
+ ]);
447
+
448
+ // Применяем deniedTools.
449
+ for (const [tool, action] of toolToAction) {
450
+ if (deniedSet.has(tool)) {
451
+ const idx = actions.findIndex((a) => a.action === action);
452
+ if (idx >= 0) actions[idx].effect = "deny";
453
+ }
454
+ }
455
+
456
+ // Если задан allowedTools — всё, чего нет в списке, запрещаем.
457
+ // deniedTools имеет приоритет (последнее правило выигрывает в OpenCode),
458
+ // поэтому применяем allowedTools ПОСЛЕ deniedTools — denied не перебивается.
459
+ if (allowedSet.size > 0) {
460
+ for (const entry of actions) {
461
+ // Если действие уже запрещено deniedTools, оставляем deny.
462
+ if (entry.effect === "deny") continue;
463
+ const tool = [...toolToAction.entries()].find(
464
+ ([, a]) => a === entry.action
465
+ )?.[0];
466
+ if (tool && !allowedSet.has(tool)) {
467
+ entry.effect = "deny";
468
+ }
469
+ }
470
+ }
471
+
472
+ // Убираем дубликаты actions (оставляем последний эффект).
473
+ const deduped = new Map<string, "allow" | "deny">();
474
+ for (const { action, effect } of actions) deduped.set(action, effect);
475
+
476
+ const permissions = [...deduped.entries()].map(
477
+ ([action, effect]) =>
478
+ ` { "action": "${action}", "resource": "*", "effect": "${effect}" }`
479
+ );
480
+
481
+ return JSON.stringify(
482
+ {
483
+ $schema: "https://opencode.ai/config.json",
484
+ permissions: permissions.map((p) => JSON.parse(p)),
485
+ },
486
+ null,
487
+ 2
488
+ );
489
+ }