arkaik-mcp 0.4.0 → 0.5.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.js +194 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15372,6 +15372,7 @@ var QualitySignalTrippedEventSchema = external_exports.object({
|
|
|
15372
15372
|
criterion_id: external_exports.string(),
|
|
15373
15373
|
surface: external_exports.string(),
|
|
15374
15374
|
signal: external_exports.string(),
|
|
15375
|
+
commit: external_exports.string().optional(),
|
|
15375
15376
|
detail: external_exports.string().optional()
|
|
15376
15377
|
}).catchall(external_exports.unknown());
|
|
15377
15378
|
var JOURNAL_EVENT_SCHEMAS = {
|
|
@@ -16017,6 +16018,18 @@ function capGrade(grade, cap) {
|
|
|
16017
16018
|
function isOpenFinding(finding) {
|
|
16018
16019
|
return (finding.status ?? "open") === "open";
|
|
16019
16020
|
}
|
|
16021
|
+
function rollUpSurface(scores, weights) {
|
|
16022
|
+
let weighted = 0;
|
|
16023
|
+
let total = 0;
|
|
16024
|
+
for (const domain2 of Object.keys(scores)) {
|
|
16025
|
+
const score = scores[domain2];
|
|
16026
|
+
if (typeof score !== "number" || !Number.isFinite(score)) continue;
|
|
16027
|
+
const weight = typeof weights?.[domain2] === "number" ? weights[domain2] : 1;
|
|
16028
|
+
weighted += score * weight;
|
|
16029
|
+
total += weight;
|
|
16030
|
+
}
|
|
16031
|
+
return total > 0 ? Math.round(weighted / total) : null;
|
|
16032
|
+
}
|
|
16020
16033
|
function resolveKritikLibrary(section, library) {
|
|
16021
16034
|
const explicit = library ?? section?.library;
|
|
16022
16035
|
if (explicit && Array.isArray(explicit.criteria) && Array.isArray(explicit.domains)) return explicit;
|
|
@@ -16092,16 +16105,12 @@ function deriveQualityMatrix(bundle, library) {
|
|
|
16092
16105
|
}
|
|
16093
16106
|
const overall = {};
|
|
16094
16107
|
for (const surface of surfaces) {
|
|
16095
|
-
|
|
16096
|
-
let total = 0;
|
|
16108
|
+
const bySurface = {};
|
|
16097
16109
|
for (const domain2 of domains) {
|
|
16098
16110
|
const cell = matrix[domain2]?.[surface];
|
|
16099
|
-
if (
|
|
16100
|
-
const weight = typeof weights?.[domain2] === "number" ? weights[domain2] : 1;
|
|
16101
|
-
weighted += cell.score * weight;
|
|
16102
|
-
total += weight;
|
|
16111
|
+
if (cell) bySurface[domain2] = cell.score;
|
|
16103
16112
|
}
|
|
16104
|
-
overall[surface] =
|
|
16113
|
+
overall[surface] = rollUpSurface(bySurface, weights);
|
|
16105
16114
|
}
|
|
16106
16115
|
const finding_counts = { critical: 0, high: 0, medium: 0, low: 0, info: 0 };
|
|
16107
16116
|
for (const finding of openFindings) finding_counts[severityOf(finding, pack)]++;
|
|
@@ -17818,6 +17827,7 @@ function signalTrippedInput(trip) {
|
|
|
17818
17827
|
criterion_id: trip.criterion_id,
|
|
17819
17828
|
surface: trip.surface,
|
|
17820
17829
|
signal: trip.signal,
|
|
17830
|
+
...trip.commit !== void 0 ? { commit: trip.commit } : {},
|
|
17821
17831
|
...trip.detail !== void 0 ? { detail: trip.detail } : {}
|
|
17822
17832
|
}
|
|
17823
17833
|
};
|
|
@@ -17900,6 +17910,151 @@ function detectRegressions(previous, next, library) {
|
|
|
17900
17910
|
return regressions;
|
|
17901
17911
|
}
|
|
17902
17912
|
|
|
17913
|
+
// ../schema/src/quality-trend.ts
|
|
17914
|
+
var NO_DELTA = { previous: null, delta: null };
|
|
17915
|
+
var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17916
|
+
function frameworkMajor(version2) {
|
|
17917
|
+
if (typeof version2 !== "string") return null;
|
|
17918
|
+
const match = /^\s*v?(\d+)/.exec(version2);
|
|
17919
|
+
return match ? Number(match[1]) : null;
|
|
17920
|
+
}
|
|
17921
|
+
function sameFrameworkMajor(a, b) {
|
|
17922
|
+
const left = frameworkMajor(a);
|
|
17923
|
+
const right = frameworkMajor(b);
|
|
17924
|
+
return left === null || right === null || left === right;
|
|
17925
|
+
}
|
|
17926
|
+
function cleanScores(raw) {
|
|
17927
|
+
const scores = {};
|
|
17928
|
+
if (!isRecord2(raw)) return scores;
|
|
17929
|
+
for (const surface of Object.keys(raw)) {
|
|
17930
|
+
const bySurface = raw[surface];
|
|
17931
|
+
if (!isRecord2(bySurface)) continue;
|
|
17932
|
+
const cleaned = {};
|
|
17933
|
+
for (const domain2 of Object.keys(bySurface)) {
|
|
17934
|
+
const score = bySurface[domain2];
|
|
17935
|
+
if (typeof score === "number" && Number.isFinite(score)) cleaned[domain2] = score;
|
|
17936
|
+
}
|
|
17937
|
+
scores[surface] = cleaned;
|
|
17938
|
+
}
|
|
17939
|
+
return scores;
|
|
17940
|
+
}
|
|
17941
|
+
function cleanCounts(raw) {
|
|
17942
|
+
const counts = { critical: 0, high: 0, medium: 0, low: 0, info: 0 };
|
|
17943
|
+
if (!isRecord2(raw)) return counts;
|
|
17944
|
+
for (const severity of Object.keys(counts)) {
|
|
17945
|
+
const value = raw[severity];
|
|
17946
|
+
if (typeof value === "number" && Number.isFinite(value)) counts[severity] = value;
|
|
17947
|
+
}
|
|
17948
|
+
return counts;
|
|
17949
|
+
}
|
|
17950
|
+
function cellSet(scores) {
|
|
17951
|
+
const cells = /* @__PURE__ */ new Map();
|
|
17952
|
+
for (const surface of Object.keys(scores)) {
|
|
17953
|
+
for (const domain2 of Object.keys(scores[surface])) cells.set(`${surface}::${domain2}`, scores[surface][domain2]);
|
|
17954
|
+
}
|
|
17955
|
+
return cells;
|
|
17956
|
+
}
|
|
17957
|
+
function liveScores(live) {
|
|
17958
|
+
const scores = {};
|
|
17959
|
+
for (const domain2 of Object.keys(live.matrix ?? {})) {
|
|
17960
|
+
const row = live.matrix[domain2];
|
|
17961
|
+
if (!isRecord2(row)) continue;
|
|
17962
|
+
for (const surface of Object.keys(row)) {
|
|
17963
|
+
const cell = row[surface];
|
|
17964
|
+
if (!cell || typeof cell.score !== "number") continue;
|
|
17965
|
+
(scores[surface] ??= {})[domain2] = cell.score;
|
|
17966
|
+
}
|
|
17967
|
+
}
|
|
17968
|
+
return scores;
|
|
17969
|
+
}
|
|
17970
|
+
function sameCells(a, b) {
|
|
17971
|
+
if (a.size !== b.size) return false;
|
|
17972
|
+
for (const [key, value] of a) {
|
|
17973
|
+
if (b.get(key) !== value) return false;
|
|
17974
|
+
}
|
|
17975
|
+
return true;
|
|
17976
|
+
}
|
|
17977
|
+
function deriveQualityTrend(events, profile, live) {
|
|
17978
|
+
const weights = profile?.domain_weights;
|
|
17979
|
+
const byAudit = /* @__PURE__ */ new Map();
|
|
17980
|
+
const audits = (Array.isArray(events) ? events : []).filter(
|
|
17981
|
+
(event) => isRecord2(event) && event.type === "quality.audit.completed"
|
|
17982
|
+
);
|
|
17983
|
+
for (const event of orderEvents(audits)) {
|
|
17984
|
+
const auditId = typeof event.audit_id === "string" ? event.audit_id : typeof event.id === "string" ? event.id : "";
|
|
17985
|
+
const scores = cleanScores(event.scores);
|
|
17986
|
+
const overall = {};
|
|
17987
|
+
for (const surface of Object.keys(scores)) overall[surface] = rollUpSurface(scores[surface], weights);
|
|
17988
|
+
const snapshot = {
|
|
17989
|
+
audit_id: auditId,
|
|
17990
|
+
ts: typeof event.ts === "string" ? event.ts : "",
|
|
17991
|
+
...typeof event.commit === "string" && event.commit !== "" ? { commit: event.commit } : {},
|
|
17992
|
+
...typeof event.framework_version === "string" ? { framework_version: event.framework_version } : {},
|
|
17993
|
+
comparable: true,
|
|
17994
|
+
scores,
|
|
17995
|
+
overall,
|
|
17996
|
+
counts: cleanCounts(event.counts)
|
|
17997
|
+
};
|
|
17998
|
+
byAudit.delete(auditId);
|
|
17999
|
+
byAudit.set(auditId, snapshot);
|
|
18000
|
+
}
|
|
18001
|
+
const snapshots = [...byAudit.values()];
|
|
18002
|
+
for (let i = 1; i < snapshots.length; i++) {
|
|
18003
|
+
snapshots[i].comparable = sameFrameworkMajor(snapshots[i - 1].framework_version, snapshots[i].framework_version);
|
|
18004
|
+
}
|
|
18005
|
+
const latest = snapshots.length > 0 ? snapshots[snapshots.length - 1] : null;
|
|
18006
|
+
let previous = latest;
|
|
18007
|
+
if (live && latest !== null && sameCells(cellSet(latest.scores), cellSet(liveScores(live)))) {
|
|
18008
|
+
previous = snapshots.length > 1 ? snapshots[snapshots.length - 2] : null;
|
|
18009
|
+
}
|
|
18010
|
+
const comparable = previous !== null && live ? sameFrameworkMajor(previous.framework_version, live.framework_version) : false;
|
|
18011
|
+
const against = (prev, current) => {
|
|
18012
|
+
if (previous === null || typeof prev !== "number") return NO_DELTA;
|
|
18013
|
+
const delta = comparable && typeof current === "number" ? current - prev : null;
|
|
18014
|
+
return { previous: prev, delta, audit_id: previous.audit_id };
|
|
18015
|
+
};
|
|
18016
|
+
return {
|
|
18017
|
+
snapshots,
|
|
18018
|
+
latest,
|
|
18019
|
+
previous,
|
|
18020
|
+
deltaCell: (domain2, surface) => against(previous?.scores[surface]?.[domain2], live?.matrix?.[domain2]?.[surface]?.score),
|
|
18021
|
+
deltaOverall: (surface) => against(previous?.overall[surface], live?.overall?.[surface])
|
|
18022
|
+
};
|
|
18023
|
+
}
|
|
18024
|
+
function trendRows(trend, filter = {}) {
|
|
18025
|
+
const surfaces = [];
|
|
18026
|
+
for (const snapshot of trend.snapshots) {
|
|
18027
|
+
for (const surface of Object.keys(snapshot.scores)) {
|
|
18028
|
+
if (filter.surface !== void 0 && surface !== filter.surface) continue;
|
|
18029
|
+
if (!surfaces.includes(surface)) surfaces.push(surface);
|
|
18030
|
+
}
|
|
18031
|
+
}
|
|
18032
|
+
const valueOf = (snapshot, surface) => {
|
|
18033
|
+
if (filter.domain !== void 0) return snapshot.scores[surface]?.[filter.domain] ?? null;
|
|
18034
|
+
return snapshot.overall[surface] ?? null;
|
|
18035
|
+
};
|
|
18036
|
+
const rows = [];
|
|
18037
|
+
trend.snapshots.forEach((snapshot, index) => {
|
|
18038
|
+
const above = index > 0 ? trend.snapshots[index - 1] : null;
|
|
18039
|
+
const cells = {};
|
|
18040
|
+
for (const surface of surfaces) {
|
|
18041
|
+
const score = valueOf(snapshot, surface);
|
|
18042
|
+
const before = above === null ? null : valueOf(above, surface);
|
|
18043
|
+
const delta = snapshot.comparable && score !== null && before !== null ? score - before : null;
|
|
18044
|
+
cells[surface] = { score, delta };
|
|
18045
|
+
}
|
|
18046
|
+
rows.push({
|
|
18047
|
+
audit_id: snapshot.audit_id,
|
|
18048
|
+
ts: snapshot.ts,
|
|
18049
|
+
...snapshot.commit !== void 0 ? { commit: snapshot.commit } : {},
|
|
18050
|
+
...snapshot.framework_version !== void 0 ? { framework_version: snapshot.framework_version } : {},
|
|
18051
|
+
comparable: snapshot.comparable,
|
|
18052
|
+
cells
|
|
18053
|
+
});
|
|
18054
|
+
});
|
|
18055
|
+
return { surfaces, rows };
|
|
18056
|
+
}
|
|
18057
|
+
|
|
17903
18058
|
// ../schema/src/cli/kritik-audit.ts
|
|
17904
18059
|
import { existsSync as existsSync2, readdirSync, statSync } from "node:fs";
|
|
17905
18060
|
import { join as join2 } from "node:path";
|
|
@@ -18561,6 +18716,37 @@ function buildKritikCatalog(ctx) {
|
|
|
18561
18716
|
return { from, to, total: regressions.length, regressions, events };
|
|
18562
18717
|
}
|
|
18563
18718
|
);
|
|
18719
|
+
tool(
|
|
18720
|
+
{
|
|
18721
|
+
name: "kritik_trend",
|
|
18722
|
+
description: "Where the product stood at each recorded audit, oldest first: one row per quality.audit.completed in the journal, the overall score per surface (or one domain's score with domain), and how each moved against the row above. The score, not the findings \u2014 'from where we started to where we are now'. Rows are ordered by when they were recorded, a re-recorded audit id keeps only its latest reading, and a framework major bump between two audits marks the later row comparable=false with no delta across it. Works in both modes: repo reads the journal sidecar, hosted reads the hosted journal.",
|
|
18723
|
+
inputSchema: {
|
|
18724
|
+
type: "object",
|
|
18725
|
+
properties: {
|
|
18726
|
+
surface: { type: "string", description: "One column only." },
|
|
18727
|
+
domain: { type: "string", description: "Domain code, e.g. SEC \u2014 that domain's score per surface instead of the roll-up." }
|
|
18728
|
+
},
|
|
18729
|
+
additionalProperties: false
|
|
18730
|
+
}
|
|
18731
|
+
},
|
|
18732
|
+
async (args) => {
|
|
18733
|
+
const graph = await load2();
|
|
18734
|
+
const profile = ctx.qualityRoot === void 0 ? graph.loaded.bundle.quality?.profile : loadProfile(ctx.qualityRoot) ?? void 0;
|
|
18735
|
+
const trend = deriveQualityTrend(graph.journal, profile);
|
|
18736
|
+
const filter = {
|
|
18737
|
+
...typeof args.surface === "string" && args.surface !== "" ? { surface: args.surface } : {},
|
|
18738
|
+
...typeof args.domain === "string" && args.domain !== "" ? { domain: args.domain } : {}
|
|
18739
|
+
};
|
|
18740
|
+
const { surfaces, rows } = trendRows(trend, filter);
|
|
18741
|
+
return {
|
|
18742
|
+
total: trend.snapshots.length,
|
|
18743
|
+
surfaces,
|
|
18744
|
+
rows,
|
|
18745
|
+
snapshots: trend.snapshots,
|
|
18746
|
+
...trend.snapshots.length === 0 ? { note: "No recorded audits yet \u2014 `kritik_matrix` with record=true writes one." } : {}
|
|
18747
|
+
};
|
|
18748
|
+
}
|
|
18749
|
+
);
|
|
18564
18750
|
tool(
|
|
18565
18751
|
{
|
|
18566
18752
|
name: "kritik_issue",
|
|
@@ -19675,7 +19861,7 @@ function resolveRemoteConfig(argv2, env, cwd) {
|
|
|
19675
19861
|
}
|
|
19676
19862
|
|
|
19677
19863
|
// src/index.ts
|
|
19678
|
-
var VERSION = "0.
|
|
19864
|
+
var VERSION = "0.5.0";
|
|
19679
19865
|
var argv = process.argv.slice(2);
|
|
19680
19866
|
if (argv.includes("--help") || argv.includes("-h")) {
|
|
19681
19867
|
process.stdout.write(
|
package/package.json
CHANGED