toolnet-memory 0.3.7 → 0.3.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.
@@ -1,5 +1,5 @@
1
- import{spawnSync as _}from"node:child_process";import{chmodSync as T,cpSync as v,existsSync as p,lstatSync as N,mkdirSync as A,mkdtempSync as F,readFileSync as C,rmSync as L,symlinkSync as w}from"node:fs";import{tmpdir as M}from"node:os";import{basename as P,dirname as b,join as r,resolve as B}from"node:path";import{fileURLToPath as J}from"node:url";var U=["package.json","bin/toolnet-memory","bundle/init.js","bundle/auto-integrate.js","bundle/mcp.js","bundle/continuity-certify.js","bundle/recovery-certify.js","bundle/production-certify.js"],D=["init.js","auto-integrate.js","mcp.js","continuity-certify.js","recovery-certify.js","production-certify.js"];function K(){if(process.env.TOOLNET_PACKAGE_ROOT?.trim())return B(process.env.TOOLNET_PACKAGE_ROOT);let t=b(J(import.meta.url));return P(t)==="bundle"?b(t):P(t)==="production"&&P(b(t))==="src"?b(b(t)):process.cwd()}function h(t,e,n,o=process.env){let i=_(t,e,{cwd:n,env:o,encoding:"utf8",timeout:3e4,maxBuffer:10485760});return{status:i.status,stdout:i.stdout??"",stderr:i.stderr??""}}function f(t){let e=`${t.stdout}
2
- ${t.stderr}`.trim();return e?e.slice(-1200):`exit=${String(t.status)}`}function u(t,e,n,o){return{id:t,label:e,passed:n,detail:n?void 0:o}}function G(t){let e=t.map(s=>s.replace(/\\/gu,"/")),n=new Set(e),o=U.filter(s=>!n.has(s)),i=e.filter(s=>s==="src"||s.startsWith("src/"));return{passed:o.length===0&&i.length===0,missing:[...o],sourceFiles:i}}function V(t){let e=h("npm",["pack","--dry-run","--json"],t);if(e.status!==0)return{files:[],error:f(e)};try{let n=JSON.parse(e.stdout);return{files:(Array.isArray(n)?n[0]:n)?.files?.map(s=>s.path).filter(s=>typeof s=="string")??[]}}catch(n){return{files:[],error:n instanceof Error?`Cannot parse npm pack JSON: ${n.message}`:String(n)}}}function x(t){try{let e=JSON.parse(C(t,"utf8"));return typeof e.id=="string"&&e.id.trim()?e.id:void 0}catch{return}}function Q(t){let e=F(r(M(),"toolnet-x3-runtime-")),n=r(e,"package"),o=r(e,"project");try{A(r(n,"bin"),{recursive:!0}),A(o,{recursive:!0}),v(r(t,"bin","toolnet-memory"),r(n,"bin","toolnet-memory")),T(r(n,"bin","toolnet-memory"),493),v(r(t,"bundle"),r(n,"bundle"),{recursive:!0}),v(r(t,"package.json"),r(n,"package.json"));let i=r(t,"node_modules");if(!p(i))return{firstStatus:null,secondStatus:null,sourceAbsent:!0,detail:"node_modules is missing; run npm ci first."};w(i,r(n,"node_modules"),"dir");let s=r(n,"bin","toolnet-memory"),j=["init","--project",o,"--json","--no-integrate"],m={...process.env,TOOLNET_MEMORY_BIN:s,TOOLNET_PACKAGE_ROOT:n},l=h(s,j,o,m),a=r(o,".toolnet","project.json"),g=x(a),d=h(s,j,o,m),y=x(a);return{firstStatus:l.status,secondStatus:d.status,firstId:g,secondId:y,sourceAbsent:!p(r(n,"src")),detail:l.status===0&&d.status===0?void 0:["First init:",f(l),"","Second init:",f(d)].join(`
3
- `)}}finally{L(e,{recursive:!0,force:!0})}}function E(t,e){return h(process.execPath,[r(t,"bundle",e)],t,{...process.env,TOOLNET_PACKAGE_ROOT:t})}async function $(t=K()){let e=[],n=r(t,"package.json"),o=r(t,"bin","toolnet-memory"),i=r(t,"bundle"),s={};try{s=JSON.parse(C(n,"utf8"))}catch{}let j=s.bin&&typeof s.bin=="object"?s.bin["toolnet-memory"]:void 0,m=Array.isArray(s.files)?s.files:[];e.push(u("package-manifest","package manifest valid",s.name==="toolnet-memory"&&typeof s.version=="string"&&s.version.length>0&&j==="bin/toolnet-memory"&&m.includes("bundle")&&m.includes("bin/toolnet-memory"),"package.json does not expose the expected production package."));let l=V(t),a=G(l.files);e.push(u("npm-package","npm package contains production runtime only",!l.error&&a.passed,l.error??[a.missing.length>0?`Missing: ${a.missing.join(", ")}`:"",a.sourceFiles.length>0?`Unexpected src files: ${a.sourceFiles.join(", ")}`:""].filter(Boolean).join(`
4
- `)));let g=!1;if(p(o))try{g=(N(o).mode&73)!==0}catch{g=!1}let d=p(o)?h(o,["--version"],t):{status:null,stdout:"",stderr:"CLI file does not exist."};e.push(u("cli","CLI executable and version command works",g&&d.status===0&&typeof s.version=="string"&&`${d.stdout}${d.stderr}`.includes(s.version),f(d)));let y=D.filter(k=>!p(r(i,k)));e.push(u("bundle-complete","production bundle complete",y.length===0,y.length>0?`Missing bundles: ${y.join(", ")}`:void 0));let c=Q(t);e.push(u("init-outside-source","init works outside source tree",c.firstStatus===0&&c.sourceAbsent&&!!c.firstId,c.detail??`firstStatus=${String(c.firstStatus)}, sourceAbsent=${String(c.sourceAbsent)}, projectId=${String(c.firstId)}`)),e.push(u("stable-project-id","project identity remains stable after re-init",c.firstStatus===0&&c.secondStatus===0&&!!c.firstId&&c.firstId===c.secondId,`first=${String(c.firstId)}, second=${String(c.secondId)}`));let S="";try{S=C(o,"utf8")}catch{S=""}e.push(u("auto-integration","automatic integration production entry available",p(r(i,"auto-integrate.js"))&&S.includes("bundle/auto-integrate.js"),"auto-integrate production bundle or CLI routing is missing.")),e.push(u("mcp-bootstrap","MCP production bootstrap available",p(r(i,"mcp.js"))&&S.includes("run bundle/mcp.js src/mcp/bootstrap.ts"),"MCP production bundle or CLI routing is missing."));let R=E(t,"continuity-certify.js");e.push(u("x1","X1 cross-agent certification passes",R.status===0,f(R)));let O=E(t,"recovery-certify.js");e.push(u("x2","X2 recovery certification passes",O.status===0,f(O)));let I=e.filter(k=>k.passed).length;return{passed:I===e.length,total:e.length,passedCount:I,checks:e}}async function X(){let t=await $();console.log(""),console.log("\u25C7 ToolNet Production Readiness Certification"),console.log("\u2502");for(let e of t.checks)if(console.log(`\u2502 ${e.passed?"\u2713":"\u2717"} ${e.label}`),!e.passed&&e.detail)for(let n of e.detail.split(`
5
- `))console.log(`\u2502 \u21B3 ${n}`);if(console.log("\u2502"),t.passed){console.log(`\u25C6 PASS ${t.passedCount}/${t.total} production checks`);return}console.log(`\u25C6 FAIL ${t.passedCount}/${t.total} production checks`),process.exitCode=1}await X();
1
+ import{spawnSync as _}from"node:child_process";import{chmodSync as T,cpSync as v,existsSync as a,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 C,dirname as h,join as r,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/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","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 e=h(J(import.meta.url));return C(e)==="bundle"?h(e):C(e)==="production"&&C(h(e))==="src"?h(h(e)):process.cwd()}function k(e,t,n,o=process.env){let i=_(e,t,{cwd:n,env:o,encoding:"utf8",timeout:3e4,maxBuffer:10485760});return{status:i.status,stdout:i.stdout??"",stderr:i.stderr??""}}function f(e){let t=`${e.stdout}
2
+ ${e.stderr}`.trim();return t?t.slice(-1200):`exit=${String(e.status)}`}function u(e,t,n,o){return{id:e,label:t,passed:n,detail:n?void 0:o}}function G(e){let t=e.map(s=>s.replace(/\\/gu,"/")),n=new Set(t),o=K.filter(s=>!n.has(s)),i=t.filter(s=>s==="src"||s.startsWith("src/"));return{passed:o.length===0&&i.length===0,missing:[...o],sourceFiles:i}}function V(e){let t=k("npm",["pack","--dry-run","--json"],e);if(t.status!==0)return{files:[],error:f(t)};try{let n=JSON.parse(t.stdout);return{files:(Array.isArray(n)?n[0]:n)?.files?.map(s=>s.path).filter(s=>typeof s=="string")??[]}}catch(n){return{files:[],error:n instanceof Error?`Cannot parse npm pack JSON: ${n.message}`:String(n)}}}function x(e){try{let t=JSON.parse(P(e,"utf8"));return typeof t.id=="string"&&t.id.trim()?t.id:void 0}catch{return}}function Q(e){let t=N(r(M(),"toolnet-x3-runtime-")),n=r(t,"package"),o=r(t,"project");try{A(r(n,"bin"),{recursive:!0}),A(o,{recursive:!0}),v(r(e,"bin","toolnet-memory"),r(n,"bin","toolnet-memory")),T(r(n,"bin","toolnet-memory"),493),v(r(e,"bundle"),r(n,"bundle"),{recursive:!0}),v(r(e,"package.json"),r(n,"package.json"));let i=r(e,"node_modules");if(!a(i))return{firstStatus:null,secondStatus:null,sourceAbsent:!0,detail:"node_modules is missing; run npm ci first."};w(i,r(n,"node_modules"),"dir");let s=r(n,"bin","toolnet-memory"),j=["init","--project",o,"--json","--no-integrate"],g={...process.env,TOOLNET_MEMORY_BIN:s,TOOLNET_PACKAGE_ROOT:n},m=k(s,j,o,g),d=r(o,".toolnet","project.json"),b=x(d),l=k(s,j,o,g),y=x(d);return{firstStatus:m.status,secondStatus:l.status,firstId:b,secondId:y,sourceAbsent:!a(r(n,"src")),detail:m.status===0&&l.status===0?void 0:["First init:",f(m),"","Second init:",f(l)].join(`
3
+ `)}}finally{F(t,{recursive:!0,force:!0})}}function E(e,t){return k(process.execPath,[r(e,"bundle",t)],e,{...process.env,TOOLNET_PACKAGE_ROOT:e})}async function $(e=D()){let t=[],n=r(e,"package.json"),o=r(e,"bin","toolnet-memory"),i=r(e,"bundle"),s={};try{s=JSON.parse(P(n,"utf8"))}catch{}let j=s.bin&&typeof s.bin=="object"?s.bin["toolnet-memory"]:void 0,g=Array.isArray(s.files)?s.files:[];t.push(u("package-manifest","package manifest valid",s.name==="toolnet-memory"&&typeof s.version=="string"&&s.version.length>0&&j==="bin/toolnet-memory"&&g.includes("bundle")&&g.includes("bin/toolnet-memory"),"package.json does not expose the expected production package."));let m=V(e),d=G(m.files);t.push(u("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(a(o))try{b=(L(o).mode&73)!==0}catch{b=!1}let l=a(o)?k(o,["--version"],e):{status:null,stdout:"",stderr:"CLI file does not exist."};t.push(u("cli","CLI executable and version command works",b&&l.status===0&&typeof s.version=="string"&&`${l.stdout}${l.stderr}`.includes(s.version),f(l)));let y=U.filter(S=>!a(r(i,S)));t.push(u("bundle-complete","production bundle complete",y.length===0,y.length>0?`Missing bundles: ${y.join(", ")}`:void 0));let c=Q(e);t.push(u("init-outside-source","init works outside source tree",c.firstStatus===0&&c.sourceAbsent&&!!c.firstId,c.detail??`firstStatus=${String(c.firstStatus)}, sourceAbsent=${String(c.sourceAbsent)}, projectId=${String(c.firstId)}`)),t.push(u("stable-project-id","project identity remains stable after re-init",c.firstStatus===0&&c.secondStatus===0&&!!c.firstId&&c.firstId===c.secondId,`first=${String(c.firstId)}, second=${String(c.secondId)}`));let p="";try{p=P(o,"utf8")}catch{p=""}t.push(u("auto-integration","automatic integration production entry available",a(r(i,"auto-integrate.js"))&&p.includes("bundle/auto-integrate.js"),"auto-integrate production bundle or CLI routing is missing.")),t.push(u("kiro-integration","Kiro CLI production integration available",a(r(i,"kiro.js"))&&a(r(i,"kiro-hook.js"))&&p.includes("integrate:kiro)")&&p.includes("session:kiro-hook)")&&p.includes("bundle/kiro.js")&&p.includes("bundle/kiro-hook.js"),"Kiro production bundle or CLI routing is missing.")),t.push(u("mcp-bootstrap","MCP production bootstrap available",a(r(i,"mcp.js"))&&p.includes("run bundle/mcp.js src/mcp/bootstrap.ts"),"MCP production bundle or CLI routing is missing."));let R=E(e,"continuity-certify.js");t.push(u("x1","X1 cross-agent certification passes",R.status===0,f(R)));let I=E(e,"recovery-certify.js");t.push(u("x2","X2 recovery certification passes",I.status===0,f(I)));let O=t.filter(S=>S.passed).length;return{passed:O===t.length,total:t.length,passedCount:O,checks:t}}async function X(){let e=await $();console.log(""),console.log("\u25C7 ToolNet Production Readiness Certification"),console.log("\u2502");for(let t of e.checks)if(console.log(`\u2502 ${t.passed?"\u2713":"\u2717"} ${t.label}`),!t.passed&&t.detail)for(let n of t.detail.split(`
5
+ `))console.log(`\u2502 \u21B3 ${n}`);if(console.log("\u2502"),e.passed){console.log(`\u25C6 PASS ${e.passedCount}/${e.total} production checks`);return}console.log(`\u25C6 FAIL ${e.passedCount}/${e.total} production checks`),process.exitCode=1}await X();