opencode-windows-scheduler 0.0.0-stage → 1.0.0
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 +45 -0
- package/CROSS_PLATFORM.md +113 -0
- package/LICENSE +21 -0
- package/README.md +173 -2
- package/README.ru.md +131 -0
- package/ROADMAP-STRATEGY.md +217 -0
- package/ROADMAP.md +87 -0
- package/dist/core/cron-to-schtasks.d.ts +20 -0
- package/dist/core/cron-to-schtasks.d.ts.map +1 -0
- package/dist/core/cron-to-schtasks.js +233 -0
- package/dist/core/dry-run.d.ts +44 -0
- package/dist/core/dry-run.d.ts.map +1 -0
- package/dist/core/dry-run.js +252 -0
- package/dist/core/file-watcher.d.ts +31 -0
- package/dist/core/file-watcher.d.ts.map +1 -0
- package/dist/core/file-watcher.js +128 -0
- package/dist/core/lock.d.ts +43 -0
- package/dist/core/lock.d.ts.map +1 -0
- package/dist/core/lock.js +118 -0
- package/dist/core/matrix.d.ts +167 -0
- package/dist/core/matrix.d.ts.map +1 -0
- package/dist/core/matrix.js +687 -0
- package/dist/core/ps-wrapper.d.ts +60 -0
- package/dist/core/ps-wrapper.d.ts.map +1 -0
- package/dist/core/ps-wrapper.js +538 -0
- package/dist/core/record-history.d.ts +14 -0
- package/dist/core/record-history.d.ts.map +1 -0
- package/dist/core/record-history.js +360 -0
- package/dist/core/scheduler/index.d.ts +20 -0
- package/dist/core/scheduler/index.d.ts.map +1 -0
- package/dist/core/scheduler/index.js +32 -0
- package/dist/core/scheduler/linux.d.ts +32 -0
- package/dist/core/scheduler/linux.d.ts.map +1 -0
- package/dist/core/scheduler/linux.js +115 -0
- package/dist/core/scheduler/logs.d.ts +11 -0
- package/dist/core/scheduler/logs.d.ts.map +1 -0
- package/dist/core/scheduler/logs.js +34 -0
- package/dist/core/scheduler/mac.d.ts +39 -0
- package/dist/core/scheduler/mac.d.ts.map +1 -0
- package/dist/core/scheduler/mac.js +175 -0
- package/dist/core/scheduler/posix.d.ts +40 -0
- package/dist/core/scheduler/posix.d.ts.map +1 -0
- package/dist/core/scheduler/posix.js +86 -0
- package/dist/core/scheduler/registry.d.ts +36 -0
- package/dist/core/scheduler/registry.d.ts.map +1 -0
- package/dist/core/scheduler/registry.js +56 -0
- package/dist/core/scheduler/types.d.ts +63 -0
- package/dist/core/scheduler/types.d.ts.map +1 -0
- package/dist/core/scheduler/types.js +1 -0
- package/dist/core/scheduler/windows.d.ts +47 -0
- package/dist/core/scheduler/windows.d.ts.map +1 -0
- package/dist/core/scheduler/windows.js +375 -0
- package/dist/core/wrappers/bash.d.ts +58 -0
- package/dist/core/wrappers/bash.d.ts.map +1 -0
- package/dist/core/wrappers/bash.js +223 -0
- package/dist/db/history-repo.d.ts +69 -0
- package/dist/db/history-repo.d.ts.map +1 -0
- package/dist/db/history-repo.js +150 -0
- package/dist/db/index.d.ts +47 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +120 -0
- package/dist/db/metrics-repo.d.ts +43 -0
- package/dist/db/metrics-repo.d.ts.map +1 -0
- package/dist/db/metrics-repo.js +95 -0
- package/dist/db/migrate.d.ts +24 -0
- package/dist/db/migrate.d.ts.map +1 -0
- package/dist/db/migrate.js +237 -0
- package/dist/db/recovery.d.ts +11 -0
- package/dist/db/recovery.d.ts.map +1 -0
- package/dist/db/recovery.js +38 -0
- package/dist/db/schema.d.ts +24 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +97 -0
- package/dist/db/settings-repo.d.ts +8 -0
- package/dist/db/settings-repo.d.ts.map +1 -0
- package/dist/db/settings-repo.js +27 -0
- package/dist/db/tasks-repo.d.ts +26 -0
- package/dist/db/tasks-repo.d.ts.map +1 -0
- package/dist/db/tasks-repo.js +120 -0
- package/dist/db/templates-repo.d.ts +17 -0
- package/dist/db/templates-repo.d.ts.map +1 -0
- package/dist/db/templates-repo.js +57 -0
- package/dist/gui-experimental.cjs +1 -0
- package/dist/history.d.ts +53 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +57 -0
- package/dist/index.d.ts +156 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2077 -0
- package/dist/notifications.d.ts +45 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/notifications.js +135 -0
- package/dist/rpc.d.ts +2052 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +863 -0
- package/dist/schtasks.d.ts +32 -0
- package/dist/schtasks.d.ts.map +1 -0
- package/dist/schtasks.js +45 -0
- package/dist/server.d.ts +106 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +1478 -0
- package/dist/settings.d.ts +43 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +96 -0
- package/dist/shared/jobs-view.d.ts +21 -0
- package/dist/shared/jobs-view.d.ts.map +1 -0
- package/dist/shared/jobs-view.js +28 -0
- package/dist/skill.d.ts +15 -0
- package/dist/skill.d.ts.map +1 -0
- package/dist/skill.js +93 -0
- package/dist/task-transfer.d.ts +176 -0
- package/dist/task-transfer.d.ts.map +1 -0
- package/dist/task-transfer.js +442 -0
- package/dist/templates.d.ts +57 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +16 -0
- package/dist/types.d.ts +78 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +88 -0
- package/dist/workspaces.d.ts +55 -0
- package/dist/workspaces.d.ts.map +1 -0
- package/dist/workspaces.js +183 -0
- package/docs/ARCHITECTURE.md +302 -0
- package/docs/FEATURES.md +288 -0
- package/docs/MIGRATION.md +266 -0
- package/docs/dashboard.png +0 -0
- package/gui-experimental.cjs +2 -0
- package/index.js +1 -0
- package/package.json +92 -4
- package/scripts/demo-dashboard.mjs +199 -0
- package/skills/scheduled-job-best-practices/SKILL.md +155 -0
- package/skills/scheduled-job-best-practices/references/recipes.md +123 -0
- package/src/core/cron-to-schtasks.ts +269 -0
- package/src/core/dry-run.ts +315 -0
- package/src/core/file-watcher.ts +171 -0
- package/src/core/lock.ts +134 -0
- package/src/core/matrix.ts +907 -0
- package/src/core/ps-wrapper.ts +572 -0
- package/src/core/record-history.ts +493 -0
- package/src/core/scheduler/index.ts +44 -0
- package/src/core/scheduler/linux.ts +125 -0
- package/src/core/scheduler/logs.ts +37 -0
- package/src/core/scheduler/mac.ts +222 -0
- package/src/core/scheduler/posix.ts +111 -0
- package/src/core/scheduler/registry.ts +93 -0
- package/src/core/scheduler/types.ts +67 -0
- package/src/core/scheduler/windows.ts +469 -0
- package/src/core/wrappers/bash.ts +282 -0
- package/src/db/history-repo.ts +303 -0
- package/src/db/index.ts +166 -0
- package/src/db/metrics-repo.ts +158 -0
- package/src/db/migrate.ts +322 -0
- package/src/db/recovery.ts +46 -0
- package/src/db/schema.ts +109 -0
- package/src/db/settings-repo.ts +31 -0
- package/src/db/tasks-repo.ts +162 -0
- package/src/db/templates-repo.ts +77 -0
- package/src/gui.tsx +2725 -0
- package/src/history.ts +107 -0
- package/src/index.ts +2672 -0
- package/src/notifications.ts +174 -0
- package/src/rpc.ts +933 -0
- package/src/schtasks.ts +75 -0
- package/src/server.ts +1663 -0
- package/src/settings.ts +157 -0
- package/src/shared/jobs-view.ts +38 -0
- package/src/skill.ts +113 -0
- package/src/task-transfer.ts +648 -0
- package/src/templates.ts +67 -0
- package/src/tui.tsx +46 -0
- package/src/types.ts +145 -0
- package/src/workspaces.ts +236 -0
package/src/settings.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { PLUGIN_DIR } from "./types.js";
|
|
4
|
+
|
|
5
|
+
/** Настройки webhook-уведомлений (Discord/Slack/generic). */
|
|
6
|
+
export interface WebhookNotificationSettings {
|
|
7
|
+
/** Включён ли канал. */
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
/** URL вебхука. */
|
|
10
|
+
url: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Уведомления о завершении задач.
|
|
15
|
+
*
|
|
16
|
+
* ntfy.sh намеренно не поддерживается: остаётся только webhook, который
|
|
17
|
+
* работает с Discord, Slack и любым generic-эндпоинтом.
|
|
18
|
+
*/
|
|
19
|
+
export interface NotificationSettings {
|
|
20
|
+
/** Главный выключатель уведомлений. */
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
/** true — отправлять только при ошибке (экономит лимиты и не спамит). */
|
|
23
|
+
onlyOnError: boolean;
|
|
24
|
+
/** Webhook-канал. */
|
|
25
|
+
webhook?: WebhookNotificationSettings;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Глобальные настройки плагина, которые меняются из GUI.
|
|
30
|
+
* Хранятся в settings.json рядом с tasks.json / history.json.
|
|
31
|
+
*/
|
|
32
|
+
export interface SchedulerSettings {
|
|
33
|
+
/** Максимум одновременно выполняющихся задач. 0 — без ограничения. */
|
|
34
|
+
maxConcurrent: number;
|
|
35
|
+
/** Зимняя тема оформления GUI (снежинки, морозные рамки, градиент). */
|
|
36
|
+
winterMode: boolean;
|
|
37
|
+
/** Уведомления о завершении задач. */
|
|
38
|
+
notifications: NotificationSettings;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const SETTINGS_FILE = path.join(PLUGIN_DIR, "settings.json");
|
|
42
|
+
export const DEFAULT_MAX_CONCURRENT = 1;
|
|
43
|
+
export const DEFAULT_WINTER_MODE = false;
|
|
44
|
+
|
|
45
|
+
/** Значения уведомлений по умолчанию: всё выключено, только ошибки. */
|
|
46
|
+
export function defaultNotifications(): NotificationSettings {
|
|
47
|
+
return {
|
|
48
|
+
enabled: false,
|
|
49
|
+
onlyOnError: true,
|
|
50
|
+
webhook: { enabled: false, url: "" },
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Приводит значение лимита к безопасному целому (>= 0). */
|
|
55
|
+
function normalizeMaxConcurrent(value: unknown, fallback: number): number {
|
|
56
|
+
const n = Number(value);
|
|
57
|
+
if (!Number.isFinite(n)) return fallback;
|
|
58
|
+
const int = Math.floor(n);
|
|
59
|
+
return int >= 0 ? int : fallback;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Приводит значение зимнего режима к boolean. */
|
|
63
|
+
function normalizeWinterMode(value: unknown, fallback: boolean): boolean {
|
|
64
|
+
if (typeof value === "boolean") return value;
|
|
65
|
+
if (value === "true") return true;
|
|
66
|
+
if (value === "false") return false;
|
|
67
|
+
return fallback;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Приводит настройки уведомлений к безопасному виду. */
|
|
71
|
+
function normalizeNotifications(
|
|
72
|
+
value: unknown,
|
|
73
|
+
fallback: NotificationSettings
|
|
74
|
+
): NotificationSettings {
|
|
75
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
76
|
+
return {
|
|
77
|
+
...fallback,
|
|
78
|
+
webhook: fallback.webhook ? { ...fallback.webhook } : { enabled: false, url: "" },
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const raw = value as Partial<NotificationSettings> & { webhook?: unknown };
|
|
83
|
+
const rawWebhook =
|
|
84
|
+
raw.webhook && typeof raw.webhook === "object" && !Array.isArray(raw.webhook)
|
|
85
|
+
? (raw.webhook as Partial<WebhookNotificationSettings>)
|
|
86
|
+
: undefined;
|
|
87
|
+
const fallbackWebhook = fallback.webhook ?? { enabled: false, url: "" };
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
enabled: typeof raw.enabled === "boolean" ? raw.enabled : fallback.enabled,
|
|
91
|
+
onlyOnError:
|
|
92
|
+
typeof raw.onlyOnError === "boolean" ? raw.onlyOnError : fallback.onlyOnError,
|
|
93
|
+
webhook: {
|
|
94
|
+
enabled:
|
|
95
|
+
typeof rawWebhook?.enabled === "boolean"
|
|
96
|
+
? rawWebhook.enabled
|
|
97
|
+
: fallbackWebhook.enabled,
|
|
98
|
+
url:
|
|
99
|
+
typeof rawWebhook?.url === "string"
|
|
100
|
+
? rawWebhook.url.trim()
|
|
101
|
+
: fallbackWebhook.url,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Читает настройки. Битый/отсутствующий файл — значения по умолчанию. */
|
|
107
|
+
export async function loadSettings(): Promise<SchedulerSettings> {
|
|
108
|
+
const fallbackNotifications = defaultNotifications();
|
|
109
|
+
try {
|
|
110
|
+
const raw = await fs.readFile(SETTINGS_FILE, "utf8");
|
|
111
|
+
const parsed = JSON.parse(raw) as Partial<SchedulerSettings> | null;
|
|
112
|
+
return {
|
|
113
|
+
maxConcurrent: normalizeMaxConcurrent(
|
|
114
|
+
parsed?.maxConcurrent,
|
|
115
|
+
DEFAULT_MAX_CONCURRENT
|
|
116
|
+
),
|
|
117
|
+
winterMode: normalizeWinterMode(
|
|
118
|
+
parsed?.winterMode,
|
|
119
|
+
DEFAULT_WINTER_MODE
|
|
120
|
+
),
|
|
121
|
+
notifications: normalizeNotifications(
|
|
122
|
+
parsed?.notifications,
|
|
123
|
+
fallbackNotifications
|
|
124
|
+
),
|
|
125
|
+
};
|
|
126
|
+
} catch {
|
|
127
|
+
return {
|
|
128
|
+
maxConcurrent: DEFAULT_MAX_CONCURRENT,
|
|
129
|
+
winterMode: DEFAULT_WINTER_MODE,
|
|
130
|
+
notifications: fallbackNotifications,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Сохраняет настройки (частичное обновление поверх текущих). */
|
|
136
|
+
export async function saveSettings(
|
|
137
|
+
patch: Partial<SchedulerSettings>
|
|
138
|
+
): Promise<SchedulerSettings> {
|
|
139
|
+
const current = await loadSettings();
|
|
140
|
+
const next: SchedulerSettings = {
|
|
141
|
+
maxConcurrent:
|
|
142
|
+
patch.maxConcurrent !== undefined
|
|
143
|
+
? normalizeMaxConcurrent(patch.maxConcurrent, current.maxConcurrent)
|
|
144
|
+
: current.maxConcurrent,
|
|
145
|
+
winterMode:
|
|
146
|
+
patch.winterMode !== undefined
|
|
147
|
+
? normalizeWinterMode(patch.winterMode, current.winterMode)
|
|
148
|
+
: current.winterMode,
|
|
149
|
+
notifications:
|
|
150
|
+
patch.notifications !== undefined
|
|
151
|
+
? normalizeNotifications(patch.notifications, current.notifications)
|
|
152
|
+
: current.notifications,
|
|
153
|
+
};
|
|
154
|
+
await fs.mkdir(PLUGIN_DIR, { recursive: true });
|
|
155
|
+
await fs.writeFile(SETTINGS_FILE, JSON.stringify(next, null, 2), "utf8");
|
|
156
|
+
return next;
|
|
157
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type JobStatus = "running" | "success" | "error" | "unknown"
|
|
2
|
+
|
|
3
|
+
export interface JobView {
|
|
4
|
+
name: string
|
|
5
|
+
status: JobStatus
|
|
6
|
+
nextRun?: string
|
|
7
|
+
lastRun?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Возвращает символ статуса задачи для отображения в панелях TUI и GUI.
|
|
12
|
+
* Общая логика для обоих рантаймов.
|
|
13
|
+
*/
|
|
14
|
+
export function statusIcon(status: JobStatus): string {
|
|
15
|
+
switch (status) {
|
|
16
|
+
case "running":
|
|
17
|
+
return "●"
|
|
18
|
+
case "error":
|
|
19
|
+
return "✗"
|
|
20
|
+
case "success":
|
|
21
|
+
return "✓"
|
|
22
|
+
default:
|
|
23
|
+
return "?"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Возвращает список задач планировщика в едином формате для TUI и GUI.
|
|
29
|
+
*
|
|
30
|
+
* TODO (следующая итерация): подключить реальные данные через RPC / context.client
|
|
31
|
+
* (вызов серверного list_jobs). Пока возвращается заглушка и в панели отображается
|
|
32
|
+
* текст "Задач пока нет".
|
|
33
|
+
*/
|
|
34
|
+
export async function getJobsView(context: unknown): Promise<JobView[]> {
|
|
35
|
+
// Прямой доступ к серверному list_jobs из TUI/GUI-рантайма на этом этапе
|
|
36
|
+
// требует отдельной RPC-инфраструктуры, поэтому возвращаем пустой массив.
|
|
37
|
+
return []
|
|
38
|
+
}
|
package/src/skill.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Скилл плагина: `scheduled-job-best-practices`.
|
|
3
|
+
*
|
|
4
|
+
* Скилл — это markdown-инструкция, которую OpenCode показывает агенту и подгружает
|
|
5
|
+
* по требованию через инструмент `skill`. Мы не полагаемся на ручную установку в
|
|
6
|
+
* `.opencode/skills`: плагин сам регистрирует скилл в контексте сессии, поэтому он
|
|
7
|
+
* доступен сразу после `opencode plugin add opencode-windows-scheduler`.
|
|
8
|
+
*
|
|
9
|
+
* Источник правды — каталог `skills/scheduled-job-best-practices` в пакете:
|
|
10
|
+
* - `SKILL.md` — тело инструкции;
|
|
11
|
+
* - `references/recipes.md` — готовые примеры, которые агент читает по ссылке.
|
|
12
|
+
* Это даёт агенту базовую директорию с вспомогательными файлами.
|
|
13
|
+
*/
|
|
14
|
+
import fs from "node:fs";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
|
|
18
|
+
export const SCHEDULER_SKILL_ID = "scheduled-job-best-practices";
|
|
19
|
+
export const SCHEDULER_SKILL_NAME = "Scheduled Job Best Practices";
|
|
20
|
+
|
|
21
|
+
const FALLBACK_DESCRIPTION =
|
|
22
|
+
"Use when the user wants recurring or event-driven automation (cron, file changes, MCP events), multi-repository fan-out, or agent pipelines. Covers safe defaults, prompt design, Quality Gates, matrix builds, DAG dependencies and post-incident diagnosis with the scheduler tools.";
|
|
23
|
+
|
|
24
|
+
const FALLBACK_CONTENT = [
|
|
25
|
+
"# Scheduled Job Best Practices",
|
|
26
|
+
"",
|
|
27
|
+
"Use `list_tasks` before creating anything and prefer `update_task` over delete + create.",
|
|
28
|
+
"Write self-contained prompts (goal, scope, constraints, verification, output).",
|
|
29
|
+
"Always set `timeoutSeconds`, set `qualityGate` when success is machine-checkable, and",
|
|
30
|
+
"limit tools with `allowedTools`/`deniedTools`. Validate with `dry_run`, then `run_task_now`,",
|
|
31
|
+
"then inspect `get_history` and `get_task_logs`. For multi-repository work use `matrix` with",
|
|
32
|
+
"a small `concurrency`; a matrix parent never runs itself and dependencies wait for all clones.",
|
|
33
|
+
].join("\n");
|
|
34
|
+
|
|
35
|
+
export interface SchedulerSkill {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
path: string;
|
|
40
|
+
content: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Корень пакета: `dist/skill.js` → `..`, `src/skill.ts` → `..`. */
|
|
44
|
+
function packageRoot(): string {
|
|
45
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Разбирает YAML-frontmatter простого вида (`key: value`).
|
|
50
|
+
* Полноценный YAML не нужен: поддерживаем ровно те поля, которые пишем сами.
|
|
51
|
+
*/
|
|
52
|
+
function parseFrontmatter(raw: string): {
|
|
53
|
+
meta: Record<string, string>;
|
|
54
|
+
body: string;
|
|
55
|
+
} {
|
|
56
|
+
const normalized = raw.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n");
|
|
57
|
+
if (!normalized.startsWith("---\n")) {
|
|
58
|
+
return { meta: {}, body: normalized };
|
|
59
|
+
}
|
|
60
|
+
const end = normalized.indexOf("\n---", 4);
|
|
61
|
+
if (end === -1) return { meta: {}, body: normalized };
|
|
62
|
+
|
|
63
|
+
const header = normalized.slice(4, end);
|
|
64
|
+
const body = normalized.slice(end + 4).replace(/^\n+/, "");
|
|
65
|
+
const meta: Record<string, string> = {};
|
|
66
|
+
|
|
67
|
+
for (const line of header.split("\n")) {
|
|
68
|
+
const match = /^([A-Za-z0-9_-]+):\s*(.*)$/.exec(line.trim());
|
|
69
|
+
if (!match) continue;
|
|
70
|
+
const value = match[2].trim().replace(/^["']|["']$/g, "");
|
|
71
|
+
if (value) meta[match[1]] = value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return { meta, body };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Загружает скилл из пакета. Возвращает `undefined`, если файл недоступен —
|
|
79
|
+
* плагин в этом случае просто не регистрирует скилл и продолжает работать.
|
|
80
|
+
*/
|
|
81
|
+
export function loadSchedulerSkill(): SchedulerSkill | undefined {
|
|
82
|
+
const skillPath = path.join(packageRoot(), "skills", SCHEDULER_SKILL_ID, "SKILL.md");
|
|
83
|
+
|
|
84
|
+
let raw: string;
|
|
85
|
+
try {
|
|
86
|
+
raw = fs.readFileSync(skillPath, "utf8");
|
|
87
|
+
} catch {
|
|
88
|
+
if (process.env.OPENCODE_SCHEDULER_DEBUG_SKILL) {
|
|
89
|
+
console.error(`[windows-scheduler] Скилл не найден: ${skillPath}`);
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const { meta, body } = parseFrontmatter(raw);
|
|
95
|
+
const content = body.trim();
|
|
96
|
+
if (!content) {
|
|
97
|
+
return {
|
|
98
|
+
id: SCHEDULER_SKILL_ID,
|
|
99
|
+
name: meta.name || SCHEDULER_SKILL_NAME,
|
|
100
|
+
description: meta.description || FALLBACK_DESCRIPTION,
|
|
101
|
+
path: skillPath,
|
|
102
|
+
content: FALLBACK_CONTENT,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
id: SCHEDULER_SKILL_ID,
|
|
108
|
+
name: meta.name || SCHEDULER_SKILL_NAME,
|
|
109
|
+
description: meta.description || FALLBACK_DESCRIPTION,
|
|
110
|
+
path: skillPath,
|
|
111
|
+
content,
|
|
112
|
+
};
|
|
113
|
+
}
|