vibecode-anything 0.3.0 → 0.4.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 +239 -67
- package/dist/cli.js +2140 -73
- package/dist/core/adapters.d.ts +26 -3
- package/dist/core/adapters.js +411 -25
- package/dist/core/agent-adapter.d.ts +67 -0
- package/dist/core/agent-adapter.js +312 -0
- package/dist/core/anti-cheat.d.ts +6 -0
- package/dist/core/anti-cheat.js +372 -0
- package/dist/core/badge.d.ts +18 -0
- package/dist/core/badge.js +360 -0
- package/dist/core/cache.d.ts +47 -0
- package/dist/core/cache.js +403 -0
- package/dist/core/ci-export.d.ts +35 -0
- package/dist/core/ci-export.js +796 -0
- package/dist/core/ci-formats.d.ts +21 -0
- package/dist/core/ci-formats.js +388 -0
- package/dist/core/client-codegen.d.ts +36 -0
- package/dist/core/client-codegen.js +2538 -0
- package/dist/core/compose.d.ts +71 -0
- package/dist/core/compose.js +1088 -0
- package/dist/core/docs-export.d.ts +37 -0
- package/dist/core/docs-export.js +2706 -0
- package/dist/core/doctor.d.ts +21 -1
- package/dist/core/doctor.js +234 -21
- package/dist/core/exec.d.ts +26 -2
- package/dist/core/exec.js +235 -8
- package/dist/core/fixtures.d.ts +153 -0
- package/dist/core/fixtures.js +2245 -0
- package/dist/core/format.d.ts +77 -0
- package/dist/core/format.js +632 -0
- package/dist/core/fs-snapshot.d.ts +37 -0
- package/dist/core/fs-snapshot.js +216 -0
- package/dist/core/graphql-export.d.ts +34 -0
- package/dist/core/graphql-export.js +2482 -0
- package/dist/core/har-export.d.ts +29 -0
- package/dist/core/har-export.js +988 -0
- package/dist/core/html-report.d.ts +27 -0
- package/dist/core/html-report.js +1535 -0
- package/dist/core/http-export.d.ts +31 -0
- package/dist/core/http-export.js +726 -0
- package/dist/core/impact.d.ts +80 -0
- package/dist/core/impact.js +1412 -0
- package/dist/core/lint.d.ts +38 -0
- package/dist/core/lint.js +1111 -0
- package/dist/core/load-export.d.ts +37 -0
- package/dist/core/load-export.js +1813 -0
- package/dist/core/mcp-export.d.ts +35 -0
- package/dist/core/mcp-export.js +1736 -0
- package/dist/core/mock-server.d.ts +47 -0
- package/dist/core/mock-server.js +1722 -0
- package/dist/core/openapi-export.d.ts +44 -0
- package/dist/core/openapi-export.js +1074 -0
- package/dist/core/parity.d.ts +6 -1
- package/dist/core/parity.js +36 -1
- package/dist/core/playwright-exporter.d.ts +23 -0
- package/dist/core/playwright-exporter.js +1343 -0
- package/dist/core/png.js +45 -9
- package/dist/core/regression.d.ts +54 -0
- package/dist/core/regression.js +529 -0
- package/dist/core/responsive.d.ts +86 -0
- package/dist/core/responsive.js +606 -0
- package/dist/core/run.d.ts +74 -0
- package/dist/core/run.js +696 -0
- package/dist/core/scheduler.d.ts +24 -0
- package/dist/core/scheduler.js +162 -0
- package/dist/core/schema-export.d.ts +29 -0
- package/dist/core/schema-export.js +2215 -0
- package/dist/core/schema.d.ts +3 -2
- package/dist/core/schema.js +460 -17
- package/dist/core/security.d.ts +233 -0
- package/dist/core/security.js +1839 -0
- package/dist/core/server-export.d.ts +38 -0
- package/dist/core/server-export.js +3198 -0
- package/dist/core/spec-writer.d.ts +9 -0
- package/dist/core/spec-writer.js +1202 -0
- package/dist/core/store.d.ts +11 -2
- package/dist/core/store.js +128 -8
- package/dist/core/target-map.d.ts +34 -0
- package/dist/core/target-map.js +262 -0
- package/dist/core/test-exporter.d.ts +25 -0
- package/dist/core/test-exporter.js +1918 -0
- package/dist/core/types.d.ts +182 -14
- package/dist/core/visual-semantic.d.ts +67 -0
- package/dist/core/visual-semantic.js +673 -0
- package/dist/core/visual.js +65 -16
- package/dist/core/watch.d.ts +28 -3
- package/dist/core/watch.js +222 -12
- package/dist/core/yaml.d.ts +5 -0
- package/dist/core/yaml.js +1009 -0
- package/dist/diagnostics/diagnose.d.ts +53 -0
- package/dist/diagnostics/diagnose.js +1083 -0
- package/dist/diagnostics/flake.d.ts +71 -0
- package/dist/diagnostics/flake.js +608 -0
- package/dist/diagnostics/mutation-audit.d.ts +69 -0
- package/dist/diagnostics/mutation-audit.js +769 -0
- package/dist/diagnostics/spatial.d.ts +42 -0
- package/dist/diagnostics/spatial.js +346 -0
- package/dist/diagnostics/trends.d.ts +122 -0
- package/dist/diagnostics/trends.js +1190 -0
- package/dist/discovery/discover.d.ts +111 -0
- package/dist/discovery/discover.js +2017 -0
- package/dist/discovery/lock.d.ts +116 -0
- package/dist/discovery/lock.js +1505 -0
- package/dist/discovery/routes.d.ts +36 -0
- package/dist/discovery/routes.js +1494 -0
- package/dist/discovery/test-importer.d.ts +92 -0
- package/dist/discovery/test-importer.js +4952 -0
- package/dist/index.d.ts +123 -0
- package/dist/index.js +99 -0
- package/dist/ingestors/api-collections.d.ts +28 -0
- package/dist/ingestors/api-collections.js +2335 -0
- package/dist/ingestors/api-repo.d.ts +2 -1
- package/dist/ingestors/api-repo.js +483 -85
- package/dist/ingestors/asyncapi.d.ts +26 -0
- package/dist/ingestors/asyncapi.js +2105 -0
- package/dist/ingestors/bridges.d.ts +2 -0
- package/dist/ingestors/bridges.js +702 -0
- package/dist/ingestors/cli.d.ts +2 -1
- package/dist/ingestors/cli.js +234 -46
- package/dist/ingestors/curl.d.ts +14 -0
- package/dist/ingestors/curl.js +1024 -0
- package/dist/ingestors/graphql.d.ts +56 -0
- package/dist/ingestors/graphql.js +1852 -0
- package/dist/ingestors/http-file.d.ts +20 -0
- package/dist/ingestors/http-file.js +923 -0
- package/dist/ingestors/index.js +486 -6
- package/dist/ingestors/openrpc.d.ts +29 -0
- package/dist/ingestors/openrpc.js +1807 -0
- package/dist/ingestors/proto.d.ts +47 -0
- package/dist/ingestors/proto.js +2690 -0
- package/dist/ingestors/trace.d.ts +10 -0
- package/dist/ingestors/trace.js +599 -0
- package/dist/ingestors/video.d.ts +4 -1
- package/dist/ingestors/video.js +86 -36
- package/dist/ingestors/web.d.ts +16 -1
- package/dist/ingestors/web.js +474 -32
- package/dist/mcp/server.js +3532 -67
- package/dist/oracles/api-repo.js +102 -30
- package/dist/oracles/cli.js +65 -17
- package/dist/oracles/http-workflow.d.ts +68 -0
- package/dist/oracles/http-workflow.js +828 -0
- package/dist/oracles/image.js +178 -28
- package/dist/oracles/index.d.ts +3 -1
- package/dist/oracles/index.js +243 -14
- package/dist/oracles/perf-budget.d.ts +90 -0
- package/dist/oracles/perf-budget.js +1329 -0
- package/dist/oracles/stream.d.ts +94 -0
- package/dist/oracles/stream.js +1268 -0
- package/dist/oracles/ui-states.d.ts +49 -0
- package/dist/oracles/ui-states.js +894 -0
- package/dist/oracles/video.d.ts +1 -1
- package/dist/oracles/video.js +232 -16
- package/dist/oracles/web.js +464 -73
- package/dist/plugins/builtins.d.ts +12 -0
- package/dist/plugins/builtins.js +1052 -0
- package/dist/plugins/registry.d.ts +86 -0
- package/dist/plugins/registry.js +554 -0
- package/dist/setup/index.js +145 -33
- package/package.json +56 -47
- package/skills/vibecode-anything/SKILL.md +75 -52
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-dependency SARIF 2.1.0 JSON and JUnit XML exporters for CI platforms
|
|
3
|
+
* (GitHub Code Scanning, GitLab CI, Jenkins, Azure DevOps, Buildkite).
|
|
4
|
+
*
|
|
5
|
+
* Strictly preserves holdout redaction and strips secrets/vault paths.
|
|
6
|
+
*/
|
|
7
|
+
import type { ParityReport } from "./types.js";
|
|
8
|
+
export interface SarifReportOptions {
|
|
9
|
+
contractName?: string;
|
|
10
|
+
target?: string;
|
|
11
|
+
toolVersion?: string;
|
|
12
|
+
uriBaseId?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface JunitXmlOptions {
|
|
15
|
+
suiteName?: string;
|
|
16
|
+
target?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function renderSarifReport(report: ParityReport, options?: SarifReportOptions): string;
|
|
19
|
+
export declare function writeSarifReport(report: ParityReport, outPath: string, options?: SarifReportOptions): string;
|
|
20
|
+
export declare function renderJunitXml(report: ParityReport, options?: JunitXmlOptions): string;
|
|
21
|
+
export declare function writeJunitXml(report: ParityReport, outPath: string, options?: JunitXmlOptions): string;
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-dependency SARIF 2.1.0 JSON and JUnit XML exporters for CI platforms
|
|
3
|
+
* (GitHub Code Scanning, GitLab CI, Jenkins, Azure DevOps, Buildkite).
|
|
4
|
+
*
|
|
5
|
+
* Strictly preserves holdout redaction and strips secrets/vault paths.
|
|
6
|
+
*/
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { redactSensitiveText as redactCoreSensitiveText } from "./security.js";
|
|
10
|
+
import { ensureDir } from "./store.js";
|
|
11
|
+
const SARIF_SCHEMA_URI = "https://json.schemastore.org/sarif-2.1.0.json";
|
|
12
|
+
const SARIF_VERSION = "2.1.0";
|
|
13
|
+
const TOOL_NAME = "vibecode-anything";
|
|
14
|
+
const DEFAULT_TOOL_VERSION = "0.4.0";
|
|
15
|
+
const TOOL_INFO_URI = "https://github.com/nguyenthanhthe/vibecode-anything";
|
|
16
|
+
const DEFAULT_SPEC_URI = ".vibecode/contract.json";
|
|
17
|
+
const DEFAULT_HOLDOUT_MESSAGE = "Holdout invariant failed (expected details redacted)";
|
|
18
|
+
const DEFAULT_HOLDOUT_SKIPPED_MESSAGE = "Holdout invariant skipped (details redacted)";
|
|
19
|
+
const DEFAULT_ANTICHEAT_REASON = "Anti-cheat check suspected bypass or tampering";
|
|
20
|
+
const INVALID_XML_CONTROL_RE = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g;
|
|
21
|
+
const VAULT_PATH_RE = /\.vibecode-vault\b|holdouts?(?:-[a-f0-9]+)?\.json/i;
|
|
22
|
+
function finiteNumber(value, fallback = 0) {
|
|
23
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
24
|
+
}
|
|
25
|
+
function stripControlChars(text) {
|
|
26
|
+
return String(text).replace(INVALID_XML_CONTROL_RE, "");
|
|
27
|
+
}
|
|
28
|
+
function normalizeSingleLine(text) {
|
|
29
|
+
return stripControlChars(text)
|
|
30
|
+
.replace(/\r?\n/g, " ")
|
|
31
|
+
.replace(/\s+/g, " ")
|
|
32
|
+
.trim();
|
|
33
|
+
}
|
|
34
|
+
function normalizeMultiLine(text) {
|
|
35
|
+
return stripControlChars(text)
|
|
36
|
+
.replace(/\r\n?/g, "\n")
|
|
37
|
+
.trim();
|
|
38
|
+
}
|
|
39
|
+
function escapeXml(value) {
|
|
40
|
+
return stripControlChars(value)
|
|
41
|
+
.replace(/&/g, "&")
|
|
42
|
+
.replace(/</g, "<")
|
|
43
|
+
.replace(/>/g, ">")
|
|
44
|
+
.replace(/"/g, """)
|
|
45
|
+
.replace(/'/g, "'");
|
|
46
|
+
}
|
|
47
|
+
function redactSensitiveText(input) {
|
|
48
|
+
return redactCoreSensitiveText(input).replace(/\[REDACTED_VAULT\]/g, "[REDACTED_VAULT_PATH]");
|
|
49
|
+
}
|
|
50
|
+
function isHoldoutResult(item) {
|
|
51
|
+
const raw = item;
|
|
52
|
+
return (item.metrics?.redacted === true ||
|
|
53
|
+
item.metrics?.holdout === true ||
|
|
54
|
+
raw.holdout === true);
|
|
55
|
+
}
|
|
56
|
+
function getSafeHoldoutHint(item) {
|
|
57
|
+
const raw = item;
|
|
58
|
+
if (typeof raw.holdoutHint === "string" && raw.holdoutHint.trim().length > 0) {
|
|
59
|
+
const hint = normalizeSingleLine(redactSensitiveText(raw.holdoutHint));
|
|
60
|
+
if (hint && !hint.includes("[REDACTED_VAULT_PATH]")) {
|
|
61
|
+
return hint;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (item.metrics?.redacted === true &&
|
|
65
|
+
Array.isArray(item.failures) &&
|
|
66
|
+
typeof item.failures[0] === "string" &&
|
|
67
|
+
item.failures[0].trim().length > 0 &&
|
|
68
|
+
!VAULT_PATH_RE.test(item.failures[0])) {
|
|
69
|
+
const candidate = normalizeSingleLine(redactSensitiveText(item.failures[0]));
|
|
70
|
+
if (candidate && !candidate.includes("[REDACTED_VAULT_PATH]")) {
|
|
71
|
+
return candidate;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return DEFAULT_HOLDOUT_MESSAGE;
|
|
75
|
+
}
|
|
76
|
+
function summarizeVisibleIssue(item) {
|
|
77
|
+
const raw = (Array.isArray(item.failures) && typeof item.failures[0] === "string" && item.failures[0].trim()) ||
|
|
78
|
+
(typeof item.reason === "string" && item.reason.trim()) ||
|
|
79
|
+
(typeof item.diagnostic?.message === "string" && item.diagnostic.message.trim()) ||
|
|
80
|
+
`status=${item.status}`;
|
|
81
|
+
return normalizeSingleLine(redactSensitiveText(raw));
|
|
82
|
+
}
|
|
83
|
+
function collectVisibleDetails(item) {
|
|
84
|
+
const parts = [];
|
|
85
|
+
if (Array.isArray(item.failures)) {
|
|
86
|
+
for (const failure of item.failures) {
|
|
87
|
+
if (typeof failure === "string" && failure.trim().length > 0) {
|
|
88
|
+
const clean = normalizeMultiLine(redactSensitiveText(failure));
|
|
89
|
+
if (clean && !parts.includes(clean)) {
|
|
90
|
+
parts.push(clean);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (parts.length === 0 && typeof item.reason === "string" && item.reason.trim().length > 0) {
|
|
96
|
+
const clean = normalizeMultiLine(redactSensitiveText(item.reason));
|
|
97
|
+
if (clean)
|
|
98
|
+
parts.push(clean);
|
|
99
|
+
}
|
|
100
|
+
if (parts.length === 0 && typeof item.diagnostic?.message === "string" && item.diagnostic.message.trim().length > 0) {
|
|
101
|
+
const clean = normalizeMultiLine(redactSensitiveText(item.diagnostic.message));
|
|
102
|
+
if (clean)
|
|
103
|
+
parts.push(clean);
|
|
104
|
+
}
|
|
105
|
+
if (parts.length === 0) {
|
|
106
|
+
parts.push(`status=${item.status}`);
|
|
107
|
+
}
|
|
108
|
+
if (typeof item.repro === "string" && item.repro.trim().length > 0) {
|
|
109
|
+
const cleanRepro = normalizeSingleLine(redactSensitiveText(item.repro));
|
|
110
|
+
if (cleanRepro) {
|
|
111
|
+
parts.push(`Repro: ${cleanRepro}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return parts.join("\n");
|
|
115
|
+
}
|
|
116
|
+
function sanitizeId(raw) {
|
|
117
|
+
const clean = normalizeSingleLine(redactSensitiveText(raw))
|
|
118
|
+
.replace(/\.{2,}/g, "-")
|
|
119
|
+
.replace(/[^A-Za-z0-9._-]+/g, "-")
|
|
120
|
+
.replace(/-+/g, "-")
|
|
121
|
+
.replace(/^[.-]+|[.-]+$/g, "");
|
|
122
|
+
return clean || "unknown";
|
|
123
|
+
}
|
|
124
|
+
function sanitizeArtifactUri(target) {
|
|
125
|
+
if (typeof target !== "string" || target.trim().length === 0) {
|
|
126
|
+
return DEFAULT_SPEC_URI;
|
|
127
|
+
}
|
|
128
|
+
const clean = normalizeSingleLine(redactSensitiveText(target));
|
|
129
|
+
if (!clean || clean.includes("[REDACTED_VAULT_PATH]")) {
|
|
130
|
+
return DEFAULT_SPEC_URI;
|
|
131
|
+
}
|
|
132
|
+
const normalized = clean.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
133
|
+
return normalized || DEFAULT_SPEC_URI;
|
|
134
|
+
}
|
|
135
|
+
function sanitizeAntiCheatReasonText(report) {
|
|
136
|
+
const reasons = (report.antiCheat?.reasons ?? [])
|
|
137
|
+
.filter((r) => typeof r === "string" && r.trim().length > 0)
|
|
138
|
+
.map((r) => normalizeSingleLine(redactSensitiveText(r)))
|
|
139
|
+
.filter((r) => r.length > 0);
|
|
140
|
+
return reasons.length > 0 ? reasons.join("; ") : DEFAULT_ANTICHEAT_REASON;
|
|
141
|
+
}
|
|
142
|
+
function formatDurationSeconds(durationMs) {
|
|
143
|
+
if (typeof durationMs !== "number" || !Number.isFinite(durationMs) || durationMs < 0) {
|
|
144
|
+
return "0.000";
|
|
145
|
+
}
|
|
146
|
+
return (durationMs / 1000).toFixed(3);
|
|
147
|
+
}
|
|
148
|
+
function writeFileAtomically(outPath, content) {
|
|
149
|
+
const resolved = path.resolve(outPath);
|
|
150
|
+
ensureDir(path.dirname(resolved));
|
|
151
|
+
const tmpPath = `${resolved}.tmp`;
|
|
152
|
+
fs.writeFileSync(tmpPath, content, "utf8");
|
|
153
|
+
fs.renameSync(tmpPath, resolved);
|
|
154
|
+
return resolved;
|
|
155
|
+
}
|
|
156
|
+
export function renderSarifReport(report, options = {}) {
|
|
157
|
+
const toolVersion = normalizeSingleLine(redactSensitiveText(options.toolVersion ?? "")) || DEFAULT_TOOL_VERSION;
|
|
158
|
+
const cleanContractName = options.contractName?.trim()
|
|
159
|
+
? normalizeSingleLine(redactSensitiveText(options.contractName))
|
|
160
|
+
: "";
|
|
161
|
+
const cleanUriBaseId = options.uriBaseId?.trim()
|
|
162
|
+
? sanitizeId(options.uriBaseId)
|
|
163
|
+
: "";
|
|
164
|
+
const artifactUri = sanitizeArtifactUri(options.target);
|
|
165
|
+
const artifactLocation = {
|
|
166
|
+
uri: artifactUri,
|
|
167
|
+
...(cleanUriBaseId ? { uriBaseId: cleanUriBaseId } : {})
|
|
168
|
+
};
|
|
169
|
+
const ruleMap = new Map();
|
|
170
|
+
const sarifResults = [];
|
|
171
|
+
const items = Array.isArray(report.results) ? report.results : [];
|
|
172
|
+
for (const item of items) {
|
|
173
|
+
if (item.status !== "fail" && item.status !== "error" && item.status !== "warn") {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
const holdout = isHoldoutResult(item);
|
|
177
|
+
const cleanId = normalizeSingleLine(redactSensitiveText(item.id)) || "unknown";
|
|
178
|
+
const cleanType = normalizeSingleLine(redactSensitiveText(String(item.type))) || "unknown";
|
|
179
|
+
const cleanSeverity = normalizeSingleLine(redactSensitiveText(String(item.severity))) || "hard";
|
|
180
|
+
const cleanStatus = normalizeSingleLine(redactSensitiveText(String(item.status))) || "fail";
|
|
181
|
+
const ruleId = `vibecode/${sanitizeId(item.id)}`;
|
|
182
|
+
const typeTag = `vibecode/${sanitizeId(String(item.type))}`;
|
|
183
|
+
const level = item.status === "warn" ? "warning" : item.severity === "hard" ? "error" : "warning";
|
|
184
|
+
if (!ruleMap.has(ruleId)) {
|
|
185
|
+
ruleMap.set(ruleId, {
|
|
186
|
+
id: ruleId,
|
|
187
|
+
shortDescription: {
|
|
188
|
+
text: holdout
|
|
189
|
+
? `Holdout ${cleanSeverity} parity invariant (${cleanType})`
|
|
190
|
+
: `Parity invariant ${cleanId} (${cleanSeverity}, ${cleanType})`
|
|
191
|
+
},
|
|
192
|
+
defaultConfiguration: { level },
|
|
193
|
+
properties: {
|
|
194
|
+
category: typeTag,
|
|
195
|
+
invariantType: cleanType,
|
|
196
|
+
severity: cleanSeverity,
|
|
197
|
+
tags: [typeTag, cleanSeverity, ...(holdout ? ["holdout"] : [])]
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
const messageText = holdout ? getSafeHoldoutHint(item) : collectVisibleDetails(item);
|
|
202
|
+
sarifResults.push({
|
|
203
|
+
ruleId,
|
|
204
|
+
level,
|
|
205
|
+
message: { text: messageText },
|
|
206
|
+
locations: [
|
|
207
|
+
{
|
|
208
|
+
physicalLocation: {
|
|
209
|
+
artifactLocation: { ...artifactLocation }
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
properties: {
|
|
214
|
+
invariantId: cleanId,
|
|
215
|
+
invariantType: cleanType,
|
|
216
|
+
severity: cleanSeverity,
|
|
217
|
+
status: cleanStatus,
|
|
218
|
+
score: finiteNumber(item.score, 0),
|
|
219
|
+
redacted: holdout
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
if (report.antiCheat?.status === "suspected") {
|
|
224
|
+
const antiCheatRuleId = "vibecode/anti-cheat";
|
|
225
|
+
if (!ruleMap.has(antiCheatRuleId)) {
|
|
226
|
+
ruleMap.set(antiCheatRuleId, {
|
|
227
|
+
id: antiCheatRuleId,
|
|
228
|
+
shortDescription: {
|
|
229
|
+
text: "Anti-cheat integrity check detected suspected bypass or tampering"
|
|
230
|
+
},
|
|
231
|
+
defaultConfiguration: { level: "error" },
|
|
232
|
+
properties: {
|
|
233
|
+
category: antiCheatRuleId,
|
|
234
|
+
tags: [antiCheatRuleId, "integrity", "security"]
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
sarifResults.push({
|
|
239
|
+
ruleId: antiCheatRuleId,
|
|
240
|
+
level: "error",
|
|
241
|
+
message: { text: sanitizeAntiCheatReasonText(report) },
|
|
242
|
+
locations: [
|
|
243
|
+
{
|
|
244
|
+
physicalLocation: {
|
|
245
|
+
artifactLocation: { ...artifactLocation }
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
],
|
|
249
|
+
properties: {
|
|
250
|
+
antiCheatStatus: "suspected",
|
|
251
|
+
severity: "hard",
|
|
252
|
+
status: "fail",
|
|
253
|
+
redacted: false
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
const cleanTimestamp = typeof report.timestamp === "string" ? normalizeSingleLine(redactSensitiveText(report.timestamp)) : "";
|
|
258
|
+
const invocation = {
|
|
259
|
+
executionSuccessful: Boolean(report.gate?.passed),
|
|
260
|
+
...(cleanTimestamp ? { endTimeUtc: cleanTimestamp } : {})
|
|
261
|
+
};
|
|
262
|
+
const run = {
|
|
263
|
+
tool: {
|
|
264
|
+
driver: {
|
|
265
|
+
name: TOOL_NAME,
|
|
266
|
+
version: toolVersion,
|
|
267
|
+
informationUri: TOOL_INFO_URI,
|
|
268
|
+
rules: [...ruleMap.values()]
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
invocations: [invocation],
|
|
272
|
+
results: sarifResults,
|
|
273
|
+
properties: {
|
|
274
|
+
...(cleanContractName ? { contractName: cleanContractName } : {}),
|
|
275
|
+
gateStatus: normalizeSingleLine(redactSensitiveText(String(report.gate?.status ?? "fail"))) || "fail",
|
|
276
|
+
compositeScore: finiteNumber(report.compositeScore, 0),
|
|
277
|
+
hardParity: finiteNumber(report.hard?.parity, 0),
|
|
278
|
+
softMeanScore: finiteNumber(report.soft?.meanScore, 0)
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
const sarifLog = {
|
|
282
|
+
$schema: SARIF_SCHEMA_URI,
|
|
283
|
+
version: SARIF_VERSION,
|
|
284
|
+
runs: [run]
|
|
285
|
+
};
|
|
286
|
+
return `${JSON.stringify(sarifLog, null, 2)}\n`;
|
|
287
|
+
}
|
|
288
|
+
export function writeSarifReport(report, outPath, options = {}) {
|
|
289
|
+
const sarif = renderSarifReport(report, options);
|
|
290
|
+
return writeFileAtomically(outPath, sarif);
|
|
291
|
+
}
|
|
292
|
+
export function renderJunitXml(report, options = {}) {
|
|
293
|
+
const suiteName = options.suiteName?.trim()
|
|
294
|
+
? normalizeSingleLine(redactSensitiveText(options.suiteName))
|
|
295
|
+
: TOOL_NAME;
|
|
296
|
+
const cleanTarget = options.target?.trim()
|
|
297
|
+
? normalizeSingleLine(redactSensitiveText(options.target))
|
|
298
|
+
: "";
|
|
299
|
+
const timestamp = (typeof report.timestamp === "string" && normalizeSingleLine(redactSensitiveText(report.timestamp))) ||
|
|
300
|
+
new Date().toISOString();
|
|
301
|
+
const items = Array.isArray(report.results) ? report.results : [];
|
|
302
|
+
const antiCheatSuspected = report.antiCheat?.status === "suspected";
|
|
303
|
+
let failuresCount = 0;
|
|
304
|
+
let errorsCount = 0;
|
|
305
|
+
let skippedCount = 0;
|
|
306
|
+
let totalDurationMs = 0;
|
|
307
|
+
const testcaseLines = [];
|
|
308
|
+
for (const item of items) {
|
|
309
|
+
const holdout = isHoldoutResult(item);
|
|
310
|
+
const cleanType = sanitizeId(String(item.type));
|
|
311
|
+
const classname = `vibecode.${cleanType}`;
|
|
312
|
+
const name = normalizeSingleLine(redactSensitiveText(item.id)) || "unknown";
|
|
313
|
+
const durationMs = typeof item.durationMs === "number" && Number.isFinite(item.durationMs) && item.durationMs >= 0
|
|
314
|
+
? item.durationMs
|
|
315
|
+
: 0;
|
|
316
|
+
totalDurationMs += durationMs;
|
|
317
|
+
const timeAttr = formatDurationSeconds(durationMs);
|
|
318
|
+
const openAttrs = `classname="${escapeXml(classname)}" name="${escapeXml(name)}" time="${timeAttr}"`;
|
|
319
|
+
if (item.status === "pass") {
|
|
320
|
+
testcaseLines.push(` <testcase ${openAttrs}/>`);
|
|
321
|
+
}
|
|
322
|
+
else if (item.status === "skipped") {
|
|
323
|
+
skippedCount += 1;
|
|
324
|
+
const skipMsg = holdout
|
|
325
|
+
? DEFAULT_HOLDOUT_SKIPPED_MESSAGE
|
|
326
|
+
: normalizeSingleLine(redactSensitiveText((typeof item.reason === "string" && item.reason.trim()) ||
|
|
327
|
+
(typeof item.diagnostic?.message === "string" && item.diagnostic.message.trim()) ||
|
|
328
|
+
"Skipped"));
|
|
329
|
+
testcaseLines.push(` <testcase ${openAttrs}>`);
|
|
330
|
+
testcaseLines.push(` <skipped message="${escapeXml(skipMsg)}"/>`);
|
|
331
|
+
testcaseLines.push(` </testcase>`);
|
|
332
|
+
}
|
|
333
|
+
else if (item.status === "warn") {
|
|
334
|
+
const warnBody = holdout ? getSafeHoldoutHint(item) : collectVisibleDetails(item);
|
|
335
|
+
testcaseLines.push(` <testcase ${openAttrs}>`);
|
|
336
|
+
testcaseLines.push(` <system-out>${escapeXml(warnBody)}</system-out>`);
|
|
337
|
+
testcaseLines.push(` </testcase>`);
|
|
338
|
+
}
|
|
339
|
+
else if (item.status === "error") {
|
|
340
|
+
errorsCount += 1;
|
|
341
|
+
const errMsg = holdout ? getSafeHoldoutHint(item) : summarizeVisibleIssue(item);
|
|
342
|
+
const errBody = holdout ? getSafeHoldoutHint(item) : collectVisibleDetails(item);
|
|
343
|
+
const errType = `${normalizeSingleLine(redactSensitiveText(String(item.severity))) || "hard"}:${cleanType}`;
|
|
344
|
+
testcaseLines.push(` <testcase ${openAttrs}>`);
|
|
345
|
+
testcaseLines.push(` <error message="${escapeXml(errMsg)}" type="${escapeXml(errType)}">${escapeXml(errBody)}</error>`);
|
|
346
|
+
testcaseLines.push(` </testcase>`);
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
failuresCount += 1;
|
|
350
|
+
const failMsg = holdout ? getSafeHoldoutHint(item) : summarizeVisibleIssue(item);
|
|
351
|
+
const failBody = holdout ? getSafeHoldoutHint(item) : collectVisibleDetails(item);
|
|
352
|
+
const failType = `${normalizeSingleLine(redactSensitiveText(String(item.severity))) || "hard"}:${cleanType}`;
|
|
353
|
+
testcaseLines.push(` <testcase ${openAttrs}>`);
|
|
354
|
+
testcaseLines.push(` <failure message="${escapeXml(failMsg)}" type="${escapeXml(failType)}">${escapeXml(failBody)}</failure>`);
|
|
355
|
+
testcaseLines.push(` </testcase>`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (antiCheatSuspected) {
|
|
359
|
+
failuresCount += 1;
|
|
360
|
+
const reasonText = sanitizeAntiCheatReasonText(report);
|
|
361
|
+
testcaseLines.push(` <testcase classname="vibecode.antiCheat" name="anti-cheat-gate" time="0.000">`);
|
|
362
|
+
testcaseLines.push(` <failure message="${escapeXml(reasonText)}" type="anti-cheat">${escapeXml(reasonText)}</failure>`);
|
|
363
|
+
testcaseLines.push(` </testcase>`);
|
|
364
|
+
}
|
|
365
|
+
const totalTests = items.length + (antiCheatSuspected ? 1 : 0);
|
|
366
|
+
const totalTime = formatDurationSeconds(totalDurationMs);
|
|
367
|
+
const lines = [
|
|
368
|
+
`<?xml version="1.0" encoding="UTF-8"?>`,
|
|
369
|
+
`<testsuites name="${escapeXml(suiteName)}" tests="${totalTests}" failures="${failuresCount}" errors="${errorsCount}" skipped="${skippedCount}" time="${totalTime}">`,
|
|
370
|
+
` <testsuite name="${escapeXml(suiteName)}" tests="${totalTests}" failures="${failuresCount}" errors="${errorsCount}" skipped="${skippedCount}" time="${totalTime}" timestamp="${escapeXml(timestamp)}">`
|
|
371
|
+
];
|
|
372
|
+
if (cleanTarget) {
|
|
373
|
+
lines.push(` <properties>`);
|
|
374
|
+
lines.push(` <property name="target" value="${escapeXml(cleanTarget)}"/>`);
|
|
375
|
+
lines.push(` <property name="gateStatus" value="${escapeXml(normalizeSingleLine(redactSensitiveText(String(report.gate?.status ?? "fail"))) || "fail")}"/>`);
|
|
376
|
+
lines.push(` </properties>`);
|
|
377
|
+
}
|
|
378
|
+
for (const tc of testcaseLines) {
|
|
379
|
+
lines.push(tc);
|
|
380
|
+
}
|
|
381
|
+
lines.push(` </testsuite>`);
|
|
382
|
+
lines.push(`</testsuites>`);
|
|
383
|
+
return `${lines.join("\n")}\n`;
|
|
384
|
+
}
|
|
385
|
+
export function writeJunitXml(report, outPath, options = {}) {
|
|
386
|
+
const xml = renderJunitXml(report, options);
|
|
387
|
+
return writeFileAtomically(outPath, xml);
|
|
388
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ContractV02 } from "./types.js";
|
|
2
|
+
export type ClientExportFormat = "ts-fetch" | "python" | "go";
|
|
3
|
+
export interface ExportClientOptions {
|
|
4
|
+
format?: ClientExportFormat;
|
|
5
|
+
title?: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
packageName?: string;
|
|
9
|
+
includeSkippedComments?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ExportClientResult {
|
|
12
|
+
format: ClientExportFormat;
|
|
13
|
+
suggestedFilename: string;
|
|
14
|
+
content: string;
|
|
15
|
+
exportedCount: number;
|
|
16
|
+
skippedCount: number;
|
|
17
|
+
warnings: string[];
|
|
18
|
+
baseUrl: string;
|
|
19
|
+
className: string;
|
|
20
|
+
packageName?: string;
|
|
21
|
+
methodNames: string[];
|
|
22
|
+
outPath?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Compile visible HTTP invariants from a ContractV02 into a zero-dependency typed API client SDK
|
|
26
|
+
* (`ts-fetch`, `python`, or `go`). Holdout invariants are completely excluded and never disclosed.
|
|
27
|
+
*/
|
|
28
|
+
export declare function exportClientCode(contract: ContractV02, options?: ExportClientOptions): ExportClientResult;
|
|
29
|
+
/**
|
|
30
|
+
* Generate and atomically write a typed API client SDK file to disk via temp file + rename.
|
|
31
|
+
*/
|
|
32
|
+
export declare function writeClientCode(contract: ContractV02, outPath: string, options?: ExportClientOptions): ExportClientResult;
|
|
33
|
+
/**
|
|
34
|
+
* Render a pure ASCII/ANSI terminal summary for a client SDK export with zero raw secrets or vault paths.
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatPrettyClientExport(result: ExportClientResult, outPath?: string, color?: boolean): string;
|