@gethmy/mcp 2.3.4 → 2.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/src/server.ts CHANGED
@@ -58,7 +58,12 @@ import {
58
58
  } from "./context-assembly.js";
59
59
  import { autoExpandGraph } from "./graph-expansion.js";
60
60
  import { runLifecycleMaintenance } from "./lifecycle-maintenance.js";
61
- import { runMemoryCleanup, purgeMemories, type PurgeFilters } from "./memory-cleanup.js";
61
+ import { runMemoryAudit } from "./memory-audit.js";
62
+ import {
63
+ type PurgeFilters,
64
+ purgeMemories,
65
+ runMemoryCleanup,
66
+ } from "./memory-cleanup.js";
62
67
  import { onboardNewUser } from "./onboard.js";
63
68
  import type { PromptVariant } from "./prompt-builder.js";
64
69
 
@@ -1657,7 +1662,7 @@ const TOOLS = {
1657
1662
 
1658
1663
  harmony_cleanup_memories: {
1659
1664
  description:
1660
- "Run a unified memory cleanup: prune stale drafts, consolidate similar memories, detect orphans and duplicates, and backfill embeddings. Returns a health report. Dry-run by default — run with dryRun=false to execute.",
1665
+ "Run a unified memory cleanup: prune stale drafts, consolidate similar memories, detect orphans and duplicates, backfill embeddings, and optionally run a quality audit. Returns a health report. Dry-run by default — run with dryRun=false to execute.",
1661
1666
  inputSchema: {
1662
1667
  type: "object",
1663
1668
  properties: {
@@ -1678,10 +1683,17 @@ const TOOLS = {
1678
1683
  type: "array",
1679
1684
  items: {
1680
1685
  type: "string",
1681
- enum: ["prune", "consolidate", "orphans", "duplicates", "backfill"],
1686
+ enum: [
1687
+ "prune",
1688
+ "consolidate",
1689
+ "orphans",
1690
+ "duplicates",
1691
+ "backfill",
1692
+ "audit",
1693
+ ],
1682
1694
  },
1683
1695
  description:
1684
- "Which cleanup steps to run (default: all). Options: prune, consolidate, orphans, duplicates, backfill.",
1696
+ "Which cleanup steps to run (default: all). Options: prune, consolidate, orphans, duplicates, backfill, audit.",
1685
1697
  },
1686
1698
  maxAgeDays: {
1687
1699
  type: "number",
@@ -1695,6 +1707,52 @@ const TOOLS = {
1695
1707
  type: "number",
1696
1708
  description: "Min age in days for orphan detection (default: 14)",
1697
1709
  },
1710
+ auditArchiveBelow: {
1711
+ type: "number",
1712
+ description: "Audit: archive entities scoring below this (default: 40)",
1713
+ },
1714
+ auditDeleteBelow: {
1715
+ type: "number",
1716
+ description: "Audit: delete entities scoring below this (default: 20)",
1717
+ },
1718
+ },
1719
+ required: [],
1720
+ },
1721
+ },
1722
+ harmony_audit_memories: {
1723
+ description:
1724
+ "Rate every memory against state-of-the-art quality standards (confidence, decay, structural completeness, content, tier-age fit, access). Flags legacy entities from before recent optimizations (default confidence, missing embeddings, stuck drafts). Buckets: keep (≥70), review (40-69), archive (20-39), delete (<20). Dry-run by default.",
1725
+ inputSchema: {
1726
+ type: "object",
1727
+ properties: {
1728
+ workspaceId: {
1729
+ type: "string",
1730
+ description: "Workspace ID (optional if context set)",
1731
+ },
1732
+ projectId: {
1733
+ type: "string",
1734
+ description: "Project ID (optional)",
1735
+ },
1736
+ dryRun: {
1737
+ type: "boolean",
1738
+ description:
1739
+ "Preview audit without flagging/archiving/deleting (default: true)",
1740
+ },
1741
+ archiveBelow: {
1742
+ type: "number",
1743
+ description:
1744
+ "Score threshold below which entities are archived (confidence set to 0.25). Default: 40",
1745
+ },
1746
+ deleteBelow: {
1747
+ type: "number",
1748
+ description:
1749
+ "Score threshold below which entities are hard-deleted. Default: 20. Set to 0 to never delete.",
1750
+ },
1751
+ limit: {
1752
+ type: "number",
1753
+ description:
1754
+ "Max number of entities to audit (default: 500). Paginated fetch.",
1755
+ },
1698
1756
  },
1699
1757
  required: [],
1700
1758
  },
@@ -4091,6 +4149,37 @@ async function handleToolCall(
4091
4149
  };
4092
4150
  }
4093
4151
 
4152
+ case "harmony_audit_memories": {
4153
+ const workspaceId =
4154
+ (args.workspaceId as string) || deps.getActiveWorkspaceId();
4155
+ if (!workspaceId) {
4156
+ throw new Error(
4157
+ "No workspace specified. Use harmony_set_workspace_context or provide workspaceId.",
4158
+ );
4159
+ }
4160
+ const projectId =
4161
+ (args.projectId as string) || deps.getActiveProjectId() || undefined;
4162
+
4163
+ const report = await runMemoryAudit(client, workspaceId, projectId, {
4164
+ dryRun: args.dryRun as boolean | undefined,
4165
+ archiveBelow: args.archiveBelow as number | undefined,
4166
+ deleteBelow: args.deleteBelow as number | undefined,
4167
+ limit: args.limit as number | undefined,
4168
+ });
4169
+
4170
+ return {
4171
+ success: report.success,
4172
+ dryRun: report.dryRun,
4173
+ summary: report.summary,
4174
+ distribution: report.distribution,
4175
+ legacyBreakdown: report.legacyBreakdown,
4176
+ actionsTaken: report.actionsTaken,
4177
+ lowest: report.lowest,
4178
+ errors: report.errors,
4179
+ healthReport: report.healthReport,
4180
+ };
4181
+ }
4182
+
4094
4183
  case "harmony_cleanup_memories": {
4095
4184
  const workspaceId =
4096
4185
  (args.workspaceId as string) || deps.getActiveWorkspaceId();
@@ -4108,6 +4197,7 @@ async function handleToolCall(
4108
4197
  "orphans",
4109
4198
  "duplicates",
4110
4199
  "backfill",
4200
+ "audit",
4111
4201
  ];
4112
4202
  const rawSteps = args.steps as string[] | undefined;
4113
4203
  const steps = rawSteps?.filter((s) => validSteps.includes(s));
@@ -4119,10 +4209,14 @@ async function handleToolCall(
4119
4209
 
4120
4210
  const report = await runMemoryCleanup(client, workspaceId, projectId, {
4121
4211
  dryRun: args.dryRun as boolean | undefined,
4122
- steps,
4212
+ steps: steps as
4213
+ | ("prune" | "consolidate" | "orphans" | "duplicates" | "backfill" | "audit")[]
4214
+ | undefined,
4123
4215
  maxAgeDays: args.maxAgeDays as number | undefined,
4124
4216
  minClusterSize: args.minClusterSize as number | undefined,
4125
4217
  orphanAgeDays: args.orphanAgeDays as number | undefined,
4218
+ auditArchiveBelow: args.auditArchiveBelow as number | undefined,
4219
+ auditDeleteBelow: args.auditDeleteBelow as number | undefined,
4126
4220
  });
4127
4221
 
4128
4222
  return {
@@ -4142,8 +4236,7 @@ async function handleToolCall(
4142
4236
  "No workspace specified. Use harmony_set_workspace_context or provide workspaceId.",
4143
4237
  );
4144
4238
  }
4145
- const projectId =
4146
- (args.projectId as string) || deps.getActiveProjectId();
4239
+ const projectId = (args.projectId as string) || deps.getActiveProjectId();
4147
4240
  if (!projectId) {
4148
4241
  throw new Error(
4149
4242
  "No project specified. Purge requires a project scope. Use harmony_set_project_context or provide projectId.",