opencode-haimati 2.2.8 → 2.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -129,7 +129,7 @@ ${c}`),await s.info(`[haimati_list] \u5217\u51FA\u6210\u529F: ${t.category}${t.d
|
|
|
129
129
|
${c}`),await s.info("[haimati_list] \u5217\u51FA\u6210\u529F: \u5168\u90E8 (\u8BE6\u7EC6\u6A21\u5F0F)"),c}let a=`## \u6D77\u9A6C\u4F53\u7D22\u5F15
|
|
130
130
|
|
|
131
131
|
${qt(i)||"(\u7A7A)"}`;return await s.debug(`[haimati_list] \u51FA\u53C2:
|
|
132
|
-
${a}`),await s.info("[haimati_list] \u5217\u51FA\u6210\u529F: \u5168\u90E8"),a}catch(i){return await it(i,"haimati_list")}}})}}import{readFile as mn,rm as gn}from"node:fs/promises";import{basename as lt,dirname as rt,join as Kt}from"node:path";import{fileURLToPath as pn}from"node:url";var hn="opencode-haimati";function Se(t,n){if(!n)return;let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);yn(e.signal).then(i=>{i.updated&&(s.info(`[autoUpdate] \u53D1\u73B0\u65B0\u7248\u672C: ${i.current} \u2192 ${i.latest}`),setTimeout(()=>{t.client.tui.showToast({body:{title:"\u6D77\u9A6C\u4F53\u8BB0\u5FC6\u63D2\u4EF6\u66F4\u65B0",message:`${i.name} \u5DF2\u4ECE ${i.current} \u66F4\u65B0\u5230 ${i.latest}\uFF0C\u91CD\u542F OpenCode \u5B8C\u6210\u66F4\u65B0`,variant:"info"}})},5e3))}).catch(()=>{}).finally(()=>clearTimeout(r))}async function yn(t){let n=await wn(hn);if(!n)return{updated:!1};let e=await Bt(Kt(n,"package.json"));if(!e?.name||!e.version)return{updated:!1};let r=await Pn(e.name,t);if(!r||!_n(r,e.version))return{updated:!1};let i=await $n(n,e.name);if(!i)return{updated:!1};try{await gn(i,{recursive:!0,force:!0})}catch{return{updated:!1,error:"remove_failed",name:e.name,current:e.version,latest:r}}return{updated:!0,name:e.name,current:e.version,latest:r}}async function wn(t){let n=rt(pn(import.meta.url));for(;;){if((await Bt(Kt(n,"package.json")))?.name===t)return lt(n)==="dist"?rt(n):n;let r=rt(n);if(r===n)return;n=r}}async function $n(t,n){let e=rt(t),r=lt(e).startsWith("@")?rt(e):e;if(lt(r)!=="node_modules")return;let i=rt(r),o=await Bt(Kt(i,"package.json")),a=bn(i,n)??o?.dependencies?.[n];if(!(!a||!Mn(a)))return i}function bn(t,n){if(n.startsWith("@")){let[i,o]=n.split("/");if(!i||!o||lt(rt(t))!==i)return;let a=`${o}@`,c=lt(t);return c.startsWith(a)?c.slice(a.length):void 0}let e=`${n}@`,r=lt(t);return r.startsWith(e)?r.slice(e.length):void 0}function Mn(t){let n=t.trim();return n?!!(n==="latest"||n==="*"||/^[~^]/.test(n)||/^(?:>=|>|<=|<)/.test(n)||/\s+(?:\|\||-|[<>=])\s+/.test(n)):!1}async function Bt(t){try{let n=JSON.parse(await mn(t,"utf-8"));return n&&typeof n=="object"?n:void 0}catch{return}}async function Pn(t,n){try{let e=await fetch(`https://registry.npmjs.org/${encodeURIComponent(t)}/latest`,{signal:n});if(!e.ok)return;let r=await e.json();if(!r||typeof r!="object")return;let i=r.version;return typeof i=="string"?i:void 0}catch{return}}function _n(t,n){let e=xe(t),r=xe(n);if(!e||!r)return!1;for(let i=0;i<3;i++)if(e.parts[i]!==r.parts[i])return e.parts[i]>r.parts[i];if(!e.pre.length&&r.pre.length)return!0;if(e.pre.length&&!r.pre.length)return!1;for(let i=0;i<Math.max(e.pre.length,r.pre.length);i++){let o=e.pre[i],a=r.pre[i];if(o===void 0)return!1;if(a===void 0)return!0;if(o===a)continue;let c=/^\d+$/.test(o)?Number(o):void 0,l=/^\d+$/.test(a)?Number(a):void 0;return c!==void 0&&l!==void 0?c>l:c!==void 0?!1:l!==void 0?!0:o>a}return!1}function xe(t){let n=t.match(/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+.+)?$/);if(n)return{parts:[Number(n[1]),Number(n[2]),Number(n[3])],pre:n[4]?.split(".")??[]}}var xn="2026-06-10
|
|
132
|
+
${a}`),await s.info("[haimati_list] \u5217\u51FA\u6210\u529F: \u5168\u90E8"),a}catch(i){return await it(i,"haimati_list")}}})}}import{readFile as mn,rm as gn}from"node:fs/promises";import{basename as lt,dirname as rt,join as Kt}from"node:path";import{fileURLToPath as pn}from"node:url";var hn="opencode-haimati";function Se(t,n){if(!n)return;let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);yn(e.signal).then(i=>{i.updated&&(s.info(`[autoUpdate] \u53D1\u73B0\u65B0\u7248\u672C: ${i.current} \u2192 ${i.latest}`),setTimeout(()=>{t.client.tui.showToast({body:{title:"\u6D77\u9A6C\u4F53\u8BB0\u5FC6\u63D2\u4EF6\u66F4\u65B0",message:`${i.name} \u5DF2\u4ECE ${i.current} \u66F4\u65B0\u5230 ${i.latest}\uFF0C\u91CD\u542F OpenCode \u5B8C\u6210\u66F4\u65B0`,variant:"info"}})},5e3))}).catch(()=>{}).finally(()=>clearTimeout(r))}async function yn(t){let n=await wn(hn);if(!n)return{updated:!1};let e=await Bt(Kt(n,"package.json"));if(!e?.name||!e.version)return{updated:!1};let r=await Pn(e.name,t);if(!r||!_n(r,e.version))return{updated:!1};let i=await $n(n,e.name);if(!i)return{updated:!1};try{await gn(i,{recursive:!0,force:!0})}catch{return{updated:!1,error:"remove_failed",name:e.name,current:e.version,latest:r}}return{updated:!0,name:e.name,current:e.version,latest:r}}async function wn(t){let n=rt(pn(import.meta.url));for(;;){if((await Bt(Kt(n,"package.json")))?.name===t)return lt(n)==="dist"?rt(n):n;let r=rt(n);if(r===n)return;n=r}}async function $n(t,n){let e=rt(t),r=lt(e).startsWith("@")?rt(e):e;if(lt(r)!=="node_modules")return;let i=rt(r),o=await Bt(Kt(i,"package.json")),a=bn(i,n)??o?.dependencies?.[n];if(!(!a||!Mn(a)))return i}function bn(t,n){if(n.startsWith("@")){let[i,o]=n.split("/");if(!i||!o||lt(rt(t))!==i)return;let a=`${o}@`,c=lt(t);return c.startsWith(a)?c.slice(a.length):void 0}let e=`${n}@`,r=lt(t);return r.startsWith(e)?r.slice(e.length):void 0}function Mn(t){let n=t.trim();return n?!!(n==="latest"||n==="*"||/^[~^]/.test(n)||/^(?:>=|>|<=|<)/.test(n)||/\s+(?:\|\||-|[<>=])\s+/.test(n)):!1}async function Bt(t){try{let n=JSON.parse(await mn(t,"utf-8"));return n&&typeof n=="object"?n:void 0}catch{return}}async function Pn(t,n){try{let e=await fetch(`https://registry.npmjs.org/${encodeURIComponent(t)}/latest`,{signal:n});if(!e.ok)return;let r=await e.json();if(!r||typeof r!="object")return;let i=r.version;return typeof i=="string"?i:void 0}catch{return}}function _n(t,n){let e=xe(t),r=xe(n);if(!e||!r)return!1;for(let i=0;i<3;i++)if(e.parts[i]!==r.parts[i])return e.parts[i]>r.parts[i];if(!e.pre.length&&r.pre.length)return!0;if(e.pre.length&&!r.pre.length)return!1;for(let i=0;i<Math.max(e.pre.length,r.pre.length);i++){let o=e.pre[i],a=r.pre[i];if(o===void 0)return!1;if(a===void 0)return!0;if(o===a)continue;let c=/^\d+$/.test(o)?Number(o):void 0,l=/^\d+$/.test(a)?Number(a):void 0;return c!==void 0&&l!==void 0?c>l:c!==void 0?!1:l!==void 0?!0:o>a}return!1}function xe(t){let n=t.match(/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+.+)?$/);if(n)return{parts:[Number(n[1]),Number(n[2]),Number(n[3])],pre:n[4]?.split(".")??[]}}var xn="2026-06-10 15:57:23",Ee=!1;function Sn(t){return t.type==="text"&&t.ignored!==!0}var Ki=async t=>{await ee(),Ee||(Ee=!0,await s.debug(`[HaimatiPlugin] \u4EE3\u7801\u6700\u540E\u4FEE\u6539\u65E5\u671F: ${xn}`));let n=Pt(t.directory),e=_e(),r=new Set,i=new Set,o=new Set,a=new Map,c=1e4,l=new Set,m=new Map,d=50,f=500,u=1e4,g=100,M=1e3;function $(p,h){for(;p.size>=h;){let x=p.keys().next().value;if(x===void 0)break;p.delete(x)}}function w(p){let h=m.get(p);return h||($(m,d),h=new Map,m.set(p,h)),h}function P(p,h,x){$(p,f),p.set(h,x)}return Se(t,n.autoUpdate!==!1),be(t.directory).then(p=>{p>0&&s.info(`[HaimatiPlugin] \u542F\u52A8\u65F6\u6E05\u7406\u4E86 ${p} \u4E2A\u4E0D\u5B58\u5728\u7684\u6587\u4EF6\u5173\u8054`)}).catch(p=>{s.warn(`[HaimatiPlugin] \u6E05\u7406\u8FC7\u671F\u6587\u4EF6\u5173\u8054\u5931\u8D25: ${p instanceof Error?p.message:String(p)}`)}),{tool:e,event:async({event:p})=>{if(p.type==="message.updated"&&p.properties.info.role==="assistant"){let h=p.properties.info;if(h.finish==="stop"&&!r.has(h.id)){if($(r,u),r.add(h.id),o.has(h.id)){o.delete(h.id);return}if(i.has(h.sessionID))return;let x=a.get(h.sessionID);if(x&&Date.now()<x)return;n.autoWrite===!0&&($(a,d),i.add(h.sessionID),s.info(`[autoWrite] \u5F00\u59CB\u5F02\u6B65\u8BB0\u5FC6\u5199\u5165 session=${h.sessionID}`),t.client.session.prompt({path:{id:h.sessionID},body:{parts:[{type:"text",text:`\u56DE\u987E\u5F53\u524D\u4F1A\u8BDD\uFF0C\u5BF9\u6D77\u9A6C\u4F53\u8BB0\u5FC6\u8FDB\u884C\u7EF4\u62A4\u3002
|
|
133
133
|
|
|
134
134
|
\u4F60\u7684\u804C\u8D23\uFF1A
|
|
135
135
|
1. \u5199\u5165\u65B0\u77E5\u8BC6 - \u67B6\u6784\u51B3\u7B56\u3001API\u7528\u6CD5\u3001Bug\u6839\u56E0\u4E0E\u4FEE\u590D\u3001\u914D\u7F6E\u65B9\u6CD5\u3001\u5F00\u53D1\u89C4\u8303\u7B49\u503C\u5F97\u957F\u671F\u8BB0\u5F55\u7684\u77E5\u8BC6
|
|
@@ -166,7 +166,7 @@ ${B}`),E.push(`#${v.id.padStart(3,"0")}`),P(L,A,K.updatedAt)}k.length>0&&(C+=`
|
|
|
166
166
|
|
|
167
167
|
${k.join(`
|
|
168
168
|
|
|
169
|
-
`)}`,t.client.session.prompt({path:{id:h.message.sessionID},body:{parts:[{type:"text",text:`\u6D77\u9A6C\u4F53: \u5DF2\u6CE8\u5165\u6839\u76EE\u5F55\u8BB0\u5FC6 ${E.join(", ")}`,ignored:!0}]}}).catch(A=>{let v=A instanceof Error?A.message:String(A);s.error(`[chat.message] \u53D1\u9001\u901A\u77E5\u5931\u8D25: ${v}`)}))}}catch(y){await s.warn(`[chat.message] \u8BFB\u53D6\u6839\u76EE\u5F55\u5173\u8054\u8BB0\u5FC6\u5931\u8D25: ${y instanceof Error?y.message:String(y)}`)}C+=`
|
|
169
|
+
`)}`,t.client.session.prompt({path:{id:h.message.sessionID},body:{noReply:!0,parts:[{type:"text",text:`\u6D77\u9A6C\u4F53: \u5DF2\u6CE8\u5165\u6839\u76EE\u5F55\u8BB0\u5FC6 ${E.join(", ")}`,ignored:!0}]}}).catch(A=>{let v=A instanceof Error?A.message:String(A);s.error(`[chat.message] \u53D1\u9001\u901A\u77E5\u5931\u8D25: ${v}`)}))}}catch(y){await s.warn(`[chat.message] \u8BFB\u53D6\u6839\u76EE\u5F55\u5173\u8054\u8BB0\u5FC6\u5931\u8D25: ${y instanceof Error?y.message:String(y)}`)}C+=`
|
|
170
170
|
</system-reminder>`,h.parts.unshift({id:`prt_auto_reminder_${Date.now()}`,sessionID:x[0].sessionID??h.message.sessionID,messageID:x[0].messageID??h.message.id,type:"text",text:C,synthetic:!0}),await s.debug("[chat.message] \u9996\u6761\u6D88\u606F\u6CE8\u5165\u5B8C\u6210")}},"tool.execute.after":async(p,h)=>{if(p.tool==="haimati_read"){try{let y=p.args?.query;if(typeof y!="string")return;let S=kt(y);if(!S)return;let D=t.directory,k=p.sessionID;if(typeof k=="string"){let E=w(k);for(let L of S){let A=await I(D,L);A&&P(E,L,A.updatedAt)}}await s.debug(`[tool.execute.after] \u8BB0\u5F55 haimati_read \u7248\u672C: ${S.join(",")}`)}catch(y){await s.error(`[tool.execute.after] haimati_read \u8BB0\u5F55\u7248\u672C\u5931\u8D25: ${y instanceof Error?y.message:String(y)}`)}return}if(p.tool==="haimati_write"){try{let y=p.args?.category,S=p.args?.title;if(typeof y!="string"||typeof S!="string")return;let D=t.directory;if(!D)return;let k=await j(D),E=St(k,y,S);if(!E)return;let L=p.sessionID;if(typeof L=="string"){let A=w(L),v=await I(D,E.id);v&&(P(A,E.id,v.updatedAt),await s.debug(`[tool.execute.after] \u8BB0\u5F55 haimati_write \u8BB0\u5FC6\u7248\u672C: #${E.id}`))}}catch(y){await s.error(`[tool.execute.after] haimati_write \u8BB0\u5F55\u7248\u672C\u5931\u8D25: ${y instanceof Error?y.message:String(y)}`)}return}if(p.tool==="haimati_edit"){try{let y=p.args?.query;if(typeof y!="string")return;let S=kt(y);if(!S)return;let D=p.sessionID;if(typeof D=="string"){let k=w(D);for(let E of S){let L=await I(t.directory,E);L&&P(k,E,L.updatedAt)}}await s.debug(`[tool.execute.after] \u8BB0\u5F55 haimati_edit \u7248\u672C: ${S.join(",")}`)}catch(y){await s.error(`[tool.execute.after] haimati_edit \u8BB0\u5F55\u7248\u672C\u5931\u8D25: ${y instanceof Error?y.message:String(y)}`)}return}if(p.tool!=="read"||n.autoMemory===!1)return;let x=p.args?.filePath;if(!x||typeof x!="string")return;let C=p.sessionID;if(typeof C=="string")try{let y=t.directory,S=ct(y,x),D=w(C),k=[],E=[],L=[],A=[],v="",K=await q(y);if(Object.keys(K).length>0){let W=zt(K,S,y);if(W.length>0){let F=await j(y);for(let N of W){let T=J(F,N);if(!T)continue;let O=await I(y,T.id);if(!O)continue;let V=et(K,T.id);if(V.length>0&&(O.systemMeta={...O.systemMeta,file_paths:V.join(", ")}),D.get(N)===O.updatedAt)continue;E.push(N);let ht=Q(T,O);k.push(`===== #${T.id.padStart(3,"0")} =====
|
|
171
171
|
${ht}`),P(D,N,O.updatedAt)}}}let ft=Ie.isAbsolute(x)?x.replace(/\\/g,"/"):Ie.resolve(y,x).replace(/\\/g,"/"),B=await ye(ft,y);if(B){v=B.replace(/\\/g,"/").replace(/\/+$/,"");let W=await q(B);if(Object.keys(W).length>0){let F=zt(W,ft,B);if(F.length>0){let N=await j(B);for(let T of F){let O=J(N,T);if(!O)continue;let V=await I(B,O.id);if(!V)continue;let ht=et(W,O.id);ht.length>0&&(V.systemMeta={...V.systemMeta,file_paths:ht.join(", ")});let Vt=`${B}::${T}`;if(D.get(Vt)===V.updatedAt)continue;A.push(T);let ke=Q(O,V);L.push(`===== [${v}] #${O.id.padStart(3,"0")} =====
|
|
172
172
|
${ke}`),P(D,Vt,V.updatedAt)}}}}let H=[],De=[];if(k.length>0&&L.length>0?(H.push("--- \u5F53\u524D\u9879\u76EE\u8BB0\u5FC6 ---"),H.push(...k),H.push(`--- \u5916\u90E8\u9879\u76EE\u8BB0\u5FC6\uFF08${v}\uFF09 ---`),H.push(...L)):k.length>0?H.push(...k):L.length>0&&(H.push(`--- \u5916\u90E8\u9879\u76EE\u8BB0\u5FC6\uFF08${v}\uFF09 ---`),H.push(...L)),De.push(...E,...A),H.length>0){h.output+=`
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-haimati",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.9",
|
|
4
4
|
"description": "OpenCode plugin for a file-based memory system inspired by the hippocampus, providing long-term memory storage and retrieval across sessions.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-haimati",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.9",
|
|
4
4
|
"description": "OpenCode plugin for a file-based memory system inspired by the hippocampus, providing long-term memory storage and retrieval across sessions.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|