@xn-intenton-z2a/agentic-lib 7.4.34 → 7.4.35

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,16 @@ jobs:
296
296
  }
297
297
  if (!model) model = 'gpt-5-mini';
298
298
 
299
- // Problem 4 fix: Use "never fires" cron for off instead of removing the block
300
- const SCHEDULE_MAP = {
301
- off: '0 0 31 2 *',
302
- weekly: '25 6 * * 1',
303
- daily: '25 6 * * *',
304
- hourly: '25 * * * *',
305
- continuous: '5,25,45 * * * *',
306
- };
299
+ // Shared schedule maps and helper (single source of truth)
300
+ const { updateAllSchedules } = require('./.github/agentic-lib/scripts/schedule-utils.cjs');
301
+ const logger = { info: core.info };
307
302
 
303
+ // Update all three workflow files proportionally
304
+ updateAllSchedules(frequency, logger);
305
+
306
+ // Stamp the workflow file with current date
308
307
  if (fs.existsSync(workflowPath)) {
309
308
  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
309
  const dateStamp = `# Schedule updated: ${new Date().toISOString()}`;
320
310
  const stampRegex = /^# Schedule updated: .*/m;
321
311
  if (stampRegex.test(content)) {
@@ -324,8 +314,8 @@ jobs:
324
314
  content = content.replace(/^(# .*\n)+/m, (match) => match + dateStamp + '\n');
325
315
  }
326
316
  fs.writeFileSync(workflowPath, content);
327
- core.info(`Updated schedule to: ${frequency}`);
328
317
  }
318
+ core.info(`Updated proportional schedules to: ${frequency}`);
329
319
 
330
320
  if (fs.existsSync(tomlPath)) {
331
321
  let toml = fs.readFileSync(tomlPath, 'utf8');
@@ -168,62 +168,14 @@ jobs:
168
168
  const isMaintenance = frequency === 'maintenance';
169
169
  const effectiveFrequency = isMaintenance ? 'weekly' : frequency;
170
170
 
171
- // Proportional schedule maps for each workflow
172
- const WORKFLOW_SCHEDULE_MAP = {
173
- off: '0 0 31 2 *',
174
- weekly: '25 6 * * 1', // Monday 6:25am
175
- daily: '25 6 * * *', // Every day 6:25am
176
- hourly: '25 * * * *', // Every hour at :25
177
- continuous: '5,25,45 * * * *', // Every 20 min
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
+ const { WORKFLOW_SCHEDULE_MAP, updateAllSchedules } = require('./.github/agentic-lib/scripts/schedule-utils.cjs');
173
+ const logger = { info: core.info };
221
174
 
222
175
  const workflowCron = WORKFLOW_SCHEDULE_MAP[effectiveFrequency];
223
- const initCron = INIT_SCHEDULE_MAP[effectiveFrequency];
224
- const testCron = TEST_SCHEDULE_MAP[effectiveFrequency];
225
176
 
226
177
  // Check if the frequency is already set — skip if no-op (but never skip maintenance)
178
+ const workflowPath = '.github/workflows/agentic-lib-workflow.yml';
227
179
  const supervisorRegex2 = /^\s*supervisor\s*=\s*"([^"]*)"/m;
228
180
  if (!isMaintenance && fs.existsSync(tomlPath)) {
229
181
  const currentToml = fs.readFileSync(tomlPath, 'utf8');
@@ -242,9 +194,7 @@ jobs:
242
194
  }
243
195
 
244
196
  // Update all three workflow files proportionally
245
- updateWorkflowCron(workflowPath, workflowCron, 'workflow');
246
- updateWorkflowCron(initPath, initCron, 'init');
247
- updateWorkflowCron(testPath, testCron, 'test');
197
+ updateAllSchedules(effectiveFrequency, logger);
248
198
 
249
199
  // Stamp the workflow file with current date
250
200
  if (fs.existsSync(workflowPath)) {
@@ -589,6 +589,7 @@ function initScripts(agenticDir) {
589
589
  "initialise.sh",
590
590
  "md-to-html.js",
591
591
  "push-to-logs.sh",
592
+ "schedule-utils.cjs",
592
593
  "update.sh",
593
594
  ];
594
595
  if (!existsSync(scriptsDir)) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xn-intenton-z2a/agentic-lib",
3
- "version": "7.4.34",
3
+ "version": "7.4.35",
4
4
  "description": "Agentic-lib Agentic Coding Systems SDK powering automated GitHub workflows.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -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
+ };
@@ -17,7 +17,7 @@
17
17
  "author": "",
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
- "@xn-intenton-z2a/agentic-lib": "^7.4.34"
20
+ "@xn-intenton-z2a/agentic-lib": "^7.4.35"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@playwright/test": "^1.58.0",