toolnet-memory 0.3.9 → 0.3.11
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/README.md +8 -1
- package/bin/toolnet-memory +53 -0
- package/bundle/auto-integrate.js +113 -28
- package/bundle/continuity-certify.js +1 -1
- package/bundle/copilot-hook.js +208 -0
- package/bundle/copilot.js +29 -0
- package/bundle/cursor-hook.js +206 -0
- package/bundle/cursor.js +30 -0
- package/bundle/grok-hook.js +114 -0
- package/bundle/grok.js +32 -0
- package/bundle/help-cli.js +4 -4
- package/bundle/init.js +118 -33
- package/bundle/integration-status.js +55 -0
- package/bundle/kiro-hook.js +1 -1
- package/bundle/production-certify.js +5 -5
- package/bundle/setup.js +116 -31
- package/bundle/status-cli.js +4 -4
- package/bundle/update.js +5 -4
- package/package.json +26 -3
package/bundle/kiro-hook.js
CHANGED
|
@@ -68,7 +68,7 @@ Forbidden At Startup:
|
|
|
68
68
|
- Do not perform deep recovery merely because an agent starts.
|
|
69
69
|
- If the user asks to resume previous work and fast context is insufficient,
|
|
70
70
|
use memory_agent_ask before guessing.
|
|
71
|
-
`;return u+m+d+g+h}var wn=6500,ro=[/\bcontinue\b/i,/\bresume\b/i,/\bpick\s+up\b/i,/\bcarry\s+on\b/i,/\bfinish\s+(?:the\s+)?(?:previous|last|unfinished|remaining)\b/i,/\bwhere\s+(?:did\s+we|were\s+we)\b/i,/\bwhat\s+was\s+(?:the\s+)?(?:last|previous)\b/i
|
|
71
|
+
`;return u+m+d+g+h}var wn=6500,ro=[/\bcontinue\b/i,/\bresume\b/i,/\bpick\s+up\b/i,/\bcarry\s+on\b/i,/\bfinish\s+(?:the\s+)?(?:previous|last|unfinished|remaining)\b/i,/\bwhere\s+(?:did\s+we|were\s+we)\b/i,/\bwhat\s+was\s+(?:the\s+)?(?:last|previous)\b/i,/(?:^|[\s,.;:!?])tiếp\s+tục(?:$|[\s,.;:!?])/iu,/(?:^|[\s,.;:!?])làm\s+tiếp(?:$|[\s,.;:!?])/iu,/(?:^|[\s,.;:!?])làm\s+nốt(?:$|[\s,.;:!?])/iu,/(?:^|[\s,.;:!?])tiếp\s+phần(?:$|[\s,.;:!?])/iu,/(?:^|[\s,.;:!?])phần\s+đang\s+dở(?:$|[\s,.;:!?])/iu,/(?:^|[\s,.;:!?])đang\s+làm\s+(?:gì|đến\s+đâu)(?:$|[\s,.;:!?])/iu,/(?:^|[\s,.;:!?])dừng\s+(?:ở|tại)\s+đâu(?:$|[\s,.;:!?])/iu,/(?:^|[\s,.;:!?])task\s+(?:lúc\s+nãy|trước|đang\s+dở)(?:$|[\s,.;:!?])/iu],so=[".toolnet/sessions/",".toolnet\\sessions\\","/.toolnet/sessions","\\.toolnet\\sessions",".gemini/antigravity-cli/brain/",".gemini\\antigravity-cli\\brain\\","/transcript.jsonl","\\transcript.jsonl"];function St(t){return typeof t=="string"&&t.trim()?t.trim():void 0}function vn(t){return t.replace(/\\/g,"/").toLowerCase()}function bn(t){return t.length<=wn?t:`${t.slice(0,wn)}
|
|
72
72
|
|
|
73
73
|
[ToolNet Kiro context truncated]`}function kt(t,e,n=0){if(!(n>6||e.length>=200)){if(typeof t=="string"){e.push(t);return}if(Array.isArray(t)){for(let r of t)if(kt(r,e,n+1),e.length>=200)break;return}if(t&&typeof t=="object"){for(let r of Object.values(t))if(kt(r,e,n+1),e.length>=200)break}}}function oo(t){let e=vn(t);return e.includes(".toolnet/sessions/")||e.endsWith(".toolnet/sessions")||e.includes(".gemini/antigravity-cli/brain/")||e.includes("/transcript.jsonl")||e.endsWith("transcript.jsonl")?!0:so.some(n=>e.includes(vn(n)))}function io(t){let e=t.trim();return e?ro.some(n=>n.test(e)):!1}function wt(t){if(!t.trim())return"";try{let e=kn({projectPath:t});return e?.trim()?bn(e.trim()):""}catch{return""}}function xn(t){let e=St(t.prompt)??St(process.env.USER_PROMPT)??"";if(!e||!io(e))return"";let n=St(t.cwd)??"",r=wt(n),s=`
|
|
74
74
|
[TOOLNET RESUME REQUEST]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{spawnSync as _}from"node:child_process";import{chmodSync as T,cpSync as
|
|
2
|
-
${
|
|
3
|
-
`)}}finally{F(
|
|
4
|
-
`)));let b=!1;if(
|
|
5
|
-
`))console.log(`\u2502 \u21B3 ${
|
|
1
|
+
import{spawnSync as _}from"node:child_process";import{chmodSync as T,cpSync as C,existsSync as u,lstatSync as L,mkdirSync as A,mkdtempSync as N,readFileSync as P,rmSync as F,symlinkSync as w}from"node:fs";import{tmpdir as M}from"node:os";import{basename as v,dirname as j,join as t,resolve as B}from"node:path";import{fileURLToPath as J}from"node:url";var K=["package.json","bin/toolnet-memory","bundle/init.js","bundle/auto-integrate.js","bundle/kiro.js","bundle/kiro-hook.js","bundle/cursor.js","bundle/cursor-hook.js","bundle/copilot.js","bundle/copilot-hook.js","bundle/grok.js","bundle/grok-hook.js","bundle/mcp.js","bundle/continuity-certify.js","bundle/recovery-certify.js","bundle/production-certify.js"],U=["init.js","auto-integrate.js","kiro.js","kiro-hook.js","cursor.js","cursor-hook.js","copilot.js","copilot-hook.js","grok.js","grok-hook.js","mcp.js","continuity-certify.js","recovery-certify.js","production-certify.js"];function D(){if(process.env.TOOLNET_PACKAGE_ROOT?.trim())return B(process.env.TOOLNET_PACKAGE_ROOT);let n=j(J(import.meta.url));return v(n)==="bundle"?j(n):v(n)==="production"&&v(j(n))==="src"?j(j(n)):process.cwd()}function y(n,e,s,c=process.env){let r=_(n,e,{cwd:s,env:c,encoding:"utf8",timeout:3e4,maxBuffer:10485760});return{status:r.status,stdout:r.stdout??"",stderr:r.stderr??""}}function f(n){let e=`${n.stdout}
|
|
2
|
+
${n.stderr}`.trim();return e?e.slice(-1200):`exit=${String(n.status)}`}function a(n,e,s,c){return{id:n,label:e,passed:s,detail:s?void 0:c}}function G(n){let e=n.map(o=>o.replace(/\\/gu,"/")),s=new Set(e),c=K.filter(o=>!s.has(o)),r=e.filter(o=>o==="src"||o.startsWith("src/"));return{passed:c.length===0&&r.length===0,missing:[...c],sourceFiles:r}}function V(n){let e=y("npm",["pack","--dry-run","--json"],n);if(e.status!==0)return{files:[],error:f(e)};try{let s=JSON.parse(e.stdout);return{files:(Array.isArray(s)?s[0]:s)?.files?.map(o=>o.path).filter(o=>typeof o=="string")??[]}}catch(s){return{files:[],error:s instanceof Error?`Cannot parse npm pack JSON: ${s.message}`:String(s)}}}function x(n){try{let e=JSON.parse(P(n,"utf8"));return typeof e.id=="string"&&e.id.trim()?e.id:void 0}catch{return}}function Q(n){let e=N(t(M(),"toolnet-x3-runtime-")),s=t(e,"package"),c=t(e,"project");try{A(t(s,"bin"),{recursive:!0}),A(c,{recursive:!0}),C(t(n,"bin","toolnet-memory"),t(s,"bin","toolnet-memory")),T(t(s,"bin","toolnet-memory"),493),C(t(n,"bundle"),t(s,"bundle"),{recursive:!0}),C(t(n,"package.json"),t(s,"package.json"));let r=t(n,"node_modules");if(!u(r))return{firstStatus:null,secondStatus:null,sourceAbsent:!0,detail:"node_modules is missing; run npm ci first."};w(r,t(s,"node_modules"),"dir");let o=t(s,"bin","toolnet-memory"),h=["init","--project",c,"--json","--no-integrate"],g={...process.env,TOOLNET_MEMORY_BIN:o,TOOLNET_PACKAGE_ROOT:s},m=y(o,h,c,g),d=t(c,".toolnet","project.json"),b=x(d),p=y(o,h,c,g),k=x(d);return{firstStatus:m.status,secondStatus:p.status,firstId:b,secondId:k,sourceAbsent:!u(t(s,"src")),detail:m.status===0&&p.status===0?void 0:["First init:",f(m),"","Second init:",f(p)].join(`
|
|
3
|
+
`)}}finally{F(e,{recursive:!0,force:!0})}}function E(n,e){return y(process.execPath,[t(n,"bundle",e)],n,{...process.env,TOOLNET_PACKAGE_ROOT:n})}async function $(n=D()){let e=[],s=t(n,"package.json"),c=t(n,"bin","toolnet-memory"),r=t(n,"bundle"),o={};try{o=JSON.parse(P(s,"utf8"))}catch{}let h=o.bin&&typeof o.bin=="object"?o.bin["toolnet-memory"]:void 0,g=Array.isArray(o.files)?o.files:[];e.push(a("package-manifest","package manifest valid",o.name==="toolnet-memory"&&typeof o.version=="string"&&o.version.length>0&&h==="bin/toolnet-memory"&&g.includes("bundle")&&g.includes("bin/toolnet-memory"),"package.json does not expose the expected production package."));let m=V(n),d=G(m.files);e.push(a("npm-package","npm package contains production runtime only",!m.error&&d.passed,m.error??[d.missing.length>0?`Missing: ${d.missing.join(", ")}`:"",d.sourceFiles.length>0?`Unexpected src files: ${d.sourceFiles.join(", ")}`:""].filter(Boolean).join(`
|
|
4
|
+
`)));let b=!1;if(u(c))try{b=(L(c).mode&73)!==0}catch{b=!1}let p=u(c)?y(c,["--version"],n):{status:null,stdout:"",stderr:"CLI file does not exist."};e.push(a("cli","CLI executable and version command works",b&&p.status===0&&typeof o.version=="string"&&`${p.stdout}${p.stderr}`.includes(o.version),f(p)));let k=U.filter(S=>!u(t(r,S)));e.push(a("bundle-complete","production bundle complete",k.length===0,k.length>0?`Missing bundles: ${k.join(", ")}`:void 0));let l=Q(n);e.push(a("init-outside-source","init works outside source tree",l.firstStatus===0&&l.sourceAbsent&&!!l.firstId,l.detail??`firstStatus=${String(l.firstStatus)}, sourceAbsent=${String(l.sourceAbsent)}, projectId=${String(l.firstId)}`)),e.push(a("stable-project-id","project identity remains stable after re-init",l.firstStatus===0&&l.secondStatus===0&&!!l.firstId&&l.firstId===l.secondId,`first=${String(l.firstId)}, second=${String(l.secondId)}`));let i="";try{i=P(c,"utf8")}catch{i=""}e.push(a("auto-integration","automatic integration production entry available",u(t(r,"auto-integrate.js"))&&i.includes("bundle/auto-integrate.js"),"auto-integrate production bundle or CLI routing is missing.")),e.push(a("kiro-integration","Kiro CLI production integration available",u(t(r,"kiro.js"))&&u(t(r,"kiro-hook.js"))&&i.includes("integrate:kiro)")&&i.includes("session:kiro-hook)")&&i.includes("bundle/kiro.js")&&i.includes("bundle/kiro-hook.js"),"Kiro production bundle or CLI routing is missing.")),e.push(a("cursor-copilot-grok-integrations","Cursor, Copilot and Grok production integrations available",u(t(r,"cursor.js"))&&u(t(r,"cursor-hook.js"))&&u(t(r,"copilot.js"))&&u(t(r,"copilot-hook.js"))&&u(t(r,"grok.js"))&&u(t(r,"grok-hook.js"))&&i.includes("integrate:cursor)")&&i.includes("session:cursor-hook)")&&i.includes("integrate:copilot)")&&i.includes("session:copilot-hook)")&&i.includes("integrate:grok)")&&i.includes("session:grok-hook)")&&i.includes("bundle/cursor.js")&&i.includes("bundle/cursor-hook.js")&&i.includes("bundle/copilot.js")&&i.includes("bundle/copilot-hook.js")&&i.includes("bundle/grok.js")&&i.includes("bundle/grok-hook.js"),"Cursor/Copilot/Grok production bundle or CLI routing is missing.")),e.push(a("mcp-bootstrap","MCP production bootstrap available",u(t(r,"mcp.js"))&&i.includes("run bundle/mcp.js src/mcp/bootstrap.ts"),"MCP production bundle or CLI routing is missing."));let I=E(n,"continuity-certify.js");e.push(a("x1","X1 cross-agent certification passes",I.status===0,f(I)));let R=E(n,"recovery-certify.js");e.push(a("x2","X2 recovery certification passes",R.status===0,f(R)));let O=e.filter(S=>S.passed).length;return{passed:O===e.length,total:e.length,passedCount:O,checks:e}}async function X(){let n=await $();console.log(""),console.log("\u25C7 ToolNet Production Readiness Certification"),console.log("\u2502");for(let e of n.checks)if(console.log(`\u2502 ${e.passed?"\u2713":"\u2717"} ${e.label}`),!e.passed&&e.detail)for(let s of e.detail.split(`
|
|
5
|
+
`))console.log(`\u2502 \u21B3 ${s}`);if(console.log("\u2502"),n.passed){console.log(`\u25C6 PASS ${n.passedCount}/${n.total} production checks`);return}console.log(`\u25C6 FAIL ${n.passedCount}/${n.total} production checks`),process.exitCode=1}await X();
|