@asiflow/devcortex 0.1.3 → 0.1.4

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/daemon.js CHANGED
@@ -10347,7 +10347,7 @@ function contentTypeFor(filename) {
10347
10347
  }
10348
10348
 
10349
10349
  // ../daemon/src/ship-reports.ts
10350
- import { readFile as readFile8, readdir as readdir2 } from "fs/promises";
10350
+ import { readFile as readFile8, readdir as readdir2, stat as stat2 } from "fs/promises";
10351
10351
  import path7 from "path";
10352
10352
  var NO_REPORT_STATUS = "NO_REPORT";
10353
10353
  var DEFAULT_SHIP_REPORT_LIMIT = 10;
@@ -10377,11 +10377,13 @@ async function listShipReports(root, limit = DEFAULT_SHIP_REPORT_LIMIT) {
10377
10377
  return reports;
10378
10378
  }
10379
10379
  var STATUS_LINE = /^- \*\*Status:\*\* (.+)$/;
10380
+ var GENERATED_LINE = /^- \*\*Generated:\*\* (.+)$/;
10380
10381
  function parseShipReport(markdown) {
10381
10382
  let status = "UNKNOWN";
10382
10383
  let passed = 0;
10383
10384
  let blocked = 0;
10384
10385
  let warnings = 0;
10386
+ let generatedAt = null;
10385
10387
  let section = "other";
10386
10388
  for (const line of markdown.split(/\r?\n/)) {
10387
10389
  const statusMatch = STATUS_LINE.exec(line);
@@ -10389,6 +10391,11 @@ function parseShipReport(markdown) {
10389
10391
  status = statusMatch[1].trim();
10390
10392
  continue;
10391
10393
  }
10394
+ const generatedMatch = GENERATED_LINE.exec(line);
10395
+ if (generatedMatch && generatedMatch[1] !== void 0) {
10396
+ generatedAt = generatedMatch[1].trim();
10397
+ continue;
10398
+ }
10392
10399
  if (line.startsWith("## ")) {
10393
10400
  const heading = line.slice(3).trim();
10394
10401
  section = heading === "Passed" ? "passed" : heading.startsWith("Blocked") ? "blocked" : heading === "Warnings" ? "warnings" : "other";
@@ -10403,18 +10410,48 @@ function parseShipReport(markdown) {
10403
10410
  if (line.startsWith("- ")) warnings += 1;
10404
10411
  }
10405
10412
  }
10406
- return { status, passed, blocked, warnings };
10413
+ return { status, passed, blocked, warnings, generatedAt };
10414
+ }
10415
+ async function isStaleSince(root, generatedAt) {
10416
+ if (generatedAt === null) return false;
10417
+ const shippedAt = Date.parse(generatedAt);
10418
+ if (Number.isNaN(shippedAt)) return false;
10419
+ let files;
10420
+ try {
10421
+ const graph = JSON.parse(await readFile8(workspacePaths(root).graph, "utf8"));
10422
+ files = Array.isArray(graph.files) ? graph.files.slice(0, 5e3) : [];
10423
+ } catch {
10424
+ return false;
10425
+ }
10426
+ for (const f of files) {
10427
+ try {
10428
+ const s = await stat2(path7.join(root, f.path));
10429
+ if (s.mtimeMs > shippedAt) return true;
10430
+ } catch {
10431
+ }
10432
+ }
10433
+ return false;
10407
10434
  }
10408
10435
  async function readyScore(root) {
10409
10436
  const [latest] = await listShipReports(root, 1);
10410
10437
  if (latest === void 0) {
10411
- return { score: 0, status: NO_REPORT_STATUS, passed: 0, blocked: 0, warnings: 0 };
10438
+ return {
10439
+ score: 0,
10440
+ status: NO_REPORT_STATUS,
10441
+ passed: 0,
10442
+ blocked: 0,
10443
+ warnings: 0,
10444
+ generatedAt: null,
10445
+ reportName: null,
10446
+ stale: false
10447
+ };
10412
10448
  }
10413
- const { status, passed, blocked, warnings } = parseShipReport(latest.markdown);
10449
+ const { status, passed, blocked, warnings, generatedAt } = parseShipReport(latest.markdown);
10414
10450
  const total = passed + blocked + warnings;
10415
10451
  const numerator = passed + 0.5 * warnings;
10416
10452
  const score = total === 0 ? 0 : Math.round(100 * numerator / total);
10417
- return { score, status, passed, blocked, warnings };
10453
+ const stale = await isStaleSince(root, generatedAt);
10454
+ return { score, status, passed, blocked, warnings, generatedAt, reportName: latest.name, stale };
10418
10455
  }
10419
10456
 
10420
10457
  // ../daemon/src/api.ts