@xn-intenton-z2a/agentic-lib 7.4.34 → 7.4.36
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.
|
@@ -296,26 +296,20 @@ jobs:
|
|
|
296
296
|
}
|
|
297
297
|
if (!model) model = 'gpt-5-mini';
|
|
298
298
|
|
|
299
|
-
//
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
};
|
|
299
|
+
// Shared schedule maps and helper (single source of truth)
|
|
300
|
+
// In consumer repos: .github/agentic-lib/scripts/; in agentic-lib itself: src/scripts/
|
|
301
|
+
const scheduleUtilsPath = fs.existsSync('./.github/agentic-lib/scripts/schedule-utils.cjs')
|
|
302
|
+
? './.github/agentic-lib/scripts/schedule-utils.cjs'
|
|
303
|
+
: './src/scripts/schedule-utils.cjs';
|
|
304
|
+
const { updateAllSchedules } = require(scheduleUtilsPath);
|
|
305
|
+
const logger = { info: core.info };
|
|
307
306
|
|
|
307
|
+
// Update all three workflow files proportionally
|
|
308
|
+
updateAllSchedules(frequency, logger);
|
|
309
|
+
|
|
310
|
+
// Stamp the workflow file with current date
|
|
308
311
|
if (fs.existsSync(workflowPath)) {
|
|
309
312
|
let content = fs.readFileSync(workflowPath, 'utf8');
|
|
310
|
-
const cron = SCHEDULE_MAP[frequency];
|
|
311
|
-
// Replace existing cron or insert new schedule block
|
|
312
|
-
const cronRegex = /- cron: "[^"]*"/;
|
|
313
|
-
if (cronRegex.test(content)) {
|
|
314
|
-
content = content.replace(cronRegex, `- cron: "${cron}"`);
|
|
315
|
-
} else {
|
|
316
|
-
const scheduleBlock = `\n schedule:\n - cron: "${cron}"\n`;
|
|
317
|
-
content = content.replace(/\non:\n/, `\non:${scheduleBlock}`);
|
|
318
|
-
}
|
|
319
313
|
const dateStamp = `# Schedule updated: ${new Date().toISOString()}`;
|
|
320
314
|
const stampRegex = /^# Schedule updated: .*/m;
|
|
321
315
|
if (stampRegex.test(content)) {
|
|
@@ -324,8 +318,8 @@ jobs:
|
|
|
324
318
|
content = content.replace(/^(# .*\n)+/m, (match) => match + dateStamp + '\n');
|
|
325
319
|
}
|
|
326
320
|
fs.writeFileSync(workflowPath, content);
|
|
327
|
-
core.info(`Updated schedule to: ${frequency}`);
|
|
328
321
|
}
|
|
322
|
+
core.info(`Updated proportional schedules to: ${frequency}`);
|
|
329
323
|
|
|
330
324
|
if (fs.existsSync(tomlPath)) {
|
|
331
325
|
let toml = fs.readFileSync(tomlPath, 'utf8');
|
|
@@ -168,62 +168,18 @@ jobs:
|
|
|
168
168
|
const isMaintenance = frequency === 'maintenance';
|
|
169
169
|
const effectiveFrequency = isMaintenance ? 'weekly' : frequency;
|
|
170
170
|
|
|
171
|
-
//
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
};
|
|
179
|
-
const INIT_SCHEDULE_MAP = {
|
|
180
|
-
off: '0 0 31 2 *',
|
|
181
|
-
weekly: '0 4 1 * *', // 1st of month 4:00am
|
|
182
|
-
daily: '0 4 * * 1', // Monday 4:00am
|
|
183
|
-
hourly: '0 4 * * *', // Every day 4:00am
|
|
184
|
-
continuous: '0 1,5,9,13,17,21 * * *', // Every 4 hours
|
|
185
|
-
};
|
|
186
|
-
const TEST_SCHEDULE_MAP = {
|
|
187
|
-
off: '0 0 31 2 *',
|
|
188
|
-
weekly: '40 6 * * 1', // Monday 6:40am
|
|
189
|
-
daily: '40 6 * * *', // Every day 6:40am
|
|
190
|
-
hourly: '40 0,4,8,12,16,20 * * *', // Every 4 hours at :40
|
|
191
|
-
continuous: '40 * * * *', // Every hour at :40
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
// Helper: update cron in a workflow file
|
|
195
|
-
function updateWorkflowCron(path, cron, label) {
|
|
196
|
-
if (!fs.existsSync(path)) {
|
|
197
|
-
core.info(`${label}: file not found at ${path}, skipping`);
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
let content = fs.readFileSync(path, 'utf8');
|
|
201
|
-
// Remove any duplicate schedule: blocks (keep only the first)
|
|
202
|
-
const dupScheduleRegex = /(\n schedule:\n - cron: "[^"]*"\n)(\s*schedule:\n\s*- cron: "[^"]*"\n)/;
|
|
203
|
-
if (dupScheduleRegex.test(content)) {
|
|
204
|
-
content = content.replace(dupScheduleRegex, '$1');
|
|
205
|
-
core.info(`${label}: removed duplicate schedule block`);
|
|
206
|
-
}
|
|
207
|
-
const cronRegex = /- cron: "[^"]*"/;
|
|
208
|
-
if (cronRegex.test(content)) {
|
|
209
|
-
content = content.replace(cronRegex, `- cron: "${cron}"`);
|
|
210
|
-
} else {
|
|
211
|
-
const scheduleBlock = `\n schedule:\n - cron: "${cron}"\n`;
|
|
212
|
-
content = content.replace(/\non:\n/, `\non:${scheduleBlock}`);
|
|
213
|
-
}
|
|
214
|
-
fs.writeFileSync(path, content);
|
|
215
|
-
core.info(`${label}: set cron to "${cron}"`);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const workflowPath = '.github/workflows/agentic-lib-workflow.yml';
|
|
219
|
-
const initPath = '.github/workflows/agentic-lib-init.yml';
|
|
220
|
-
const testPath = '.github/workflows/agentic-lib-test.yml';
|
|
171
|
+
// Shared schedule maps and helper (single source of truth)
|
|
172
|
+
// In consumer repos: .github/agentic-lib/scripts/; in agentic-lib itself: src/scripts/
|
|
173
|
+
const scheduleUtilsPath = fs.existsSync('./.github/agentic-lib/scripts/schedule-utils.cjs')
|
|
174
|
+
? './.github/agentic-lib/scripts/schedule-utils.cjs'
|
|
175
|
+
: './src/scripts/schedule-utils.cjs';
|
|
176
|
+
const { WORKFLOW_SCHEDULE_MAP, updateAllSchedules } = require(scheduleUtilsPath);
|
|
177
|
+
const logger = { info: core.info };
|
|
221
178
|
|
|
222
179
|
const workflowCron = WORKFLOW_SCHEDULE_MAP[effectiveFrequency];
|
|
223
|
-
const initCron = INIT_SCHEDULE_MAP[effectiveFrequency];
|
|
224
|
-
const testCron = TEST_SCHEDULE_MAP[effectiveFrequency];
|
|
225
180
|
|
|
226
181
|
// Check if the frequency is already set — skip if no-op (but never skip maintenance)
|
|
182
|
+
const workflowPath = '.github/workflows/agentic-lib-workflow.yml';
|
|
227
183
|
const supervisorRegex2 = /^\s*supervisor\s*=\s*"([^"]*)"/m;
|
|
228
184
|
if (!isMaintenance && fs.existsSync(tomlPath)) {
|
|
229
185
|
const currentToml = fs.readFileSync(tomlPath, 'utf8');
|
|
@@ -242,9 +198,7 @@ jobs:
|
|
|
242
198
|
}
|
|
243
199
|
|
|
244
200
|
// Update all three workflow files proportionally
|
|
245
|
-
|
|
246
|
-
updateWorkflowCron(initPath, initCron, 'init');
|
|
247
|
-
updateWorkflowCron(testPath, testCron, 'test');
|
|
201
|
+
updateAllSchedules(effectiveFrequency, logger);
|
|
248
202
|
|
|
249
203
|
// Stamp the workflow file with current date
|
|
250
204
|
if (fs.existsSync(workflowPath)) {
|
package/bin/agentic-lib.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
// Copyright (C) 2025-2026 Polycode Limited
|
|
3
|
+
// schedule-utils.cjs — Shared schedule maps and helpers for workflow YAML updates.
|
|
4
|
+
//
|
|
5
|
+
// Used by agentic-lib-schedule.yml and agentic-lib-init.yml via:
|
|
6
|
+
// const { WORKFLOW_SCHEDULE_MAP, ... } = require('./.github/agentic-lib/scripts/schedule-utils.cjs');
|
|
7
|
+
//
|
|
8
|
+
// CRITICAL: These maps must stay in sync. That's the whole point of this file —
|
|
9
|
+
// a single source of truth for proportional schedule crons.
|
|
10
|
+
|
|
11
|
+
const fs = require("fs");
|
|
12
|
+
|
|
13
|
+
// Workflow (main pipeline) — runs most often
|
|
14
|
+
const WORKFLOW_SCHEDULE_MAP = {
|
|
15
|
+
off: "0 0 31 2 *",
|
|
16
|
+
weekly: "25 6 * * 1", // Monday 6:25am
|
|
17
|
+
daily: "25 6 * * *", // Every day 6:25am
|
|
18
|
+
hourly: "25 * * * *", // Every hour at :25
|
|
19
|
+
continuous: "5,25,45 * * * *", // Every 20 min
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Init (infrastructure updates) — runs least often
|
|
23
|
+
const INIT_SCHEDULE_MAP = {
|
|
24
|
+
off: "0 0 31 2 *",
|
|
25
|
+
weekly: "0 4 1 * *", // 1st of month 4:00am
|
|
26
|
+
daily: "0 4 * * 1", // Monday 4:00am
|
|
27
|
+
hourly: "0 4 * * *", // Every day 4:00am
|
|
28
|
+
continuous: "0 1,5,9,13,17,21 * * *", // Every 4 hours
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Test (CI health checks) — more often than init, less than workflow
|
|
32
|
+
const TEST_SCHEDULE_MAP = {
|
|
33
|
+
off: "0 0 31 2 *",
|
|
34
|
+
weekly: "40 6 * * 1", // Monday 6:40am
|
|
35
|
+
daily: "40 6 * * *", // Every day 6:40am
|
|
36
|
+
hourly: "40 0,4,8,12,16,20 * * *", // Every 4 hours at :40
|
|
37
|
+
continuous: "40 * * * *", // Every hour at :40
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Update the cron schedule in a workflow YAML file.
|
|
42
|
+
* Handles duplicate schedule: block deduplication.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} path - Path to the workflow YAML file
|
|
45
|
+
* @param {string} cron - New cron expression
|
|
46
|
+
* @param {string} label - Label for log messages
|
|
47
|
+
* @param {Object} [logger] - Logger with .info() method (defaults to console)
|
|
48
|
+
*/
|
|
49
|
+
function updateWorkflowCron(path, cron, label, logger) {
|
|
50
|
+
const log = logger || { info: console.log };
|
|
51
|
+
if (!fs.existsSync(path)) {
|
|
52
|
+
log.info(`${label}: file not found at ${path}, skipping`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let content = fs.readFileSync(path, "utf8");
|
|
56
|
+
// Remove any duplicate schedule: blocks (keep only the first)
|
|
57
|
+
const dupScheduleRegex =
|
|
58
|
+
/(\n schedule:\n - cron: "[^"]*"\n)(\s*schedule:\n\s*- cron: "[^"]*"\n)/;
|
|
59
|
+
if (dupScheduleRegex.test(content)) {
|
|
60
|
+
content = content.replace(dupScheduleRegex, "$1");
|
|
61
|
+
log.info(`${label}: removed duplicate schedule block`);
|
|
62
|
+
}
|
|
63
|
+
const cronRegex = /- cron: "[^"]*"/;
|
|
64
|
+
if (cronRegex.test(content)) {
|
|
65
|
+
content = content.replace(cronRegex, `- cron: "${cron}"`);
|
|
66
|
+
} else {
|
|
67
|
+
const scheduleBlock = `\n schedule:\n - cron: "${cron}"\n`;
|
|
68
|
+
content = content.replace(/\non:\n/, `\non:${scheduleBlock}`);
|
|
69
|
+
}
|
|
70
|
+
fs.writeFileSync(path, content);
|
|
71
|
+
log.info(`${label}: set cron to "${cron}"`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Update all three workflow crons proportionally for a given frequency.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} frequency - off | weekly | daily | hourly | continuous
|
|
78
|
+
* @param {Object} [logger] - Logger with .info() method
|
|
79
|
+
*/
|
|
80
|
+
function updateAllSchedules(frequency, logger) {
|
|
81
|
+
const workflowCron = WORKFLOW_SCHEDULE_MAP[frequency];
|
|
82
|
+
const initCron = INIT_SCHEDULE_MAP[frequency];
|
|
83
|
+
const testCron = TEST_SCHEDULE_MAP[frequency];
|
|
84
|
+
|
|
85
|
+
if (workflowCron) {
|
|
86
|
+
updateWorkflowCron(
|
|
87
|
+
".github/workflows/agentic-lib-workflow.yml",
|
|
88
|
+
workflowCron,
|
|
89
|
+
"workflow",
|
|
90
|
+
logger,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (initCron) {
|
|
94
|
+
updateWorkflowCron(
|
|
95
|
+
".github/workflows/agentic-lib-init.yml",
|
|
96
|
+
initCron,
|
|
97
|
+
"init",
|
|
98
|
+
logger,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
if (testCron) {
|
|
102
|
+
updateWorkflowCron(
|
|
103
|
+
".github/workflows/agentic-lib-test.yml",
|
|
104
|
+
testCron,
|
|
105
|
+
"test",
|
|
106
|
+
logger,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
module.exports = {
|
|
112
|
+
WORKFLOW_SCHEDULE_MAP,
|
|
113
|
+
INIT_SCHEDULE_MAP,
|
|
114
|
+
TEST_SCHEDULE_MAP,
|
|
115
|
+
updateWorkflowCron,
|
|
116
|
+
updateAllSchedules,
|
|
117
|
+
};
|