next-issue 6.6.43 → 6.6.44

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.
Files changed (2) hide show
  1. package/dist/verdict.mjs +33 -6
  2. package/package.json +1 -1
package/dist/verdict.mjs CHANGED
@@ -31,18 +31,45 @@ export function readVerdict(value) {
31
31
  }
32
32
  return { summary, findings: checked };
33
33
  }
34
- const JSON_BLOCK = /```json[^\n]*\n([\s\S]*?)```/g;
34
+ const JSON_FENCE = /```json[^\n]*\n/g;
35
+ const FENCE = '```';
36
+ function parseJson(text) {
37
+ try {
38
+ return { value: JSON.parse(text) };
39
+ }
40
+ catch {
41
+ return undefined;
42
+ }
43
+ }
35
44
  export function parseVerdict(text) {
36
- const last = [...text.matchAll(JSON_BLOCK)].at(-1);
45
+ const fences = [...text.matchAll(JSON_FENCE)];
46
+ const last = fences.at(-1);
37
47
  if (last === undefined) {
38
48
  return undefined;
39
49
  }
40
- try {
41
- return readVerdict(JSON.parse(last[1]));
50
+ for (const fence of fences.toReversed()) {
51
+ const block = readBlock(text, fence.index + fence[0].length);
52
+ if (block === undefined) {
53
+ continue;
54
+ }
55
+ if (block.end < last.index) {
56
+ return undefined;
57
+ }
58
+ const verdict = readVerdict(block.value);
59
+ if (verdict !== undefined) {
60
+ return verdict;
61
+ }
42
62
  }
43
- catch {
44
- return undefined;
63
+ return undefined;
64
+ }
65
+ function readBlock(text, start) {
66
+ for (let end = text.indexOf(FENCE, start); end !== -1; end = text.indexOf(FENCE, end + 1)) {
67
+ const parsed = parseJson(text.slice(start, end));
68
+ if (parsed !== undefined) {
69
+ return { value: parsed.value, end };
70
+ }
45
71
  }
72
+ return undefined;
46
73
  }
47
74
  export function blockingFindings(verdict) {
48
75
  return verdict.findings.filter((finding) => finding.severity === 'blocking');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.43",
3
+ "version": "6.6.44",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",