arkaik-mcp 0.7.0 → 0.8.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 +222 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18287,14 +18287,175 @@ function scopeSummary(scope) {
|
|
|
18287
18287
|
return `${cells}${split} from ${from}${scope.since !== null ? ` since ${scope.since}` : ""}`;
|
|
18288
18288
|
}
|
|
18289
18289
|
|
|
18290
|
+
// ../schema/src/quality-burndown.ts
|
|
18291
|
+
var EVENT_CAUSE = {
|
|
18292
|
+
"quality.finding.opened": "opened",
|
|
18293
|
+
"quality.finding.resolved": "resolved",
|
|
18294
|
+
"quality.finding.accepted": "accepted",
|
|
18295
|
+
"quality.audit.completed": "audit"
|
|
18296
|
+
};
|
|
18297
|
+
var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18298
|
+
var isString2 = (value) => typeof value === "string" && value !== "";
|
|
18299
|
+
var emptyCounts = () => ({ critical: 0, high: 0, medium: 0, low: 0, info: 0 });
|
|
18300
|
+
var asSeverity = (value) => typeof value === "string" && FINDING_SEVERITIES.includes(value) ? value : null;
|
|
18301
|
+
function cleanCounts2(raw) {
|
|
18302
|
+
const counts = emptyCounts();
|
|
18303
|
+
if (!isRecord3(raw)) return counts;
|
|
18304
|
+
for (const severity of FINDING_SEVERITIES) {
|
|
18305
|
+
const value = raw[severity];
|
|
18306
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) counts[severity] = value;
|
|
18307
|
+
}
|
|
18308
|
+
return counts;
|
|
18309
|
+
}
|
|
18310
|
+
function openTotal(open) {
|
|
18311
|
+
return FINDING_SEVERITIES.reduce((sum, severity) => sum + (open[severity] ?? 0), 0);
|
|
18312
|
+
}
|
|
18313
|
+
function deriveFindingsBurndown(events, options = {}) {
|
|
18314
|
+
const { surface, domain: domain2, library } = options;
|
|
18315
|
+
const filtered = surface !== void 0 || domain2 !== void 0;
|
|
18316
|
+
const sectionById = /* @__PURE__ */ new Map();
|
|
18317
|
+
for (const finding of Array.isArray(options.findings) ? options.findings : []) {
|
|
18318
|
+
if (isRecord3(finding) && isString2(finding.id)) sectionById.set(finding.id, finding);
|
|
18319
|
+
}
|
|
18320
|
+
const inView = (where) => {
|
|
18321
|
+
if (!filtered) return true;
|
|
18322
|
+
if (where === void 0) return false;
|
|
18323
|
+
if (surface !== void 0 && where.surface !== surface) return false;
|
|
18324
|
+
if (domain2 !== void 0 && (!isString2(where.criterion_id) || domainCodeOf(where.criterion_id, library) !== domain2)) {
|
|
18325
|
+
return false;
|
|
18326
|
+
}
|
|
18327
|
+
return true;
|
|
18328
|
+
};
|
|
18329
|
+
const relevant = (Array.isArray(events) ? events : []).filter(
|
|
18330
|
+
(event) => isRecord3(event) && typeof event.type === "string" && event.type in EVENT_CAUSE
|
|
18331
|
+
);
|
|
18332
|
+
const openedIds = /* @__PURE__ */ new Set();
|
|
18333
|
+
const decidedIds = /* @__PURE__ */ new Set();
|
|
18334
|
+
for (const event of relevant) {
|
|
18335
|
+
if (!isString2(event.finding_id)) continue;
|
|
18336
|
+
if (event.type === "quality.finding.opened") openedIds.add(event.finding_id);
|
|
18337
|
+
else if (event.type !== "quality.audit.completed") decidedIds.add(event.finding_id);
|
|
18338
|
+
}
|
|
18339
|
+
const seedable = (id, finding) => {
|
|
18340
|
+
if (openedIds.has(id) || !inView(finding)) return false;
|
|
18341
|
+
if (finding.status === "open") return true;
|
|
18342
|
+
return (finding.status === "resolved" || finding.status === "accepted-risk") && decidedIds.has(id);
|
|
18343
|
+
};
|
|
18344
|
+
const tracked = /* @__PURE__ */ new Map();
|
|
18345
|
+
const open = emptyCounts();
|
|
18346
|
+
const points = [];
|
|
18347
|
+
const totals = { opened: 0, resolved: 0, accepted: 0 };
|
|
18348
|
+
let since = null;
|
|
18349
|
+
let seeded = false;
|
|
18350
|
+
const bump = (severity, by) => {
|
|
18351
|
+
if (severity !== null) open[severity] = Math.max(0, open[severity] + by);
|
|
18352
|
+
};
|
|
18353
|
+
const mark = (event, type, id) => {
|
|
18354
|
+
points.push({ ts: typeof event.ts === "string" ? event.ts : "", open: { ...open }, cause: { type, id } });
|
|
18355
|
+
};
|
|
18356
|
+
const count = (type) => {
|
|
18357
|
+
totals[type]++;
|
|
18358
|
+
if (since !== null) since[type]++;
|
|
18359
|
+
};
|
|
18360
|
+
for (const event of orderEvents(relevant)) {
|
|
18361
|
+
const type = EVENT_CAUSE[event.type];
|
|
18362
|
+
if (type === "audit") {
|
|
18363
|
+
if (!seeded) {
|
|
18364
|
+
seeded = true;
|
|
18365
|
+
for (const [id2, finding] of sectionById) {
|
|
18366
|
+
if (tracked.has(id2) || !seedable(id2, finding)) continue;
|
|
18367
|
+
const severity = severityOf(finding, library);
|
|
18368
|
+
tracked.set(id2, { severity, open: true, surface: finding.surface, criterion_id: finding.criterion_id });
|
|
18369
|
+
bump(severity, 1);
|
|
18370
|
+
}
|
|
18371
|
+
}
|
|
18372
|
+
if (!filtered) Object.assign(open, cleanCounts2(event.counts));
|
|
18373
|
+
const auditId = isString2(event.audit_id) ? event.audit_id : isString2(event.id) ? event.id : "";
|
|
18374
|
+
since = { audit_id: auditId, ts: typeof event.ts === "string" ? event.ts : "", opened: 0, resolved: 0, accepted: 0 };
|
|
18375
|
+
mark(event, "audit", auditId);
|
|
18376
|
+
continue;
|
|
18377
|
+
}
|
|
18378
|
+
const id = event.finding_id;
|
|
18379
|
+
if (!isString2(id)) continue;
|
|
18380
|
+
const known = tracked.get(id);
|
|
18381
|
+
if (type === "opened") {
|
|
18382
|
+
if (known?.open) continue;
|
|
18383
|
+
if (!inView(event)) continue;
|
|
18384
|
+
const severity = asSeverity(event.severity);
|
|
18385
|
+
tracked.set(id, {
|
|
18386
|
+
severity,
|
|
18387
|
+
open: true,
|
|
18388
|
+
...typeof event.surface === "string" ? { surface: event.surface } : {},
|
|
18389
|
+
...typeof event.criterion_id === "string" ? { criterion_id: event.criterion_id } : {}
|
|
18390
|
+
});
|
|
18391
|
+
bump(severity, 1);
|
|
18392
|
+
count("opened");
|
|
18393
|
+
mark(event, "opened", id);
|
|
18394
|
+
continue;
|
|
18395
|
+
}
|
|
18396
|
+
if (known !== void 0) {
|
|
18397
|
+
if (!known.open) continue;
|
|
18398
|
+
known.open = false;
|
|
18399
|
+
bump(known.severity, -1);
|
|
18400
|
+
} else {
|
|
18401
|
+
const fromSection = sectionById.get(id);
|
|
18402
|
+
if (!inView(fromSection)) continue;
|
|
18403
|
+
tracked.set(id, {
|
|
18404
|
+
severity: null,
|
|
18405
|
+
open: false,
|
|
18406
|
+
...fromSection ? { surface: fromSection.surface, criterion_id: fromSection.criterion_id } : {}
|
|
18407
|
+
});
|
|
18408
|
+
}
|
|
18409
|
+
count(type);
|
|
18410
|
+
mark(event, type, id);
|
|
18411
|
+
}
|
|
18412
|
+
return { points, ...totals, since };
|
|
18413
|
+
}
|
|
18414
|
+
function burndownRows(burndown) {
|
|
18415
|
+
const { points, since } = burndown;
|
|
18416
|
+
if (points.length === 0) return { reference: null, rows: [] };
|
|
18417
|
+
let referenceIndex = 0;
|
|
18418
|
+
if (since !== null) {
|
|
18419
|
+
for (let index = points.length - 1; index >= 0; index--) {
|
|
18420
|
+
if (points[index].cause.type === "audit") {
|
|
18421
|
+
referenceIndex = index;
|
|
18422
|
+
break;
|
|
18423
|
+
}
|
|
18424
|
+
}
|
|
18425
|
+
}
|
|
18426
|
+
const reference = points[referenceIndex];
|
|
18427
|
+
const last = points[points.length - 1];
|
|
18428
|
+
return {
|
|
18429
|
+
reference: {
|
|
18430
|
+
kind: since !== null ? "audit" : "start",
|
|
18431
|
+
id: reference.cause.id,
|
|
18432
|
+
ts: reference.ts
|
|
18433
|
+
},
|
|
18434
|
+
rows: FINDING_SEVERITIES.map((severity) => ({
|
|
18435
|
+
severity,
|
|
18436
|
+
at_reference: reference.open[severity],
|
|
18437
|
+
now: last.open[severity],
|
|
18438
|
+
change: last.open[severity] - reference.open[severity]
|
|
18439
|
+
}))
|
|
18440
|
+
};
|
|
18441
|
+
}
|
|
18442
|
+
function burndownSummary(burndown, openNow) {
|
|
18443
|
+
if (burndown.points.length === 0) return null;
|
|
18444
|
+
const tally = burndown.since ?? burndown;
|
|
18445
|
+
const closed = tally.resolved + tally.accepted;
|
|
18446
|
+
const where = burndown.since ? ` since the ${burndown.since.audit_id} audit` : "";
|
|
18447
|
+
const open = openNow ?? openTotal(burndown.points[burndown.points.length - 1].open);
|
|
18448
|
+
return `${closed} closed${where} (${tally.resolved} resolved, ${tally.accepted} accepted) \xB7 ${tally.opened} opened \xB7 ${open} open`;
|
|
18449
|
+
}
|
|
18450
|
+
|
|
18290
18451
|
// ../schema/src/quality-baseline.ts
|
|
18291
18452
|
var EPOCH = "1970-01-01T00:00:00.000Z";
|
|
18292
18453
|
var DECISIONS = /* @__PURE__ */ new Set(["quality.finding.resolved", "quality.finding.accepted"]);
|
|
18293
18454
|
var REVERTIBLE = /* @__PURE__ */ new Set(["resolved", "accepted-risk"]);
|
|
18294
18455
|
var SCOPED_AUDIT_ID = /-scoped(-\d+)?$/;
|
|
18295
18456
|
var rowsOf3 = (value) => Array.isArray(value) ? value : [];
|
|
18296
|
-
var
|
|
18297
|
-
var isScopedAuditId = (value) =>
|
|
18457
|
+
var isString3 = (value) => typeof value === "string" && value !== "";
|
|
18458
|
+
var isScopedAuditId = (value) => isString3(value) && SCOPED_AUDIT_ID.test(value);
|
|
18298
18459
|
var isRow = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18299
18460
|
var objectRowsOf = (value) => rowsOf3(value).filter(isRow);
|
|
18300
18461
|
function omit2(obj, keys) {
|
|
@@ -18303,7 +18464,7 @@ function omit2(obj, keys) {
|
|
|
18303
18464
|
return out;
|
|
18304
18465
|
}
|
|
18305
18466
|
function isoOf(value) {
|
|
18306
|
-
if (!
|
|
18467
|
+
if (!isString3(value)) return void 0;
|
|
18307
18468
|
const at = Date.parse(value);
|
|
18308
18469
|
return Number.isFinite(at) ? new Date(at).toISOString() : void 0;
|
|
18309
18470
|
}
|
|
@@ -18315,7 +18476,7 @@ function implicitAuditBaseline(events, section, library) {
|
|
|
18315
18476
|
const rows = objectRowsOf(events);
|
|
18316
18477
|
if (rows.some((event) => event.type === "quality.audit.completed")) return null;
|
|
18317
18478
|
const assessmentRows = objectRowsOf(section?.assessments).filter((row) => !isScopedAuditId(row.audit_id));
|
|
18318
|
-
const taggedAssessments = assessmentRows.filter((row) =>
|
|
18479
|
+
const taggedAssessments = assessmentRows.filter((row) => isString3(row.audit_id));
|
|
18319
18480
|
if (taggedAssessments.length === 0) return null;
|
|
18320
18481
|
const auditId = taggedAssessments.map((row) => row.audit_id).sort().at(-1);
|
|
18321
18482
|
const assessedAts = taggedAssessments.filter((row) => row.audit_id === auditId).map((row) => isoOf(row.ts)).filter((at) => at !== void 0).sort();
|
|
@@ -18343,10 +18504,10 @@ function implicitAuditBaseline(events, section, library) {
|
|
|
18343
18504
|
const decided = /* @__PURE__ */ new Set();
|
|
18344
18505
|
for (const event of decisions) {
|
|
18345
18506
|
const id = event.finding_id;
|
|
18346
|
-
if (
|
|
18507
|
+
if (isString3(id)) decided.add(id);
|
|
18347
18508
|
}
|
|
18348
18509
|
const findings = objectRowsOf(section?.findings).map((finding) => {
|
|
18349
|
-
if (!
|
|
18510
|
+
if (!isString3(finding.id) || !decided.has(finding.id) || !REVERTIBLE.has(finding.status)) return finding;
|
|
18350
18511
|
return { ...omit2(finding, ["resolved_by"]), status: "open" };
|
|
18351
18512
|
});
|
|
18352
18513
|
const matrix = deriveQualityMatrix({ quality: { ...section, assessments: assessmentRows, findings } }, library);
|
|
@@ -19271,6 +19432,60 @@ function buildKritikCatalog(ctx) {
|
|
|
19271
19432
|
};
|
|
19272
19433
|
}
|
|
19273
19434
|
);
|
|
19435
|
+
tool(
|
|
19436
|
+
{
|
|
19437
|
+
name: "kritik_burndown",
|
|
19438
|
+
description: "What was done since the last audit, not what the code is: how many findings closed (resolved or accepted) since the newest recorded audit, how many opened, and the open count by severity then and now \u2014 plus every point of the burndown. A score only moves when its cell is re-scored; this moves the day a finding closes. Replays quality.finding.opened / resolved / accepted in journal order; each quality.audit.completed re-baselines the open counts to what that audit counted, so a finding closed by hand is corrected at the next audit. An opened finding counts at the severity stored on its event; a close of a finding no event opened still counts as closed. surface and domain narrow the replay (never re-baselined, since an audit's counts are project-wide). Works in both modes: repo reads the journal sidecar, hosted reads the hosted journal \u2014 and there a restored audit with no recorded reading is the first point.",
|
|
19439
|
+
inputSchema: {
|
|
19440
|
+
type: "object",
|
|
19441
|
+
properties: {
|
|
19442
|
+
surface: { type: "string", description: "Only findings on this surface." },
|
|
19443
|
+
domain: { type: "string", description: "Domain code, e.g. SEC \u2014 only findings in this domain." }
|
|
19444
|
+
},
|
|
19445
|
+
additionalProperties: false
|
|
19446
|
+
}
|
|
19447
|
+
},
|
|
19448
|
+
async (args) => {
|
|
19449
|
+
const graph = await load2();
|
|
19450
|
+
let section;
|
|
19451
|
+
let library;
|
|
19452
|
+
if (ctx.qualityRoot === void 0) {
|
|
19453
|
+
const hosted = graph.loaded.bundle.quality;
|
|
19454
|
+
if (hosted !== void 0 && Array.isArray(hosted.findings) && Array.isArray(hosted.assessments)) {
|
|
19455
|
+
section = hosted;
|
|
19456
|
+
library = resolveKritikLibrary(hosted);
|
|
19457
|
+
}
|
|
19458
|
+
} else {
|
|
19459
|
+
try {
|
|
19460
|
+
library = libraryOf(ctx.qualityRoot);
|
|
19461
|
+
section = loadCurrentQualitySection(ctx.qualityRoot, library);
|
|
19462
|
+
} catch {
|
|
19463
|
+
}
|
|
19464
|
+
}
|
|
19465
|
+
const events = ctx.qualityRoot === void 0 && section !== void 0 ? withImplicitBaseline(graph.journal, section, library) : graph.journal;
|
|
19466
|
+
const filter = {
|
|
19467
|
+
...typeof args.surface === "string" && args.surface !== "" ? { surface: args.surface } : {},
|
|
19468
|
+
...typeof args.domain === "string" && args.domain !== "" ? { domain: args.domain } : {}
|
|
19469
|
+
};
|
|
19470
|
+
const burndown = deriveFindingsBurndown(events, { ...filter, library, findings: section?.findings });
|
|
19471
|
+
const open = section ? section.findings.filter(
|
|
19472
|
+
(finding) => isOpenFinding(finding) && (filter.surface === void 0 || finding.surface === filter.surface) && (filter.domain === void 0 || domainCodeOf(finding.criterion_id, library) === filter.domain)
|
|
19473
|
+
).length : void 0;
|
|
19474
|
+
const { reference, rows } = burndownRows(burndown);
|
|
19475
|
+
return {
|
|
19476
|
+
summary: burndownSummary(burndown, open),
|
|
19477
|
+
opened: burndown.opened,
|
|
19478
|
+
resolved: burndown.resolved,
|
|
19479
|
+
accepted: burndown.accepted,
|
|
19480
|
+
since: burndown.since,
|
|
19481
|
+
...open !== void 0 ? { open } : {},
|
|
19482
|
+
reference,
|
|
19483
|
+
rows,
|
|
19484
|
+
points: burndown.points,
|
|
19485
|
+
...burndown.points.length === 0 ? { note: "No finding history yet \u2014 kritik_open_finding and kritik_resolve_finding write it, and kritik_matrix with record=true records an audit to measure from." } : {}
|
|
19486
|
+
};
|
|
19487
|
+
}
|
|
19488
|
+
);
|
|
19274
19489
|
tool(
|
|
19275
19490
|
{
|
|
19276
19491
|
name: "kritik_scope",
|
|
@@ -20556,7 +20771,7 @@ function resolveRemoteConfig(argv2, env, cwd) {
|
|
|
20556
20771
|
}
|
|
20557
20772
|
|
|
20558
20773
|
// src/index.ts
|
|
20559
|
-
var VERSION = "0.
|
|
20774
|
+
var VERSION = "0.8.0";
|
|
20560
20775
|
var argv = process.argv.slice(2);
|
|
20561
20776
|
if (argv.includes("--help") || argv.includes("-h")) {
|
|
20562
20777
|
process.stdout.write(
|
package/package.json
CHANGED