dsh-memory-eternal 0.4.24 → 0.4.26
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/index.js +14 -2
- package/lib/client.js +49 -4
- package/lib/vault.js +19 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import path from 'node:path'
|
|
|
19
19
|
import os from 'node:os'
|
|
20
20
|
import z from '@deepseek-ai/schemastery'
|
|
21
21
|
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
22
|
-
import { ensureVault, listCards, readCard, search, searchAll, graph, graphAll, overview, exportCards, deleteCard, writeCard, parseCard, stats, optimizeCandidates, readFeedback, addFeedback, dailyBrief, generateDailyBrief, mergeCards } from './lib/vault.js'
|
|
22
|
+
import { ensureVault, listCards, readCard, search, searchAll, graph, graphAll, overview, exportCards, deleteCard, writeCard, parseCard, stats, optimizeCandidates, readFeedback, addFeedback, dailyBrief, generateDailyBrief, mergeCards, dailyCounts } from './lib/vault.js'
|
|
23
23
|
import { compressExcerpt } from './lib/capture.js'
|
|
24
24
|
import { summarizeTurn, extractLastTurn, sliceNewEvents, resolveRoute, captureCard, captureUpdate, pickNeighbors } from './lib/capture.js'
|
|
25
25
|
|
|
@@ -344,6 +344,17 @@ async function handleApi(req, res, vaultRoot) {
|
|
|
344
344
|
json(res, 200, { ok: true })
|
|
345
345
|
return
|
|
346
346
|
}
|
|
347
|
+
case '/write': {
|
|
348
|
+
let raw = ''
|
|
349
|
+
for await (const chunk of req) raw += chunk
|
|
350
|
+
let body
|
|
351
|
+
try { body = JSON.parse(raw || '{}') } catch { return json(res, 400, { ok: false, error: 'JSON 解析失败' }) }
|
|
352
|
+
if (!body.body) return json(res, 400, { ok: false, error: '缺少正文' })
|
|
353
|
+
await ensureVault(vaultRoot)
|
|
354
|
+
const r = await writeCard(vaultRoot, { kind: body.kind || 'knowledge', title: body.title || '无标题', tags: body.tags || [], body: body.body, source: body.source || 'manual' }, { dedup: false })
|
|
355
|
+
json(res, 200, r)
|
|
356
|
+
return
|
|
357
|
+
}
|
|
347
358
|
case '/import': {
|
|
348
359
|
let raw = ''
|
|
349
360
|
for await (const chunk of req) raw += chunk
|
|
@@ -372,7 +383,8 @@ async function handleApi(req, res, vaultRoot) {
|
|
|
372
383
|
}
|
|
373
384
|
case '/stats': {
|
|
374
385
|
await ensureVault(vaultRoot)
|
|
375
|
-
|
|
386
|
+
const days = Math.min(Number(query.get('days')) || 30, 90)
|
|
387
|
+
json(res, 200, { ok: true, ...(await stats(vaultRoot)), trend: await dailyCounts(vaultRoot, days) })
|
|
376
388
|
return
|
|
377
389
|
}
|
|
378
390
|
case '/optimize': {
|
package/lib/client.js
CHANGED
|
@@ -3,7 +3,7 @@ window.__ModuleLoader__.load({
|
|
|
3
3
|
factory: (require) => {
|
|
4
4
|
var module = { exports: {} };
|
|
5
5
|
var exports = module.exports;
|
|
6
|
-
var kt=Object.create;var Qe=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames;var Mt=Object.getPrototypeOf,St=Object.prototype.hasOwnProperty;var It=(a,l)=>{for(var f in l)Qe(a,f,{get:l[f],enumerable:!0})},bt=(a,l,f,h)=>{if(l&&typeof l=="object"||typeof l=="function")for(let u of Nt(l))!St.call(a,u)&&u!==f&&Qe(a,u,{get:()=>l[u],enumerable:!(h=Ct(l,u))||h.enumerable});return a};var zt=(a,l,f)=>(f=a!=null?kt(Mt(a)):{},bt(l||!a||!a.__esModule?Qe(f,"default",{value:a,enumerable:!0}):f,a)),Tt=a=>bt(Qe({},"__esModule",{value:!0}),a);var Kt={};It(Kt,{apply:()=>$t,inject:()=>Lt});module.exports=Tt(Kt);var c=zt(require("react"),1),e=require("react/jsx-runtime"),Ee="memory-eternal",W="/memory-eternal/api",Lt=["settingsScope","slots","locale","connection","remote"],Bt={nav:"\u8BB0\u5FC6",loading:"\u52A0\u8F7D\u4E2D\u2026",refresh:"\u5237\u65B0",overview:"\u8BB0\u5FC6\u5E93\u6982\u89C8",total:"\u77E5\u8BC6\u5361",recent:"\u8FD1 7 \u5929\u65B0\u589E",tags:"\u6807\u7B7E",searchPlaceholder:"\u641C\u7D22\u8BB0\u5FC6\uFF08\u652F\u6301\u4E2D\u6587\u7247\u6BB5\uFF09\u2026",search:"\u641C\u7D22",all:"\u5168\u90E8",kindProject:"\u9879\u76EE",kindKnowledge:"\u77E5\u8BC6",kindContent:"\u5185\u5BB9",kindPrompt:"\u63D0\u793A\u8BCD",kindBusiness:"\u4E1A\u52A1",kindTool:"\u5DE5\u5177",kindMistake:"\u6559\u8BAD",cardsTab:"\u77E5\u8BC6\u5361",graphTab:"\u77E5\u8BC6\u56FE\u8C31",graph:"\u77E5\u8BC6\u56FE\u8C31",graphHint:"\u8282\u70B9=\u77E5\u8BC6\u5361\uFF1B\u8FDE\u7EBF=[[\u94FE\u63A5]] \u6216\u5171\u4EAB\u6807\u7B7E\u3002\u70B9\u51FB\u8282\u70B9\u9605\u8BFB\u5361\u7247\u3002",graphTip:"\u5DE6\u952E\u51F8\u663E \xB7 Shift+\u62D6\u62FD\u6846\u9009 \xB7 \u53F3\u952E\u83DC\u5355 \xB7 \u6EDA\u8F6E\u7F29\u653E \xB7 \u62D6\u62FD\u5E73\u79FB",rebuild:"\u91CD\u5EFA",reset:"\u91CD\u7F6E",expandAll:"\u5168\u90E8\u5C55\u5F00",capped:"\u5DF2\u5C55\u793A\u6700\u6838\u5FC3\u7684",clearFocus:"\u53D6\u6D88\u9AD8\u4EAE",empty:"\u8BB0\u5FC6\u5E93\u8FD8\u662F\u7A7A\u7684\u3002\u591A\u804A\u51E0\u8F6E\u540E\uFF0C\u503C\u5F97\u4FDD\u5B58\u7684\u5185\u5BB9\u4F1A\u81EA\u52A8\u6C89\u6DC0\u6210\u77E5\u8BC6\u5361\u3002",emptyGraph:"\u56FE\u8C31\u6682\u65E0\u6570\u636E\u3002",open:"\u9605\u8BFB",updated:"\u66F4\u65B0\u4E8E",created:"\u521B\u5EFA\u4E8E",source:"\u6765\u6E90",close:"\u5173\u95ED",vaultDir:"\u8BB0\u5FC6\u5E93\u76EE\u5F55",capture:"\u81EA\u52A8\u6C89\u6DC0",recall:"\u81EA\u52A8\u53EC\u56DE",enabled:"\u5DF2\u542F\u7528",disabled:"\u5DF2\u7981\u7528",error:"\u52A0\u8F7D\u5931\u8D25",back:"\u8FD4\u56DE\u5217\u8868",cardCount:"\u5F20\u5361",nodes:"\u8282\u70B9",edges:"\u8FDE\u7EBF",memoryTitle:"\u8BB0\u5FC6\u5E93",memoryHint:"\u4F60\u7684\u672C\u5730\u7B2C\u4E8C\u5927\u8111",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fit:"\u9002\u5E94",exportGraph:"\u5BFC\u51FA",openCard:"\u6253\u5F00\u5361\u7247",focusNeighbors:"\u51F8\u663E\u5173\u8054",copyName:"\u590D\u5236\u540D\u79F0",noMatch:"\u6CA1\u6709\u5339\u914D\u7684\u8BB0\u5FC6",clearFilter:"\u6E05\u9664\u8FC7\u6EE4",filterLabel:"\u7B5B\u9009",sortRecent:"\u6700\u8FD1",sortTitle:"\u6807\u9898",sortHot:"\u70ED\u70B9",exportSel:"\u5BFC\u51FA\u9009\u4E2D",clearSelection:"\u6E05\u7A7A\u9009\u62E9",download:"\u4E0B\u8F7D",openNewTab:"\u65B0\u6807\u7B7E\u6253\u5F00",copyImage:"\u590D\u5236\u56FE\u7247",done:"\u5B8C\u6210",downloaded:"\u5DF2\u5F00\u59CB\u4E0B\u8F7D",openedTab:"\u5DF2\u5728\u65B0\u6807\u7B7E\u6253\u5F00",copied:"\u5DF2\u590D\u5236",exportedSel:"\u4E2A\u8282\u70B9\u5DF2\u5BFC\u51FA",fullscreen:"\u5168\u5C4F",exitFull:"\u9000\u51FA\u5168\u5C4F",copyFail:"\u590D\u5236\u5931\u8D25",timeDim:"\u65F6\u95F4\u7EF4",timeNew:"3 \u5929\u5185",timeRecent:"2 \u5468\u5185",timeMonth:"1 \u6708\u5185",timeOld:"\u66F4\u65E9",newBadge:"\u65B0",expand:"\u5C55\u5F00\u5168\u90E8",collapse:"\u6536\u8D77",exportVault:"\u5BFC\u51FAMD",exportJson:"\u5BFC\u51FAJSON",exporting:"\u5BFC\u51FA\u4E2D\u2026",exportedVault:"\u8BB0\u5FC6\u5E93\u5DF2\u5BFC\u51FA",exportFail:"\u5BFC\u51FA\u5931\u8D25",importVault:"\u5BFC\u5165",importedVault:"\u5BFC\u5165\u5B8C\u6210",importedSkipped:"\uFF08\u8DF3\u8FC7\u91CD\u590D ",importFail:"\u5BFC\u5165\u5931\u8D25",location:"\u81EA\u9009\u4F4D\u7F6E",saveAs:"\u53E6\u5B58\u4E3A",saveAsUnsupported:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9009\u62E9\u4FDD\u5B58\u4F4D\u7F6E",exportedTo:"\u5DF2\u5BFC\u51FA\u5230",defaultDownloads:"\u9ED8\u8BA4\u4E0B\u8F7D\u6587\u4EF6\u5939",exportCancel:"\u5DF2\u53D6\u6D88\u5BFC\u51FA",manage:"\u7BA1\u7406",tabUsage:"\u7528\u91CF/\u4ECA\u65E5",tabOptimize:"\u6574\u7406\u5EFA\u8BAE",adminLoadFail:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A\u8BF7\u5F7B\u5E95\u91CD\u542F dsh-desktop\uFF08host \u9700\u52A0\u8F7D\u65B0\u7248 /memory-eternal \u8DEF\u7531\uFF09",retry:"\u91CD\u8BD5",mergeSimilar:"\u4E00\u952E\u5408\u5E76\u76F8\u4F3C",fbUseful:"\u6709\u7528",fbIrr:"\u65E0\u5173",todayAdd:"\u4ECA\u65E5\u65B0\u589E",weekAdd:"\u8FD1 7 \u5929",byKind:"\u5206\u7C7B\u7EDF\u8BA1",todayList:"\u4ECA\u65E5\u6C89\u6DC0",budgetLabel:"\u4F1A\u8BDD\u9884\u7B97",budgetChars:"\u9884\u7B97\u5B57\u7B26",recallLimitLabel:"\u53EC\u56DE\u6761\u6570",embeddingLabel:"\u8BED\u4E49\u53EC\u56DE",mergePairs:"\u76F8\u4F3C\u5361\u5BF9\uFF08\u53EF\u5408\u5E76\uFF09",staleCards:"\u9648\u65E7\u5361\uFF08>90 \u5929\u672A\u66F4\u65B0\uFF09",noOptimize:"\u6682\u65E0\u53EF\u6574\u7406\u9879\uFF0C\u5F88\u5065\u5EB7 \u{1F389}",mergeNow:"\u5408\u5E76",delete:"\u5220\u9664",todayBriefLabel:"\u6BCF\u65E5\u56DE\u987E",todayBrief:"\u67E5\u770B\u4ECA\u65E5\u7B80\u62A5",batchMerge:"\u4E00\u952E\u667A\u80FD\u5408\u5E76",mergeAllConfirm:"\u5C06\u6309\u76F8\u4F3C\u5EA6\u5206\u7EC4\u7684\u5361\u7247\u5404\u5408\u5E76\u4E3A\u4E00\u5F20\uFF08\u4FDD\u7559\u5404\u81EA kind\uFF09\uFF0C\u539F\u5361\u5220\u9664\uFF1F",crossVault:"\u8DE8\u5E93\u805A\u5408",deleteConfirm:"\u786E\u5B9A\u5220\u9664\u8BE5\u8BB0\u5FC6\u5361\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",deleted:"\u5DF2\u5220\u9664",deleteFail:"\u5220\u9664\u5931\u8D25",deleteSelected:"\u5220\u9664\u9009\u4E2D",deletedSelected:"\u5F20\u5361\u5DF2\u5220\u9664",merge:"\u5408\u5E76",mergeNeed:"\u81F3\u5C11\u9009 2 \u5F20\u5361",mergeConfirm:"\u5C06\u6240\u9009\u5361\u7247\u5408\u5E76\u4E3A\u4E00\u5F20\u5E76\u5220\u9664\u539F\u5361\uFF1F",merged:"\u5DF2\u5408\u5E76",mergeFail:"\u5408\u5E76\u5931\u8D25"},Ft={nav:"Memory",loading:"Loading\u2026",refresh:"Refresh",overview:"Memory Overview",total:"Cards",recent:"Added (7d)",tags:"Tags",searchPlaceholder:"Search memory\u2026",search:"Search",all:"All",kindProject:"Projects",kindKnowledge:"Knowledge",kindContent:"Content",kindPrompt:"Prompts",kindBusiness:"Business",kindTool:"Tools",kindMistake:"Mistakes",cardsTab:"Cards",graphTab:"Graph",graph:"Knowledge Graph",graphHint:"Nodes = cards; edges = [[links]] or shared tags. Click a node to read.",graphTip:"Left-click highlights \xB7 Shift+drag box-select \xB7 right-click menu \xB7 scroll zoom \xB7 drag to pan",rebuild:"Rebuild",reset:"Reset",expandAll:"Expand all",capped:"Showing the",clearFocus:"Clear highlight",empty:"Memory is empty. After a few conversations, valuable content is auto-captured.",emptyGraph:"No graph data yet.",open:"Read",updated:"Updated",created:"Created",source:"Source",close:"Close",vaultDir:"Vault directory",capture:"Auto capture",recall:"Auto recall",enabled:"on",disabled:"off",error:"Load failed",back:"Back to list",cardCount:"cards",nodes:"nodes",edges:"edges",memoryTitle:"Memory Library",memoryHint:"Your local second brain",zoomIn:"Zoom in",zoomOut:"Zoom out",fit:"Fit",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear filter",filterLabel:"Filter",sortRecent:"Recent",sortTitle:"Title",sortHot:"Hot",exportSel:"Export selected",clearSelection:"Clear selection",download:"Download",openNewTab:"Open in new tab",copyImage:"Copy image",done:"Done",downloaded:"Download started",openedTab:"Opened in new tab",copied:"Copied",exportedSel:" nodes exported",fullscreen:"Fullscreen",exitFull:"Exit fullscreen",copyFail:"Copy failed",timeDim:"Time",timeNew:"\u22643 days",timeRecent:"\u22642 weeks",timeMonth:"\u22641 month",timeOld:"Older",newBadge:"NEW",expand:"Expand",collapse:"Collapse",exportVault:"Export MD",exportJson:"Export JSON",exporting:"Exporting\u2026",exportedVault:"Vault exported",exportFail:"Export failed",importVault:"Import",importedVault:"Import complete",importedSkipped:" (skipped dup ",importFail:"Import failed",location:"Choose location",saveAs:"Save as",saveAsUnsupported:"Choose-save-location not supported here",exportedTo:"Exported to",defaultDownloads:"default Downloads folder",exportCancel:"Export cancelled",manage:"Manage",tabUsage:"Usage / Today",tabOptimize:"Optimize",adminLoadFail:"Load failed: fully restart dsh-desktop so the host picks up the new /memory-eternal routes",retry:"Retry",mergeSimilar:"Merge similar",fbUseful:"Useful",fbIrr:"Irrelevant",todayAdd:"Added today",weekAdd:"Last 7d",byKind:"By kind",todayList:"Captured today",budgetLabel:"Session budget",budgetChars:"Budget chars",recallLimitLabel:"Recall limit",embeddingLabel:"Semantic recall",mergePairs:"Similar pairs (mergeable)",staleCards:"Stale (>90d)",noOptimize:"Nothing to organize, healthy \u{1F389}",mergeNow:"Merge",delete:"Delete",todayBriefLabel:"Daily review",todayBrief:"Today brief",batchMerge:"Smart batch merge",mergeAllConfirm:"Merge similar-grouped cards into one each (keep kind), delete originals?",crossVault:"All vaults",deleteConfirm:"Delete this memory card? This cannot be undone.",deleted:"Deleted",deleteFail:"Delete failed",deleteSelected:"Delete selected",deletedSelected:" cards deleted",merge:"Merge",mergeNeed:"Select at least 2 cards",mergeConfirm:"Merge the selected cards into one and delete the originals?",merged:"Merged",mergeFail:"Merge failed"},jt=["all","project","knowledge","content","prompt","business","tool","mistake"],tt={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},Le={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},Be=`
|
|
6
|
+
var wt=Object.create;var Ve=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var Ct=Object.getOwnPropertyNames;var Nt=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty;var St=(t,s)=>{for(var d in s)Ve(t,d,{get:s[d],enumerable:!0})},gt=(t,s,d,y)=>{if(s&&typeof s=="object"||typeof s=="function")for(let u of Ct(s))!Mt.call(t,u)&&u!==d&&Ve(t,u,{get:()=>s[u],enumerable:!(y=kt(s,u))||y.enumerable});return t};var It=(t,s,d)=>(d=t!=null?wt(Nt(t)):{},gt(s||!t||!t.__esModule?Ve(d,"default",{value:t,enumerable:!0}):d,t)),zt=t=>gt(Ve({},"__esModule",{value:!0}),t);var Kt={};St(Kt,{apply:()=>jt,inject:()=>Tt});module.exports=zt(Kt);var c=It(require("react"),1),e=require("react/jsx-runtime"),Fe="memory-eternal",Y="/memory-eternal/api",Tt=["settingsScope","slots","locale","connection","remote"],Lt={nav:"\u8BB0\u5FC6",loading:"\u52A0\u8F7D\u4E2D\u2026",refresh:"\u5237\u65B0",overview:"\u8BB0\u5FC6\u5E93\u6982\u89C8",total:"\u77E5\u8BC6\u5361",recent:"\u8FD1 7 \u5929\u65B0\u589E",tags:"\u6807\u7B7E",searchPlaceholder:"\u641C\u7D22\u8BB0\u5FC6\uFF08\u652F\u6301\u4E2D\u6587\u7247\u6BB5\uFF09\u2026",search:"\u641C\u7D22",all:"\u5168\u90E8",kindProject:"\u9879\u76EE",kindKnowledge:"\u77E5\u8BC6",kindContent:"\u5185\u5BB9",kindPrompt:"\u63D0\u793A\u8BCD",kindBusiness:"\u4E1A\u52A1",kindTool:"\u5DE5\u5177",kindMistake:"\u6559\u8BAD",cardsTab:"\u77E5\u8BC6\u5361",graphTab:"\u77E5\u8BC6\u56FE\u8C31",graph:"\u77E5\u8BC6\u56FE\u8C31",graphHint:"\u8282\u70B9=\u77E5\u8BC6\u5361\uFF1B\u8FDE\u7EBF=[[\u94FE\u63A5]] \u6216\u5171\u4EAB\u6807\u7B7E\u3002\u70B9\u51FB\u8282\u70B9\u9605\u8BFB\u5361\u7247\u3002",graphTip:"\u5DE6\u952E\u51F8\u663E \xB7 Shift+\u62D6\u62FD\u6846\u9009 \xB7 \u53F3\u952E\u83DC\u5355 \xB7 \u6EDA\u8F6E\u7F29\u653E \xB7 \u62D6\u62FD\u5E73\u79FB",rebuild:"\u91CD\u5EFA",reset:"\u91CD\u7F6E",expandAll:"\u5168\u90E8\u5C55\u5F00",capped:"\u5DF2\u5C55\u793A\u6700\u6838\u5FC3\u7684",clearFocus:"\u53D6\u6D88\u9AD8\u4EAE",empty:"\u8BB0\u5FC6\u5E93\u8FD8\u662F\u7A7A\u7684\u3002\u591A\u804A\u51E0\u8F6E\u540E\uFF0C\u503C\u5F97\u4FDD\u5B58\u7684\u5185\u5BB9\u4F1A\u81EA\u52A8\u6C89\u6DC0\u6210\u77E5\u8BC6\u5361\u3002",emptyGraph:"\u56FE\u8C31\u6682\u65E0\u6570\u636E\u3002",open:"\u9605\u8BFB",updated:"\u66F4\u65B0\u4E8E",created:"\u521B\u5EFA\u4E8E",source:"\u6765\u6E90",close:"\u5173\u95ED",vaultDir:"\u8BB0\u5FC6\u5E93\u76EE\u5F55",capture:"\u81EA\u52A8\u6C89\u6DC0",recall:"\u81EA\u52A8\u53EC\u56DE",enabled:"\u5DF2\u542F\u7528",disabled:"\u5DF2\u7981\u7528",error:"\u52A0\u8F7D\u5931\u8D25",back:"\u8FD4\u56DE\u5217\u8868",cardCount:"\u5F20\u5361",nodes:"\u8282\u70B9",edges:"\u8FDE\u7EBF",memoryTitle:"\u8BB0\u5FC6\u5E93",memoryHint:"\u4F60\u7684\u672C\u5730\u7B2C\u4E8C\u5927\u8111",zoomIn:"\u653E\u5927",zoomOut:"\u7F29\u5C0F",fit:"\u9002\u5E94",exportGraph:"\u5BFC\u51FA",openCard:"\u6253\u5F00\u5361\u7247",focusNeighbors:"\u51F8\u663E\u5173\u8054",copyName:"\u590D\u5236\u540D\u79F0",noMatch:"\u6CA1\u6709\u5339\u914D\u7684\u8BB0\u5FC6",clearFilter:"\u6E05\u9664\u8FC7\u6EE4",filterLabel:"\u7B5B\u9009",sortRecent:"\u6700\u8FD1",sortTitle:"\u6807\u9898",sortHot:"\u70ED\u70B9",exportSel:"\u5BFC\u51FA\u9009\u4E2D",clearSelection:"\u6E05\u7A7A\u9009\u62E9",download:"\u4E0B\u8F7D",openNewTab:"\u65B0\u6807\u7B7E\u6253\u5F00",copyImage:"\u590D\u5236\u56FE\u7247",done:"\u5B8C\u6210",downloaded:"\u5DF2\u5F00\u59CB\u4E0B\u8F7D",openedTab:"\u5DF2\u5728\u65B0\u6807\u7B7E\u6253\u5F00",copied:"\u5DF2\u590D\u5236",exportedSel:"\u4E2A\u8282\u70B9\u5DF2\u5BFC\u51FA",fullscreen:"\u5168\u5C4F",exitFull:"\u9000\u51FA\u5168\u5C4F",copyFail:"\u590D\u5236\u5931\u8D25",timeDim:"\u65F6\u95F4\u7EF4",timeNew:"3 \u5929\u5185",timeRecent:"2 \u5468\u5185",timeMonth:"1 \u6708\u5185",timeOld:"\u66F4\u65E9",newBadge:"\u65B0",expand:"\u5C55\u5F00\u5168\u90E8",collapse:"\u6536\u8D77",exportVault:"\u5BFC\u51FAMD",exportJson:"\u5BFC\u51FAJSON",exporting:"\u5BFC\u51FA\u4E2D\u2026",exportedVault:"\u8BB0\u5FC6\u5E93\u5DF2\u5BFC\u51FA",exportFail:"\u5BFC\u51FA\u5931\u8D25",importVault:"\u5BFC\u5165",importedVault:"\u5BFC\u5165\u5B8C\u6210",importedSkipped:"\uFF08\u8DF3\u8FC7\u91CD\u590D ",importFail:"\u5BFC\u5165\u5931\u8D25",location:"\u81EA\u9009\u4F4D\u7F6E",saveAs:"\u53E6\u5B58\u4E3A",saveAsUnsupported:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u9009\u62E9\u4FDD\u5B58\u4F4D\u7F6E",exportedTo:"\u5DF2\u5BFC\u51FA\u5230",defaultDownloads:"\u9ED8\u8BA4\u4E0B\u8F7D\u6587\u4EF6\u5939",exportCancel:"\u5DF2\u53D6\u6D88\u5BFC\u51FA",manage:"\u7BA1\u7406",tabUsage:"\u7528\u91CF/\u4ECA\u65E5",tabOptimize:"\u6574\u7406\u5EFA\u8BAE",adminLoadFail:"\u6570\u636E\u52A0\u8F7D\u5931\u8D25\uFF1A\u8BF7\u5F7B\u5E95\u91CD\u542F dsh-desktop\uFF08host \u9700\u52A0\u8F7D\u65B0\u7248 /memory-eternal \u8DEF\u7531\uFF09",retry:"\u91CD\u8BD5",mergeSimilar:"\u4E00\u952E\u5408\u5E76\u76F8\u4F3C",trendLabel:"\u8FD1 30 \u5929\u8D8B\u52BF",cleanStale:"\u{1F5D1}\uFE0F \u4E00\u952E\u6E05\u7406\u9648\u65E7",deletedStale:"\u4E2A\u9648\u65E7\u5361\u5DF2\u6E05\u7406",newCard:"\u65B0\u5EFA",tplDecision:"\u{1F4DD} \u6280\u672F\u51B3\u7B56",tplBug:"\u{1F41B} \u8E29\u5751",tplMeeting:"\u{1F4CB} \u4F1A\u8BAE\u7EAA\u8981",tplWeekly:"\u{1F4CA} \u5468\u62A5",createCard:"\u521B\u5EFA",cardTitle:"\u6807\u9898",cardBody:"\u6B63\u6587",fbUseful:"\u6709\u7528",fbIrr:"\u65E0\u5173",todayAdd:"\u4ECA\u65E5\u65B0\u589E",weekAdd:"\u8FD1 7 \u5929",byKind:"\u5206\u7C7B\u7EDF\u8BA1",todayList:"\u4ECA\u65E5\u6C89\u6DC0",budgetLabel:"\u4F1A\u8BDD\u9884\u7B97",budgetChars:"\u9884\u7B97\u5B57\u7B26",recallLimitLabel:"\u53EC\u56DE\u6761\u6570",embeddingLabel:"\u8BED\u4E49\u53EC\u56DE",mergePairs:"\u76F8\u4F3C\u5361\u5BF9\uFF08\u53EF\u5408\u5E76\uFF09",staleCards:"\u9648\u65E7\u5361\uFF08>90 \u5929\u672A\u66F4\u65B0\uFF09",noOptimize:"\u6682\u65E0\u53EF\u6574\u7406\u9879\uFF0C\u5F88\u5065\u5EB7 \u{1F389}",mergeNow:"\u5408\u5E76",delete:"\u5220\u9664",todayBriefLabel:"\u6BCF\u65E5\u56DE\u987E",todayBrief:"\u67E5\u770B\u4ECA\u65E5\u7B80\u62A5",batchMerge:"\u4E00\u952E\u667A\u80FD\u5408\u5E76",mergeAllConfirm:"\u5C06\u6309\u76F8\u4F3C\u5EA6\u5206\u7EC4\u7684\u5361\u7247\u5404\u5408\u5E76\u4E3A\u4E00\u5F20\uFF08\u4FDD\u7559\u5404\u81EA kind\uFF09\uFF0C\u539F\u5361\u5220\u9664\uFF1F",crossVault:"\u8DE8\u5E93\u805A\u5408",deleteConfirm:"\u786E\u5B9A\u5220\u9664\u8BE5\u8BB0\u5FC6\u5361\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002",deleted:"\u5DF2\u5220\u9664",deleteFail:"\u5220\u9664\u5931\u8D25",deleteSelected:"\u5220\u9664\u9009\u4E2D",deletedSelected:"\u5F20\u5361\u5DF2\u5220\u9664",merge:"\u5408\u5E76",mergeNeed:"\u81F3\u5C11\u9009 2 \u5F20\u5361",mergeConfirm:"\u5C06\u6240\u9009\u5361\u7247\u5408\u5E76\u4E3A\u4E00\u5F20\u5E76\u5220\u9664\u539F\u5361\uFF1F",merged:"\u5DF2\u5408\u5E76",mergeFail:"\u5408\u5E76\u5931\u8D25"},Bt={nav:"Memory",loading:"Loading\u2026",refresh:"Refresh",overview:"Memory Overview",total:"Cards",recent:"Added (7d)",tags:"Tags",searchPlaceholder:"Search memory\u2026",search:"Search",all:"All",kindProject:"Projects",kindKnowledge:"Knowledge",kindContent:"Content",kindPrompt:"Prompts",kindBusiness:"Business",kindTool:"Tools",kindMistake:"Mistakes",cardsTab:"Cards",graphTab:"Graph",graph:"Knowledge Graph",graphHint:"Nodes = cards; edges = [[links]] or shared tags. Click a node to read.",graphTip:"Left-click highlights \xB7 Shift+drag box-select \xB7 right-click menu \xB7 scroll zoom \xB7 drag to pan",rebuild:"Rebuild",reset:"Reset",expandAll:"Expand all",capped:"Showing the",clearFocus:"Clear highlight",empty:"Memory is empty. After a few conversations, valuable content is auto-captured.",emptyGraph:"No graph data yet.",open:"Read",updated:"Updated",created:"Created",source:"Source",close:"Close",vaultDir:"Vault directory",capture:"Auto capture",recall:"Auto recall",enabled:"on",disabled:"off",error:"Load failed",back:"Back to list",cardCount:"cards",nodes:"nodes",edges:"edges",memoryTitle:"Memory Library",memoryHint:"Your local second brain",zoomIn:"Zoom in",zoomOut:"Zoom out",fit:"Fit",exportGraph:"Export",openCard:"Open card",focusNeighbors:"Highlight links",copyName:"Copy name",noMatch:"No matching memory",clearFilter:"Clear filter",filterLabel:"Filter",sortRecent:"Recent",sortTitle:"Title",sortHot:"Hot",exportSel:"Export selected",clearSelection:"Clear selection",download:"Download",openNewTab:"Open in new tab",copyImage:"Copy image",done:"Done",downloaded:"Download started",openedTab:"Opened in new tab",copied:"Copied",exportedSel:" nodes exported",fullscreen:"Fullscreen",exitFull:"Exit fullscreen",copyFail:"Copy failed",timeDim:"Time",timeNew:"\u22643 days",timeRecent:"\u22642 weeks",timeMonth:"\u22641 month",timeOld:"Older",newBadge:"NEW",expand:"Expand",collapse:"Collapse",exportVault:"Export MD",exportJson:"Export JSON",exporting:"Exporting\u2026",exportedVault:"Vault exported",exportFail:"Export failed",importVault:"Import",importedVault:"Import complete",importedSkipped:" (skipped dup ",importFail:"Import failed",location:"Choose location",saveAs:"Save as",saveAsUnsupported:"Choose-save-location not supported here",exportedTo:"Exported to",defaultDownloads:"default Downloads folder",exportCancel:"Export cancelled",manage:"Manage",tabUsage:"Usage / Today",tabOptimize:"Optimize",adminLoadFail:"Load failed: fully restart dsh-desktop so the host picks up the new /memory-eternal routes",retry:"Retry",mergeSimilar:"Merge similar",trendLabel:"Last 30 days trend",cleanStale:"\u{1F5D1}\uFE0F Clean stale",deletedStale:" stale cards cleaned",newCard:"New",tplDecision:"\u{1F4DD} Decision",tplBug:"\u{1F41B} Bug",tplMeeting:"\u{1F4CB} Meeting",tplWeekly:"\u{1F4CA} Weekly",createCard:"Create",cardTitle:"Title",cardBody:"Body",fbUseful:"Useful",fbIrr:"Irrelevant",todayAdd:"Added today",weekAdd:"Last 7d",byKind:"By kind",todayList:"Captured today",budgetLabel:"Session budget",budgetChars:"Budget chars",recallLimitLabel:"Recall limit",embeddingLabel:"Semantic recall",mergePairs:"Similar pairs (mergeable)",staleCards:"Stale (>90d)",noOptimize:"Nothing to organize, healthy \u{1F389}",mergeNow:"Merge",delete:"Delete",todayBriefLabel:"Daily review",todayBrief:"Today brief",batchMerge:"Smart batch merge",mergeAllConfirm:"Merge similar-grouped cards into one each (keep kind), delete originals?",crossVault:"All vaults",deleteConfirm:"Delete this memory card? This cannot be undone.",deleted:"Deleted",deleteFail:"Delete failed",deleteSelected:"Delete selected",deletedSelected:" cards deleted",merge:"Merge",mergeNeed:"Select at least 2 cards",mergeConfirm:"Merge the selected cards into one and delete the originals?",merged:"Merged",mergeFail:"Merge failed"},Ft=["all","project","knowledge","content","prompt","business","tool","mistake"],_e={project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},Ie={project:"kindProject",knowledge:"kindKnowledge",content:"kindContent",prompt:"kindPrompt",business:"kindBusiness",tool:"kindTool",mistake:"kindMistake",other:"kindKnowledge"},Ne=`
|
|
7
7
|
.memory-eternal-root { font-family: inherit; color: var(--dsw-alias-label-primary, #1f2937); }
|
|
8
8
|
.mc-card { background: var(--dsw-alias-bg-layer-1, #fff); border: 1px solid var(--dsw-alias-border-l1, #e5e7eb); border-radius: 12px; padding: 14px 16px; }
|
|
9
9
|
.mc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-bottom: 14px; }
|
|
@@ -119,12 +119,57 @@ var kt=Object.create;var Qe=Object.defineProperty;var Ct=Object.getOwnPropertyDe
|
|
|
119
119
|
.me-graph-ctxmenu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: none; border-radius: 7px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
|
|
120
120
|
.me-graph-ctxmenu button:hover { background: rgba(255,255,255,0.1); }
|
|
121
121
|
.me-graph-hint { font-size: 11px; opacity: 0.6; margin-left: auto; }
|
|
122
|
-
`;function
|
|
122
|
+
`;function jt(t){t.effect(()=>t.locale.register(Fe,{zh:Lt,en:Bt}),"memory-eternal: locale");let s=t.locale.bind(Fe);t.effect(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:Fe,order:25,label:()=>s("nav"),locale:Fe,inject:()=>({})},()=>c.default.createElement(yt,{t:s,inModal:!1}))),"memory-eternal: settings section"),t.effect(()=>t.slots.inject("sidebar.footer.action",()=>t.slots.register({name:"sidebar.footer.action",id:`${Fe}:footer`,order:100,label:()=>s("nav"),locale:Fe,inject:()=>({})},d=>c.default.createElement($t,{t:s,wide:!(d&&d.wide===!1)}))),"memory-eternal: sidebar footer action")}function $t({t,wide:s}){let[d,y]=(0,c.useState)(!1);return(0,e.jsxs)("div",{className:`me-footer${s?"":" rail"}`,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("button",{type:"button",className:"me-footer-btn",onClick:()=>y(!0),"aria-label":t("nav"),title:t("nav"),children:[(0,e.jsx)("span",{className:"me-footer-ico","aria-hidden":"true",children:(0,e.jsx)(ht,{})}),(0,e.jsx)("span",{className:"me-footer-label",children:t("nav")})]}),d&&(0,e.jsx)(Et,{t,onClose:()=>y(!1)})]})}function ht(){return(0,e.jsxs)("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:[(0,e.jsx)("defs",{children:(0,e.jsxs)("linearGradient",{id:"mg-brain",x1:"0",y1:"0",x2:"1",y2:"1",children:[(0,e.jsx)("stop",{offset:"0%",stopColor:"#FFC46B"}),(0,e.jsx)("stop",{offset:"50%",stopColor:"#F97316"}),(0,e.jsx)("stop",{offset:"100%",stopColor:"#EA580C"})]})}),(0,e.jsx)("path",{fill:"url(#mg-brain)",d:"M12 4.5a3.2 3.2 0 0 0-6.4.1 4.1 4.1 0 0 0-2.7 5.9 4.1 4.1 0 0 0 .6 6.7A4.2 4.2 0 0 0 12 18.2Z"}),(0,e.jsx)("path",{fill:"url(#mg-brain)",d:"M12 4.5a3.2 3.2 0 0 1 6.4.1 4.1 4.1 0 0 1 2.7 5.9 4.1 4.1 0 0 1-.6 6.7A4.2 4.2 0 0 1 12 18.2Z"}),(0,e.jsx)("path",{d:"M12 9.2c-.8-1.4-1.7-2-3.1-2.2M12 9.2c.8-1.4 1.7-2 3.1-2.2M12 12.4c-1.2 1-3.2 1.6-5 1.4M12 12.4c1.2 1 3.2 1.6 5 1.4M12 13.2v4",fill:"none",stroke:"rgba(255,255,255,0.62)",strokeWidth:"1",strokeLinecap:"round"}),(0,e.jsx)("circle",{cx:"12",cy:"8.6",r:"1.1",fill:"rgba(255,255,255,0.85)"})]})}function Et({t,onClose:s}){let[d,y]=(0,c.useState)(!1);return(0,c.useEffect)(()=>{let u=r=>{r.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s]),(0,e.jsxs)("div",{className:"me-overlay-top",onClick:s,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsx)("div",{className:"me-modal",onClick:u=>u.stopPropagation(),style:d?{position:"fixed",inset:0,width:"100vw",height:"100vh",maxWidth:"100vw",maxHeight:"100vh",borderRadius:0}:{},children:(0,e.jsx)(yt,{t,inModal:!0,onClose:s,onFull:()=>y(u=>!u),full:d})})]})}function yt({t,inModal:s,onClose:d,onFull:y,full:u}){let[r,T]=(0,c.useState)(null),[S,X]=(0,c.useState)([]),[O,oe]=(0,c.useState)(!0),[m,x]=(0,c.useState)(""),[R,ye]=(0,c.useState)("all"),[_,Me]=(0,c.useState)(""),[L,ve]=(0,c.useState)("cards"),[K,fe]=(0,c.useState)("recent"),[ce,p]=(0,c.useState)(null),N=(0,c.useRef)(null),W=(0,c.useRef)(null),[A,H]=(0,c.useState)(!1),[q,j]=(0,c.useState)(null),[te,re]=(0,c.useState)(!1),[ne,We]=(0,c.useState)(!0),[ae,de]=(0,c.useState)(null),we=(0,c.useRef)(null),[Ae,ie]=(0,c.useState)(24),be=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(L!=="cards")return;let g=be.current;if(!g)return;let I=new IntersectionObserver(b=>{b[0]&&b[0].isIntersecting&&ie(se=>se+24)},{rootMargin:"400px"});return I.observe(g),()=>I.disconnect()},[L,S,R,_]);let xe=(0,c.useCallback)(async(g=R,I=_)=>{try{oe(!0),x("");let b=new URLSearchParams;g&&g!=="all"&&b.set("kind",g),I.trim()&&b.set("q",I.trim());let P=await(await fetch(`${Y}/cards?${b.toString()}`)).json();P.ok&&(X(P.cards||[]),ie(24))}catch(b){x(String(b&&b.message?b.message:b))}finally{oe(!1)}},[R,_]),V=(0,c.useCallback)(async()=>{try{let[g,I]=await Promise.all([fetch(`${Y}/overview`).then(b=>b.json()),fetch(`${Y}/cards`).then(b=>b.json())]);g.ok&&T(g),I.ok&&(X(I.cards||[]),ie(24))}catch(g){x(String(g&&g.message?g.message:g))}finally{oe(!1)}},[]),ze=async g=>{try{let b=await(await fetch(`${Y}/delete?path=${encodeURIComponent(g)}`)).json();b.ok?(p({ok:!0,msg:t("deleted")}),await V()):p({ok:!1,msg:b.error||t("deleteFail")})}catch{p({ok:!1,msg:t("deleteFail")})}N.current&&clearTimeout(N.current),N.current=setTimeout(()=>p(null),2e3)};(0,c.useEffect)(()=>(V(),()=>{we.current&&clearTimeout(we.current)}),[V]);let pe=g=>{Me(g),we.current&&clearTimeout(we.current),we.current=setTimeout(()=>xe(R,g),280)},Te=g=>{ye(g),xe(g,_)},ke=async g=>{try{let b=await(await fetch(`${Y}/card?path=${encodeURIComponent(g.path||g.id)}`)).json();b.ok&&j({path:b.path,title:g.title,text:b.text})}catch(I){x(String(I&&I.message?I.message:I))}},$e=async(g,I)=>{H(!0);try{let b=await fetch(`${Y}/export`);if(!b.ok)throw new Error("HTTP "+b.status);let se=await b.json();if(!se.ok)throw new Error(se.error||"export failed");let P,n,o;g==="json"?(n="memory-vault.json",o="application/json",P=JSON.stringify(se.cards.map(D=>({path:D.path,title:D.title,kind:D.kind,text:D.text})),null,2)):(n="memory-vault.md",o="text/markdown;charset=utf-8",P=se.cards.map(D=>D.text.trim()).filter(Boolean).join(`
|
|
123
123
|
|
|
124
124
|
---
|
|
125
125
|
|
|
126
|
-
`));let We=new Blob([X],{type:T}),ne=await qt(We,ke,!1);if(!ne.ok){m({ok:!1,msg:a("exportFail")}),oe(!1);return}m({ok:!0,msg:a("exportedTo")+"\uFF1A"+a("defaultDownloads")+" \xB7 "+ne.name})}catch(v){m({ok:!1,msg:a("exportFail")+" \xB7 "+(v.message||"")})}finally{oe(!1)}N.current&&clearTimeout(N.current),N.current=setTimeout(()=>m(null),2600)},ue=async d=>{let S=d.target.files&&d.target.files[0];if(d.target.value="",!!S){try{let v=await S.text(),X=await(await fetch(`${W}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:v})).json();X.ok?(await te(),m({ok:!0,msg:a("importedVault")+"\uFF1A"+(X.imported||0)+(X.skipped?a("importedSkipped")+X.skipped:"")})):m({ok:!1,msg:X.error||a("importFail")})}catch{m({ok:!1,msg:a("importFail")})}N.current&&clearTimeout(N.current),N.current=setTimeout(()=>m(null),2400)}},ze=(0,c.useMemo)(()=>{let d=z.slice();return H==="title"?d.sort((S,v)=>String(S.title||"").localeCompare(String(v.title||""))):H==="hot"?d.sort((S,v)=>(v.weight||v.links||0)-(S.weight||S.links||0)):d.sort((S,v)=>new Date(v.updated||0).getTime()-new Date(S.updated||0).getTime()),d},[z,H]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Be}),de&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(de.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:de.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:de.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:de.msg})]}),l&&(0,e.jsxs)("div",{className:"me-modal-head",children:[(0,e.jsxs)("div",{className:"me-modal-title",children:[(0,e.jsx)("span",{className:"me-wicon",children:(0,e.jsx)(xt,{})}),(0,e.jsx)("h2",{children:a("memoryTitle")}),(0,e.jsx)("span",{children:a("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),h&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:h,"aria-label":a(u?"exitFull":"fullscreen"),children:u?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:f,"aria-label":a("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${re?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>Xe(d=>!d),"aria-label":a(re?"collapse":"expand"),title:a(re?"collapse":"expand"),children:re?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${L==="cards"?" active":""}`,onClick:()=>Ce("cards"),title:a("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C7}"}),re&&(0,e.jsx)("span",{className:"mc-rail-label",children:a("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${L==="graph"?" active":""}`,onClick:()=>Ce("graph"),title:a("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F578}"}),re&&(0,e.jsx)("span",{className:"mc-rail-label",children:a("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${L==="stats"?" active":""}`,onClick:()=>Ce("stats"),title:a("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4CA}"}),re&&(0,e.jsx)("span",{className:"mc-rail-label",children:a("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${L==="optimize"?" active":""}`,onClick:()=>Ce("optimize"),title:a("tabOptimize"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9F9}"}),re&&(0,e.jsx)("span",{className:"mc-rail-label",children:a("tabOptimize")})]})]}),(0,e.jsxs)("div",{className:"mc-main",children:[L==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(et,{label:a("total"),value:r?r.total:"\u2014"}),(0,e.jsx)(et,{label:a("recent"),value:r?r.recent:"\u2014"}),(0,e.jsx)(et,{label:a("tags"),value:r?r.tags:"\u2014"}),(0,e.jsx)(et,{label:a("cardCount"),value:r?r.byKind?.knowledge??0:"\u2014"})]}),L==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:a("searchPlaceholder"),value:G,onChange:d=>xe(d.target.value)}),(0,e.jsx)("input",{ref:U,type:"file",accept:".json,application/json",style:{display:"none"},onChange:ue}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>U.current&&U.current.click(),children:a("importVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:Y,onClick:()=>Ae("md"),children:a(Y?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:Y,onClick:()=>Ae("json"),children:a(Y?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>te(),children:a("refresh")})]}),L==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[jt.map(d=>(0,e.jsx)("button",{type:"button",className:`mc-chip${K===d?" active":""}`,onClick:()=>Oe(d),children:a(d==="all"?"all":Le[d])},d)),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),[{key:"recent",label:a("sortRecent")},{key:"title",label:a("sortTitle")},{key:"hot",label:a("sortHot")}].map(d=>(0,e.jsx)("button",{type:"button",className:`mc-chip${H===d.key?" active":""}`,onClick:()=>ye(d.key),children:d.label},d.key))]}),C&&(0,e.jsxs)("div",{className:"mc-empty",children:[a("error"),"\uFF1A",C]}),L==="cards"?O&&!z.length?(0,e.jsx)("div",{className:"mc-empty",children:a("loading")}):z.length===0?(0,e.jsx)("div",{className:"mc-empty",children:a("empty")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"mc-grid",children:ze.slice(0,pe).map(d=>(0,e.jsx)(Dt,{card:d,t:a,query:G.trim(),onOpen:Pe,onDelete:ve},d.path))}),ze.length>pe&&(0,e.jsx)("div",{ref:Ke,style:{height:1}})]}):L==="graph"?(0,e.jsx)(Pt,{t:a,onOpen:Pe,all:se,onAllChange:le}):L==="stats"?(0,e.jsx)(ht,{t:a,tab:"stats",onReload:()=>te()}):(0,e.jsx)(ht,{t:a,tab:"optimize",onReload:()=>te()}),ie&&(0,e.jsx)(Ot,{t:a,card:ie,query:G.trim(),onClose:()=>E(null),onDelete:d=>{E(null),ve(d)},onFeedback:d=>{let S=ie.path;fetch(`${W}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:G.trim(),path:S,useful:d})}).then(()=>m({ok:!0,msg:a(d?"fbUseful":"fbIrr")})).catch(()=>{}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>m(null),2e3)}})]})]})]})}var et=({label:a,value:l})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:l}),(0,e.jsx)("span",{children:a})]}),Dt=({card:a,t:l,onOpen:f,query:h,onDelete:u})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>f(a),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:tt[a.kind]||tt.other}}),h?yt(a.title,h):a.title,Yt(a.updated)&&(0,e.jsx)("span",{className:"mc-new",children:l("newBadge")})]}),(0,e.jsx)("p",{children:h?yt(a.summary||"",h):a.summary||""}),a.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:a.tags.slice(0,4).map(r=>(0,e.jsx)("span",{className:"mc-tag",children:r},r))}),(0,e.jsxs)("footer",{children:[(0,e.jsx)("span",{children:l(Le[a.kind])}),(0,e.jsx)("span",{children:vt(a.updated)}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:l("delete"),onClick:r=>{r.stopPropagation(),window.confirm(l("deleteConfirm"))&&u&&u(a.path)},children:"\u2715"})]})]});function ht({t:a,tab:l,onReload:f}){let[h,u]=(0,c.useState)(null),[r,R]=(0,c.useState)(""),[z,ae]=(0,c.useState)(null),[O,ce]=(0,c.useState)(null),[C,M]=(0,c.useState)(""),[K,Se]=(0,c.useState)(""),G=(0,c.useCallback)(async()=>{if(C){M("");return}try{let m=await fetch(`${W}/todayBrief`).then(N=>N.json());M(m.ok&&m.brief||"")}catch{}},[C]),Ie=(0,c.useCallback)(async()=>{if(!(!z||!z.merge||!z.merge.length)&&window.confirm(a("mergeAllConfirm"))){Se("merge");try{let m={},N=E=>m[E]===void 0?E:m[E]=N(m[E]),U=(E,se)=>{m[N(E)]=N(se)},Y=new Set;for(let E of z.merge)Y.add(E.a.path),Y.add(E.b.path),U(E.a.path,E.b.path);let oe={};for(let E of Y){let se=N(E);(oe[se]=oe[se]||[]).push(E)}let ie=0;for(let E of Object.values(oe)){if(E.length<2)continue;(await fetch(`${W}/merge?paths=${encodeURIComponent(E.join(","))}`).then(le=>le.json())).ok&&ie++}await L(),f&&f()}catch{}Se("")}},[z,L,f,a]);async function L(){try{let m=await Promise.all([fetch(`${W}/stats`),fetch(`${W}/optimize`),fetch(`${W}/budget`)]),[N,U,Y]=await Promise.all(m.map(oe=>oe.json()));N.ok&&u(N),U.ok&&ae(U),Y.ok&&ce(Y),R(N.ok&&U.ok?"":a("adminLoadFail"))}catch{R(a("adminLoadFail"))}}(0,c.useEffect)(()=>{L()},[]);let Ce=async(m,N)=>{if(window.confirm(a("mergeConfirm")))try{(await fetch(`${W}/merge?paths=${encodeURIComponent(m+","+N)}`).then(Y=>Y.json())).ok&&(await L(),f&&f())}catch{}},H=async m=>{if(window.confirm(a("deleteConfirm")))try{(await fetch(`${W}/delete?path=${encodeURIComponent(m)}`).then(U=>U.json())).ok&&(await L(),f&&f())}catch{}},ye=["project","knowledge","content","prompt","business","tool","mistake"],de=({title:m,kind:N,updated:U,path:Y})=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:De.colors[N]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:vt(U)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>H(Y),children:[a("delete")," \u2715"]})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:Be}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[r&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",r]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:L,children:["\u21BB ",a("retry")]})]}),l==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:a("todayBriefLabel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:G,children:C?`\u{1F4D5} ${a("collapse")}`:`\u{1F4D6} ${a("todayBrief")}`}),C&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:C})]}),h&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:h.total}),(0,e.jsx)("span",{children:a("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:h.today}),(0,e.jsx)("span",{children:a("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:h.week}),(0,e.jsx)("span",{children:a("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:h.tags}),(0,e.jsx)("span",{children:a("tags")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:a("byKind")}),(0,e.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:ye.map(m=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:De.colors[m]||"#666"}}),a(Le[m]),": ",h.byKind?.[m]||0]},m))})]}),O&&(O.budgetChars||O.recallLimit||O.embedding)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,fontSize:12},children:[(0,e.jsx)("b",{children:a("budgetLabel")}),"\uFF1A",a("budgetChars")," ",(0,e.jsx)("b",{children:O.budgetChars||8e4})," \xB7 ",a("recallLimitLabel")," ",(0,e.jsx)("b",{children:O.recallLimit||5})," \xB7 ",a("embeddingLabel")," ",O.embedding?"ON":"OFF"]}),(0,e.jsxs)("div",{className:"mc-card",children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[a("todayList"),"\uFF08",h.todayCards?.length||0,"\uFF09"]}),h.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:h.todayCards.map(m=>(0,e.jsx)(de,{title:m.title,kind:m.kind,updated:m.updated,path:m.path},m.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:a("noOptimize")})]})]})]}),l==="optimize"&&(0,e.jsx)("div",{children:z&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:z.merge?.length?a("mergePairs"):a("noOptimize")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),z.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!K,onClick:Ie,children:a(K==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:a("mergePairs")}),z.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:z.merge.map((m,N)=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[m.a.title," \u21C4 ",m.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(m.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>Ce(m.a.path,m.b.path),children:a("mergeNow")})]},N))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:12},children:a("noOptimize")}),(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[a("staleCards"),"\uFF08",z.stale?.length||0,"\uFF09"]}),z.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:z.stale.map(m=>(0,e.jsx)(de,{title:m.title,kind:"other",updated:m.updated,path:m.path},m.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:a("noOptimize")})]})})]})]})}function Ot({t:a,card:l,query:f,onClose:h,onDelete:u,onFeedback:r}){(0,c.useEffect)(()=>{let O=ce=>{ce.key==="Escape"&&h()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[h]);let[R,z]=(0,c.useState)(!1),ae=(l.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:h,children:[(0,e.jsx)("style",{children:Be}),(0,e.jsxs)("div",{className:"me-dialog",onClick:O=>O.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:l.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[f&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>r&&r(!0),children:["\u{1F44D} ",a("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>r&&r(!1),children:["\u{1F44E} ",a("fbIrr")]})]}),ae&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>z(O=>!O),children:a(R?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(a("deleteConfirm"))&&u&&u(l.path)},children:a("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:h,children:a("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:R?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:Xt(l.text)}})]})]})}function Pt({t:a,onOpen:l,all:f,onAllChange:h}){let[u,r]=(0,c.useState)(null),[R,z]=(0,c.useState)(""),ae=(0,c.useCallback)(async()=>{try{let M=await(await fetch(`${W}/graph${f?"?all=1":""}`)).json();M.ok?(r(M),z("")):(r(null),z(M.error||a("error")))}catch(C){z(String(C&&C.message?C.message:C))}},[f,a]);(0,c.useEffect)(()=>{let C=!0;return fetch(`${W}/graph${f?"?all=1":""}`).then(M=>M.json()).then(M=>{C&&(M.ok?(r(M),z("")):(r(null),z(M.error||a("error"))))}).catch(M=>{C&&z(String(M&&M.message?M.message:M))}),()=>{C=!1}},[f,a]);let O=(0,c.useCallback)(async C=>{try{let K=await(await fetch(`${W}/delete?path=${encodeURIComponent(C)}`)).json();return K&&K.ok?(await ae(),!0):!1}catch{return!1}},[ae]),ce=(0,c.useCallback)(async C=>{if(!C||C.length<2)return!1;try{let M=await fetch(`${W}/merge?paths=${encodeURIComponent(C.join(","))}`).then(K=>K.json());return M&&M.ok?(await ae(),!0):!1}catch{return!1}},[ae]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Be}),R&&(0,e.jsxs)("div",{className:"mc-empty",children:[a("error"),"\uFF1A",R]}),!u&&!R&&(0,e.jsx)("div",{className:"mc-empty",children:a("loading")}),u&&u.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:a("emptyGraph")}),u&&u.nodes.length>0&&(0,e.jsx)(Wt,{nodes:u.nodes,edges:u.edges,onOpen:l,onDelete:O,onMerge:ce,t:a,all:f,onAllChange:h,countLabel:`${u.nodes.length} ${a("nodes")} \xB7 ${At(u.edges)} ${a("edges")}`})]})}function At(a){let l=new Set;for(let f of a||[])l.add([f.source,f.target].sort().join("|"));return l.size}var De={colors:{project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},shapes:{project:"circle",knowledge:"circle",content:"rect",prompt:"diamond",business:"hexagon",tool:"circle",mistake:"diamond",other:"circle"}};function Wt({nodes:a,edges:l,onOpen:f,onDelete:h,onMerge:u,t:r,countLabel:R,all:z,onAllChange:ae}){let O=(0,c.useRef)(null),ce=(0,c.useRef)(null),C=(0,c.useRef)(null),M=(0,c.useRef)(null),K=(0,c.useRef)(null),Se=(0,c.useRef)(f);(0,c.useEffect)(()=>{Se.current=f},[f]);let G=(0,c.useRef)(h);(0,c.useEffect)(()=>{G.current=h},[h]);let Ie=(0,c.useRef)(u);(0,c.useEffect)(()=>{Ie.current=u},[u]);let[L,Ce]=(0,c.useState)(""),[H,ye]=(0,c.useState)(null),de=(0,c.useRef)("");(0,c.useEffect)(()=>{de.current=L.trim().toLowerCase()},[L]),(0,c.useEffect)(()=>{let n=C.current;if(!n)return;let o=L.trim().toLowerCase();if(!o)return;let b=n.nodes.find(F=>(F.name||"").toLowerCase().includes(o));b&&(C.current.selectedId=b.id,ye(b.id),n.panX=n.w/2-b.x*n.zoom,n.panY=n.h/2-b.y*n.zoom,n.render&&n.render())},[L]);let[m,N]=(0,c.useState)("all"),[U,Y]=(0,c.useState)(!1),oe=(0,c.useRef)("all"),[ie,E]=(0,c.useState)(""),se=(0,c.useRef)(""),[le,re]=(0,c.useState)(!1),Xe=(0,c.useRef)(!1),[q,pe]=(0,c.useState)(null);(0,c.useEffect)(()=>{oe.current=m},[m]),(0,c.useEffect)(()=>{se.current=ie},[ie]),(0,c.useEffect)(()=>{Xe.current=le},[le]);let Fe=(0,c.useMemo)(()=>{let n=new Map;for(let o of a)for(let b of o.tags||[]){let F=String(b).trim();F&&n.set(F,(n.get(F)||0)+1)}return[...n.entries()].sort((o,b)=>b[1]-o[1]).slice(0,24).map(([o,b])=>({tag:o,n:b}))},[a]),Ke=(()=>{let n=L.trim().toLowerCase();return!!n&&!a.some(o=>(o.title||o.name||"").toLowerCase().includes(n)||String(o.kind||"").toLowerCase().includes(n)||String(Le[o.kind]||"").toLowerCase().includes(n))})();(0,c.useEffect)(()=>{let n=C.current;n&&n.wake&&n.wake()},[L]),(0,c.useEffect)(()=>{let n=C.current;n&&n.render&&n.render()},[m,ie,le]);let me=(0,c.useRef)(null),[te,ve]=(0,c.useState)([]),[xe,Oe]=(0,c.useState)(null),[Pe,Ae]=(0,c.useState)(!1),[ue,ze]=(0,c.useState)(!1),[d,S]=(0,c.useState)(null),[v,ge]=(0,c.useState)(""),X=(0,c.useRef)(null),ke=(0,c.useRef)(null),T=(n,o=!0)=>{X.current&&clearTimeout(X.current),S({msg:n,ok:o}),X.current=setTimeout(()=>S(null),1900)},We=n=>{ge(n),ke.current&&clearTimeout(ke.current),ke.current=setTimeout(()=>ge(""),1600)};(0,c.useEffect)(()=>()=>{X.current&&clearTimeout(X.current),ke.current&&clearTimeout(ke.current)},[]);let ne=(0,c.useMemo)(()=>a.reduce((n,o)=>(n[o.id]=o,n),{}),[a]);return(0,c.useEffect)(()=>{let n=O.current;if(!n||a.length===0)return;let o=n.getContext("2d");if(!o)return;let b=Math.max(1,window.devicePixelRatio||1),F=()=>document.documentElement.getAttribute("data-theme")==="dark",P={};l.forEach(i=>{P[i.source]=(P[i.source]||0)+1,P[i.target]=(P[i.target]||0)+1});let J=Math.max(1,...Object.values(P)),t={nodes:a.map(i=>({id:i.id,name:i.title||"",type:i.kind||"other",r:9+Math.min(10,(P[i.id]||0)/J*8),x:0,y:0,vx:0,vy:0})),edges:l.map(i=>({sourceNodeId:i.source,targetNodeId:i.target,weight:1})),panX:0,panY:0,zoom:1,running:!0,raf:0,tickCount:0,quietTicks:0,dragNode:null,selectedId:null,mouseX:0,mouseY:0,w:0,h:0,dpr:b,ctx:o,multi:[],marquee:null};t.domain=a,t.domainById=a.reduce((i,g)=>(i[g.id]=g,i),{}),t.nodes.forEach((i,g)=>{let p=g/t.nodes.length*Math.PI*2-Math.PI/2;i.x=Math.cos(p)*60,i.y=Math.sin(p)*60});let je=[...new Set(t.nodes.map(i=>i.type))];t.clustered=je.length>1,t.typeCenters={},je.forEach((i,g)=>{let p=g/je.length*Math.PI*2-Math.PI/2;t.typeCenters[i]={x:Math.cos(p)*160,y:Math.sin(p)*160}}),C.current=t;let D=()=>{let i=n.clientWidth,g=n.clientHeight;t.w=i,t.h=g,n.width=i*b,n.height=g*b,o.setTransform(b,0,0,b,0,0)};D();let Ne=new ResizeObserver(D);Ne.observe(n.parentElement);let at=(i,g)=>i&&i.length>g?i.slice(0,g)+"\u2026":i,Ue=(i,g,p,y)=>{if(o.beginPath(),y==="rect")o.rect(i-p,g-p*.75,p*2,p*1.5);else if(y==="diamond")o.moveTo(i,g-p),o.lineTo(i+p,g),o.lineTo(i,g+p),o.lineTo(i-p,g),o.closePath();else if(y==="hexagon"){for(let x=0;x<6;x++){let B=Math.PI/3*x-Math.PI/2,I=i+p*Math.cos(B),_=g+p*Math.sin(B);x===0?o.moveTo(I,_):o.lineTo(I,_)}o.closePath()}else o.arc(i,g,p,0,Math.PI*2)},He=()=>{if(!t.nodes.length)return;let i=1/0,g=-1/0,p=1/0,y=-1/0;t.nodes.forEach(s=>{i=Math.min(i,s.x),g=Math.max(g,s.x),p=Math.min(p,s.y),y=Math.max(y,s.y)});let x=20,B=g-i+x*2,I=y-p+x*2,_=Math.min(t.w/B,t.h/I);t.zoom=Math.max(.35,Math.min(1.8,_)),t.panX=t.w/2-(i+g)/2*t.zoom,t.panY=t.h/2-(p+y)/2*t.zoom};M.current=He;let rt=()=>{o.clearRect(0,0,t.w,t.h),t.searchTerm=de.current,t.kindFilter=oe.current,t.timeMode=Xe.current,t.tagFilter=se.current;let i=t.tagFilter,g=t.kindFilter,p=s=>String(s||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");o.save(),o.strokeStyle=F()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",o.lineWidth=.5;for(let s=0;s<t.w;s+=24)o.beginPath(),o.moveTo(s,0),o.lineTo(s,t.h),o.stroke();for(let s=0;s<t.h;s+=24)o.beginPath(),o.moveTo(0,s),o.lineTo(t.w,s),o.stroke();o.restore(),o.save(),o.translate(t.panX,t.panY),o.scale(t.zoom,t.zoom);let y={};t.nodes.forEach(s=>y[s.id]=s);let x=t.nodes.length>40,B=x?1.5:.55,I=t.selectedId||t.hoverId;t.edges.forEach(s=>{let j=y[s.sourceNodeId],w=y[s.targetNodeId];if(!j||!w)return;if(g!=="all"){let _e=t.domainById[s.sourceNodeId]&&t.domainById[s.sourceNodeId].kind,ee=t.domainById[s.targetNodeId]&&t.domainById[s.targetNodeId].kind;if(_e!==g&&ee!==g)return}if(i){let _e=t.domainById[s.sourceNodeId]&&(t.domainById[s.sourceNodeId].tags||[]).includes(i),ee=t.domainById[s.targetNodeId]&&(t.domainById[s.targetNodeId].tags||[]).includes(i);if(!_e&&!ee)return}let k=w.x-j.x,$=w.y-j.y,A=Math.sqrt(k*k+$*$)||1,V=x?12:18,Z=-$/A*V,Q=k/A*V,be=(j.x+w.x)/2+Z,he=(j.y+w.y)/2+Q,we=De.colors[t.domainById[j.id]&&t.domainById[j.id].kind||"other"],Te=I&&(s.sourceNodeId===I||s.targetNodeId===I),ot=I?Te?.6:.08:x?.14:.24,nt=parseInt(we.slice(1,3),16),qe=parseInt(we.slice(3,5),16),Je=parseInt(we.slice(5,7),16);o.strokeStyle="rgba("+nt+","+qe+","+Je+","+ot+")",o.lineWidth=Te?1.6+(s.weight||1):.8+(s.weight||1)*.5,o.beginPath(),o.moveTo(j.x,j.y),o.quadraticCurveTo(be,he,w.x,w.y),o.stroke()});let _=[];if(t.nodes.forEach(s=>{let j=t.domainById[s.id]||{},w=j.kind||"other",k=t.timeMode?Ut(j.updated):De.colors[w],$=De.shapes[w],A=t.selectedId===s.id,V=t.hoverId===s.id,Z=t.searchTerm||"",Q=!Z||(s.name||"").toLowerCase().includes(Z)||String(Le[w]||"").toLowerCase().includes(Z)||String(w).toLowerCase().includes(Z),be=g==="all"||w===g,he=!i||(j.tags||[]).includes(i),we=I&&s.id!==I&&!t.edges.some(ee=>ee.sourceNodeId===I&&ee.targetNodeId===s.id||ee.targetNodeId===I&&ee.sourceNodeId===s.id)||Z&&!Q||!be||!he;o.save(),o.globalAlpha=we?.08:1,(A||V)&&(o.shadowColor=k,o.shadowBlur=A?20:14),Ue(s.x,s.y,s.r,$);let Te=parseInt(k.slice(1,3),16),ot=parseInt(k.slice(3,5),16),nt=parseInt(k.slice(5,7),16),qe=o.createRadialGradient(s.x-s.r*.3,s.y-s.r*.3,0,s.x,s.y,s.r*1.2);qe.addColorStop(0,"rgba("+Math.min(255,Te+70)+","+Math.min(255,ot+70)+","+Math.min(255,nt+70)+",0.95)"),qe.addColorStop(1,k),o.fillStyle=qe,o.fill(),o.restore(),A?(o.save(),Ue(s.x,s.y,s.r+3,$),o.strokeStyle=k,o.lineWidth=3,o.shadowColor=k,o.shadowBlur=12,o.stroke(),o.restore()):V?(o.save(),Ue(s.x,s.y,s.r+2,$),o.strokeStyle=k,o.lineWidth=2,o.stroke(),o.restore()):Z&&Q?(o.save(),Ue(s.x,s.y,s.r+2,$),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):t.multi.indexOf(s.id)>=0&&(o.save(),Ue(s.x,s.y,s.r+2,$),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let Je=at(s.name,16);if((A||V||t.zoom>B||!x&&t.zoom>.6)&&be&&he){let ee=1/t.zoom;o.font="500 "+(12*ee).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Me=o.measureText(Je).width+16*ee,Ze=18*ee,$e=s.y+s.r+8*ee,ft=!0;for(let Re of _)if(s.x-Me/2<Re.x+Re.w&&s.x+Me/2>Re.x&&$e<Re.y+Re.h&&$e+Ze>Re.y){ft=!1;break}if(!ft&&!A&&!V)return;_.push({x:s.x-Me/2,y:$e,w:Me,h:Ze}),o.fillStyle=F()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(s.x-Me/2,$e,Me,Ze,4*ee):o.rect(s.x-Me/2,$e,Me,Ze),o.fill(),o.strokeStyle=F()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*ee,o.stroke(),o.fillStyle=F()?A||V?"#eee":"#bbb":A||V?"#111":"#444",o.textAlign="center",o.fillText(Je,s.x,$e+13*ee)}}),o.restore(),t.marquee){let s=t.marquee,j=Math.min(s.sx,s.ex),w=Math.min(s.sy,s.ey),k=Math.abs(s.ex-s.sx),$=Math.abs(s.ey-s.sy);o.save(),o.setLineDash([4,4]),o.strokeStyle="rgba(96,165,250,0.9)",o.lineWidth=1,o.fillStyle="rgba(96,165,250,0.12)",o.fillRect(j,w,k,$),o.strokeRect(j,w,k,$),o.restore()}if(t.hoverId&&me.current){let s=t.domainById[t.hoverId],j=t.nodes.find(function(w){return w.id===t.hoverId});if(s&&j){let w=t.edges.filter(function(A){return A.sourceNodeId===s.id||A.targetNodeId===s.id}).length,k=j.x*t.zoom+t.panX,$=j.y*t.zoom+t.panY;me.current.style.display="block",me.current.style.left=k+14+"px",me.current.style.top=$-6+"px",me.current.innerHTML="<b>"+p(s.title||s.name||"")+'</b><br/><span style="opacity:.8">'+p(s.kind||"")+" \xB7 "+w+" \u8FDE\u63A5</span>"}}else me.current&&(me.current.style.display="none")},fe=()=>{t.running=!0,t.raf||(t.raf=requestAnimationFrame(st))};t.wake=fe,t.render=rt;let it=()=>{let i=t.nodes.length;t.tickCount++;let p=.9-Math.min(.4,t.tickCount/1500),y=i>1e3?3e3:i>100?2e3:i>50?1200:800,x=i>100?.002:.005,B=i>1e3?.012:i>100?.005:.01,I=i>1e3?6:i>200?12:24,_={};t.nodes.forEach(w=>_[w.id]=w);for(let w=0;w<i;w++){if(t.dragNode===t.nodes[w])continue;let k=t.nodes[w],$=0,A=0;for(let Q=0;Q<i;Q++){if(w===Q)continue;let be=k.x-t.nodes[Q].x,he=k.y-t.nodes[Q].y,we=Math.sqrt(be*be+he*he)||1,Te=y/(we*we);$+=be/we*Te,A+=he/we*Te}if(t.clustered&&t.typeCenters[k.type]){let Q=t.typeCenters[k.type];$+=(Q.x-k.x)*.006,A+=(Q.y-k.y)*.006}else $-=k.x*B,A-=k.y*B;let V=(k.vx+$)*p,Z=(k.vy+A)*p;V=Math.max(-I,Math.min(I,V)),Z=Math.max(-I,Math.min(I,Z)),k.vx=V,k.vy=Z}t.edges.forEach(w=>{let k=_[w.sourceNodeId],$=_[w.targetNodeId];if(!k||!$)return;let A=$.x-k.x,V=$.y-k.y,Z=Math.sqrt(A*A+V*V)||1,Q=(Z-100)*x,be=A/Z*Q,he=V/Z*Q;t.dragNode!==k&&(k.vx+=be,k.vy+=he),t.dragNode!==$&&($.vx-=be,$.vy-=he)});let s=0;t.nodes.forEach(w=>{t.dragNode!==w&&(w.x+=w.vx,w.y+=w.vy,s+=w.vx*w.vx+w.vy*w.vy)}),t.autoFitPending&&t.tickCount>45&&(t.autoFitPending=!1,He()),(i?Math.sqrt(s/i):0)<.05&&t.tickCount>60&&!t.dragNode?t.quietTicks=(t.quietTicks|0)+1:t.quietTicks=0},st=()=>{if(t.running){try{it(),rt()}catch{}if(t.quietTicks>30){t.raf=0;return}t.raf=requestAnimationFrame(st)}},Ye=(i,g)=>{let p=n.getBoundingClientRect();return{x:(i-p.left-t.panX)/t.zoom,y:(g-p.top-t.panY)/t.zoom}},Ve=i=>{let g=t.domainById[i];return!(!g||oe.current!=="all"&&g.kind!==oe.current||se.current&&!(g.tags||[]).includes(se.current))},Ge=(i,g,p)=>Math.max(g,Math.min(p,i)),lt=i=>{t.mouseX=i.clientX,t.mouseY=i.clientY;let g=Ye(i.clientX,i.clientY),p=null;for(let y=t.nodes.length-1;y>=0;y--){let x=t.nodes[y];if(!Ve(x.id))continue;let B=x.x-g.x,I=x.y-g.y;if(B*B+I*I<x.r*x.r+36){p=x.id;break}}p!==t.hoverId&&(t.hoverId=p,fe())},ct=i=>{if(i.button!==0)return;let g=Ye(i.clientX,i.clientY),p=null;for(let y=t.nodes.length-1;y>=0;y--){let x=t.nodes[y];if(!Ve(x.id))continue;let B=x.x-g.x,I=x.y-g.y;if(B*B+I*I<x.r*x.r+25){p=x;break}}if(i.shiftKey){t.marquee={sx:i.clientX,sy:i.clientY,ex:i.clientX,ey:i.clientY};return}t.dragStart={x:i.clientX,y:i.clientY,px:t.panX,py:t.panY},t.dragging=!1,t.dragNode=p||null,p&&(t.dragOffset={dx:p.x-g.x,dy:p.y-g.y})},dt=i=>{if(t.marquee){t.marquee.ex=i.clientX,t.marquee.ey=i.clientY,fe();return}if(!t.dragStart)return;let g=i.clientX-t.dragStart.x,p=i.clientY-t.dragStart.y;if(Math.abs(g)+Math.abs(p)>3&&(t.dragging=!0),t.dragNode){let y=Ye(i.clientX,i.clientY);t.dragNode.x=y.x+t.dragOffset.dx,t.dragNode.y=y.y+t.dragOffset.dy,fe()}else t.dragging&&(t.panX=Ge(t.dragStart.px+g,-1e5,1e5),t.panY=Ge(t.dragStart.py+p,-1e5,1e5),fe())},pt=i=>{if(t.marquee){let p=t.marquee;t.marquee=null;let y=n.getBoundingClientRect(),x=Math.min(p.sx,p.ex)-y.left,B=Math.max(p.sx,p.ex)-y.left,I=Math.min(p.sy,p.ey)-y.top,_=Math.max(p.sy,p.ey)-y.top,s=t.nodes.filter(j=>{let w=j.x*t.zoom+t.panX,k=j.y*t.zoom+t.panY;return w>=x&&w<=B&&k>=I&&k<=_}).map(j=>j.id);t.multi=s,ve(s),fe();return}if(t.dragStart&&!t.dragging){let p=Ye(i.clientX,i.clientY),y=null;for(let x=t.nodes.length-1;x>=0;x--){let B=t.nodes[x];if(!Ve(B.id))continue;let I=B.x-p.x,_=B.y-p.y;if(I*I+_*_<B.r*B.r+20){y=B;break}}y?(t.selectedId=y.id,ye(y.id),fe()):(t.selectedId=null,t.hoverId=null,i.shiftKey||(t.multi=[],ve([])),ye(null),fe())}t.dragStart=null,t.dragging=!1,t.dragNode=null},mt=i=>{i.preventDefault();let g=Ye(i.clientX,i.clientY),p=null;for(let y=t.nodes.length-1;y>=0;y--){let x=t.nodes[y];if(!Ve(x.id))continue;let B=x.x-g.x,I=x.y-g.y;if(B*B+I*I<x.r*x.r+25){p=x;break}}if(p){let y=t.domainById[p.id];y&&pe({x:i.clientX,y:i.clientY,id:p.id,path:y.id,title:y.title})}else pe(null)},ut=i=>{i.preventDefault();let g=n.getBoundingClientRect(),p=(i.clientX-g.left-t.panX)/t.zoom,y=(i.clientY-g.top-t.panY)/t.zoom,x=Math.max(.3,Math.min(3,t.zoom*(i.deltaY<0?1.1:1/1.1)));t.panX=Ge(t.panX+p*(t.zoom-x),-1e5,1e5),t.panY=Ge(t.panY+y*(t.zoom-x),-1e5,1e5),t.zoom=x,fe()};n.addEventListener("mousemove",lt),n.addEventListener("mousedown",ct),window.addEventListener("mousemove",dt),window.addEventListener("mouseup",pt),n.addEventListener("wheel",ut,{passive:!1}),n.addEventListener("contextmenu",mt),K.current=()=>{t.selectedId=null,t.hoverId=null,t.multi=[],ve([]),He(),fe()};for(let i=0;i<200;i++)it();He(),fe();let gt=()=>Y(!1);return window.addEventListener("mousedown",gt),()=>{t.running=!1,t.raf&&cancelAnimationFrame(t.raf),Ne.disconnect(),n.removeEventListener("mousemove",lt),n.removeEventListener("mousedown",ct),window.removeEventListener("mousemove",dt),window.removeEventListener("mouseup",pt),n.removeEventListener("wheel",ut),n.removeEventListener("contextmenu",mt),window.removeEventListener("mousedown",gt)}},[a,l]),(0,e.jsxs)("div",{className:"me-graph",ref:ce,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[a.length," ",r("nodes")," \xB7 ",l.length," ",r("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:r("search"),value:L,onChange:n=>Ce(n.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>Y(n=>!n),"aria-expanded":U,title:"\u7B5B\u9009",style:{borderRadius:8},children:["\u{1F50D} ",r("filterLabel")," ",m!=="all"||le||ie?"\u25CF":"\u25BE"]}),U&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:n=>n.stopPropagation(),style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:50,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:8,minWidth:240,boxShadow:"0 12px 34px rgba(0,0,0,.35)"},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsx)("button",{type:"button",className:`lg${m==="all"&&!le?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{N("all"),re(!1)},children:r("all")}),Object.keys(tt).map(n=>(0,e.jsxs)("button",{type:"button",className:`lg${m===n?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>N(o=>o===n?"all":n),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:De.colors[n]||tt[n]}}),r(Le[n])]},n)),(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsxs)("button",{type:"button",className:`lg${le?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>re(n=>!n),children:["\u23F1 ",r("timeDim")]}),Fe.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsx)("div",{style:{maxHeight:130,overflow:"auto",display:"flex",flexWrap:"wrap",gap:4},children:Fe.map(n=>(0,e.jsxs)("button",{type:"button",className:`lg${ie===n.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>E(o=>o===n.tag?"":n.tag),title:n.tag,children:["#",n.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:n.n})]},n.tag))})]}),(m!=="all"||le||ie)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{N("all"),re(!1),E("")},children:[r("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:r("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!z,onChange:n=>ae&&ae(n.target.checked)}),r("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${le?" me-on":""}`,onClick:()=>re(n=>!n),children:r("timeDim")}),(0,e.jsxs)("button",{type:"button",disabled:Pe,onClick:async()=>{if(!Pe){Ae(!0);try{let n=await fetch(`${W}/optimize`).then(D=>D.json());if(!n.ok||!n.merge||!n.merge.length){T(r("noOptimize"));return}let o={},b=D=>o[D]===void 0?D:o[D]=b(o[D]),F=(D,Ne)=>{o[b(D)]=b(Ne)},P=new Set;for(let D of n.merge)P.add(D.a.path),P.add(D.b.path),F(D.a.path,D.b.path);let J={};for(let D of P){let Ne=b(D);(J[Ne]=J[Ne]||[]).push(D)}let t=Object.values(J).filter(D=>D.length>=2);if(!t.length){T(r("noOptimize"));return}if(!window.confirm(r("mergeAllConfirm")))return;let je=0;for(let D of t)(await fetch(`${W}/merge?paths=${encodeURIComponent(D.join(","))}`).then(at=>at.json())).ok&&je++;T(`${je} ${r("mergeNow")}`)}catch{T(r("mergeFail"),!1)}Ae(!1)}},style:{background:"#f97316",color:"#fff",border:"none",fontWeight:700,boxShadow:"0 4px 14px rgba(249,115,22,0.35)"},children:["\u{1F500} ",r("mergeSimilar")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=O.current;if(n)try{n.toBlob(o=>{o&&Oe({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:r("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>M.current&&M.current(),children:r("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{ye(null),N("all"),K.current&&K.current()},children:r("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:O,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:me,style:{display:"none",position:"absolute",zIndex:4,pointerEvents:"none",background:"rgba(28,28,32,0.88)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:8,padding:"7px 10px",fontSize:12,maxWidth:220,boxShadow:"0 8px 24px rgba(0,0,0,.2)"}}),Ke&&(0,e.jsx)("div",{className:"mc-empty",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)"},children:r("noMatch")}),q&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>pe(null)}),q&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:q.x,top:q.y,zIndex:31},onMouseDown:n=>n.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{Se.current({path:q.path,title:q.title}),pe(null)},children:r("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{q.id&&(C.current.selectedId=q.id,ye(q.id)),pe(null);let n=C.current;n&&n.wake&&n.wake()},children:r("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(q.title||"")}catch{}pe(null),T(r("copied"))},children:r("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let n=C.current,o=n&&Array.isArray(n.multi)?n.multi.slice():[],b=q.id;if(b&&!o.includes(b)&&o.push(b),pe(null),o.length<2){T(r("mergeNeed"),!1);return}if(!window.confirm(r("mergeConfirm")))return;let F=Ie.current&&Ie.current(o);F&&F.then?F.then(P=>P?T(r("merged")):T(r("mergeFail"),!1)).catch(()=>T(r("mergeFail"),!1)):F&&T(r("merged"))},children:r("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let n=q.path;pe(null),window.confirm(r("deleteConfirm"))&&(async()=>{try{(G.current?await G.current(n):!1)?T(r("deleted")):T(r("deleteFail"),!1)}catch{T(r("deleteFail"),!1)}})()},children:r("delete")})]}),te.length>0&&(0,e.jsxs)("div",{style:{position:"absolute",left:10,top:10,zIndex:3,display:"flex",gap:8,alignItems:"center",background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:"6px 10px",fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsxs)("span",{style:{fontWeight:700},children:[te.length," ",r("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=te.map(J=>ne[J]).filter(Boolean).map(J=>J.title||J.name).join(`
|
|
127
|
-
|
|
126
|
+
`));let v=new Blob([P],{type:o}),B=await qt(v,n,!1);if(!B.ok){p({ok:!1,msg:t("exportFail")}),H(!1);return}p({ok:!0,msg:t("exportedTo")+"\uFF1A"+t("defaultDownloads")+" \xB7 "+B.name})}catch(b){p({ok:!1,msg:t("exportFail")+" \xB7 "+(b.message||"")})}finally{H(!1)}N.current&&clearTimeout(N.current),N.current=setTimeout(()=>p(null),2600)},Ee=async g=>{let I=g.target.files&&g.target.files[0];if(g.target.value="",!!I){try{let b=await I.text(),P=await(await fetch(`${Y}/import`,{method:"POST",headers:{"Content-Type":"application/json"},body:b})).json();P.ok?(await V(),p({ok:!0,msg:t("importedVault")+"\uFF1A"+(P.imported||0)+(P.skipped?t("importedSkipped")+P.skipped:"")})):p({ok:!1,msg:P.error||t("importFail")})}catch{p({ok:!1,msg:t("importFail")})}N.current&&clearTimeout(N.current),N.current=setTimeout(()=>p(null),2400)}},Re=(0,c.useMemo)(()=>{let g=S.slice();return K==="title"?g.sort((I,b)=>String(I.title||"").localeCompare(String(b.title||""))):K==="hot"?g.sort((I,b)=>(b.weight||b.links||0)-(I.weight||I.links||0)):g.sort((I,b)=>new Date(b.updated||0).getTime()-new Date(I.updated||0).getTime()),g},[S,K]);return(0,e.jsxs)("div",{className:"memory-eternal-root",style:{height:"100%",display:"flex",flexDirection:"column"},children:[(0,e.jsx)("style",{children:Ne}),ce&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(ce.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ce.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ce.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{children:ce.msg})]}),s&&(0,e.jsxs)("div",{className:"me-modal-head",children:[(0,e.jsxs)("div",{className:"me-modal-title",children:[(0,e.jsx)("span",{className:"me-wicon",children:(0,e.jsx)(ht,{})}),(0,e.jsx)("h2",{children:t("memoryTitle")}),(0,e.jsx)("span",{children:t("memoryHint")})]}),(0,e.jsx)("div",{className:"spacer"}),y&&(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:y,"aria-label":t(u?"exitFull":"fullscreen"),children:u?"\u2750":"\u26F6"}),(0,e.jsx)("button",{type:"button",className:"me-modal-close",onClick:d,"aria-label":t("close"),children:"\u2715"})]}),(0,e.jsxs)("div",{className:"me-modal-body",children:[(0,e.jsxs)("div",{className:`mc-rail${ne?" open":""}`,children:[(0,e.jsx)("button",{type:"button",className:"mc-rail-collapse",onClick:()=>We(g=>!g),"aria-label":t(ne?"collapse":"expand"),title:t(ne?"collapse":"expand"),children:ne?"\xAB":"\xBB"}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${L==="cards"?" active":""}`,onClick:()=>ve("cards"),title:t("cardsTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4C7}"}),ne&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("cardsTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${L==="graph"?" active":""}`,onClick:()=>ve("graph"),title:t("graphTab"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F578}"}),ne&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("graphTab")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${L==="stats"?" active":""}`,onClick:()=>ve("stats"),title:t("tabUsage"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F4CA}"}),ne&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabUsage")})]}),(0,e.jsxs)("button",{type:"button",className:`mc-railbtn${L==="optimize"?" active":""}`,onClick:()=>ve("optimize"),title:t("tabOptimize"),children:[(0,e.jsx)("span",{className:"mc-rail-ico",children:"\u{1F9F9}"}),ne&&(0,e.jsx)("span",{className:"mc-rail-label",children:t("tabOptimize")})]})]}),(0,e.jsxs)("div",{className:"mc-main",children:[L==="cards"&&(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsx)(Ge,{label:t("total"),value:r?r.total:"\u2014"}),(0,e.jsx)(Ge,{label:t("recent"),value:r?r.recent:"\u2014"}),(0,e.jsx)(Ge,{label:t("tags"),value:r?r.tags:"\u2014"}),(0,e.jsx)(Ge,{label:t("cardCount"),value:r?r.byKind?.knowledge??0:"\u2014"})]}),L==="cards"&&(0,e.jsxs)("div",{className:"mc-toolbar",children:[(0,e.jsx)("input",{type:"text",placeholder:t("searchPlaceholder"),value:_,onChange:g=>pe(g.target.value)}),(0,e.jsx)("input",{ref:W,type:"file",accept:".json,application/json",style:{display:"none"},onChange:Ee}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>W.current&&W.current.click(),children:t("importVault")}),(0,e.jsxs)("button",{type:"button",className:"mc-btn me-on",onClick:()=>de({kind:"knowledge",title:"",body:"",tags:"",template:""}),children:["+ ",t("newCard")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:A,onClick:()=>$e("md"),children:t(A?"exporting":"exportVault")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",disabled:A,onClick:()=>$e("json"),children:t(A?"exporting":"exportJson")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>V(),children:t("refresh")})]}),L==="cards"&&(0,e.jsxs)("div",{className:"mc-chips",children:[Ft.map(g=>(0,e.jsx)("button",{type:"button",className:`mc-chip${R===g?" active":""}`,onClick:()=>Te(g),children:t(g==="all"?"all":Ie[g])},g)),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),[{key:"recent",label:t("sortRecent")},{key:"title",label:t("sortTitle")},{key:"hot",label:t("sortHot")}].map(g=>(0,e.jsx)("button",{type:"button",className:`mc-chip${K===g.key?" active":""}`,onClick:()=>fe(g.key),children:g.label},g.key))]}),m&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",m]}),L==="cards"?O&&!S.length?(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}):S.length===0?(0,e.jsx)("div",{className:"mc-empty",children:t("empty")}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"mc-grid",children:Re.slice(0,Ae).map(g=>(0,e.jsx)(Rt,{card:g,t,query:_.trim(),onOpen:ke,onDelete:ze},g.path))}),Re.length>Ae&&(0,e.jsx)("div",{ref:be,style:{height:1}})]}):L==="graph"?(0,e.jsx)(Pt,{t,onOpen:ke,all:te,onAllChange:re}):L==="stats"?(0,e.jsx)(ft,{t,tab:"stats",onReload:()=>V()}):(0,e.jsx)(ft,{t,tab:"optimize",onReload:()=>V()}),q&&(0,e.jsx)(Ot,{t,card:q,query:_.trim(),onClose:()=>j(null),onDelete:g=>{j(null),ze(g)},onFeedback:g=>{let I=q.path;fetch(`${Y}/feedback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:_.trim(),path:I,useful:g})}).then(()=>p({ok:!0,msg:t(g?"fbUseful":"fbIrr")})).catch(()=>{}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>p(null),2e3)}}),(0,e.jsx)(Dt,{t,newCard:ae,setNewCard:de,onCreated:()=>{V(),p({ok:!0,msg:t("created")}),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>p(null),2e3)}})]})]})]})}var Ge=({label:t,value:s})=>(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:s}),(0,e.jsx)("span",{children:t})]}),Rt=({card:t,t:s,onOpen:d,query:y,onDelete:u})=>(0,e.jsxs)("article",{className:"mc-cardrow mc-card",onClick:()=>d(t),children:[(0,e.jsxs)("h4",{children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:_e[t.kind]||_e.other}}),y?bt(t.title,y):t.title,Yt(t.updated)&&(0,e.jsx)("span",{className:"mc-new",children:s("newBadge")})]}),(0,e.jsx)("p",{children:y?bt(t.summary||"",y):t.summary||""}),t.tags.length>0&&(0,e.jsx)("div",{className:"mc-tags",children:t.tags.slice(0,4).map(r=>(0,e.jsx)("span",{className:"mc-tag",children:r},r))}),(0,e.jsxs)("footer",{children:[(0,e.jsx)("span",{children:s(Ie[t.kind])}),(0,e.jsx)("span",{children:xt(t.updated)}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("button",{type:"button",className:"mc-card-del",title:s("delete"),onClick:r=>{r.stopPropagation(),window.confirm(s("deleteConfirm"))&&u&&u(t.path)},children:"\u2715"})]})]});function ft({t,tab:s,onReload:d}){let[y,u]=(0,c.useState)(null),[r,T]=(0,c.useState)(""),[S,X]=(0,c.useState)(null),[O,oe]=(0,c.useState)(null),[m,x]=(0,c.useState)(""),[R,ye]=(0,c.useState)(""),_=(0,c.useCallback)(async()=>{if(m){x("");return}try{let p=await fetch(`${Y}/todayBrief`).then(N=>N.json());x(p.ok&&p.brief||"")}catch{}},[m]),Me=(0,c.useCallback)(async()=>{if(!(!S||!S.merge||!S.merge.length)&&window.confirm(t("mergeAllConfirm"))){ye("merge");try{let p={},N=j=>p[j]===void 0?j:p[j]=N(p[j]),W=(j,te)=>{p[N(j)]=N(te)},A=new Set;for(let j of S.merge)A.add(j.a.path),A.add(j.b.path),W(j.a.path,j.b.path);let H={};for(let j of A){let te=N(j);(H[te]=H[te]||[]).push(j)}let q=0;for(let j of Object.values(H)){if(j.length<2)continue;(await fetch(`${Y}/merge?paths=${encodeURIComponent(j.join(","))}`).then(re=>re.json())).ok&&q++}await L(),d&&d()}catch{}ye("")}},[S,L,d,t]);async function L(){try{let p=await Promise.all([fetch(`${Y}/stats`),fetch(`${Y}/optimize`),fetch(`${Y}/budget`)]),[N,W,A]=await Promise.all(p.map(H=>H.json()));N.ok&&u(N),W.ok&&X(W),A.ok&&oe(A),T(N.ok&&W.ok?"":t("adminLoadFail"))}catch{T(t("adminLoadFail"))}}(0,c.useEffect)(()=>{L()},[]);let ve=async(p,N)=>{if(window.confirm(t("mergeConfirm")))try{(await fetch(`${Y}/merge?paths=${encodeURIComponent(p+","+N)}`).then(A=>A.json())).ok&&(await L(),d&&d())}catch{}},K=async p=>{if(window.confirm(t("deleteConfirm")))try{(await fetch(`${Y}/delete?path=${encodeURIComponent(p)}`).then(W=>W.json())).ok&&(await L(),d&&d())}catch{}},fe=["project","knowledge","content","prompt","business","tool","mistake"],ce=({title:p,kind:N,updated:W,path:A})=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)"},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:je.colors[N]||"#666"}}),(0,e.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}),(0,e.jsx)("span",{style:{opacity:.55,fontSize:11},children:xt(W)}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>K(A),children:[t("delete")," \u2715"]})]});return(0,e.jsxs)("div",{className:"mc-admin",style:{display:"flex",flexDirection:"column",overflow:"auto",flex:1,minHeight:0},children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{style:{overflow:"auto"},children:[r&&(0,e.jsxs)("div",{className:"mc-card",style:{borderLeft:"4px solid #ef4444",background:"rgba(239,68,68,0.08)",padding:"12px 14px",marginBottom:10},children:[(0,e.jsxs)("div",{style:{fontSize:13,color:"#b91c1c",fontWeight:600,marginBottom:6},children:["\u26A0 ",r]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:L,children:["\u21BB ",t("retry")]})]}),s==="stats"&&(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center",flexWrap:"wrap"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:t("todayBriefLabel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:_,children:m?`\u{1F4D5} ${t("collapse")}`:`\u{1F4D6} ${t("todayBrief")}`}),m&&(0,e.jsx)("pre",{style:{margin:0,fontSize:12,width:"100%",whiteSpace:"pre-wrap",opacity:.85},children:m})]}),y&&(0,e.jsxs)(e.Fragment,{children:[y.trend&&y.trend.length>0&&(()=>{let p=y.trend,N=Math.max(...p.map(q=>q.count),1),W=260,A=50,H=W/p.length;return(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,padding:"10px 14px"},children:[(0,e.jsxs)("div",{style:{fontSize:11,opacity:.6,marginBottom:4},children:["\u{1F4C8} ",t("trendLabel")]}),(0,e.jsx)("svg",{width:W,height:A,style:{display:"block",width:"100%",height:50},children:p.map((q,j)=>{let te=Math.round(q.count/N*(A-4));return(0,e.jsx)("rect",{x:j*H+1,y:A-te,width:Math.max(H-2,2),height:te,rx:1.5,fill:q.count>0?"var(--dsw-alias-accent, #3b82f6)":"var(--dsw-alias-border-l1, #e5e7eb)",opacity:q.count>0?.85:.35},q.date)})})]})})(),(0,e.jsxs)("div",{className:"mc-stats",children:[(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:y.total}),(0,e.jsx)("span",{children:t("total")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:y.today}),(0,e.jsx)("span",{children:t("todayAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:y.week}),(0,e.jsx)("span",{children:t("weekAdd")})]}),(0,e.jsxs)("div",{className:"mc-stat mc-card",children:[(0,e.jsx)("b",{children:y.tags}),(0,e.jsx)("span",{children:t("tags")})]})]}),(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10},children:[(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("byKind")}),(0,e.jsx)("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:fe.map(p=>(0,e.jsxs)("span",{style:{fontSize:12},children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:je.colors[p]||"#666"}}),t(Ie[p]),": ",y.byKind?.[p]||0]},p))})]}),O&&(O.budgetChars||O.recallLimit||O.embedding)&&(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,fontSize:12},children:[(0,e.jsx)("b",{children:t("budgetLabel")}),"\uFF1A",t("budgetChars")," ",(0,e.jsx)("b",{children:O.budgetChars||8e4})," \xB7 ",t("recallLimitLabel")," ",(0,e.jsx)("b",{children:O.recallLimit||5})," \xB7 ",t("embeddingLabel")," ",O.embedding?"ON":"OFF"]}),(0,e.jsxs)("div",{className:"mc-card",children:[(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("todayList"),"\uFF08",y.todayCards?.length||0,"\uFF09"]}),y.todayCards?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:y.todayCards.map(p=>(0,e.jsx)(ce,{title:p.title,kind:p.kind,updated:p.updated,path:p.path},p.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})]})]}),s==="optimize"&&(0,e.jsx)("div",{children:S&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"mc-card",style:{marginBottom:10,display:"flex",gap:10,alignItems:"center"},children:[(0,e.jsx)("b",{style:{fontSize:12},children:S.merge?.length?t("mergePairs"):t("noOptimize")}),(0,e.jsx)("div",{className:"spacer",style:{flex:1}}),S.merge?.length>0&&(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:!!R,onClick:Me,children:t(R==="merge"?"exporting":"batchMerge")})]}),(0,e.jsx)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:t("mergePairs")}),S.merge?.length?(0,e.jsx)("ul",{style:{margin:"0 0 12px",padding:0,listStyle:"none"},children:S.merge.map((p,N)=>(0,e.jsxs)("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px",borderBottom:"1px solid rgba(127,127,127,0.12)",fontSize:12},children:[(0,e.jsxs)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[p.a.title," \u21C4 ",p.b.title]}),(0,e.jsxs)("span",{style:{opacity:.6},children:[Math.round(p.sim*100),"%"]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{padding:"2px 8px"},onClick:()=>ve(p.a.path,p.b.path),children:t("mergeNow")})]},N))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12,marginBottom:12},children:t("noOptimize")}),(0,e.jsxs)("div",{style:{fontSize:12,fontWeight:700,marginBottom:6},children:[t("staleCards"),"\uFF08",S.stale?.length||0,"\uFF09"]}),S.stale?.length>0&&(0,e.jsx)("div",{style:{marginBottom:6},children:(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},disabled:!!R,onClick:async()=>{if(!window.confirm(t("deleteConfirm")))return;ye("clean");let p=0;for(let N of S.stale)try{await fetch(`${Y}/delete?path=${encodeURIComponent(N.path)}`),p++}catch{}ye(""),notify(`${p} ${t("deletedStale")}`),await L(),d&&d()},children:t("cleanStale")})}),S.stale?.length?(0,e.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none"},children:S.stale.map(p=>(0,e.jsx)(ce,{title:p.title,kind:"other",updated:p.updated,path:p.path},p.path))}):(0,e.jsx)("div",{style:{opacity:.6,fontSize:12},children:t("noOptimize")})]})})]})]})}var et=[{key:"decision",label:"tplDecision",kind:"knowledge",tags:["\u51B3\u7B56","\u65B9\u6848"],body:`# \u6280\u672F\u51B3\u7B56\uFF1A[\u6807\u9898]
|
|
127
|
+
|
|
128
|
+
## \u80CC\u666F
|
|
129
|
+
- \u95EE\u9898\u63CF\u8FF0
|
|
130
|
+
|
|
131
|
+
## \u5019\u9009\u65B9\u6848
|
|
132
|
+
| \u65B9\u6848 | \u4F18\u70B9 | \u7F3A\u70B9 |
|
|
133
|
+
| --- | --- | --- |
|
|
134
|
+
| A | | |
|
|
135
|
+
| B | | |
|
|
136
|
+
|
|
137
|
+
## \u51B3\u7B56
|
|
138
|
+
\u9009\u62E9\u65B9\u6848 A\uFF0C\u539F\u56E0\uFF1A
|
|
139
|
+
|
|
140
|
+
## \u98CE\u9669\u4E0E\u540E\u7EED
|
|
141
|
+
`},{key:"bug",label:"tplBug",kind:"mistake",tags:["\u8E29\u5751","\u6559\u8BAD"],body:`# \u8E29\u5751\u8BB0\u5F55\uFF1A[\u6807\u9898]
|
|
142
|
+
|
|
143
|
+
## \u73B0\u8C61
|
|
144
|
+
- \u53D1\u751F\u4E86\u4EC0\u4E48
|
|
145
|
+
|
|
146
|
+
## \u6839\u56E0
|
|
147
|
+
|
|
148
|
+
## \u89E3\u51B3\u65B9\u6848
|
|
149
|
+
|
|
150
|
+
## \u6559\u8BAD
|
|
151
|
+
- \u5982\u4F55\u907F\u514D\u4E0B\u6B21`},{key:"meeting",label:"tplMeeting",kind:"content",tags:["\u4F1A\u8BAE","\u7EAA\u8981"],body:`# \u4F1A\u8BAE\u7EAA\u8981\uFF1A[\u6807\u9898]
|
|
152
|
+
|
|
153
|
+
**\u65E5\u671F**\uFF1A
|
|
154
|
+
**\u53C2\u4F1A\u4EBA**\uFF1A
|
|
155
|
+
|
|
156
|
+
## \u8BAE\u9898
|
|
157
|
+
1.
|
|
158
|
+
|
|
159
|
+
## \u7ED3\u8BBA
|
|
160
|
+
|
|
161
|
+
## \u5F85\u529E
|
|
162
|
+
- [ ] `},{key:"weekly",label:"tplWeekly",kind:"content",tags:["\u5468\u62A5"],body:`# \u5468\u62A5 [YYYY-MM-DD]
|
|
163
|
+
|
|
164
|
+
## \u672C\u5468\u5B8C\u6210
|
|
165
|
+
-
|
|
166
|
+
|
|
167
|
+
## \u4E0B\u5468\u8BA1\u5212
|
|
168
|
+
-
|
|
169
|
+
|
|
170
|
+
## \u98CE\u9669/\u963B\u585E
|
|
171
|
+
- `}];function Dt({t,newCard:s,setNewCard:d,onCreated:y}){if(!s)return null;let u=et.find(m=>m.key===s.template),r=s.body||(u?u.body:""),T=s.kind||(u?u.kind:"knowledge"),S=s.tags||(u?u.tags.join(", "):""),X=s._creating,O=m=>{let x=et.find(R=>R.key===m);d(R=>({...R,template:m,kind:x?x.kind:R.kind,body:x?x.body:R.body,tags:x?x.tags.join(", "):R.tags}))},oe=async()=>{if(!(!s.title&&!r)){d(m=>({...m,_creating:!0}));try{(await fetch(`${Y}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:s.title||"\u65E0\u6807\u9898",kind:T,tags:S.split(",").map(x=>x.trim()).filter(Boolean),body:r,source:"manual"})}).then(x=>x.json())).ok?(d(null),y&&y()):d(x=>({...x,_creating:!1}))}catch{d(x=>({...x,_creating:!1}))}}};return(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>d(null),children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:600,width:"92vw",maxHeight:"85vh"},onClick:m=>m.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:t("newCard")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>d(null),children:t("close")})]}),(0,e.jsxs)("div",{className:"me-dialog-body",style:{display:"flex",flexDirection:"column",gap:10,overflow:"auto"},children:[(0,e.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[et.map(m=>(0,e.jsx)("button",{type:"button",className:`mc-btn${s.template===m.key?" me-on":""}`,onClick:()=>O(m.key),children:t(m.label)},m.key)),(0,e.jsx)("button",{type:"button",className:`mc-btn${s.template===""?" me-on":""}`,onClick:()=>d(m=>({...m,template:"",body:"",tags:"",kind:"knowledge"})),children:"\u{1F4C4} \u7A7A\u767D"})]}),(0,e.jsx)("select",{className:"mc-btn",value:T,onChange:m=>d(x=>({...x,kind:m.target.value})),style:{maxWidth:180},children:["project","knowledge","content","prompt","business","tool","mistake"].map(m=>(0,e.jsx)("option",{value:m,children:m},m))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("cardTitle"),value:s.title||"",onChange:m=>d(x=>({...x,title:m.target.value}))}),(0,e.jsx)("input",{type:"text",className:"mc-btn",placeholder:t("tags")+" (\u9017\u53F7\u5206\u9694)",value:S,onChange:m=>d(x=>({...x,tags:m.target.value}))}),(0,e.jsx)("textarea",{className:"mc-btn",placeholder:t("cardBody"),value:r,onChange:m=>d(x=>({...x,body:m.target.value})),style:{minHeight:180,resize:"vertical",fontFamily:"inherit"}}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:(0,e.jsx)("button",{type:"button",className:"mc-btn me-on",disabled:X,onClick:oe,children:t(X?"exporting":"createCard")})})]})]})]})}function Ot({t,card:s,query:d,onClose:y,onDelete:u,onFeedback:r}){(0,c.useEffect)(()=>{let O=oe=>{oe.key==="Escape"&&y()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[y]);let[T,S]=(0,c.useState)(!1),X=(s.text||"").length>460;return(0,e.jsxs)("div",{className:"me-overlay",onClick:y,children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",onClick:O=>O.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:s.title}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[d&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>r&&r(!0),children:["\u{1F44D} ",t("fbUseful")]}),(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>r&&r(!1),children:["\u{1F44E} ",t("fbIrr")]})]}),X&&(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>S(O=>!O),children:t(T?"collapse":"expand")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{window.confirm(t("deleteConfirm"))&&u&&u(s.path)},children:t("delete")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:y,children:t("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:T?{}:{maxHeight:300,overflow:"hidden"},dangerouslySetInnerHTML:{__html:Xt(s.text)}})]})]})}function Pt({t,onOpen:s,all:d,onAllChange:y}){let[u,r]=(0,c.useState)(null),[T,S]=(0,c.useState)(""),X=(0,c.useCallback)(async()=>{try{let x=await(await fetch(`${Y}/graph${d?"?all=1":""}`)).json();x.ok?(r(x),S("")):(r(null),S(x.error||t("error")))}catch(m){S(String(m&&m.message?m.message:m))}},[d,t]);(0,c.useEffect)(()=>{let m=!0;return fetch(`${Y}/graph${d?"?all=1":""}`).then(x=>x.json()).then(x=>{m&&(x.ok?(r(x),S("")):(r(null),S(x.error||t("error"))))}).catch(x=>{m&&S(String(x&&x.message?x.message:x))}),()=>{m=!1}},[d,t]);let O=(0,c.useCallback)(async m=>{try{let R=await(await fetch(`${Y}/delete?path=${encodeURIComponent(m)}`)).json();return R&&R.ok?(await X(),!0):!1}catch{return!1}},[X]),oe=(0,c.useCallback)(async m=>{if(!m||m.length<2)return!1;try{let x=await fetch(`${Y}/merge?paths=${encodeURIComponent(m.join(","))}`).then(R=>R.json());return x&&x.ok?(await X(),!0):!1}catch{return!1}},[X]);return(0,e.jsxs)("div",{className:"me-graph",children:[(0,e.jsx)("style",{children:Ne}),T&&(0,e.jsxs)("div",{className:"mc-empty",children:[t("error"),"\uFF1A",T]}),!u&&!T&&(0,e.jsx)("div",{className:"mc-empty",children:t("loading")}),u&&u.nodes.length===0&&(0,e.jsx)("div",{className:"mc-empty",children:t("emptyGraph")}),u&&u.nodes.length>0&&(0,e.jsx)(At,{nodes:u.nodes,edges:u.edges,onOpen:s,onDelete:O,onMerge:oe,t,all:d,onAllChange:y,countLabel:`${u.nodes.length} ${t("nodes")} \xB7 ${Wt(u.edges)} ${t("edges")}`})]})}function Wt(t){let s=new Set;for(let d of t||[])s.add([d.source,d.target].sort().join("|"));return s.size}var je={colors:{project:"#3B82F6",knowledge:"#10B981",content:"#F59E0B",prompt:"#A855F7",business:"#EC4899",tool:"#06B6D4",mistake:"#EF4444",other:"#6B7280"},shapes:{project:"circle",knowledge:"circle",content:"rect",prompt:"diamond",business:"hexagon",tool:"circle",mistake:"diamond",other:"circle"}};function At({nodes:t,edges:s,onOpen:d,onDelete:y,onMerge:u,t:r,countLabel:T,all:S,onAllChange:X}){let O=(0,c.useRef)(null),oe=(0,c.useRef)(null),m=(0,c.useRef)(null),x=(0,c.useRef)(null),R=(0,c.useRef)(null),ye=(0,c.useRef)(d);(0,c.useEffect)(()=>{ye.current=d},[d]);let _=(0,c.useRef)(y);(0,c.useEffect)(()=>{_.current=y},[y]);let Me=(0,c.useRef)(u);(0,c.useEffect)(()=>{Me.current=u},[u]);let[L,ve]=(0,c.useState)(""),[K,fe]=(0,c.useState)(null),ce=(0,c.useRef)("");(0,c.useEffect)(()=>{ce.current=L.trim().toLowerCase()},[L]),(0,c.useEffect)(()=>{let n=m.current;if(!n)return;let o=L.trim().toLowerCase();if(!o)return;let v=n.nodes.find(B=>(B.name||"").toLowerCase().includes(o));v&&(m.current.selectedId=v.id,fe(v.id),n.panX=n.w/2-v.x*n.zoom,n.panY=n.h/2-v.y*n.zoom,n.render&&n.render())},[L]);let[p,N]=(0,c.useState)("all"),[W,A]=(0,c.useState)(!1),H=(0,c.useRef)("all"),[q,j]=(0,c.useState)(""),te=(0,c.useRef)(""),[re,ne]=(0,c.useState)(!1),We=(0,c.useRef)(!1),[ae,de]=(0,c.useState)(null);(0,c.useEffect)(()=>{H.current=p},[p]),(0,c.useEffect)(()=>{te.current=q},[q]),(0,c.useEffect)(()=>{We.current=re},[re]);let we=(0,c.useMemo)(()=>{let n=new Map;for(let o of t)for(let v of o.tags||[]){let B=String(v).trim();B&&n.set(B,(n.get(B)||0)+1)}return[...n.entries()].sort((o,v)=>v[1]-o[1]).slice(0,24).map(([o,v])=>({tag:o,n:v}))},[t]),Ae=(()=>{let n=L.trim().toLowerCase();return!!n&&!t.some(o=>(o.title||o.name||"").toLowerCase().includes(n)||String(o.kind||"").toLowerCase().includes(n)||String(Ie[o.kind]||"").toLowerCase().includes(n))})();(0,c.useEffect)(()=>{let n=m.current;n&&n.wake&&n.wake()},[L]),(0,c.useEffect)(()=>{let n=m.current;n&&n.render&&n.render()},[p,q,re]);let ie=(0,c.useRef)(null),[be,xe]=(0,c.useState)([]),[V,ze]=(0,c.useState)(null),[pe,Te]=(0,c.useState)(!1),[ke,$e]=(0,c.useState)(null),[Ee,Re]=(0,c.useState)(""),g=(0,c.useRef)(null),I=(0,c.useRef)(null),b=(n,o=!0)=>{g.current&&clearTimeout(g.current),$e({msg:n,ok:o}),g.current=setTimeout(()=>$e(null),1900)},se=n=>{Re(n),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>Re(""),1600)};(0,c.useEffect)(()=>()=>{g.current&&clearTimeout(g.current),I.current&&clearTimeout(I.current)},[]);let P=(0,c.useMemo)(()=>t.reduce((n,o)=>(n[o.id]=o,n),{}),[t]);return(0,c.useEffect)(()=>{let n=O.current;if(!n||t.length===0)return;let o=n.getContext("2d");if(!o)return;let v=Math.max(1,window.devicePixelRatio||1),B=()=>document.documentElement.getAttribute("data-theme")==="dark",D={};s.forEach(i=>{D[i.source]=(D[i.source]||0)+1,D[i.target]=(D[i.target]||0)+1});let le=Math.max(1,...Object.values(D)),a={nodes:t.map(i=>({id:i.id,name:i.title||"",type:i.kind||"other",r:9+Math.min(10,(D[i.id]||0)/le*8),x:0,y:0,vx:0,vy:0})),edges:s.map(i=>({sourceNodeId:i.source,targetNodeId:i.target,weight:1})),panX:0,panY:0,zoom:1,running:!0,raf:0,tickCount:0,quietTicks:0,dragNode:null,selectedId:null,mouseX:0,mouseY:0,w:0,h:0,dpr:v,ctx:o,multi:[],marquee:null};a.domain=t,a.domainById=t.reduce((i,h)=>(i[h.id]=h,i),{}),a.nodes.forEach((i,h)=>{let f=h/a.nodes.length*Math.PI*2-Math.PI/2;i.x=Math.cos(f)*60,i.y=Math.sin(f)*60});let Je=[...new Set(a.nodes.map(i=>i.type))];a.clustered=Je.length>1,a.typeCenters={},Je.forEach((i,h)=>{let f=h/Je.length*Math.PI*2-Math.PI/2;a.typeCenters[i]={x:Math.cos(f)*160,y:Math.sin(f)*160}}),m.current=a;let tt=()=>{let i=n.clientWidth,h=n.clientHeight;a.w=i,a.h=h,n.width=i*v,n.height=h*v,o.setTransform(v,0,0,v,0,0)};tt();let at=new ResizeObserver(tt);at.observe(n.parentElement);let vt=(i,h)=>i&&i.length>h?i.slice(0,h)+"\u2026":i,De=(i,h,f,w)=>{if(o.beginPath(),w==="rect")o.rect(i-f,h-f*.75,f*2,f*1.5);else if(w==="diamond")o.moveTo(i,h-f),o.lineTo(i+f,h),o.lineTo(i,h+f),o.lineTo(i-f,h),o.closePath();else if(w==="hexagon"){for(let k=0;k<6;k++){let F=Math.PI/3*k-Math.PI/2,z=i+f*Math.cos(F),J=h+f*Math.sin(F);k===0?o.moveTo(z,J):o.lineTo(z,J)}o.closePath()}else o.arc(i,h,f,0,Math.PI*2)},Ue=()=>{if(!a.nodes.length)return;let i=1/0,h=-1/0,f=1/0,w=-1/0;a.nodes.forEach(l=>{i=Math.min(i,l.x),h=Math.max(h,l.x),f=Math.min(f,l.y),w=Math.max(w,l.y)});let k=20,F=h-i+k*2,z=w-f+k*2,J=Math.min(a.w/F,a.h/z);a.zoom=Math.max(.35,Math.min(1.8,J)),a.panX=a.w/2-(i+h)/2*a.zoom,a.panY=a.h/2-(f+w)/2*a.zoom};x.current=Ue;let ot=()=>{o.clearRect(0,0,a.w,a.h),a.searchTerm=ce.current,a.kindFilter=H.current,a.timeMode=We.current,a.tagFilter=te.current;let i=a.tagFilter,h=a.kindFilter,f=l=>String(l||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");o.save(),o.strokeStyle=B()?"rgba(255,255,255,0.04)":"rgba(0,0,0,0.04)",o.lineWidth=.5;for(let l=0;l<a.w;l+=24)o.beginPath(),o.moveTo(l,0),o.lineTo(l,a.h),o.stroke();for(let l=0;l<a.h;l+=24)o.beginPath(),o.moveTo(0,l),o.lineTo(a.w,l),o.stroke();o.restore(),o.save(),o.translate(a.panX,a.panY),o.scale(a.zoom,a.zoom);let w={};a.nodes.forEach(l=>w[l.id]=l);let k=a.nodes.length>40,F=k?1.5:.55,z=a.selectedId||a.hoverId;a.edges.forEach(l=>{let $=w[l.sourceNodeId],C=w[l.targetNodeId];if(!$||!C)return;if(h!=="all"){let Ke=a.domainById[l.sourceNodeId]&&a.domainById[l.sourceNodeId].kind,ee=a.domainById[l.targetNodeId]&&a.domainById[l.targetNodeId].kind;if(Ke!==h&&ee!==h)return}if(i){let Ke=a.domainById[l.sourceNodeId]&&(a.domainById[l.sourceNodeId].tags||[]).includes(i),ee=a.domainById[l.targetNodeId]&&(a.domainById[l.targetNodeId].tags||[]).includes(i);if(!Ke&&!ee)return}let M=C.x-$.x,E=C.y-$.y,U=Math.sqrt(M*M+E*E)||1,G=k?12:18,Z=-E/U*G,Q=M/U*G,ue=($.x+C.x)/2+Z,ge=($.y+C.y)/2+Q,he=je.colors[a.domainById[$.id]&&a.domainById[$.id].kind||"other"],Se=z&&(l.sourceNodeId===z||l.targetNodeId===z),Ze=z?Se?.6:.08:k?.14:.24,Qe=parseInt(he.slice(1,3),16),Pe=parseInt(he.slice(3,5),16),Xe=parseInt(he.slice(5,7),16);o.strokeStyle="rgba("+Qe+","+Pe+","+Xe+","+Ze+")",o.lineWidth=Se?1.6+(l.weight||1):.8+(l.weight||1)*.5,o.beginPath(),o.moveTo($.x,$.y),o.quadraticCurveTo(ue,ge,C.x,C.y),o.stroke()});let J=[];if(a.nodes.forEach(l=>{let $=a.domainById[l.id]||{},C=$.kind||"other",M=a.timeMode?Ut($.updated):je.colors[C],E=je.shapes[C],U=a.selectedId===l.id,G=a.hoverId===l.id,Z=a.searchTerm||"",Q=!Z||(l.name||"").toLowerCase().includes(Z)||String(Ie[C]||"").toLowerCase().includes(Z)||String(C).toLowerCase().includes(Z),ue=h==="all"||C===h,ge=!i||($.tags||[]).includes(i),he=z&&l.id!==z&&!a.edges.some(ee=>ee.sourceNodeId===z&&ee.targetNodeId===l.id||ee.targetNodeId===z&&ee.sourceNodeId===l.id)||Z&&!Q||!ue||!ge;o.save(),o.globalAlpha=he?.08:1,(U||G)&&(o.shadowColor=M,o.shadowBlur=U?20:14),De(l.x,l.y,l.r,E);let Se=parseInt(M.slice(1,3),16),Ze=parseInt(M.slice(3,5),16),Qe=parseInt(M.slice(5,7),16),Pe=o.createRadialGradient(l.x-l.r*.3,l.y-l.r*.3,0,l.x,l.y,l.r*1.2);Pe.addColorStop(0,"rgba("+Math.min(255,Se+70)+","+Math.min(255,Ze+70)+","+Math.min(255,Qe+70)+",0.95)"),Pe.addColorStop(1,M),o.fillStyle=Pe,o.fill(),o.restore(),U?(o.save(),De(l.x,l.y,l.r+3,E),o.strokeStyle=M,o.lineWidth=3,o.shadowColor=M,o.shadowBlur=12,o.stroke(),o.restore()):G?(o.save(),De(l.x,l.y,l.r+2,E),o.strokeStyle=M,o.lineWidth=2,o.stroke(),o.restore()):Z&&Q?(o.save(),De(l.x,l.y,l.r+2,E),o.strokeStyle="#e11d48",o.lineWidth=2,o.stroke(),o.restore()):a.multi.indexOf(l.id)>=0&&(o.save(),De(l.x,l.y,l.r+2,E),o.strokeStyle="#60a5fa",o.lineWidth=2,o.shadowColor="#60a5fa",o.shadowBlur=8,o.stroke(),o.restore());let Xe=vt(l.name,16);if((U||G||a.zoom>F||!k&&a.zoom>.6)&&ue&&ge){let ee=1/a.zoom;o.font="500 "+(12*ee).toFixed(1)+"px -apple-system,Segoe UI,sans-serif";let Ce=o.measureText(Xe).width+16*ee,He=18*ee,Le=l.y+l.r+8*ee,ut=!0;for(let Be of J)if(l.x-Ce/2<Be.x+Be.w&&l.x+Ce/2>Be.x&&Le<Be.y+Be.h&&Le+He>Be.y){ut=!1;break}if(!ut&&!U&&!G)return;J.push({x:l.x-Ce/2,y:Le,w:Ce,h:He}),o.fillStyle=B()?"rgba(30,30,35,0.92)":"rgba(255,255,255,0.92)",o.beginPath(),o.roundRect?o.roundRect(l.x-Ce/2,Le,Ce,He,4*ee):o.rect(l.x-Ce/2,Le,Ce,He),o.fill(),o.strokeStyle=B()?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.08)",o.lineWidth=1*ee,o.stroke(),o.fillStyle=B()?U||G?"#eee":"#bbb":U||G?"#111":"#444",o.textAlign="center",o.fillText(Xe,l.x,Le+13*ee)}}),o.restore(),a.marquee){let l=a.marquee,$=Math.min(l.sx,l.ex),C=Math.min(l.sy,l.ey),M=Math.abs(l.ex-l.sx),E=Math.abs(l.ey-l.sy);o.save(),o.setLineDash([4,4]),o.strokeStyle="rgba(96,165,250,0.9)",o.lineWidth=1,o.fillStyle="rgba(96,165,250,0.12)",o.fillRect($,C,M,E),o.strokeRect($,C,M,E),o.restore()}if(a.hoverId&&ie.current){let l=a.domainById[a.hoverId],$=a.nodes.find(function(C){return C.id===a.hoverId});if(l&&$){let C=a.edges.filter(function(U){return U.sourceNodeId===l.id||U.targetNodeId===l.id}).length,M=$.x*a.zoom+a.panX,E=$.y*a.zoom+a.panY;ie.current.style.display="block",ie.current.style.left=M+14+"px",ie.current.style.top=E-6+"px",ie.current.innerHTML="<b>"+f(l.title||l.name||"")+'</b><br/><span style="opacity:.8">'+f(l.kind||"")+" \xB7 "+C+" \u8FDE\u63A5</span>"}}else ie.current&&(ie.current.style.display="none")},me=()=>{a.running=!0,a.raf||(a.raf=requestAnimationFrame(rt))};a.wake=me,a.render=ot;let nt=()=>{let i=a.nodes.length;a.tickCount++;let f=.9-Math.min(.4,a.tickCount/1500),w=i>1e3?3e3:i>100?2e3:i>50?1200:800,k=i>100?.002:.005,F=i>1e3?.012:i>100?.005:.01,z=i>1e3?6:i>200?12:24,J={};a.nodes.forEach(C=>J[C.id]=C);for(let C=0;C<i;C++){if(a.dragNode===a.nodes[C])continue;let M=a.nodes[C],E=0,U=0;for(let Q=0;Q<i;Q++){if(C===Q)continue;let ue=M.x-a.nodes[Q].x,ge=M.y-a.nodes[Q].y,he=Math.sqrt(ue*ue+ge*ge)||1,Se=w/(he*he);E+=ue/he*Se,U+=ge/he*Se}if(a.clustered&&a.typeCenters[M.type]){let Q=a.typeCenters[M.type];E+=(Q.x-M.x)*.006,U+=(Q.y-M.y)*.006}else E-=M.x*F,U-=M.y*F;let G=(M.vx+E)*f,Z=(M.vy+U)*f;G=Math.max(-z,Math.min(z,G)),Z=Math.max(-z,Math.min(z,Z)),M.vx=G,M.vy=Z}a.edges.forEach(C=>{let M=J[C.sourceNodeId],E=J[C.targetNodeId];if(!M||!E)return;let U=E.x-M.x,G=E.y-M.y,Z=Math.sqrt(U*U+G*G)||1,Q=(Z-100)*k,ue=U/Z*Q,ge=G/Z*Q;a.dragNode!==M&&(M.vx+=ue,M.vy+=ge),a.dragNode!==E&&(E.vx-=ue,E.vy-=ge)});let l=0;a.nodes.forEach(C=>{a.dragNode!==C&&(C.x+=C.vx,C.y+=C.vy,l+=C.vx*C.vx+C.vy*C.vy)}),a.autoFitPending&&a.tickCount>45&&(a.autoFitPending=!1,Ue()),(i?Math.sqrt(l/i):0)<.05&&a.tickCount>60&&!a.dragNode?a.quietTicks=(a.quietTicks|0)+1:a.quietTicks=0},rt=()=>{if(a.running){try{nt(),ot()}catch{}if(a.quietTicks>30){a.raf=0;return}a.raf=requestAnimationFrame(rt)}},Oe=(i,h)=>{let f=n.getBoundingClientRect();return{x:(i-f.left-a.panX)/a.zoom,y:(h-f.top-a.panY)/a.zoom}},Ye=i=>{let h=a.domainById[i];return!(!h||H.current!=="all"&&h.kind!==H.current||te.current&&!(h.tags||[]).includes(te.current))},qe=(i,h,f)=>Math.max(h,Math.min(f,i)),it=i=>{a.mouseX=i.clientX,a.mouseY=i.clientY;let h=Oe(i.clientX,i.clientY),f=null;for(let w=a.nodes.length-1;w>=0;w--){let k=a.nodes[w];if(!Ye(k.id))continue;let F=k.x-h.x,z=k.y-h.y;if(F*F+z*z<k.r*k.r+36){f=k.id;break}}f!==a.hoverId&&(a.hoverId=f,me())},st=i=>{if(i.button!==0)return;let h=Oe(i.clientX,i.clientY),f=null;for(let w=a.nodes.length-1;w>=0;w--){let k=a.nodes[w];if(!Ye(k.id))continue;let F=k.x-h.x,z=k.y-h.y;if(F*F+z*z<k.r*k.r+25){f=k;break}}if(i.shiftKey){a.marquee={sx:i.clientX,sy:i.clientY,ex:i.clientX,ey:i.clientY};return}a.dragStart={x:i.clientX,y:i.clientY,px:a.panX,py:a.panY},a.dragging=!1,a.dragNode=f||null,f&&(a.dragOffset={dx:f.x-h.x,dy:f.y-h.y})},lt=i=>{if(a.marquee){a.marquee.ex=i.clientX,a.marquee.ey=i.clientY,me();return}if(!a.dragStart)return;let h=i.clientX-a.dragStart.x,f=i.clientY-a.dragStart.y;if(Math.abs(h)+Math.abs(f)>3&&(a.dragging=!0),a.dragNode){let w=Oe(i.clientX,i.clientY);a.dragNode.x=w.x+a.dragOffset.dx,a.dragNode.y=w.y+a.dragOffset.dy,me()}else a.dragging&&(a.panX=qe(a.dragStart.px+h,-1e5,1e5),a.panY=qe(a.dragStart.py+f,-1e5,1e5),me())},ct=i=>{if(a.marquee){let f=a.marquee;a.marquee=null;let w=n.getBoundingClientRect(),k=Math.min(f.sx,f.ex)-w.left,F=Math.max(f.sx,f.ex)-w.left,z=Math.min(f.sy,f.ey)-w.top,J=Math.max(f.sy,f.ey)-w.top,l=a.nodes.filter($=>{let C=$.x*a.zoom+a.panX,M=$.y*a.zoom+a.panY;return C>=k&&C<=F&&M>=z&&M<=J}).map($=>$.id);a.multi=l,xe(l),me();return}if(a.dragStart&&!a.dragging){let f=Oe(i.clientX,i.clientY),w=null;for(let k=a.nodes.length-1;k>=0;k--){let F=a.nodes[k];if(!Ye(F.id))continue;let z=F.x-f.x,J=F.y-f.y;if(z*z+J*J<F.r*F.r+20){w=F;break}}w?(a.selectedId=w.id,fe(w.id),me()):(a.selectedId=null,a.hoverId=null,i.shiftKey||(a.multi=[],xe([])),fe(null),me())}a.dragStart=null,a.dragging=!1,a.dragNode=null},dt=i=>{i.preventDefault();let h=Oe(i.clientX,i.clientY),f=null;for(let w=a.nodes.length-1;w>=0;w--){let k=a.nodes[w];if(!Ye(k.id))continue;let F=k.x-h.x,z=k.y-h.y;if(F*F+z*z<k.r*k.r+25){f=k;break}}if(f){let w=a.domainById[f.id];w&&de({x:i.clientX,y:i.clientY,id:f.id,path:w.id,title:w.title})}else de(null)},pt=i=>{i.preventDefault();let h=n.getBoundingClientRect(),f=(i.clientX-h.left-a.panX)/a.zoom,w=(i.clientY-h.top-a.panY)/a.zoom,k=Math.max(.3,Math.min(3,a.zoom*(i.deltaY<0?1.1:1/1.1)));a.panX=qe(a.panX+f*(a.zoom-k),-1e5,1e5),a.panY=qe(a.panY+w*(a.zoom-k),-1e5,1e5),a.zoom=k,me()};n.addEventListener("mousemove",it),n.addEventListener("mousedown",st),window.addEventListener("mousemove",lt),window.addEventListener("mouseup",ct),n.addEventListener("wheel",pt,{passive:!1}),n.addEventListener("contextmenu",dt),R.current=()=>{a.selectedId=null,a.hoverId=null,a.multi=[],xe([]),Ue(),me()};for(let i=0;i<200;i++)nt();Ue(),me();let mt=()=>A(!1);return window.addEventListener("mousedown",mt),()=>{a.running=!1,a.raf&&cancelAnimationFrame(a.raf),at.disconnect(),n.removeEventListener("mousemove",it),n.removeEventListener("mousedown",st),window.removeEventListener("mousemove",lt),window.removeEventListener("mouseup",ct),n.removeEventListener("wheel",pt),n.removeEventListener("contextmenu",dt),window.removeEventListener("mousedown",mt)}},[t,s]),(0,e.jsxs)("div",{className:"me-graph",ref:oe,children:[(0,e.jsxs)("div",{className:"me-graph-toolbar",children:[(0,e.jsxs)("span",{className:"me-graph-count",children:[t.length," ",r("nodes")," \xB7 ",s.length," ",r("edges")]}),(0,e.jsx)("span",{className:"spacer",style:{flex:1}}),(0,e.jsx)("input",{type:"text",placeholder:r("search"),value:L,onChange:n=>ve(n.target.value)}),(0,e.jsxs)("span",{style:{position:"relative",display:"inline-flex"},children:[(0,e.jsxs)("button",{type:"button",className:"mc-btn",onClick:()=>A(n=>!n),"aria-expanded":W,title:"\u7B5B\u9009",style:{borderRadius:8},children:["\u{1F50D} ",r("filterLabel")," ",p!=="all"||re||q?"\u25CF":"\u25BE"]}),W&&(0,e.jsx)("div",{className:"me-graph-legend-pop",onMouseDown:n=>n.stopPropagation(),style:{position:"absolute",top:"calc(100% + 6px)",left:0,zIndex:50,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",border:"1px solid rgba(255,255,255,0.1)",borderRadius:10,padding:8,minWidth:240,boxShadow:"0 12px 34px rgba(0,0,0,.35)"},children:(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[(0,e.jsx)("button",{type:"button",className:`lg${p==="all"&&!re?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>{N("all"),ne(!1)},children:r("all")}),Object.keys(_e).map(n=>(0,e.jsxs)("button",{type:"button",className:`lg${p===n?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>N(o=>o===n?"all":n),children:[(0,e.jsx)("span",{className:"mc-kind",style:{background:je.colors[n]||_e[n]}}),r(Ie[n])]},n)),(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsxs)("button",{type:"button",className:`lg${re?" active":""}`,style:{justifyContent:"flex-start"},onClick:()=>ne(n=>!n),children:["\u23F1 ",r("timeDim")]}),we.length>0&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),(0,e.jsx)("div",{style:{maxHeight:130,overflow:"auto",display:"flex",flexWrap:"wrap",gap:4},children:we.map(n=>(0,e.jsxs)("button",{type:"button",className:`lg${q===n.tag?" active":""}`,style:{color:"#ddd",padding:"2px 7px",fontSize:11},onClick:()=>j(o=>o===n.tag?"":n.tag),title:n.tag,children:["#",n.tag," ",(0,e.jsx)("span",{style:{opacity:.55},children:n.n})]},n.tag))})]}),(p!=="all"||re||q)&&(0,e.jsxs)("button",{type:"button",className:"lg lg-clear",style:{justifyContent:"flex-start",color:"#f87171"},onClick:()=>{N("all"),ne(!1),j("")},children:[r("clearFilter")," \u2715"]})]})})]}),(0,e.jsxs)("label",{className:"mc-btn",style:{display:"inline-flex",alignItems:"center",gap:5,cursor:"pointer"},title:r("crossVault"),children:[(0,e.jsx)("input",{type:"checkbox",checked:!!S,onChange:n=>X&&X(n.target.checked)}),r("crossVault")]}),(0,e.jsx)("button",{type:"button",className:`mc-btn${re?" me-on":""}`,onClick:()=>ne(n=>!n),children:r("timeDim")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=O.current;if(n)try{n.toBlob(o=>{o&&ze({url:URL.createObjectURL(o),blob:o})},"image/png")}catch{}},children:r("exportGraph")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>x.current&&x.current(),children:r("fit")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{fe(null),N("all"),R.current&&R.current()},children:r("reset")})]}),(0,e.jsxs)("div",{className:"me-graph-canvas",style:{position:"relative",overflow:"hidden"},children:[(0,e.jsx)("canvas",{ref:O,style:{width:"100%",height:"100%",display:"block",cursor:"grab"}}),(0,e.jsx)("div",{className:"me-graph-tooltip",ref:ie,style:{display:"none",position:"absolute",zIndex:4,pointerEvents:"none",background:"rgba(28,28,32,0.88)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:8,padding:"7px 10px",fontSize:12,maxWidth:220,boxShadow:"0 8px 24px rgba(0,0,0,.2)"}}),Ae&&(0,e.jsx)("div",{className:"mc-empty",style:{position:"absolute",inset:0,zIndex:2,display:"flex",alignItems:"center",justifyContent:"center",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)"},children:r("noMatch")}),ae&&(0,e.jsx)("div",{className:"me-graph-ctx-back",style:{position:"fixed",inset:0,zIndex:30},onMouseDown:()=>de(null)}),ae&&(0,e.jsxs)("div",{className:"me-graph-ctxmenu",style:{position:"fixed",left:ae.x,top:ae.y,zIndex:31},onMouseDown:n=>n.stopPropagation(),children:[(0,e.jsx)("button",{type:"button",onClick:()=>{ye.current({path:ae.path,title:ae.title}),de(null)},children:r("openCard")}),(0,e.jsx)("button",{type:"button",onClick:()=>{ae.id&&(m.current.selectedId=ae.id,fe(ae.id)),de(null);let n=m.current;n&&n.wake&&n.wake()},children:r("focusNeighbors")}),(0,e.jsx)("button",{type:"button",onClick:()=>{try{navigator.clipboard&&navigator.clipboard.writeText(ae.title||"")}catch{}de(null),b(r("copied"))},children:r("copyName")}),(0,e.jsx)("button",{type:"button",onClick:()=>{let n=m.current,o=n&&Array.isArray(n.multi)?n.multi.slice():[],v=ae.id;if(v&&!o.includes(v)&&o.push(v),de(null),o.length<2){b(r("mergeNeed"),!1);return}if(!window.confirm(r("mergeConfirm")))return;let B=Me.current&&Me.current(o);B&&B.then?B.then(D=>D?b(r("merged")):b(r("mergeFail"),!1)).catch(()=>b(r("mergeFail"),!1)):B&&b(r("merged"))},children:r("merge")}),(0,e.jsx)("button",{type:"button",style:{color:"#f87171"},onClick:()=>{let n=ae.path;de(null),window.confirm(r("deleteConfirm"))&&(async()=>{try{(_.current?await _.current(n):!1)?b(r("deleted")):b(r("deleteFail"),!1)}catch{b(r("deleteFail"),!1)}})()},children:r("delete")})]}),be.length>0&&(0,e.jsxs)("div",{style:{position:"absolute",left:10,top:10,zIndex:3,display:"flex",gap:8,alignItems:"center",background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:"6px 10px",fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsxs)("span",{style:{fontWeight:700},children:[be.length," ",r("nodes")]}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let o=be.map(le=>P[le]).filter(Boolean).map(le=>le.title||le.name).join(`
|
|
172
|
+
`),v=new Blob([o],{type:"text/plain;charset=utf-8"}),B=URL.createObjectURL(v),D=document.createElement("a");D.href=B,D.download="memory-selected.txt",document.body.appendChild(D),D.click(),document.body.removeChild(D),setTimeout(()=>URL.revokeObjectURL(B),1e3),b(be.length+r("exportedSel"))},children:r("exportSel")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{if(be.length<2){b(r("mergeNeed"),!1);return}let n=be.map(v=>P[v]?P[v].id:v);if(!window.confirm(r("mergeConfirm")))return;xe([]);let o=m.current;o&&(o.multi=[]),fetch(`${Y}/merge?paths=${encodeURIComponent(n.join(","))}`).then(v=>v.json()).then(v=>{v&&v.ok?b(r("merged")):b(r("mergeFail"),!1)}).catch(()=>b(r("mergeFail"),!1))},children:r("merge")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",style:{color:"#f87171"},onClick:()=>{if(!window.confirm(r("deleteConfirm")))return;let n=be.map(v=>P[v]?P[v].id:v);xe([]);let o=m.current;o&&(o.multi=[]),(async()=>{let v=0;for(let B of n)try{(_.current?await _.current(B):!1)&&v++}catch{}b(v+r("deletedSelected"),v>0)})()},children:r("deleteSelected")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=m.current;n&&(n.multi=[]),xe([]);let o=m.current;o&&o.render&&o.render()},children:r("clearSelection")})]}),K&&(0,e.jsxs)("div",{className:"me-graph-sidebar",style:{position:"absolute",right:10,top:10,zIndex:3,maxWidth:240,background:"rgba(28,28,32,0.92)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)",color:"#eee",borderRadius:10,padding:12,fontSize:12,boxShadow:"0 10px 30px rgba(0,0,0,.25)"},children:[(0,e.jsx)("div",{style:{fontWeight:700,fontSize:13,marginBottom:4},children:P[K]?P[K].title||P[K].name:K}),(0,e.jsx)("div",{style:{opacity:.8,marginBottom:8},children:P[K]?r(Ie[P[K].kind]||"kindKnowledge"):"\u2014"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.65,letterSpacing:".04em",marginBottom:6},children:r("graphHint")}),(s.filter(n=>n.source===K||n.target===K)||[]).slice(0,8).map((n,o)=>{let v=n.source===K?n.target:n.source,B=P[v];return(0,e.jsx)("div",{style:{padding:"4px 6px",cursor:"pointer",borderRadius:6},onMouseDown:D=>{D.preventDefault();let le=m.current;le&&(le.selectedId=v,le.hoverId=v,le.wake&&le.wake()),fe(v)},children:B?(B.title||B.name).slice(0,28):v},o)})]})]}),(0,e.jsx)("div",{className:"me-graph-tip",children:r("graphTip")}),ke&&(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,position:"fixed",left:"50%",transform:"translateX(-50%)",top:22,zIndex:70,background:"rgba(20,22,26,0.97)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)",color:"#f5f5f5",borderRadius:12,padding:"10px 20px",fontSize:13.5,fontWeight:600,boxShadow:"0 14px 44px rgba(0,0,0,.5)",pointerEvents:"none",animation:"me-pop .22s ease",borderLeft:"4px solid "+(ke.ok?"#22c55e":"#ef4444"),maxWidth:"90vw"},children:[(0,e.jsx)("span",{style:{color:ke.ok?"#34d399":"#f87171",fontWeight:800,fontSize:15},children:ke.ok?"\u2713":"\u2715"}),(0,e.jsx)("span",{style:{wordBreak:"break-all"},children:ke.msg})]}),V&&(0,e.jsxs)("div",{className:"me-overlay",onClick:()=>{V.url&&URL.revokeObjectURL(V.url),ze(null),Te(!1)},children:[(0,e.jsx)("style",{children:Ne}),(0,e.jsxs)("div",{className:"me-dialog",style:{maxWidth:pe?"100vw":900,width:pe?"100vw":"92vw",maxHeight:pe?"100vh":"90vh",height:pe?"100vh":void 0,borderRadius:pe?0:14},onClick:n=>n.stopPropagation(),children:[(0,e.jsxs)("div",{className:"me-dialog-head",children:[(0,e.jsx)("h3",{children:r("exportGraph")}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("a",{className:"mc-btn",href:V.url,download:"memory-graph.png",onClick:()=>{se("download"),b(r("downloaded")+" \xB7 "+r("defaultDownloads"))},style:{textDecoration:"none",display:"inline-flex",alignItems:"center"},children:r(Ee==="download"?"done":"download")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{se("full"),Te(n=>!n),b(r("fullscreen"))},children:r(Ee==="full"?"done":pe?"exitFull":"fullscreen")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{let n=V.blob;n&&window.ClipboardItem&&navigator.clipboard?navigator.clipboard.write([new window.ClipboardItem({"image/png":n})]).then(()=>{se("copy"),b(r("copied"))}).catch(()=>{b(r("copyFail"),!1)}):b(r("copyFail"),!1)},children:r(Ee==="copy"?"done":"copyImage")}),(0,e.jsx)("button",{type:"button",className:"mc-btn",onClick:()=>{V.url&&URL.revokeObjectURL(V.url),ze(null),Te(!1)},children:r("close")})]})]}),(0,e.jsx)("div",{className:"me-dialog-body",style:{display:"flex",justifyContent:"center",background:pe?"var(--dsw-alias-bg-base, #0b0d10)":"var(--dsw-alias-bg-base, #f3f4f6)"},children:(0,e.jsx)("img",{src:V.url,alt:r("exportGraph"),style:{maxWidth:"100%",maxHeight:pe?"calc(100vh - 64px)":"70vh",borderRadius:pe?0:8,cursor:"zoom-in"},onClick:()=>Te(n=>!n)})})]})]})]})}function Ut(t){let s=new Date(t||0).getTime();if(!s)return"#94a3b8";let d=(Date.now()-s)/864e5;return d<3?"#10b981":d<14?"#f59e0b":d<30?"#f97316":"#94a3b8"}function Yt(t){let s=new Date(t||0).getTime();return!!s&&(Date.now()-s)/864e5<3}async function qt(t,s,d){if(d&&typeof window.showSaveFilePicker=="function")try{let r=await window.showSaveFilePicker({suggestedName:s}),T=await r.createWritable();return await T.write(t),await T.close(),{ok:!0,picked:!0,name:r.name}}catch(r){return r&&r.name==="AbortError"?{ok:!1,aborted:!0}:{ok:!1,err:String(r.message||r)}}let y=URL.createObjectURL(t),u=document.createElement("a");return u.href=y,u.download=s,document.body.appendChild(u),u.click(),document.body.removeChild(u),setTimeout(()=>URL.revokeObjectURL(y),1e3),{ok:!0,picked:!1,name:s}}function bt(t,s){if(!s||!t)return t;let d=t.toLowerCase(),y=s.toLowerCase(),u=[],r=0;for(;r<t.length;){let T=d.indexOf(y,r);if(T<0){u.push(t.slice(r));break}T>r&&u.push(t.slice(r,T)),u.push((0,e.jsx)("mark",{className:"mc-hl",children:t.slice(T,T+y.length)},T)),r=T+y.length}return u}function Xt(t){if(!t)return"";let s=String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),d=[];return s=s.replace(/```([\w-]*)\n([\s\S]*?)```/g,function(y,u,r){return d.push("<pre><code>"+r+"</code></pre>"),"\0"+(d.length-1)+"\0"}),s=s.replace(/^(#{1,3})\s+(.+)$/gm,function(y,u,r){return"<h"+u.length+">"+r+"</h"+u.length+">"}),s=s.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),s=s.replace(/`([^`\n]+)`/g,"<code>$1</code>"),s=s.replace(/(^|[^*])\*([^*]+)\*/g,"$1<em>$2</em>"),s=s.replace(/\[([^\]]+)\]\(([^)]+)\)/g,function(y,u,r){return/^(https?:|\/)/.test(r)?'<a href="'+r+'" target="_blank" rel="noopener noreferrer">'+u+"</a>":u}),s=s.replace(/^(-)\s+(.+)$/gm,"\u2022 $2"),s=s.replace(/^\s*(>)\s*(.+)$/gm,"<blockquote>$2</blockquote>"),s=s.replace(/\n/g,"<br/>"),s=s.replace(/\u0000(\d+)\u0000/g,function(y,u){return d[u]}),s}function xt(t){if(!t)return"";let s=new Date(t);if(Number.isNaN(s.getTime()))return"";let d=new Date,y=s.toDateString()===d.toDateString(),u=T=>String(T).padStart(2,"0"),r=`${u(s.getHours())}:${u(s.getMinutes())}`;return y?r:`${s.getMonth()+1}-${s.getDate()} ${r}`}
|
|
128
173
|
|
|
129
174
|
return module.exports;
|
|
130
175
|
},
|
package/lib/vault.js
CHANGED
|
@@ -363,6 +363,25 @@ export async function generateDailyBrief(root) {
|
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
+
/** 用量趋势:返回最近 N 天每天新增卡片数 [{date, count}]。 */
|
|
367
|
+
export async function dailyCounts(root, days = 30) {
|
|
368
|
+
const cards = await listCards(root)
|
|
369
|
+
const now = Date.now()
|
|
370
|
+
const buckets = {}
|
|
371
|
+
for (let d = 0; d < days; d++) {
|
|
372
|
+
const date = new Date(now - d * 86400000)
|
|
373
|
+
const key = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
|
|
374
|
+
buckets[key] = 0
|
|
375
|
+
}
|
|
376
|
+
for (const c of cards) {
|
|
377
|
+
if (!c.created) continue
|
|
378
|
+
const d = new Date(c.created)
|
|
379
|
+
const key = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
|
|
380
|
+
if (key in buckets) buckets[key]++
|
|
381
|
+
}
|
|
382
|
+
return Object.entries(buckets).sort(([a], [b]) => a.localeCompare(b)).map(([date, count]) => ({ date, count }))
|
|
383
|
+
}
|
|
384
|
+
|
|
366
385
|
/** 导出全部卡片原始 Markdown。 */
|
|
367
386
|
export async function exportCards(root) {
|
|
368
387
|
const cards = await listCards(root)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-memory-eternal",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.26",
|
|
4
4
|
"description": "记忆核心(Memory Eternal):自研的 DeepSeek Harness 记忆插件,不移植任何既有记忆框架——对话结束后自动沉淀知识卡到本地 Markdown Vault(自研去重、自研 CJK 检索、可 git 管理),设置页提供图形化知识库(统计 / 搜索 / 知识图谱 + 侧边栏一键弹窗),Agent 通过 memory_recall 工具按需召回历史上下文。零人工干预。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|