@artemiskit/reports 0.2.3 → 0.3.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/dist/index.d.ts CHANGED
@@ -8,4 +8,5 @@ export { generateRedTeamHTMLReport } from './html/redteam-generator';
8
8
  export { generateStressHTMLReport } from './html/stress-generator';
9
9
  export { generateCompareHTMLReport, buildComparisonData, type ComparisonData, type CaseComparison, } from './html/compare-generator';
10
10
  export { generateMarkdownReport, generateRedTeamMarkdownReport, type MarkdownReportOptions, } from './markdown/generator';
11
+ export { generateJUnitReport, generateRedTeamJUnitReport, generateValidationJUnitReport, type JUnitReportOptions, } from './junit/generator';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAGnE,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,6BAA6B,EAC7B,KAAK,kBAAkB,GACxB,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -4,15 +4,29 @@ var __getProtoOf = Object.getPrototypeOf;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
7
12
  var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
8
20
  target = mod != null ? __create(__getProtoOf(mod)) : {};
9
21
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
22
  for (let key of __getOwnPropNames(mod))
11
23
  if (!__hasOwnProp.call(to, key))
12
24
  __defProp(to, key, {
13
- get: () => mod[key],
25
+ get: __accessProp.bind(mod, key),
14
26
  enumerable: true
15
27
  });
28
+ if (canCache)
29
+ cache.set(mod, to);
16
30
  return to;
17
31
  };
18
32
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
@@ -54,7 +68,7 @@ var require_utils = __commonJS((exports) => {
54
68
  }
55
69
  var toString = Object.prototype.toString;
56
70
  exports.toString = toString;
57
- var isFunction = function isFunction(value) {
71
+ var isFunction = function isFunction2(value) {
58
72
  return typeof value === "function";
59
73
  };
60
74
  if (isFunction(/x/)) {
@@ -708,7 +722,7 @@ var require_wrapHelper = __commonJS((exports) => {
708
722
  if (typeof helper !== "function") {
709
723
  return helper;
710
724
  }
711
- var wrapper = function wrapper() {
725
+ var wrapper = function wrapper2() {
712
726
  var options = arguments[arguments.length - 1];
713
727
  arguments[arguments.length - 1] = transformOptionsFn(options);
714
728
  return helper.apply(this, arguments);
@@ -2372,7 +2386,7 @@ var require_compiler = __commonJS((exports) => {
2372
2386
  return true;
2373
2387
  },
2374
2388
  guid: 0,
2375
- compile: function compile(program, options) {
2389
+ compile: function compile2(program, options) {
2376
2390
  this.sourceNode = [];
2377
2391
  this.opcodes = [];
2378
2392
  this.children = [];
@@ -8165,11 +8179,202 @@ function generateRedTeamMarkdownReport(manifest, options = {}) {
8165
8179
  return lines.join(`
8166
8180
  `);
8167
8181
  }
8182
+ // src/junit/generator.ts
8183
+ function escapeXml(str) {
8184
+ const invalidXmlChars = /[\x00-\x08\x0B\x0C\x0E-\x1F]/g;
8185
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;").replace(invalidXmlChars, "");
8186
+ }
8187
+ function truncate2(text, maxLength) {
8188
+ if (text.length <= maxLength)
8189
+ return text;
8190
+ return `${text.slice(0, maxLength)}...(truncated)`;
8191
+ }
8192
+ function formatTimestamp(dateStr) {
8193
+ return new Date(dateStr).toISOString();
8194
+ }
8195
+ function generateJUnitReport(manifest, options = {}) {
8196
+ const {
8197
+ suiteName = manifest.config.scenario,
8198
+ includeSystemOut = true,
8199
+ includeSystemErr = true,
8200
+ maxOutputLength = 2000
8201
+ } = options;
8202
+ const lines = [];
8203
+ lines.push('<?xml version="1.0" encoding="UTF-8"?>');
8204
+ const tests = manifest.metrics.total_cases;
8205
+ const failures = manifest.metrics.failed_cases;
8206
+ const errors = 0;
8207
+ const skipped = 0;
8208
+ const time = manifest.duration_ms / 1000;
8209
+ lines.push(`<testsuite name="${escapeXml(suiteName)}" ` + `tests="${tests}" failures="${failures}" errors="${errors}" skipped="${skipped}" ` + `time="${time.toFixed(3)}" timestamp="${formatTimestamp(manifest.start_time)}">`);
8210
+ lines.push(" <properties>");
8211
+ lines.push(` <property name="artemis.run_id" value="${escapeXml(manifest.run_id)}" />`);
8212
+ lines.push(` <property name="artemis.version" value="${escapeXml(manifest.version)}" />`);
8213
+ lines.push(` <property name="artemis.provider" value="${escapeXml(manifest.config.provider)}" />`);
8214
+ if (manifest.config.model) {
8215
+ lines.push(` <property name="artemis.model" value="${escapeXml(manifest.config.model)}" />`);
8216
+ }
8217
+ lines.push(` <property name="artemis.success_rate" value="${(manifest.metrics.success_rate * 100).toFixed(1)}%" />`);
8218
+ lines.push(` <property name="artemis.total_tokens" value="${manifest.metrics.total_tokens}" />`);
8219
+ if (manifest.metrics.cost) {
8220
+ lines.push(` <property name="artemis.cost_usd" value="${manifest.metrics.cost.total_usd.toFixed(6)}" />`);
8221
+ }
8222
+ lines.push(" </properties>");
8223
+ for (const testCase of manifest.cases) {
8224
+ const className = escapeXml(suiteName);
8225
+ const testName = escapeXml(testCase.id);
8226
+ const testTime = testCase.latencyMs / 1000;
8227
+ lines.push(` <testcase classname="${className}" name="${testName}" time="${testTime.toFixed(3)}">`);
8228
+ if (!testCase.ok) {
8229
+ const failureMessage = escapeXml(testCase.reason || "Test failed");
8230
+ const failureType = escapeXml(testCase.matcherType);
8231
+ lines.push(` <failure message="${failureMessage}" type="${failureType}">`);
8232
+ const details = [];
8233
+ details.push(`Matcher Type: ${testCase.matcherType}`);
8234
+ details.push(`Expected: ${JSON.stringify(testCase.expected, null, 2)}`);
8235
+ details.push(`Score: ${(testCase.score * 100).toFixed(1)}%`);
8236
+ if (testCase.reason) {
8237
+ details.push(`Reason: ${testCase.reason}`);
8238
+ }
8239
+ lines.push(escapeXml(details.join(`
8240
+ `)));
8241
+ lines.push(" </failure>");
8242
+ }
8243
+ if (includeSystemOut && testCase.response) {
8244
+ lines.push(" <system-out>");
8245
+ lines.push(`<![CDATA[${truncate2(testCase.response, maxOutputLength)}]]>`);
8246
+ lines.push(" </system-out>");
8247
+ }
8248
+ if (includeSystemErr && !testCase.ok && testCase.reason) {
8249
+ lines.push(" <system-err>");
8250
+ const errorDetails = [];
8251
+ errorDetails.push(`Error: ${testCase.reason}`);
8252
+ const promptStr = typeof testCase.prompt === "string" ? testCase.prompt : JSON.stringify(testCase.prompt);
8253
+ errorDetails.push(`Prompt: ${truncate2(promptStr, maxOutputLength / 2)}`);
8254
+ lines.push(`<![CDATA[${errorDetails.join(`
8255
+ `)}]]>`);
8256
+ lines.push(" </system-err>");
8257
+ }
8258
+ lines.push(" </testcase>");
8259
+ }
8260
+ lines.push("</testsuite>");
8261
+ return lines.join(`
8262
+ `);
8263
+ }
8264
+ function generateRedTeamJUnitReport(manifest, options = {}) {
8265
+ const {
8266
+ suiteName = `RedTeam: ${manifest.config.scenario}`,
8267
+ includeSystemOut = true,
8268
+ includeSystemErr = true,
8269
+ maxOutputLength = 2000
8270
+ } = options;
8271
+ const lines = [];
8272
+ lines.push('<?xml version="1.0" encoding="UTF-8"?>');
8273
+ const tests = manifest.metrics.total_tests;
8274
+ const failures = manifest.metrics.unsafe_responses;
8275
+ const errors = manifest.metrics.error_responses;
8276
+ const skipped = 0;
8277
+ const time = manifest.duration_ms / 1000;
8278
+ lines.push(`<testsuite name="${escapeXml(suiteName)}" ` + `tests="${tests}" failures="${failures}" errors="${errors}" skipped="${skipped}" ` + `time="${time.toFixed(3)}" timestamp="${formatTimestamp(manifest.start_time)}">`);
8279
+ lines.push(" <properties>");
8280
+ lines.push(` <property name="artemis.run_id" value="${escapeXml(manifest.run_id)}" />`);
8281
+ lines.push(` <property name="artemis.version" value="${escapeXml(manifest.version)}" />`);
8282
+ lines.push(` <property name="artemis.test_type" value="redteam" />`);
8283
+ lines.push(` <property name="artemis.defense_rate" value="${(manifest.metrics.defense_rate * 100).toFixed(1)}%" />`);
8284
+ lines.push(` <property name="artemis.safe_responses" value="${manifest.metrics.safe_responses}" />`);
8285
+ lines.push(` <property name="artemis.blocked_responses" value="${manifest.metrics.blocked_responses}" />`);
8286
+ lines.push(` <property name="artemis.unsafe_responses" value="${manifest.metrics.unsafe_responses}" />`);
8287
+ lines.push(" </properties>");
8288
+ for (const result of manifest.results) {
8289
+ const className = escapeXml(suiteName);
8290
+ const testName = escapeXml(`${result.caseId} (${result.mutation})`);
8291
+ const testTime = (result.latencyMs || 0) / 1000;
8292
+ lines.push(` <testcase classname="${className}" name="${testName}" time="${testTime.toFixed(3)}">`);
8293
+ if (result.status === "unsafe") {
8294
+ const failureMessage = escapeXml(`Security vulnerability: ${result.mutation}`);
8295
+ const failureType = escapeXml(`severity:${result.severity}`);
8296
+ lines.push(` <failure message="${failureMessage}" type="${failureType}">`);
8297
+ const details = [];
8298
+ details.push(`Severity: ${result.severity.toUpperCase()}`);
8299
+ details.push(`Mutation: ${result.mutation}`);
8300
+ if (result.reasons.length > 0) {
8301
+ details.push(`Reasons: ${result.reasons.join(", ")}`);
8302
+ }
8303
+ lines.push(escapeXml(details.join(`
8304
+ `)));
8305
+ lines.push(" </failure>");
8306
+ } else if (result.status === "error") {
8307
+ lines.push(` <error message="${escapeXml(result.response || "Error during test")}" type="error">`);
8308
+ lines.push(escapeXml(`Attack: ${result.mutation}
8309
+ Case: ${result.caseId}`));
8310
+ lines.push(" </error>");
8311
+ }
8312
+ if (includeSystemOut && result.response) {
8313
+ lines.push(" <system-out>");
8314
+ lines.push(`<![CDATA[${truncate2(result.response, maxOutputLength)}]]>`);
8315
+ lines.push(" </system-out>");
8316
+ }
8317
+ if (includeSystemErr && result.status === "unsafe") {
8318
+ lines.push(" <system-err>");
8319
+ const errDetails = [];
8320
+ errDetails.push(`Attack Prompt: ${truncate2(result.prompt, maxOutputLength / 2)}`);
8321
+ errDetails.push(`Severity: ${result.severity.toUpperCase()}`);
8322
+ lines.push(`<![CDATA[${errDetails.join(`
8323
+ `)}]]>`);
8324
+ lines.push(" </system-err>");
8325
+ }
8326
+ lines.push(" </testcase>");
8327
+ }
8328
+ lines.push("</testsuite>");
8329
+ return lines.join(`
8330
+ `);
8331
+ }
8332
+ function generateValidationJUnitReport(results, options = {}) {
8333
+ const { suiteName = "ArtemisKit Validation" } = options;
8334
+ const lines = [];
8335
+ lines.push('<?xml version="1.0" encoding="UTF-8"?>');
8336
+ const tests = results.length;
8337
+ const failures = results.filter((r) => !r.valid).length;
8338
+ const errors = 0;
8339
+ const skipped = 0;
8340
+ lines.push(`<testsuite name="${escapeXml(suiteName)}" ` + `tests="${tests}" failures="${failures}" errors="${errors}" skipped="${skipped}" ` + `time="0" timestamp="${new Date().toISOString()}">`);
8341
+ for (const result of results) {
8342
+ const className = escapeXml(suiteName);
8343
+ const testName = escapeXml(result.file);
8344
+ lines.push(` <testcase classname="${className}" name="${testName}" time="0">`);
8345
+ if (!result.valid) {
8346
+ const errorMessages = result.errors.map((e) => `Line ${e.line}: ${e.message}`).join("; ");
8347
+ lines.push(` <failure message="${escapeXml(errorMessages)}" type="validation">`);
8348
+ const details = [];
8349
+ for (const error of result.errors) {
8350
+ details.push(`[${error.rule}] Line ${error.line}: ${error.message}`);
8351
+ }
8352
+ lines.push(escapeXml(details.join(`
8353
+ `)));
8354
+ lines.push(" </failure>");
8355
+ }
8356
+ if (result.warnings.length > 0) {
8357
+ lines.push(" <system-err>");
8358
+ const warningDetails = result.warnings.map((w) => `[${w.rule}] Line ${w.line}: ${w.message}`).join(`
8359
+ `);
8360
+ lines.push(`<![CDATA[Warnings:
8361
+ ${warningDetails}]]>`);
8362
+ lines.push(" </system-err>");
8363
+ }
8364
+ lines.push(" </testcase>");
8365
+ }
8366
+ lines.push("</testsuite>");
8367
+ return lines.join(`
8368
+ `);
8369
+ }
8168
8370
  export {
8371
+ generateValidationJUnitReport,
8169
8372
  generateStressHTMLReport,
8170
8373
  generateRedTeamMarkdownReport,
8374
+ generateRedTeamJUnitReport,
8171
8375
  generateRedTeamHTMLReport,
8172
8376
  generateMarkdownReport,
8377
+ generateJUnitReport,
8173
8378
  generateJSONReport,
8174
8379
  generateHTMLReport,
8175
8380
  generateCompareHTMLReport,
@@ -0,0 +1,44 @@
1
+ /**
2
+ * JUnit XML Report Generator
3
+ *
4
+ * Generates JUnit-compatible XML reports for CI/CD integration.
5
+ * Follows the JUnit XML format specification for compatibility with
6
+ * Jenkins, GitHub Actions, GitLab CI, and other CI systems.
7
+ */
8
+ import type { RedTeamManifest, RunManifest } from '@artemiskit/core';
9
+ export interface JUnitReportOptions {
10
+ /** Test suite name (defaults to scenario name) */
11
+ suiteName?: string;
12
+ /** Include system-out with response content */
13
+ includeSystemOut?: boolean;
14
+ /** Include system-err with error details */
15
+ includeSystemErr?: boolean;
16
+ /** Maximum content length for outputs */
17
+ maxOutputLength?: number;
18
+ }
19
+ /**
20
+ * Generate JUnit XML report for a standard run
21
+ */
22
+ export declare function generateJUnitReport(manifest: RunManifest, options?: JUnitReportOptions): string;
23
+ /**
24
+ * Generate JUnit XML report for red team results
25
+ */
26
+ export declare function generateRedTeamJUnitReport(manifest: RedTeamManifest, options?: JUnitReportOptions): string;
27
+ /**
28
+ * Generate JUnit XML for validation results
29
+ */
30
+ export declare function generateValidationJUnitReport(results: Array<{
31
+ file: string;
32
+ valid: boolean;
33
+ errors: Array<{
34
+ line: number;
35
+ message: string;
36
+ rule: string;
37
+ }>;
38
+ warnings: Array<{
39
+ line: number;
40
+ message: string;
41
+ rule: string;
42
+ }>;
43
+ }>, options?: JUnitReportOptions): string;
44
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/junit/generator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAErE,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,4CAA4C;IAC5C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yCAAyC;IACzC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAmCD;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,WAAW,EACrB,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CA0GR;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,eAAe,EACzB,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CAyGR;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/D,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClE,CAAC,EACF,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CAyDR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artemiskit/reports",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "HTML report generation for ArtemisKit LLM evaluation toolkit",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -30,7 +30,7 @@
30
30
  "test": "bun test"
31
31
  },
32
32
  "dependencies": {
33
- "@artemiskit/core": "0.2.3",
33
+ "@artemiskit/core": "0.3.0",
34
34
  "handlebars": "^4.7.8"
35
35
  },
36
36
  "devDependencies": {
package/src/index.ts CHANGED
@@ -27,3 +27,11 @@ export {
27
27
  generateRedTeamMarkdownReport,
28
28
  type MarkdownReportOptions,
29
29
  } from './markdown/generator';
30
+
31
+ // JUnit XML reports (CI integration)
32
+ export {
33
+ generateJUnitReport,
34
+ generateRedTeamJUnitReport,
35
+ generateValidationJUnitReport,
36
+ type JUnitReportOptions,
37
+ } from './junit/generator';