clawvault 1.10.2 → 1.10.3

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Observer,
3
3
  parseSessionFile
4
- } from "./chunk-CC7IJJ32.js";
4
+ } from "./chunk-RPMQZZPE.js";
5
5
 
6
6
  // src/commands/observe.ts
7
7
  import * as fs2 from "fs";
@@ -534,12 +534,29 @@ var Router = class {
534
534
  }
535
535
  return null;
536
536
  }
537
+ normalizeForDedup(content) {
538
+ return content.replace(/^\d{2}:\d{2}\s+/, "").replace(/\[\[[^\]]*\]\]/g, (m) => m.replace(/\[\[|\]\]/g, "")).replace(/\s+/g, " ").trim().toLowerCase();
539
+ }
537
540
  appendToCategory(category, item) {
538
541
  const categoryDir = path.join(this.vaultPath, category);
539
542
  fs.mkdirSync(categoryDir, { recursive: true });
540
543
  const filePath = path.join(categoryDir, `${item.date}.md`);
541
544
  const existing = fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf-8").trim() : "";
542
- if (existing.includes(item.content)) return;
545
+ const normalizedNew = this.normalizeForDedup(item.content);
546
+ const existingLines = existing.split(/\r?\n/);
547
+ for (const line of existingLines) {
548
+ const lineContent = line.replace(/^-\s*(?:🔴|🟡|🟢)\s*/, "");
549
+ if (this.normalizeForDedup(lineContent) === normalizedNew) return;
550
+ }
551
+ for (const line of existingLines) {
552
+ const lineContent = line.replace(/^-\s*(?:🔴|🟡|🟢)\s*/, "");
553
+ const normalizedExisting = this.normalizeForDedup(lineContent);
554
+ if (normalizedExisting.length > 10 && normalizedNew.length > 10) {
555
+ const shorter = normalizedNew.length < normalizedExisting.length ? normalizedNew : normalizedExisting;
556
+ const longer = normalizedNew.length >= normalizedExisting.length ? normalizedNew : normalizedExisting;
557
+ if (longer.includes(shorter) || this.similarity(normalizedNew, normalizedExisting) > 0.8) return;
558
+ }
559
+ }
543
560
  const linkedContent = this.addWikiLinks(item.content);
544
561
  const entry = `- ${item.priority} ${linkedContent}`;
545
562
  const header = existing ? "" : `# ${category} \u2014 ${item.date}
@@ -705,6 +722,23 @@ ${entry}
705
722
  return match;
706
723
  });
707
724
  }
725
+ /**
726
+ * Jaccard similarity on word bigrams — cheap approximation.
727
+ */
728
+ similarity(a, b) {
729
+ const bigrams = (s) => {
730
+ const words = s.split(" ");
731
+ const bg = /* @__PURE__ */ new Set();
732
+ for (let i = 0; i < words.length - 1; i++) bg.add(`${words[i]} ${words[i + 1]}`);
733
+ return bg;
734
+ };
735
+ const setA = bigrams(a);
736
+ const setB = bigrams(b);
737
+ if (setA.size === 0 || setB.size === 0) return 0;
738
+ let intersection = 0;
739
+ for (const bg of setA) if (setB.has(bg)) intersection++;
740
+ return intersection / (setA.size + setB.size - intersection);
741
+ }
708
742
  buildSummary(routed) {
709
743
  if (routed.length === 0) return "No items routed to vault categories.";
710
744
  const byCat = /* @__PURE__ */ new Map();
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  observeCommand,
3
3
  registerObserveCommand
4
- } from "../chunk-GENGXU34.js";
5
- import "../chunk-CC7IJJ32.js";
4
+ } from "../chunk-5VYRT2XZ.js";
5
+ import "../chunk-RPMQZZPE.js";
6
6
  export {
7
7
  observeCommand,
8
8
  registerObserveCommand
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  Observer,
15
15
  parseSessionFile
16
- } from "../chunk-CC7IJJ32.js";
16
+ } from "../chunk-RPMQZZPE.js";
17
17
 
18
18
  // src/commands/sleep.ts
19
19
  import * as fs from "fs";
package/dist/index.js CHANGED
@@ -41,13 +41,13 @@ import {
41
41
  SessionWatcher,
42
42
  observeCommand,
43
43
  registerObserveCommand
44
- } from "./chunk-GENGXU34.js";
44
+ } from "./chunk-5VYRT2XZ.js";
45
45
  import {
46
46
  Compressor,
47
47
  Observer,
48
48
  Reflector,
49
49
  parseSessionFile
50
- } from "./chunk-CC7IJJ32.js";
50
+ } from "./chunk-RPMQZZPE.js";
51
51
 
52
52
  // src/index.ts
53
53
  import * as fs from "fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawvault",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "description": "ClawVault™ - 🐘 An elephant never forgets. Structured memory for OpenClaw agents. Context death resilience, Obsidian-compatible markdown, local semantic search.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",