@xn-intenton-z2a/agentic-lib 7.2.10 → 7.2.11

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.
@@ -555,6 +555,7 @@ function initScripts(agenticDir) {
555
555
  const DISTRIBUTED_SCRIPTS = [
556
556
  "accept-release.sh",
557
557
  "activate-schedule.sh",
558
+ "build-web.cjs",
558
559
  "clean.sh",
559
560
  "initialise.sh",
560
561
  "md-to-html.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xn-intenton-z2a/agentic-lib",
3
- "version": "7.2.10",
3
+ "version": "7.2.11",
4
4
  "description": "Agentic-lib Agentic Coding Systems SDK powering automated GitHub workflows.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (C) 2025-2026 Polycode Limited
4
+ // scripts/build-web.cjs
5
+ // Usage: node .github/agentic-lib/scripts/build-web.cjs
6
+ //
7
+ // Builds the docs/ directory for web serving:
8
+ // 1. Creates docs/ and copies src/web/* into it
9
+ // 2. Generates docs/lib-meta.js with package metadata exports
10
+ // 3. Generates docs/lib-browser.js from src/lib/main.js (if it has named exports)
11
+ //
12
+ // This file is part of the Example Suite for `agentic-lib` see: https://github.com/xn-intenton-z2a/agentic-lib
13
+ // This file is licensed under the MIT License. For details, see LICENSE-MIT
14
+
15
+ const fs = require("fs");
16
+ const path = require("path");
17
+
18
+ const docsDir = path.resolve("docs");
19
+
20
+ // Step 1: Create docs/ and copy src/web/* if it exists
21
+ fs.mkdirSync(docsDir, { recursive: true });
22
+ fs.writeFileSync(path.join(docsDir, ".nojekyll"), "");
23
+
24
+ const webDir = path.resolve("src", "web");
25
+ if (fs.existsSync(webDir)) {
26
+ for (const entry of fs.readdirSync(webDir, { withFileTypes: true })) {
27
+ const src = path.join(webDir, entry.name);
28
+ const dest = path.join(docsDir, entry.name);
29
+ if (entry.isFile()) {
30
+ fs.copyFileSync(src, dest);
31
+ } else if (entry.isDirectory()) {
32
+ fs.cpSync(src, dest, { recursive: true });
33
+ }
34
+ }
35
+ }
36
+
37
+ // Step 2: Generate docs/lib-meta.js with package metadata
38
+ const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"));
39
+ const metaLines = ["name", "version", "description"].map(
40
+ (k) => `export const ${k} = ${JSON.stringify(pkg[k])};`
41
+ );
42
+ fs.writeFileSync(path.join(docsDir, "lib-meta.js"), metaLines.join("\n") + "\n");
43
+ console.log("Wrote docs/lib-meta.js");
44
+
45
+ // Step 3: Generate docs/lib-browser.js from src/lib/main.js named exports
46
+ // Parse the main module for `export function` and `export async function` declarations
47
+ // and re-emit them as a standalone browser-compatible module.
48
+ const mainPath = path.resolve("src", "lib", "main.js");
49
+ if (fs.existsSync(mainPath)) {
50
+ const mainSrc = fs.readFileSync(mainPath, "utf8");
51
+ // Match named export functions: export function foo(...) { ... } or export async function foo(...)
52
+ const exportRegex = /^export\s+(async\s+)?function\s+(\w+)/gm;
53
+ const exportNames = [];
54
+ let match;
55
+ while ((match = exportRegex.exec(mainSrc)) !== null) {
56
+ exportNames.push(match[2]);
57
+ }
58
+
59
+ if (exportNames.length > 0) {
60
+ // Extract the function bodies by finding each export function and copying it verbatim
61
+ const lines = mainSrc.split("\n");
62
+ const functionBodies = [];
63
+ for (let i = 0; i < lines.length; i++) {
64
+ if (/^export\s+(async\s+)?function\s+\w+/.test(lines[i])) {
65
+ // Collect lines until we find the closing brace at column 0
66
+ const fnLines = [lines[i]];
67
+ let braceDepth = 0;
68
+ for (let j = i; j < lines.length; j++) {
69
+ for (const ch of lines[j]) {
70
+ if (ch === "{") braceDepth++;
71
+ if (ch === "}") braceDepth--;
72
+ }
73
+ if (j > i) fnLines.push(lines[j]);
74
+ if (braceDepth === 0 && j >= i) {
75
+ break;
76
+ }
77
+ }
78
+ functionBodies.push(fnLines.join("\n"));
79
+ }
80
+ }
81
+
82
+ const header = [
83
+ "// docs/lib-browser.js",
84
+ "// Generated browser-compatible module exposing named exports from src/lib/main.js.",
85
+ "// Auto-generated by build-web.cjs — do not edit manually.",
86
+ "",
87
+ ].join("\n");
88
+
89
+ fs.writeFileSync(
90
+ path.join(docsDir, "lib-browser.js"),
91
+ header + functionBodies.join("\n\n") + "\n"
92
+ );
93
+ console.log(
94
+ `Wrote docs/lib-browser.js (${exportNames.length} exports: ${exportNames.join(", ")})`
95
+ );
96
+ }
97
+ }
@@ -6,7 +6,7 @@
6
6
  "main": "src/lib/main.js",
7
7
  "scripts": {
8
8
  "build": "npm run build:web",
9
- "build:web": "mkdir -p docs && touch docs/.nojekyll && cp -r src/web/* docs/ 2>/dev/null || true && node --input-type=commonjs -p \"var p=require('./package.json');['name','version','description'].map(function(k){return 'export const '+k+' = '+JSON.stringify(p[k])+';'}).join('\\n')\" > docs/lib-meta.js",
9
+ "build:web": "node .github/agentic-lib/scripts/build-web.cjs",
10
10
  "test": "vitest --run tests/unit/*.test.js",
11
11
  "test:unit": "vitest --run --coverage tests/unit/*.test.js",
12
12
  "test:behaviour": "npm run build:web && npx playwright test --config playwright.config.js",
@@ -17,7 +17,7 @@
17
17
  "author": "",
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
- "@xn-intenton-z2a/agentic-lib": "^7.2.10"
20
+ "@xn-intenton-z2a/agentic-lib": "^7.2.11"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@playwright/test": "^1.58.0",