claude-memory-layer 1.1.1 → 1.1.2

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/index.js CHANGED
@@ -22877,6 +22877,51 @@ function formatPruneToolObservationVectorsResult(result) {
22877
22877
  return lines.join("\n");
22878
22878
  }
22879
22879
 
22880
+ // src/apps/cli/auto-heal-tool-observation-vectors-command.ts
22881
+ function resolveAutoHealToolObservationVectorsOptions(options, cwd = process.cwd()) {
22882
+ if (options.project !== void 0 && options.project.trim().length === 0) {
22883
+ throw new Error("auto-heal-tool-observation-vectors --project must not be empty");
22884
+ }
22885
+ return {
22886
+ projectPath: options.project ?? cwd,
22887
+ lockPath: options.lockPath
22888
+ };
22889
+ }
22890
+ function formatAutoHealToolObservationVectorsResult(outcome) {
22891
+ switch (outcome.status) {
22892
+ case "already-healed":
22893
+ return "Auto-heal tool_observation vectors: already healed, nothing to do.";
22894
+ case "lock-busy":
22895
+ return "Auto-heal tool_observation vectors: another process is already healing this project, skipping.";
22896
+ case "no-store":
22897
+ return "Auto-heal tool_observation vectors: no store found for this project, nothing to do.";
22898
+ case "healed":
22899
+ return [
22900
+ "Auto-heal tool_observation vectors: done.",
22901
+ `Vectors deleted: ${outcome.result.vectorsDeleted}`,
22902
+ `Outbox rows removed: ${outcome.result.outboxRowsRemoved}`
22903
+ ].join("\n");
22904
+ }
22905
+ }
22906
+
22907
+ // src/core/operations/tool-observation-vector-auto-heal.ts
22908
+ var TOOL_OBSERVATION_VECTOR_AUTO_HEAL_KEY = "maintenance:tool_observation_vector_prune_v1";
22909
+ async function needsToolObservationVectorAutoHeal(store) {
22910
+ const flag = await store.getEndlessConfig(TOOL_OBSERVATION_VECTOR_AUTO_HEAL_KEY);
22911
+ return flag === null;
22912
+ }
22913
+ async function runToolObservationVectorAutoHeal(store, vectorStore) {
22914
+ const result = await pruneToolObservationVectors(store, vectorStore, { dryRun: false });
22915
+ await vectorStore.optimizeAll();
22916
+ const record = {
22917
+ completedAt: (/* @__PURE__ */ new Date()).toISOString(),
22918
+ vectorsDeleted: result.vectorsDeleted,
22919
+ outboxRowsRemoved: result.outboxRowsRemoved
22920
+ };
22921
+ await store.setEndlessConfig(TOOL_OBSERVATION_VECTOR_AUTO_HEAL_KEY, record);
22922
+ return result;
22923
+ }
22924
+
22880
22925
  // src/apps/cli/retention-audit-command.ts
22881
22926
  var DEFAULT_RETENTION_AUDIT_LIMIT = 100;
22882
22927
  function resolveRetentionAuditOptions(options) {
@@ -24320,7 +24365,7 @@ async function runOperationCli(action, label) {
24320
24365
  }
24321
24366
  }
24322
24367
  var program = new Command();
24323
- program.name("claude-memory-layer").description("Claude Code Memory Plugin CLI").version("1.1.1");
24368
+ program.name("claude-memory-layer").description("Claude Code Memory Plugin CLI").version("1.1.2");
24324
24369
  program.command("market-context").description("Fetch read-only DART/FRED/Finnhub context with structured MarketContextSnapshot bull/bear/risk/catalyst analysis").option("--company <name>", "Company name for DART fallback search and report subject").option("--dart-corp-code <code>", "Exact DART corp_code for issuer-specific filings").option("--symbol <ticker>", "Listed ticker for Finnhub company profile").option("--providers <list>", "Comma-separated providers: dart,fred,finnhub").option("--fred-series <list>", "Comma-separated FRED series IDs").option("--json", "Print structured JSON including analysis.marketSnapshot").option("--no-snapshot", "Disable MarketContextSnapshot and DART company snapshot analysis").action(async (options) => {
24325
24370
  try {
24326
24371
  await runMarketContextCommand(options);
@@ -24735,6 +24780,42 @@ repairCommand.command("prune-tool-observation-vectors").description("Delete alre
24735
24780
  process.exit(1);
24736
24781
  }
24737
24782
  });
24783
+ repairCommand.command("auto-heal-tool-observation-vectors").description("Internal: self-triggered one-time cleanup of already-embedded tool_observation vectors").option("-p, --project <path>", "Project path (defaults to cwd)").option("--lock-path <path>", "Override auto-heal lock path (advanced)").action(async (options) => {
24784
+ let store;
24785
+ let workerLock;
24786
+ try {
24787
+ const healOptions = resolveAutoHealToolObservationVectorsOptions(options);
24788
+ const storagePath = getProjectStoragePath(healOptions.projectPath);
24789
+ const dbPath = path28.join(storagePath, "events.sqlite");
24790
+ if (!fs20.existsSync(dbPath)) {
24791
+ console.log(formatAutoHealToolObservationVectorsResult({ status: "no-store" }));
24792
+ return;
24793
+ }
24794
+ const lockPath = healOptions.lockPath ?? path28.join(storagePath, "auto-heal.lock");
24795
+ workerLock = new WorkerLock(lockPath);
24796
+ const lockResult = workerLock.acquire();
24797
+ if (!lockResult.acquired) {
24798
+ console.log(formatAutoHealToolObservationVectorsResult({ status: "lock-busy" }));
24799
+ workerLock = void 0;
24800
+ return;
24801
+ }
24802
+ store = new SQLiteEventStore(dbPath);
24803
+ if (!await needsToolObservationVectorAutoHeal(store)) {
24804
+ console.log(formatAutoHealToolObservationVectorsResult({ status: "already-healed" }));
24805
+ return;
24806
+ }
24807
+ const vectorStore = new VectorStore(path28.join(storagePath, "vectors"));
24808
+ const result = await runToolObservationVectorAutoHeal(store, vectorStore);
24809
+ console.log(formatAutoHealToolObservationVectorsResult({ status: "healed", result }));
24810
+ } catch (error) {
24811
+ const message = error instanceof Error ? error.message : String(error);
24812
+ console.error(`Auto-heal tool_observation vectors failed: ${message}`);
24813
+ process.exitCode = 1;
24814
+ } finally {
24815
+ if (store) await store.close().catch(() => void 0);
24816
+ if (workerLock) workerLock.release();
24817
+ }
24818
+ });
24738
24819
  var actorsCommand = program.command("actors").description("Inspect and repair Perspective Memory actors and session memberships");
24739
24820
  actorsCommand.command("repair").description("Backfill Perspective Memory actors and session actor memberships from existing events").requiredOption("-p, --project <path>", "Project path").option("--session-id <id>", "Restrict backfill to a single session").option("--limit <count>", "Maximum events to scan", "10000").option("--sample-limit <count>", "Maximum privacy-safe samples to include", "10").option("--dry-run", "Inspect without mutating actors or session memberships").option("--apply", "Apply actor and membership backfill (default is dry-run)").option("--json", "Print machine-readable JSON").action((options) => runOperationCli(async () => {
24740
24821
  if (options.apply && options.dryRun) {