wiki-plugin-similarity 0.12.0 → 0.12.1

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,4 +1,4 @@
1
- /* wiki-plugin-similarity - 0.12.0 - Thu, 30 Jul 2026 07:42:20 GMT */
1
+ /* wiki-plugin-similarity - 0.12.1 - Tue, 04 Aug 2026 18:57:47 GMT */
2
2
  (()=>{var q={high:.78,medium:.68,low:.58},N=q.medium,J=10,_=t=>{let e=[],s=[],i=[],p=null,E=null,f="search",y=!1,L=!1,b=!1,k=null,C=null,S=(a,r)=>a===r||a.startsWith(r)&&/^[\s:]/.test(a.slice(r.length)),w=(a,r)=>a.slice(r.length).replace(/^\s*:?\s*/,"").trim();for(let a of t.split(`
3
3
  `)){let r=a.trim();if(!r||r.startsWith("#"))continue;let g=r.toUpperCase();if(S(g,"LIVE")){y=!0;continue}if(S(g,"SUBJECT")){L=!0;continue}if(S(g,"AUTHOR")){!e.length&&f==="search"&&(f="author");continue}if(S(g,"REPORT")){f==="search"&&(f="report");continue}if(S(g,"KEYWORD")){f==="search"&&(f="keyword");continue}if(S(g,"SITES")){f==="search"&&(f="sites");continue}if(S(g,"BUILD")){f==="search"&&(f="build");continue}if(S(g,"FORCE")){b=!0;continue}if(S(g,"GHOST")){k=w(r,"GHOST"),f==="search"&&(f="ghost");continue}if(S(g,"BUTTON")){C=w(r,"BUTTON");continue}if(S(g,"ROSTER")){let v=w(r,"ROSTER");v&&s.push(v);continue}if(S(g,"FARM")){let v=w(r,"FARM");v&&i.push(v);continue}if(S(g,"LIST")){!e.length&&f==="search"&&(f="list");continue}if(S(g,"SIMILAR")){let v=w(g,"SIMILAR").toLowerCase();p=q[v]||N,!e.length&&f==="search"&&(f="similar");continue}if(S(g,"THRESHOLD")){let v=w(r,"THRESHOLD");p=q[v.toLowerCase()]??(parseFloat(v)||N);continue}if(S(g,"LIMIT")){E=parseInt(w(r,"LIMIT"))||J;continue}e.push(["PUBLIC","LOCAL","PRIVATE","GALAXY"].includes(g)?g:r)}return{mode:f,specs:e,rosterRefs:s,farms:i,threshold:p??N,limit:E??J,live:y,subject:L,force:b,ghostUrl:k,label:C,thresholdSet:p!==null}},Y=t=>t.includes("*")||t.includes("?"),W=t=>t==="PUBLIC"||t==="LOCAL"||t==="PRIVATE"||t==="GALAXY";var X=t=>t.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""),B=new Map,pt=async(t,e)=>{if(B.has(t))return B.get(t);let s=`${e}/system/indexed-domains.json?pattern=${encodeURIComponent(t)}`,i=await fetch(s);if(!i.ok)throw new Error(`indexed-domains failed: ${i.status}`);let p=await i.json();return B.set(t,p),p},O=async(t,e)=>{t.length||(t=[window.location.hostname]);let s=new Set,i=[];for(let p of t)if(p==="*"||Y(p)||W(p))for(let E of await pt(p,e))s.has(E.domain)||(s.add(E.domain),i.push(E));else s.has(p)||(s.add(p),i.push({domain:p,page_count:null}));return i},gt=/^([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+|localhost)(:\d+)?$/,ht=/^ROSTER ([A-Za-z0-9.\-:]+\/[a-z0-9-]+)$/,wt=/^REFERENCES ([A-Za-z0-9.\-:]+\/[a-z0-9-]+)$/,Z=async t=>{let e=t.indexOf("/"),s=await fetch(`//${t.slice(0,e)}/${t.slice(e+1)}.json`);if(!s.ok)throw new Error(`roster page ${t} failed: ${s.status}`);return s.json()},Q=async(t,e,s)=>{if(s.has(t))return;s.add(t);let i;try{i=await Z(t)}catch(p){console.warn(p.message);return}for(let p of i.story||[])if(p.type==="roster")for(let E of(p.text||"").split(/\r?\n/)){let f=E.trim();if(!f)continue;let y=f.match(gt);if(y){e.add(y[0]);continue}let L=f.match(ht);if(L){await Q(L[1],e,s);continue}let b=f.match(wt);if(b)try{let k=await Z(b[1]);for(let C of k.story||[])C.type==="reference"&&C.site&&e.add(C.site)}catch(k){console.warn(k.message)}}},yt=async t=>{let e=new Set,s=new Set;for(let i of t)await Q(i,e,s);return[...e]},tt=async(t,e)=>e.length?[...t,...await yt(e)]:t;var G=new Map,$t=t=>`${window.location.origin}/system/semantic-vectors.json?domain=${encodeURIComponent(t)}`,et=async t=>{if(G.has(t))return G.get(t);let e=await fetch($t(t));if(!e.ok)return[];let s=await e.json();return G.set(t,s),s},U=async(t,e)=>{let s=await fetch(`${e}/system/embed.json`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t})});if(!s.ok)throw new Error(`embed failed: ${s.status}`);return(await s.json()).vector},st=async(t,e)=>{let i=(await et(e)).find(p=>p.slug===t);return i?i.vector:null},M=(t,e,{threshold:s,limit:i,excludeSlug:p,excludeDomain:E})=>{let f=[];for(let{domain:y,pages:L}of e)for(let{slug:b,title:k,vector:C}of L){if(b===p&&y===E)continue;let S=0;for(let w=0;w<t.length;w++)S+=t[w]*C[w];S>=s&&f.push({domain:y,slug:b,title:k,score:S})}return f.sort((y,L)=>L.score-y.score),f.slice(0,i)},z=async(t,e)=>{let s=await O(t,e);return(await Promise.all(s.map(async({domain:p})=>({domain:p,pages:await et(p)})))).filter(p=>p.pages.length>0)};var nt=t=>{let e=t.parents(".page:first"),s=e.prev(".page"),i=s.length?s:e,p=(i.attr("id")||"").split("_rev")[0],E=i.data("site")||window.location.hostname,f=i.data("data")||{},y=f.title||i.find(".title").text().trim()||p,L=[y,...(f.story||[]).filter(b=>b.type==="markdown"||b.type==="paragraph").map(b=>(b.text||"").trim()).filter(Boolean)].join(`
4
4
  `).slice(0,2e3);return{slug:p,site:E,title:y,text:L,isSelf:!s.length}},T=t=>`Subject: ${t.title}${t.isSelf?" (this page)":` @ ${t.site}`}`;var it=t=>`sim-cache-${t}`,ot=t=>{try{let e=JSON.parse(localStorage.getItem(it(t.id))||"null");return e?.text===(t.text||"")?e:null}catch{return null}},P=(t,e)=>{try{localStorage.setItem(it(t.id),JSON.stringify({text:t.text||"",ts:Date.now(),...e}))}catch{}},at=t=>{let e=Math.floor((Date.now()-t)/1e3);return e<60?`${e}s ago`:e<3600?`${Math.floor(e/60)}m ago`:e<86400?`${Math.floor(e/3600)}h ago`:`${Math.floor(e/86400)}d ago`};var D=`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wiki-plugin-similarity",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Federated Wiki plugin — semantic similarity search across wiki domains using prebuilt vector indexes",
5
5
  "keywords": [
6
6
  "wiki",
@@ -4,12 +4,37 @@
4
4
  {
5
5
  "type": "paragraph",
6
6
  "id": "6a46bc37dd15ddfb",
7
- "text": "Semantic search across every indexed domain this wiki can reach. Type a phrase \u2014 the plugin embeds it, compares it against the prebuilt page vectors, and ranks the closest pages by meaning rather than by word. Add a line reading GALAXY to search off-farm federation sites instead, where this host keeps a galaxy index."
7
+ "text": "Semantic search across every indexed domain this wiki can reach. Type a phrase \u2014 the plugin embeds it, compares it against the prebuilt page vectors, and ranks the closest pages by meaning rather than by word."
8
+ },
9
+ {
10
+ "type": "paragraph",
11
+ "id": "833526e264c6916f",
12
+ "text": "Here we search across the entire [[Farm]]:"
8
13
  },
9
14
  {
10
15
  "type": "similarity",
11
16
  "id": "ece1644752fdbfb5",
12
- "text": "*\nLIMIT: 10"
17
+ "text": "*\nREPORT\nLIMIT: 10"
18
+ },
19
+ {
20
+ "type": "markdown",
21
+ "id": "6ceb4b9c37f3c06c",
22
+ "text": "And here we search [[the federation]] (excluding our farm):"
23
+ },
24
+ {
25
+ "type": "similarity",
26
+ "id": "e659640772a8340b",
27
+ "text": "GALAXY\nREPORT\nLIMIT: 10"
28
+ },
29
+ {
30
+ "type": "markdown",
31
+ "id": "b8569a0e6aef5f8a",
32
+ "text": "You may be interested in finding a suitable [[site]] on the farm, where these pages may live:"
33
+ },
34
+ {
35
+ "type": "similarity",
36
+ "id": "3cd8b0ef7d1c10ac",
37
+ "text": "*\nSITES\nLIMIT: 5"
13
38
  },
14
39
  {
15
40
  "type": "paragraph",
@@ -24,7 +49,7 @@
24
49
  "title": "Semantic Search",
25
50
  "story": []
26
51
  },
27
- "date": 1785390072037
52
+ "date": 1785399758533
28
53
  },
29
54
  {
30
55
  "type": "add",
@@ -32,9 +57,19 @@
32
57
  "item": {
33
58
  "type": "paragraph",
34
59
  "id": "6a46bc37dd15ddfb",
35
- "text": "Semantic search across every indexed domain this wiki can reach. Type a phrase \u2014 the plugin embeds it, compares it against the prebuilt page vectors, and ranks the closest pages by meaning rather than by word. Add a line reading GALAXY to search off-farm federation sites instead, where this host keeps a galaxy index."
60
+ "text": "Semantic search across every indexed domain this wiki can reach. Type a phrase \u2014 the plugin embeds it, compares it against the prebuilt page vectors, and ranks the closest pages by meaning rather than by word."
61
+ },
62
+ "date": 1785399758533
63
+ },
64
+ {
65
+ "type": "add",
66
+ "id": "833526e264c6916f",
67
+ "item": {
68
+ "type": "paragraph",
69
+ "id": "833526e264c6916f",
70
+ "text": "Here we search across the entire [[Farm]]:"
36
71
  },
37
- "date": 1785390072037
72
+ "date": 1785399758533
38
73
  },
39
74
  {
40
75
  "type": "add",
@@ -42,9 +77,49 @@
42
77
  "item": {
43
78
  "type": "similarity",
44
79
  "id": "ece1644752fdbfb5",
45
- "text": "*\nLIMIT: 10"
80
+ "text": "*\nREPORT\nLIMIT: 10"
81
+ },
82
+ "date": 1785399758533
83
+ },
84
+ {
85
+ "type": "add",
86
+ "id": "6ceb4b9c37f3c06c",
87
+ "item": {
88
+ "type": "markdown",
89
+ "id": "6ceb4b9c37f3c06c",
90
+ "text": "And here we search [[the federation]] (excluding our farm):"
91
+ },
92
+ "date": 1785399758533
93
+ },
94
+ {
95
+ "type": "add",
96
+ "id": "e659640772a8340b",
97
+ "item": {
98
+ "type": "similarity",
99
+ "id": "e659640772a8340b",
100
+ "text": "GALAXY\nREPORT\nLIMIT: 10"
101
+ },
102
+ "date": 1785399758533
103
+ },
104
+ {
105
+ "type": "add",
106
+ "id": "b8569a0e6aef5f8a",
107
+ "item": {
108
+ "type": "markdown",
109
+ "id": "b8569a0e6aef5f8a",
110
+ "text": "You may be interested in finding a suitable [[site]] on the farm, where these pages may live:"
111
+ },
112
+ "date": 1785399758533
113
+ },
114
+ {
115
+ "type": "add",
116
+ "id": "3cd8b0ef7d1c10ac",
117
+ "item": {
118
+ "type": "similarity",
119
+ "id": "3cd8b0ef7d1c10ac",
120
+ "text": "*\nSITES\nLIMIT: 5"
46
121
  },
47
- "date": 1785390072037
122
+ "date": 1785399758533
48
123
  },
49
124
  {
50
125
  "type": "add",
@@ -54,7 +129,7 @@
54
129
  "id": "3088fca5e9418d87",
55
130
  "text": "More [[About Similarity Plugin]]"
56
131
  },
57
- "date": 1785390072037
132
+ "date": 1785399758533
58
133
  }
59
134
  ]
60
135
  }