@xera-ai/core 0.9.2 → 0.9.3
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/bin/internal.js +118 -98
- package/dist/bin/templates/LICENSE-vis-network.txt +176 -0
- package/dist/bin/templates/graph.css +88 -0
- package/dist/bin/templates/graph.html.template +31 -0
- package/dist/bin/templates/graph.js +101 -0
- package/dist/bin/templates/vis-network.min.js +25000 -0
- package/dist/src/index.js +44 -36
- package/package.json +4 -4
- package/src/bin-internal/graph-backfill.ts +2 -2
- package/src/bin-internal/graph-record-script.ts +11 -3
- package/src/bin-internal/graph-record.ts +12 -10
package/dist/src/index.js
CHANGED
|
@@ -17,6 +17,46 @@ var __export = (target, all) => {
|
|
|
17
17
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
18
18
|
var __require = import.meta.require;
|
|
19
19
|
|
|
20
|
+
// src/artifact/paths.ts
|
|
21
|
+
import { join } from "path";
|
|
22
|
+
function resolveArtifactPaths(repoRoot, ticket) {
|
|
23
|
+
if (!TICKET_RE.test(ticket)) {
|
|
24
|
+
throw new Error(`Invalid ticket key: "${ticket}" (expected e.g. JIRA-123 or SAMPLE-001)`);
|
|
25
|
+
}
|
|
26
|
+
const ticketDir = join(repoRoot, ".xera", ticket);
|
|
27
|
+
return {
|
|
28
|
+
ticketDir,
|
|
29
|
+
storyPath: join(ticketDir, "story.md"),
|
|
30
|
+
featurePath: join(ticketDir, "test.feature"),
|
|
31
|
+
specPath: join(ticketDir, "spec.ts"),
|
|
32
|
+
pageObjectsDir: join(ticketDir, "page-objects"),
|
|
33
|
+
runsDir: join(ticketDir, "runs"),
|
|
34
|
+
metaPath: join(ticketDir, "meta.json"),
|
|
35
|
+
statusPath: join(ticketDir, "status.json"),
|
|
36
|
+
logPath: join(ticketDir, "xera.log"),
|
|
37
|
+
lockPath: join(ticketDir, ".lock"),
|
|
38
|
+
authDir: join(repoRoot, ".xera", ".auth"),
|
|
39
|
+
runPath: (runId) => {
|
|
40
|
+
const runDir = join(ticketDir, "runs", runId);
|
|
41
|
+
return {
|
|
42
|
+
runDir,
|
|
43
|
+
reportJsonPath: join(runDir, "report.json"),
|
|
44
|
+
tracePath: join(runDir, "trace.zip"),
|
|
45
|
+
normalizedPath: join(runDir, "normalized.json"),
|
|
46
|
+
screenshotsDir: join(runDir, "screenshots"),
|
|
47
|
+
videoDir: join(runDir, "videos")
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function generateRunId(now = new Date) {
|
|
53
|
+
return now.toISOString().replace(/[:.]/g, "-").replace("Z", "");
|
|
54
|
+
}
|
|
55
|
+
var TICKET_RE;
|
|
56
|
+
var init_paths = __esm(() => {
|
|
57
|
+
TICKET_RE = /^[A-Z][A-Z0-9_]*-\d+$|^SAMPLE-\d+$/;
|
|
58
|
+
});
|
|
59
|
+
|
|
20
60
|
// src/artifact/hash.ts
|
|
21
61
|
import { createHash } from "crypto";
|
|
22
62
|
import { existsSync, readFileSync } from "fs";
|
|
@@ -67,42 +107,10 @@ function updateMeta(path, patch) {
|
|
|
67
107
|
writeMeta(path, next);
|
|
68
108
|
return next;
|
|
69
109
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!TICKET_RE.test(ticket)) {
|
|
75
|
-
throw new Error(`Invalid ticket key: "${ticket}" (expected e.g. JIRA-123 or SAMPLE-001)`);
|
|
76
|
-
}
|
|
77
|
-
const ticketDir = join(repoRoot, ".xera", ticket);
|
|
78
|
-
return {
|
|
79
|
-
ticketDir,
|
|
80
|
-
storyPath: join(ticketDir, "story.md"),
|
|
81
|
-
featurePath: join(ticketDir, "test.feature"),
|
|
82
|
-
specPath: join(ticketDir, "spec.ts"),
|
|
83
|
-
pageObjectsDir: join(ticketDir, "page-objects"),
|
|
84
|
-
runsDir: join(ticketDir, "runs"),
|
|
85
|
-
metaPath: join(ticketDir, "meta.json"),
|
|
86
|
-
statusPath: join(ticketDir, "status.json"),
|
|
87
|
-
logPath: join(ticketDir, "xera.log"),
|
|
88
|
-
lockPath: join(ticketDir, ".lock"),
|
|
89
|
-
authDir: join(repoRoot, ".xera", ".auth"),
|
|
90
|
-
runPath: (runId) => {
|
|
91
|
-
const runDir = join(ticketDir, "runs", runId);
|
|
92
|
-
return {
|
|
93
|
-
runDir,
|
|
94
|
-
reportJsonPath: join(runDir, "report.json"),
|
|
95
|
-
tracePath: join(runDir, "trace.zip"),
|
|
96
|
-
normalizedPath: join(runDir, "normalized.json"),
|
|
97
|
-
screenshotsDir: join(runDir, "screenshots"),
|
|
98
|
-
videoDir: join(runDir, "videos")
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function generateRunId(now = new Date) {
|
|
104
|
-
return now.toISOString().replace(/[:.]/g, "-").replace("Z", "");
|
|
105
|
-
}
|
|
110
|
+
|
|
111
|
+
// src/index.ts
|
|
112
|
+
init_paths();
|
|
113
|
+
|
|
106
114
|
// src/artifact/status.ts
|
|
107
115
|
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
108
116
|
import { dirname as dirname2 } from "path";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xera-ai/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"bin"
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
|
-
"build": "bun build ./src/index.ts ./bin/internal.ts --outdir ./dist --target bun --external @playwright/test --external @xera-ai/web --external @xera-ai/http --external zod",
|
|
28
|
+
"build": "bun build ./src/index.ts ./bin/internal.ts --outdir ./dist --target bun --external @playwright/test --external @xera-ai/web --external @xera-ai/http --external zod && cp -r src/graph/templates dist/bin/",
|
|
29
29
|
"typecheck": "tsc --noEmit",
|
|
30
30
|
"prepublishOnly": "bun run build"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"zod": "4.4.3",
|
|
34
|
-
"@xera-ai/web": "^0.9.
|
|
35
|
-
"@xera-ai/http": "^0.9.
|
|
34
|
+
"@xera-ai/web": "^0.9.3",
|
|
35
|
+
"@xera-ai/http": "^0.9.3",
|
|
36
36
|
"@playwright/test": "1.60.0",
|
|
37
37
|
"fflate": "0.8.3",
|
|
38
38
|
"yaml": "2.9.0"
|
|
@@ -14,9 +14,9 @@ async function backfillTicket(repoRoot: string, ticket: string, dryRun: boolean)
|
|
|
14
14
|
console.log(`[backfill dry-run] would backfill ${ticket}`);
|
|
15
15
|
return 0;
|
|
16
16
|
}
|
|
17
|
-
//
|
|
18
|
-
await recordScriptImpl(repoRoot, ticket);
|
|
17
|
+
// fetch first (establishes ticket node), then script (adds scenarios/POMs).
|
|
19
18
|
await recordFetch(repoRoot, ticket);
|
|
19
|
+
await recordScriptImpl(repoRoot, ticket);
|
|
20
20
|
return 0;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -133,9 +133,17 @@ function extractPomUsage(specContent: string): string[] {
|
|
|
133
133
|
|
|
134
134
|
export async function recordScriptImpl(repoRoot: string, ticket: string): Promise<number> {
|
|
135
135
|
const ticketDir = join(repoRoot, '.xera', ticket);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
136
|
+
|
|
137
|
+
// Try new layout first, fall back to pre-v0.6 layout for backfill compatibility
|
|
138
|
+
const featurePath = existsSync(join(ticketDir, 'test.feature'))
|
|
139
|
+
? join(ticketDir, 'test.feature')
|
|
140
|
+
: join(ticketDir, 'feature', `${ticket}.feature`);
|
|
141
|
+
const specPath = existsSync(join(ticketDir, 'spec.ts'))
|
|
142
|
+
? join(ticketDir, 'spec.ts')
|
|
143
|
+
: join(ticketDir, 'tests', `${ticket}.spec.ts`);
|
|
144
|
+
const pomDir = existsSync(join(ticketDir, 'page-objects'))
|
|
145
|
+
? join(ticketDir, 'page-objects')
|
|
146
|
+
: join(ticketDir, 'poms');
|
|
139
147
|
|
|
140
148
|
if (!existsSync(featurePath)) {
|
|
141
149
|
console.error(`[graph-record script] feature missing`);
|
|
@@ -2,6 +2,7 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { basename, join } from 'node:path';
|
|
4
4
|
import { parse as parseYaml } from 'yaml';
|
|
5
|
+
import { resolveArtifactPaths } from '../artifact/paths';
|
|
5
6
|
import { appendEvents } from '../graph/store';
|
|
6
7
|
import type {
|
|
7
8
|
Classification,
|
|
@@ -118,24 +119,24 @@ async function recordScript(repoRoot: string, ticket: string): Promise<number> {
|
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
async function recordExec(repoRoot: string, ticket: string, runId: string): Promise<number> {
|
|
121
|
-
const
|
|
122
|
-
if (!existsSync(
|
|
123
|
-
console.error(`[graph-record exec]
|
|
122
|
+
const { normalizedPath } = resolveArtifactPaths(repoRoot, ticket).runPath(runId);
|
|
123
|
+
if (!existsSync(normalizedPath)) {
|
|
124
|
+
console.error(`[graph-record exec] normalized.json missing`);
|
|
124
125
|
return 1;
|
|
125
126
|
}
|
|
126
|
-
const data = JSON.parse(readFileSync(
|
|
127
|
-
scenarios: Array<{ name: string;
|
|
127
|
+
const data = JSON.parse(readFileSync(normalizedPath, 'utf8')) as {
|
|
128
|
+
scenarios: Array<{ name: string; outcome: 'PASS' | 'FAIL' | 'SKIPPED' }>;
|
|
128
129
|
};
|
|
129
130
|
const events: Event[] = [];
|
|
130
131
|
for (const s of data.scenarios) {
|
|
132
|
+
if (s.outcome === 'SKIPPED') continue;
|
|
131
133
|
const p: RunCompletedPayload = {
|
|
132
134
|
scenarioId: scenarioId(ticket, s.name),
|
|
133
135
|
ticketId: ticket,
|
|
134
136
|
runId,
|
|
135
|
-
status: s.
|
|
136
|
-
runtime:
|
|
137
|
+
status: s.outcome === 'PASS' ? 'pass' : 'fail',
|
|
138
|
+
runtime: 0,
|
|
137
139
|
};
|
|
138
|
-
if (s.traceId) p.traceId = s.traceId;
|
|
139
140
|
events.push(makeEvent('xera-exec', 'run.completed', p));
|
|
140
141
|
}
|
|
141
142
|
appendEvents(repoRoot, events, { skill: 'xera-exec', ticketId: ticket });
|
|
@@ -143,9 +144,10 @@ async function recordExec(repoRoot: string, ticket: string, runId: string): Prom
|
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
async function recordClassify(repoRoot: string, ticket: string, runId: string): Promise<number> {
|
|
146
|
-
const
|
|
147
|
+
const { ticketDir } = resolveArtifactPaths(repoRoot, ticket);
|
|
148
|
+
const classifyPath = join(ticketDir, 'classifier-input.json');
|
|
147
149
|
if (!existsSync(classifyPath)) {
|
|
148
|
-
console.error(`[graph-record classify] classifier-
|
|
150
|
+
console.error(`[graph-record classify] classifier-input.json missing`);
|
|
149
151
|
return 1;
|
|
150
152
|
}
|
|
151
153
|
const data = JSON.parse(readFileSync(classifyPath, 'utf8')) as {
|