@datasynx/agentic-ai-cartography 2.5.0 → 2.7.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/cli.js CHANGED
@@ -11,10 +11,12 @@ import {
11
11
  runDrift,
12
12
  runLocalDiscovery,
13
13
  startMcp
14
- } from "./chunk-RYQ4KQCK.js";
14
+ } from "./chunk-HLWNO3RF.js";
15
15
  import {
16
- startApi
17
- } from "./chunk-NQXZUWOI.js";
16
+ entitiesToYaml,
17
+ startApi,
18
+ toBackstageEntities
19
+ } from "./chunk-TBPGFEMQ.js";
18
20
  import {
19
21
  CartographyDB,
20
22
  buildCartographyToolHandlers,
@@ -26,7 +28,7 @@ import {
26
28
  redactValue,
27
29
  stableStringify,
28
30
  stripSensitive
29
- } from "./chunk-GA4427LB.js";
31
+ } from "./chunk-YVV6NIT2.js";
30
32
  import {
31
33
  ConfigFileSchema,
32
34
  CostEntrySchema,
@@ -1377,30 +1379,7 @@ function generateDiffMermaid(diff) {
1377
1379
  return lines.join("\n");
1378
1380
  }
1379
1381
  function exportBackstageYAML(nodes, edges, org) {
1380
- const owner = org ?? "unknown";
1381
- const docs = [];
1382
- for (const node of nodes) {
1383
- const isComponent = ["web_service", "container", "pod"].includes(node.type);
1384
- const isAPI = node.type === "api_endpoint";
1385
- const kind = isComponent ? "Component" : isAPI ? "API" : "Resource";
1386
- const deps = edges.filter((e) => e.sourceId === node.id).map((e) => ` - resource:default/${sanitize(e.targetId)}`);
1387
- const doc = [
1388
- `apiVersion: backstage.io/v1alpha1`,
1389
- `kind: ${kind}`,
1390
- `metadata:`,
1391
- ` name: ${sanitize(node.id)}`,
1392
- ` annotations:`,
1393
- ` cartography/discovered-at: "${node.discoveredAt}"`,
1394
- ` cartography/confidence: "${node.confidence}"`,
1395
- `spec:`,
1396
- ` type: ${node.type}`,
1397
- ` lifecycle: production`,
1398
- ` owner: ${node.owner ?? owner}`,
1399
- ...deps.length > 0 ? [" dependsOn:", ...deps] : []
1400
- ].join("\n");
1401
- docs.push(doc);
1402
- }
1403
- return docs.join("\n---\n");
1382
+ return entitiesToYaml(toBackstageEntities(nodes, edges, org !== void 0 ? { org } : {}));
1404
1383
  }
1405
1384
  function exportJSON(db, sessionId) {
1406
1385
  const nodes = db.getNodes(sessionId);
@@ -4706,7 +4685,7 @@ ${infraSummary.substring(0, 12e3)}`;
4706
4685
  process.exitCode = 1;
4707
4686
  }
4708
4687
  });
4709
- program.command("prune").description("Delete old sessions and their data").option("--older-than <days>", "Delete sessions older than N days", "30").option("--db <path>", "DB path").option("--dry-run", "Show what would be deleted without actually deleting", false).action((opts) => {
4688
+ program.command("prune").description("Delete old sessions and their data").option("--older-than <days>", "Delete sessions older than N days", "30").option("--events-older-than <days>", "Compact the audit trail: delete activity events older than N days (4.7 retention)").option("--db <path>", "DB path").option("--dry-run", "Show what would be deleted without actually deleting", false).action((opts) => {
4710
4689
  const days = parseInt(opts.olderThan, 10);
4711
4690
  if (Number.isNaN(days) || days < 1) {
4712
4691
  process.stderr.write(`Invalid --older-than: "${opts.olderThan}" (must be >= 1)
@@ -4717,6 +4696,26 @@ ${infraSummary.substring(0, 12e3)}`;
4717
4696
  const config = defaultConfig({ ...opts.db ? { dbPath: opts.db } : {} });
4718
4697
  const db = new CartographyDB(config.dbPath);
4719
4698
  const cutoff = new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString();
4699
+ if (opts.eventsOlderThan !== void 0) {
4700
+ const eventDays = parseInt(opts.eventsOlderThan, 10);
4701
+ if (Number.isNaN(eventDays) || eventDays < 1) {
4702
+ process.stderr.write(`Invalid --events-older-than: "${opts.eventsOlderThan}" (must be >= 1)
4703
+ `);
4704
+ process.exitCode = 2;
4705
+ db.close();
4706
+ return;
4707
+ }
4708
+ const eventCutoff = new Date(Date.now() - eventDays * 24 * 60 * 60 * 1e3).toISOString();
4709
+ if (opts.dryRun) {
4710
+ process.stderr.write(`Would compact the audit trail (delete events older than ${eventDays} days).
4711
+ `);
4712
+ } else {
4713
+ const removed = db.pruneEventsOlderThan(eventCutoff);
4714
+ logInfo("Audit events pruned", { removed, olderThanDays: eventDays });
4715
+ process.stderr.write(`Deleted ${removed} audit event(s) older than ${eventDays} days.
4716
+ `);
4717
+ }
4718
+ }
4720
4719
  const sessions = db.getSessions().filter((s) => s.startedAt < cutoff);
4721
4720
  if (sessions.length === 0) {
4722
4721
  process.stderr.write(`No sessions older than ${days} days.