@allurereport/plugin-agent 3.20.0 → 3.21.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/README.md CHANGED
@@ -158,7 +158,7 @@ npx allure agent \
158
158
  ```
159
159
 
160
160
  That command uses the default `--report auto` policy. Configured presentation or
161
- export plugins such as Dashboard or TestOps are otherwise ignored for agent runs
161
+ export plugins such as Dashboard or Allure TestOps are otherwise ignored for agent runs
162
162
  unless you explicitly use `--report config`.
163
163
 
164
164
  ## Options
@@ -0,0 +1,3 @@
1
+ import type { TestLabel } from "@allurereport/core-api";
2
+ import type { AgentLabelFilter } from "./selection.js";
3
+ export declare const matchesLabelFilters: (labels: TestLabel[], filters: AgentLabelFilter[]) => boolean;
@@ -0,0 +1 @@
1
+ export const matchesLabelFilters = (labels, filters) => filters.every((filter) => labels.some((label) => label.name === filter.name && label.value === filter.value));
@@ -0,0 +1,10 @@
1
+ type FindingWithSubject = {
2
+ subject_ref?: string;
3
+ subject: string | {
4
+ type: string;
5
+ id?: string;
6
+ path?: string;
7
+ };
8
+ };
9
+ export declare const findingSubjectRef: (finding: FindingWithSubject) => string;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ export const findingSubjectRef = (finding) => {
2
+ if (finding.subject_ref) {
3
+ return finding.subject_ref;
4
+ }
5
+ if (typeof finding.subject === "string") {
6
+ return finding.subject;
7
+ }
8
+ return finding.subject.path ?? finding.subject.id ?? finding.subject.type;
9
+ };
package/dist/harness.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { join, resolve } from "node:path";
3
3
  import { AgentUsageError } from "./errors.js";
4
+ import { findingSubjectRef } from "./findings.js";
4
5
  import { ENRICHMENT_ACTIONS_BY_CHECK_NAME } from "./guidance.js";
5
6
  import { isPathInside } from "./paths.js";
6
7
  import { isFileNotFoundError } from "./utils.js";
@@ -48,19 +49,10 @@ const IMPACT_ORDER = {
48
49
  };
49
50
  const uniqueValues = (values) => Array.from(new Set(values));
50
51
  const checkNameForFinding = (finding) => finding.check_id ?? finding.check_name;
51
- const subjectRefForFinding = (finding) => {
52
- if (finding.subject_ref) {
53
- return finding.subject_ref;
54
- }
55
- if (typeof finding.subject === "string") {
56
- return finding.subject;
57
- }
58
- return finding.subject.path ?? finding.subject.id ?? finding.subject.type;
59
- };
60
52
  const subjectTypeForFinding = (finding) => finding.subject_type ??
61
53
  (typeof finding.subject === "object" && finding.subject.type === "test"
62
54
  ? "test"
63
- : subjectRefForFinding(finding) === "run"
55
+ : findingSubjectRef(finding) === "run"
64
56
  ? "run"
65
57
  : "test");
66
58
  const normalizeStringArray = (value) => {
@@ -241,7 +233,7 @@ export const planAgentEnrichmentReview = (output, options = {}) => {
241
233
  const testsByPath = new Map(output.tests.map((test) => [test.markdown_path, test]));
242
234
  const plan = sortPlan(output.findings.map((finding) => {
243
235
  const action = mapFindingToEnrichmentAction(finding);
244
- const subject = subjectRefForFinding(finding);
236
+ const subject = findingSubjectRef(finding);
245
237
  const matchedTest = testsByPath.get(subject);
246
238
  return {
247
239
  ...action,
package/dist/query.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { AgentUsageError } from "./errors.js";
4
+ import { matchesLabelFilters } from "./filters.js";
5
+ import { findingSubjectRef } from "./findings.js";
4
6
  import { isPathInside } from "./paths.js";
5
7
  export const AGENT_QUERY_SCHEMA = "allure-agent-query/v1";
6
8
  export const AGENT_QUERY_VIEWS = ["summary", "tests", "findings", "test"];
@@ -52,20 +54,10 @@ export const normalizeAgentQueryLimit = (value) => {
52
54
  }
53
55
  return parsed;
54
56
  };
55
- const matchesLabelFilters = (labels, filters) => filters.every((filter) => labels.some((label) => label.name === filter.name && label.value === filter.value));
56
57
  const matchesAgentTestIdentifier = (test, identifier) => test.full_name === identifier ||
57
58
  test.test_result_id === identifier ||
58
59
  test.retry_hash === identifier ||
59
60
  test.markdown_path === identifier;
60
- const agentFindingSubjectRef = (finding) => {
61
- if (finding.subject_ref) {
62
- return finding.subject_ref;
63
- }
64
- if (typeof finding.subject === "string") {
65
- return finding.subject;
66
- }
67
- return finding.subject.path ?? finding.subject.id ?? finding.subject.type;
68
- };
69
61
  const agentFindingCheckName = (finding) => finding.check_id ?? finding.check_name;
70
62
  const filterAgentQueryTests = (tests, filters) => tests
71
63
  .filter((test) => (filters.statuses?.length ? filters.statuses.includes(test.status) : true))
@@ -78,7 +70,7 @@ const filterAgentQueryFindings = (output, filters) => {
78
70
  ? new Set(filterAgentQueryTests(output.tests, filters).map((test) => test.markdown_path))
79
71
  : undefined;
80
72
  return output.findings
81
- .filter((finding) => (matchedSubjects ? matchedSubjects.has(agentFindingSubjectRef(finding)) : true))
73
+ .filter((finding) => (matchedSubjects ? matchedSubjects.has(findingSubjectRef(finding)) : true))
82
74
  .filter((finding) => (filters.severities?.length ? filters.severities.includes(finding.severity) : true))
83
75
  .filter((finding) => (filters.categories?.length ? filters.categories.includes(finding.category) : true))
84
76
  .filter((finding) => (filters.checks?.length ? filters.checks.includes(agentFindingCheckName(finding)) : true));
@@ -159,7 +151,7 @@ const buildAgentQueryTestPayload = async (output, filters) => {
159
151
  }
160
152
  const test = matched[0];
161
153
  const markdownPath = resolveAgentOutputPath(output, test.markdown_path);
162
- const findings = output.findings.filter((finding) => agentFindingSubjectRef(finding) === test.markdown_path);
154
+ const findings = output.findings.filter((finding) => findingSubjectRef(finding) === test.markdown_path);
163
155
  let markdown;
164
156
  if (filters.includeMarkdown && markdownPath) {
165
157
  try {
package/dist/selection.js CHANGED
@@ -2,13 +2,13 @@ import { mkdtemp, rm, writeFile } from "node:fs/promises";
2
2
  import { tmpdir } from "node:os";
3
3
  import { join, resolve } from "node:path";
4
4
  import { AgentUsageError } from "./errors.js";
5
+ import { matchesLabelFilters } from "./filters.js";
5
6
  import { loadAgentOutput, planAgentEnrichmentReview, } from "./harness.js";
6
7
  import { readLatestAgentState } from "./state.js";
7
8
  export const AGENT_RERUN_PRESETS = ["review", "failed", "unsuccessful", "all"];
8
9
  const ALLURE_ID_LABEL = "ALLURE_ID";
9
10
  const isAgentRerunPreset = (value) => AGENT_RERUN_PRESETS.includes(value);
10
11
  const readAllureId = (labels) => labels.find((label) => label.name === ALLURE_ID_LABEL)?.value;
11
- const matchesLabelFilters = (labels, filters) => filters.every((filter) => labels.some((label) => label.name === filter.name && label.value === filter.value));
12
12
  const buildTestPlan = (tests) => {
13
13
  const seenSelectors = new Set();
14
14
  const seenIds = new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/plugin-agent",
3
- "version": "3.20.0",
3
+ "version": "3.21.0",
4
4
  "description": "Allure Agent Plugin – AI-friendly markdown report generator",
5
5
  "keywords": [
6
6
  "agent",
@@ -27,17 +27,20 @@
27
27
  "build": "run clean && tsc --project ./tsconfig.json",
28
28
  "clean": "rimraf ./dist",
29
29
  "test": "rimraf ./out && vitest run",
30
+ "test:unit": "yarn test",
30
31
  "lint": "yarn run -T oxlint --import-plugin src test features stories",
31
32
  "lint:fix": "yarn run -T oxlint --import-plugin --fix src test features stories"
32
33
  },
33
34
  "dependencies": {
34
- "@allurereport/core-api": "3.20.0",
35
- "@allurereport/plugin-api": "3.20.0",
36
- "yaml": "^2.8.1"
35
+ "@allurereport/core-api": "3.21.0",
36
+ "@allurereport/plugin-api": "3.21.0",
37
+ "yaml": "^2.9.1"
37
38
  },
38
39
  "devDependencies": {
39
- "@allurereport/reader-api": "3.20.0",
40
+ "@allurereport/reader-api": "3.21.0",
41
+ "@allurereport/test-config": "3.21.0",
40
42
  "@types/node": "^20",
43
+ "@vitest/coverage-istanbul": "^4.1.0",
41
44
  "@vitest/runner": "^2",
42
45
  "allure-js-commons": "^3",
43
46
  "allure-vitest": "^3",