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.
- package/README.md +443 -368
- package/bin/toolnet-memory +29 -0
- package/bundle/auto-integrate.js +23 -21
- package/bundle/continuity-certify.js +1 -1
- package/bundle/help-cli.js +2 -2
- package/bundle/init.js +28 -26
- package/bundle/kiro-hook.js +199 -0
- package/bundle/kiro.js +3 -0
- package/bundle/mcp.js +18 -18
- package/bundle/production-certify.js +5 -5
- package/bundle/setup.js +29 -27
- package/bundle/status-cli.js +4 -4
- package/package.json +9 -3
package/bin/toolnet-memory
CHANGED
|
@@ -322,6 +322,20 @@ case "$COMMAND" in
|
|
|
322
322
|
exit 0
|
|
323
323
|
;;
|
|
324
324
|
|
|
325
|
+
session:kiro-hook)
|
|
326
|
+
shift
|
|
327
|
+
|
|
328
|
+
if [ -f "$ROOT/bundle/kiro-hook.js" ]; then
|
|
329
|
+
exec node "$ROOT/bundle/kiro-hook.js" "$@"
|
|
330
|
+
fi
|
|
331
|
+
|
|
332
|
+
if [ -x "${TSX:-}" ] && [ -f "$ROOT/src/session/kiro/hook.ts" ]; then
|
|
333
|
+
exec "$TSX" "$ROOT/src/session/kiro/hook.ts" "$@"
|
|
334
|
+
fi
|
|
335
|
+
|
|
336
|
+
exit 0
|
|
337
|
+
;;
|
|
338
|
+
|
|
325
339
|
integrate:claude)
|
|
326
340
|
shift
|
|
327
341
|
|
|
@@ -337,6 +351,21 @@ case "$COMMAND" in
|
|
|
337
351
|
exit 1
|
|
338
352
|
;;
|
|
339
353
|
|
|
354
|
+
integrate:kiro)
|
|
355
|
+
shift
|
|
356
|
+
|
|
357
|
+
if [ -f "$ROOT/bundle/kiro.js" ]; then
|
|
358
|
+
exec node "$ROOT/bundle/kiro.js" install "$@"
|
|
359
|
+
fi
|
|
360
|
+
|
|
361
|
+
if [ -x "${TSX:-}" ] && [ -f "$ROOT/src/session/kiro/cli.ts" ]; then
|
|
362
|
+
exec "$TSX" "$ROOT/src/session/kiro/cli.ts" install "$@"
|
|
363
|
+
fi
|
|
364
|
+
|
|
365
|
+
echo "Kiro CLI integration installer not found."
|
|
366
|
+
exit 1
|
|
367
|
+
;;
|
|
368
|
+
|
|
340
369
|
session:codex-notify)
|
|
341
370
|
shift
|
|
342
371
|
|
package/bundle/auto-integrate.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{existsSync as
|
|
2
|
-
`,{encoding:"utf8",mode:384}),
|
|
3
|
-
`,{encoding:"utf8",mode:384}),
|
|
1
|
+
import{existsSync as Ve}from"node:fs";import{homedir as ze}from"node:os";import{join as Qe}from"node:path";import{spawnSync as Ze}from"node:child_process";import{homedir as Ye}from"node:os";import{join as p}from"node:path";function H(e={}){return p(e.home??Ye(),".gemini")}function j(e={}){return p(H(e),"config")}function w(e={}){return p(j(e),"mcp_config.json")}function I(e={}){return p(j(e),"hooks.json")}function L(e={}){return p(H(e),"antigravity-cli")}function K(e="toolnet-memory",n={}){return p(L(n),"plugins",e)}function B(e={}){return[L(e),j(e)]}import{homedir as qe}from"node:os";import{join as h}from"node:path";function m(e={}){let n=e.xdgConfigHome??process.env.XDG_CONFIG_HOME?.trim();return n?h(n,"opencode"):h(e.home??qe(),".config","opencode")}function U(e={}){return h(m(e),"opencode.json")}function Y(e={}){return h(m(e),"plugins")}function q(e={}){return h(m(e),"AGENTS.md")}import{homedir as W}from"node:os";import{join as T}from"node:path";function A(e={}){return T(e.home??W(),".claude")}function G(e={}){return T(A(e),"settings.json")}function X(e={}){return T(e.home??W(),".claude.json")}import{homedir as We}from"node:os";import{join as O}from"node:path";function M(e={}){return e.kiroHome??process.env.KIRO_HOME??O(e.home??We(),".kiro")}function Ge(e={}){return O(M(e),"settings")}function V(e={}){return O(Ge(e),"mcp.json")}function Xe(e={}){return O(M(e),"hooks")}function z(e={}){return O(Xe(e),"toolnet-memory.json")}function Q(e={}){return[M(e)]}function et(e){return Ze("sh",["-lc",`command -v ${JSON.stringify(e)} >/dev/null 2>&1`],{stdio:"ignore"}).status===0}function v(e){let n=e.commandExists(e.command),t=e.configPaths.filter(i=>Ve(i)),o=t.length>0,s=[];n&&s.push(`command:${e.command}`);for(let i of t)s.push(`config:${i}`);return{agent:e.agent,detected:n||o,commandDetected:n,configDetected:o,evidence:s}}function Z(e={}){let n=e.home??ze(),t=e.commandExists??et,o=e.codexHome??process.env.CODEX_HOME??Qe(n,".codex");return[v({agent:"agy",command:"agy",commandExists:t,configPaths:B({home:n})}),v({agent:"opencode",command:"opencode",commandExists:t,configPaths:[m({home:n,xdgConfigHome:e.xdgConfigHome})]}),v({agent:"claude",command:"claude",commandExists:t,configPaths:[A({home:n})]}),v({agent:"kiro",command:"kiro-cli",commandExists:t,configPaths:Q({home:n,kiroHome:e.kiroHome})}),v({agent:"codex",command:"codex",commandExists:t,configPaths:[o]})]}import{existsSync as E,mkdirSync as ie,readFileSync as se,renameSync as yt,writeFileSync as ht}from"node:fs";import{dirname as Ot,join as N}from"node:path";import{existsSync as tt,mkdirSync as nt,readFileSync as ot,renameSync as rt,rmSync as it,writeFileSync as st}from"node:fs";import{dirname as ct}from"node:path";function at(e){return`'${e.replace(/'/g,"'\\''")}'`}function ee(e={}){let n=e.hooksFile??I();nt(ct(n),{recursive:!0,mode:448});let t={};if(tt(n)){let r;try{r=JSON.parse(ot(n,"utf8"))}catch(c){throw new Error(`Invalid existing Agy hooks.json: ${c instanceof Error?c.message:String(c)}`)}if(typeof r!="object"||r===null||Array.isArray(r))throw new Error("Invalid existing Agy hooks.json: root must be a JSON object.");t=r}let o=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",s=`${at(o)} session:agy-hook`;t["toolnet-memory"]={enabled:!0,PreToolUse:[{matcher:"view_file|list_dir|find_by_name|grep_search|run_command",hooks:[{type:"command",command:`${s} pre-tool`,timeout:5}]}],PreInvocation:[{type:"command",command:`${s} pre`,timeout:15}],PostInvocation:[{type:"command",command:`${s} post`,timeout:15}],Stop:[{type:"command",command:`${s} stop`,timeout:30}]};let i=`${n}.tmp-${process.pid}-${Date.now()}`;try{st(i,JSON.stringify(t,null,2)+`
|
|
2
|
+
`,{encoding:"utf8",mode:384}),rt(i,n)}finally{it(i,{force:!0})}return n}import{existsSync as lt,mkdirSync as ut,readFileSync as dt,renameSync as mt,writeFileSync as gt}from"node:fs";import{dirname as pt}from"node:path";function x(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ft(e,n){ut(pt(e),{recursive:!0,mode:448});let t=`${e}.tmp-${process.pid}-${Date.now()}`;gt(t,`${JSON.stringify(n,null,2)}
|
|
3
|
+
`,{encoding:"utf8",mode:384}),mt(t,e)}function te(e){if(!lt(e))return{};let n=dt(e,"utf8").trim();if(!n)return{};let t;try{t=JSON.parse(n)}catch(o){throw new Error(`Invalid existing Agy MCP config: ${o instanceof Error?o.message:String(o)}`)}if(!x(t))throw new Error("Invalid existing Agy MCP config: root must be a JSON object.");return t}function ne(e,n){return x(e)?e.command===n&&Array.isArray(e.args)&&e.args.length===1&&e.args[0]==="mcp":!1}function oe(e={}){let n=e.configFile??w(),t=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",o=e.serverName??"toolnet-memory",s=te(n),i=s.mcpServers;if(i!==void 0&&!x(i))throw new Error("Invalid existing Agy MCP config: mcpServers must be an object.");let r=x(i)?{...i}:{},c=r[o];if(ne(c,t))return{installed:!0,changed:!1,configFile:n,serverName:o,command:t,args:["mcp"]};r[o]={command:t,args:["mcp"]};let l={...s,mcpServers:r};ft(n,l);let a=te(n).mcpServers;if(!x(a)||!ne(a[o],t))throw new Error("Agy MCP configuration was written but verification failed.");return{installed:!0,changed:!0,configFile:n,serverName:o,command:t,args:["mcp"]}}var vt=`# ToolNet Memory Continuity
|
|
4
4
|
|
|
5
5
|
ToolNet Memory is the authoritative continuity layer for previous project work.
|
|
6
6
|
|
|
@@ -41,15 +41,15 @@ Use \`mode="ai"\` only when continuity is ambiguous or requires synthesis.
|
|
|
41
41
|
Current repository evidence overrides stale memory after ToolNet has restored the working context.
|
|
42
42
|
|
|
43
43
|
Do not ask the user to repeat context already available through ToolNet Memory.
|
|
44
|
-
`;function
|
|
45
|
-
`),!0}function
|
|
46
|
-
`),!0}function
|
|
47
|
-
`),
|
|
48
|
-
`);let l=e.legacyMcpFile??
|
|
44
|
+
`;function ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function F(e,n){ie(Ot(e),{recursive:!0});let t=`${e}.tmp-${process.pid}-${Date.now()}`;ht(t,n,{encoding:"utf8",mode:384}),yt(t,e)}function re(e,n){E(e)&&se(e,"utf8")===n||F(e,n)}function ae(e){if(!E(e))return{};let n=se(e,"utf8").trim();if(!n)return{};let t;try{t=JSON.parse(n)}catch(o){throw new Error(`Invalid legacy Antigravity config ${e}: ${o instanceof Error?o.message:String(o)}`)}if(!ce(t))throw new Error(`Invalid legacy Antigravity config ${e}: root must be object`);return t}function xt(e,n){if(!E(e))return!1;let t=ae(e);if(!ce(t.mcpServers)||!Object.prototype.hasOwnProperty.call(t.mcpServers,n))return!1;let o={...t.mcpServers};return delete o[n],F(e,`${JSON.stringify({...t,mcpServers:o},null,2)}
|
|
45
|
+
`),!0}function bt(e){if(!E(e))return!1;let n=ae(e);if(!Object.prototype.hasOwnProperty.call(n,"toolnet-memory"))return!1;let t={...n};return delete t["toolnet-memory"],F(e,`${JSON.stringify(t,null,2)}
|
|
46
|
+
`),!0}function le(e={}){let n=e.pluginName??"toolnet-memory",t=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",o=e.pluginRoot??K(n),s=N(o,"plugin.json"),i=N(o,"mcp_config.json"),r=N(o,"hooks.json"),c=N(o,"rules","toolnet-memory-continuity.md");ie(o,{recursive:!0,mode:448}),re(s,`${JSON.stringify({$schema:"https://antigravity.google/schemas/v1/plugin.json",name:n,description:"Persistent project continuity and memory for Antigravity coding sessions."},null,2)}
|
|
47
|
+
`),oe({configFile:i,binary:t,serverName:"toolnet-memory"}),ee({hooksFile:r,binary:t}),re(c,`${vt.trim()}
|
|
48
|
+
`);let l=e.legacyMcpFile??w(),u=e.legacyHooksFile??I(),a=[];return l!==i&&xt(l,"toolnet-memory")&&a.push(l),u!==r&&bt(u)&&a.push(u),{installed:!0,pluginRoot:o,files:[s,i,r,c],migratedLegacy:a}}import{existsSync as kt,mkdirSync as me,readFileSync as St,writeFileSync as ge}from"node:fs";import{join as wt}from"node:path";var Ct="memory_agent_ask";function ue(){return`
|
|
49
49
|
[TOOLNET MEMORY AGENT]
|
|
50
50
|
|
|
51
51
|
Tool available:
|
|
52
|
-
- ${
|
|
52
|
+
- ${Ct}
|
|
53
53
|
|
|
54
54
|
Use it automatically BEFORE guessing when:
|
|
55
55
|
|
|
@@ -96,7 +96,7 @@ Rules:
|
|
|
96
96
|
- After receiving the ToolNet answer, continue the task
|
|
97
97
|
instead of asking the user to repeat known context.
|
|
98
98
|
- If ToolNet says information is not recorded, say so.
|
|
99
|
-
`.trim()}var
|
|
99
|
+
`.trim()}var de="<!-- TOOLNET_MEMORY_BOOTSTRAP_START -->",R="<!-- TOOLNET_MEMORY_BOOTSTRAP_END -->";function It(){let e=q();me(m(),{recursive:!0});let n=`${de}
|
|
100
100
|
## ToolNet Memory
|
|
101
101
|
|
|
102
102
|
ToolNet Memory is available for projects that already contain a valid \`.toolnet/project.json\`.
|
|
@@ -112,12 +112,12 @@ Rules:
|
|
|
112
112
|
7. Current repository evidence has priority over stale memory when they conflict.
|
|
113
113
|
|
|
114
114
|
|
|
115
|
-
${
|
|
115
|
+
${ue()}
|
|
116
116
|
|
|
117
|
-
${
|
|
117
|
+
${R}`,t=kt(e)?St(e,"utf8"):"",o=t.indexOf(de),s=t.indexOf(R);return o>=0&&s>=o?t=t.slice(0,o)+n+t.slice(s+R.length):(t=t.trimEnd(),t&&(t+=`
|
|
118
118
|
|
|
119
|
-
`),t+=n),
|
|
120
|
-
`,{encoding:"utf8",mode:384}),e}function
|
|
119
|
+
`),t+=n),ge(e,t.trimEnd()+`
|
|
120
|
+
`,{encoding:"utf8",mode:384}),e}function pe(e={}){let n=e.directory??Y();me(n,{recursive:!0}),It();let t=wt(n,"toolnet-memory.js"),o=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",s=`
|
|
121
121
|
// Generated by ToolNet Memory.
|
|
122
122
|
// OpenCode integration:
|
|
123
123
|
// - project gated
|
|
@@ -1051,14 +1051,16 @@ export const ToolNetMemoryPlugin =
|
|
|
1051
1051
|
},
|
|
1052
1052
|
}
|
|
1053
1053
|
}
|
|
1054
|
-
`;return
|
|
1055
|
-
`,{encoding:"utf8",mode:384}),
|
|
1054
|
+
`;return ge(t,s.trimStart(),{encoding:"utf8",mode:384}),t}import{existsSync as he,mkdirSync as Nt,readFileSync as Et,renameSync as jt,writeFileSync as Tt}from"node:fs";import{dirname as Oe,join as At}from"node:path";function f(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mt(e,n){Nt(Oe(e),{recursive:!0});let t=`${e}.tmp-${process.pid}-${Date.now()}`;Tt(t,`${JSON.stringify(n,null,2)}
|
|
1055
|
+
`,{encoding:"utf8",mode:384}),jt(t,e)}function fe(e){if(!he(e))return{};let n=Et(e,"utf8").trim();if(!n)return{};let t;try{t=JSON.parse(n)}catch(o){throw new Error(`Invalid existing OpenCode opencode.json: ${o instanceof Error?o.message:String(o)}`)}if(!f(t))throw new Error("Invalid existing OpenCode opencode.json: root must be a JSON object.");return t}function ye(e,n){if(!f(e))return!1;let t=e.command;return e.type==="local"&&e.enabled!==!1&&Array.isArray(t)&&t.length===2&&t[0]===n&&t[1]==="mcp"}function Ft(e,n){let t=e.mcpServers;if(!f(t)||!Object.prototype.hasOwnProperty.call(t,n))return{root:e,changed:!1};let o={...t};return delete o[n],{root:{...e,mcpServers:o},changed:!0}}function ve(e={}){let n=e.configFile??U(),t=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",o=e.serverName??"toolnet-memory",s=At(Oe(n),"opencode.jsonc"),i=he(s)?s:void 0,r=fe(n),c=Ft(r,o),l=c.root,u=l.mcp;if(u!==void 0&&!f(u))throw new Error("Invalid existing OpenCode config: mcp must be an object.");let a=f(u)?{...u}:{},g=a[o];if(ye(g,t)&&!c.changed)return{installed:!0,changed:!1,configFile:n,serverName:o,command:[t,"mcp"],preservedJsonc:i};a[o]={type:"local",command:[t,"mcp"],enabled:!0};let d={...l,mcp:a};Mt(n,d);let D=fe(n);if(!f(D.mcp)||!ye(D.mcp[o],t))throw new Error("OpenCode MCP configuration was written but verification failed.");return{installed:!0,changed:!0,configFile:n,serverName:o,command:[t,"mcp"],preservedJsonc:i}}import{existsSync as Rt,mkdirSync as xe,readFileSync as Pt,writeFileSync as be}from"node:fs";import{homedir as Ce}from"node:os";import{dirname as ke,join as P}from"node:path";function _t(e){let n=[],t=/"((?:\\.|[^"\\])*)"|'([^']*)'/g,o;for(;o=t.exec(e);){let s=o[1]??o[2]??"";try{n.push(o[1]!==void 0?JSON.parse(`"${s}"`):s)}catch{n.push(s)}}return n}function Se(e={}){let n=e.configFile??P(process.env.CODEX_HOME??P(Ce(),".codex"),"config.toml"),t=e.previousFile??P(Ce(),".config","toolnet-memory","codex-notify-previous.json");xe(ke(n),{recursive:!0}),xe(ke(t),{recursive:!0});let o=Rt(n)?Pt(n,"utf8"):"",s=e.binary??"toolnet-memory",i=`notify = [${JSON.stringify(s)}, "session:codex-notify"]`,r=o.split(`
|
|
1056
1056
|
`),c=r.findIndex(d=>/^\s*\[/.test(d));c<0&&(c=r.length);let l=-1,u=-1;for(let d=0;d<c;d+=1)if(/^\s*notify\s*=/.test(r[d])){if(l=d,u=d,r[d].includes("[")&&!r[d].includes("]"))for(;u+1<c&&(u+=1,!r[u].includes("]")););break}let a=[];if(l>=0){let d=r.slice(l,u+1).join(`
|
|
1057
|
-
`);a=
|
|
1057
|
+
`);a=_t(d),r.splice(l,u-l+1,i)}else c=r.findIndex(d=>/^\s*\[/.test(d)),c<0&&(c=r.length),r.splice(c,0,i);let g=a.length>=2&&a[a.length-1]==="session:codex-notify";return a.length>0&&!g&&be(t,JSON.stringify(a,null,2)+`
|
|
1058
1058
|
`,{encoding:"utf8",mode:384}),o=r.join(`
|
|
1059
1059
|
`),o.endsWith(`
|
|
1060
1060
|
`)||(o+=`
|
|
1061
|
-
`),
|
|
1062
|
-
`,{encoding:"utf8",mode:384}),n}import{spawnSync as
|
|
1063
|
-
`,{encoding:"utf8",mode:384}),
|
|
1064
|
-
`,{encoding:"utf8",mode:384}),
|
|
1061
|
+
`),be(n,o,{encoding:"utf8",mode:384}),{configFile:n,previousFile:t,preservedPrevious:a.length>0&&!g}}import{existsSync as Jt,mkdirSync as $t,readFileSync as Dt,writeFileSync as Ht}from"node:fs";import{homedir as Lt}from"node:os";import{dirname as Kt,join as we}from"node:path";function Bt(e){return`'${e.replace(/'/g,"'\\''")}'`}function Ie(e={}){let n=e.hooksFile??we(process.env.CODEX_HOME??we(Lt(),".codex"),"hooks.json");$t(Kt(n),{recursive:!0});let t={};if(Jt(n))try{t=JSON.parse(Dt(n,"utf8"))}catch(c){throw new Error(`Invalid existing Codex hooks.json: ${c instanceof Error?c.message:String(c)}`)}let o=t.hooks&&typeof t.hooks=="object"&&!Array.isArray(t.hooks)?t.hooks:{};t.hooks=o;let i=(Array.isArray(o.SessionStart)?o.SessionStart:[]).filter(c=>{try{return!JSON.stringify(c).includes("session:codex-context")}catch{return!0}}),r=e.binary??"toolnet-memory";return i.push({matcher:"startup|resume|clear|compact",hooks:[{type:"command",command:`${Bt(r)} session:codex-context`,timeout:15,additionalContextLimit:1e3,statusMessage:"Loading ToolNet project continuity"}]}),o.SessionStart=i,Ht(n,JSON.stringify(t,null,2)+`
|
|
1062
|
+
`,{encoding:"utf8",mode:384}),n}import{spawnSync as Ut}from"node:child_process";function _(e,n){return Ut(e,n,{encoding:"utf8",stdio:["ignore","pipe","pipe"]})}function Ne(e,n){let t=_(e,["mcp","get",n,"--json"]);if(t.status!==0||!t.stdout)return null;try{return JSON.parse(t.stdout)}catch{return null}}function Ee(e,n){return e.enabled!==!1&&e.transport?.type==="stdio"&&e.transport?.command===n&&Array.isArray(e.transport?.args)&&e.transport?.args.length===1&&e.transport.args[0]==="mcp"}function je(e={}){let n=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",t=e.codexBinary??"codex",o=e.serverName??"toolnet-memory",s=Ne(t,o);if(s&&Ee(s,n))return{installed:!0,changed:!1,serverName:o,command:n,args:["mcp"]};if(s){let c=_(t,["mcp","remove",o]);if(c.status!==0)return{installed:!1,changed:!1,serverName:o,command:n,args:["mcp"],error:(c.stderr||c.stdout||"Unable to remove old ToolNet MCP configuration.").trim()}}let i=_(t,["mcp","add",o,"--",n,"mcp"]);if(i.status!==0)return{installed:!1,changed:!1,serverName:o,command:n,args:["mcp"],error:(i.stderr||i.stdout||"Unable to register ToolNet MCP.").trim()};let r=Ne(t,o);return!r||!Ee(r,n)?{installed:!1,changed:!0,serverName:o,command:n,args:["mcp"],error:"Codex accepted MCP registration but verification did not match expected ToolNet command."}:{installed:!0,changed:!0,serverName:o,command:n,args:["mcp"]}}import{existsSync as Yt,mkdirSync as qt,readFileSync as Wt,renameSync as Gt,rmSync as Xt,writeFileSync as Vt}from"node:fs";import{dirname as zt}from"node:path";function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Qt(e){return/^[A-Za-z0-9_./:-]+$/u.test(e)?e:`'${e.replace(/'/gu,"'\\''")}'`}function Zt(e){if(!Yt(e))return{};let n;try{n=JSON.parse(Wt(e,"utf8"))}catch(t){throw new Error(`Invalid existing Claude settings.json: ${t instanceof Error?t.message:String(t)}`)}if(!b(n))throw new Error("Invalid existing Claude settings.json: root must be a JSON object.");return n}function J(e){if(e===void 0)return[];if(!Array.isArray(e))throw new Error("Invalid existing Claude settings.json: hook event must be an array.");let n=[];for(let t of e){if(!b(t)){n.push(t);continue}let o=t.hooks;if(!Array.isArray(o)){n.push(t);continue}let s=o.filter(i=>{if(!b(i))return!0;let r=i.command;return!(typeof r=="string"&&r.includes("session:claude-hook"))});s.length!==0&&n.push({...t,hooks:s})}return n}function $(e){return{type:"command",command:e,timeout:10}}function en(e,n){qt(zt(e),{recursive:!0,mode:448});let t=`${e}.toolnet-${process.pid}-${Date.now()}.tmp`;try{Vt(t,JSON.stringify(n,null,2)+`
|
|
1063
|
+
`,{encoding:"utf8",mode:384}),Gt(t,e)}finally{Xt(t,{force:!0})}}function Te(e={}){let n=e.settingsFile??G(),t=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",o=Zt(n),s=o.hooks;if(s!==void 0&&!b(s))throw new Error("Invalid existing Claude settings.json: hooks must be an object.");let i=b(s)?{...s}:{},r=`${Qt(t)} session:claude-hook`,c=J(i.SessionStart);c.push({matcher:"startup|resume|clear|compact",hooks:[$(r)]}),i.SessionStart=c;let l=J(i.PostToolUse);l.push({matcher:"Edit|Write",hooks:[$(r)]}),i.PostToolUse=l;let u=J(i.Stop);u.push({hooks:[$(r)]}),i.Stop=u;let a={...o,hooks:i},g=JSON.stringify(o),d=JSON.stringify(a);return g===d?{settingsFile:n,changed:!1}:(en(n,a),{settingsFile:n,changed:!0})}import{existsSync as tn,mkdirSync as nn,readFileSync as on,renameSync as rn,rmSync as sn,writeFileSync as cn}from"node:fs";import{dirname as an}from"node:path";function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ae(e){if(!tn(e))return{};let n;try{n=JSON.parse(on(e,"utf8"))}catch(t){throw new Error(`Invalid existing Claude Code config: ${t instanceof Error?t.message:String(t)}`)}if(!C(n))throw new Error("Invalid existing Claude Code config: root must be a JSON object.");return n}function Me(e,n){if(!C(e))return!1;let t=e.args;return e.type==="stdio"&&e.command===n&&Array.isArray(t)&&t.length===1&&t[0]==="mcp"}function ln(e,n){nn(an(e),{recursive:!0});let t=`${e}.toolnet-${process.pid}-${Date.now()}.tmp`;try{cn(t,JSON.stringify(n,null,2)+`
|
|
1064
|
+
`,{encoding:"utf8",mode:384}),rn(t,e)}finally{sn(t,{force:!0})}}function Fe(e={}){let n=e.stateFile??X(),t=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",o=e.serverName??"toolnet-memory",s=Ae(n),i=s.mcpServers;if(i!==void 0&&!C(i))throw new Error("Invalid existing Claude Code config: mcpServers must be an object.");let r=C(i)?{...i}:{},c=r[o];if(Me(c,t))return{installed:!0,changed:!1,configFile:n,serverName:o,command:[t,"mcp"],repaired:!1};let l=c!==void 0;r[o]={type:"stdio",command:t,args:["mcp"]},ln(n,{...s,mcpServers:r});let a=Ae(n).mcpServers;if(!C(a)||!Me(a[o],t))throw new Error("Claude Code MCP configuration was written but verification failed.");return{installed:!0,changed:!0,configFile:n,serverName:o,command:[t,"mcp"],repaired:l}}function Re(e={}){let n=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",t=Te({binary:n,settingsFile:e.settingsFile}),o=Fe({binary:n,stateFile:e.stateFile});return{hooks:t,mcp:o,files:[t.settingsFile,o.configFile]}}import{existsSync as un,mkdirSync as dn,readFileSync as mn,renameSync as gn,rmSync as pn,writeFileSync as fn}from"node:fs";import{dirname as yn}from"node:path";var y="ToolNet Memory - ";function Je(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function hn(e){return/^[A-Za-z0-9_./:-]+$/u.test(e)?e:`'${e.replace(/'/gu,"'\\''")}'`}function Pe(e){if(!un(e))return{};let n=mn(e,"utf8").trim();if(!n)return{};let t;try{t=JSON.parse(n)}catch(o){throw new Error(`Invalid existing Kiro hooks file: ${o instanceof Error?o.message:String(o)}`)}if(!Je(t))throw new Error("Invalid existing Kiro hooks file: root must be a JSON object.");return t}function _e(e){return Je(e)?typeof e.name=="string"&&e.name.startsWith(y):!1}function k(e){return{type:"command",command:e}}function On(e){return[{name:`${y}Session Start`,description:"Inject compact local ToolNet continuity and capture Kiro session activation.",trigger:"SessionStart",action:k(e),timeout:10,enabled:!0},{name:`${y}Prompt Continuity`,description:"Capture prompts and refresh ToolNet guidance only for resume/continue requests.",trigger:"UserPromptSubmit",action:k(e),timeout:10,enabled:!0},{name:`${y}Raw History Guard`,description:"Prevent Kiro from reconstructing continuity from raw ToolNet/agent session history.",trigger:"PreToolUse",matcher:"*",action:k(e),timeout:10,enabled:!0},{name:`${y}Tool Capture`,description:"Capture durable tool activity while filtering noisy read-only events.",trigger:"PostToolUse",matcher:"*",action:k(e),timeout:15,enabled:!0},{name:`${y}Final Flush`,description:"Flush pending Kiro WAL events when the assistant finishes a turn.",trigger:"Stop",action:k(e),timeout:30,enabled:!0}]}function vn(e,n){dn(yn(e),{recursive:!0,mode:448});let t=`${e}.toolnet-${process.pid}-${Date.now()}.tmp`;try{fn(t,JSON.stringify(n,null,2)+`
|
|
1065
|
+
`,{encoding:"utf8",mode:384}),gn(t,e)}finally{pn(t,{force:!0})}}function $e(e={}){let n=e.hooksFile??z(),t=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",o=Pe(n);if(o.version!==void 0&&o.version!=="v1")throw new Error(`Unsupported existing Kiro hooks version: ${String(o.version)}`);let s=o.hooks;if(s!==void 0&&!Array.isArray(s))throw new Error("Invalid existing Kiro hooks file: hooks must be an array.");let i=Array.isArray(s)?s.filter(a=>!_e(a)):[],r=`${hn(t)} session:kiro-hook`,c=On(r),l={...o,version:"v1",hooks:[...i,...c]};if(JSON.stringify(o)===JSON.stringify(l))return{hooksFile:n,changed:!1,hookCount:c.length};vn(n,l);let u=Pe(n);if(u.version!=="v1"||!Array.isArray(u.hooks)||u.hooks.filter(_e).length!==c.length)throw new Error("Kiro hooks were written but verification failed.");return{hooksFile:n,changed:!0,hookCount:c.length}}import{existsSync as xn,mkdirSync as bn,readFileSync as Cn,renameSync as kn,rmSync as Sn,writeFileSync as wn}from"node:fs";import{dirname as In}from"node:path";function S(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function De(e){if(!xn(e))return{};let n=Cn(e,"utf8").trim();if(!n)return{};let t;try{t=JSON.parse(n)}catch(o){throw new Error(`Invalid existing Kiro MCP config: ${o instanceof Error?o.message:String(o)}`)}if(!S(t))throw new Error("Invalid existing Kiro MCP config: root must be a JSON object.");return t}function He(e,n){return S(e)?e.command===n&&Array.isArray(e.args)&&e.args.length===1&&e.args[0]==="mcp"&&e.disabled===!1:!1}function Nn(e,n){bn(In(e),{recursive:!0,mode:448});let t=`${e}.tmp-${process.pid}-${Date.now()}`;try{wn(t,`${JSON.stringify(n,null,2)}
|
|
1066
|
+
`,{encoding:"utf8",mode:384}),kn(t,e)}finally{Sn(t,{force:!0})}}function Le(e={}){let n=e.configFile??V(),t=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",o=e.serverName??"toolnet-memory",s=De(n),i=s.mcpServers;if(i!==void 0&&!S(i))throw new Error("Invalid existing Kiro MCP config: mcpServers must be an object.");let r=S(i)?{...i}:{},c=r[o];if(He(c,t))return{installed:!0,changed:!1,configFile:n,serverName:o,command:t,args:["mcp"]};r[o]={command:t,args:["mcp"],disabled:!1};let l={...s,mcpServers:r};Nn(n,l);let a=De(n).mcpServers;if(!S(a)||!He(a[o],t))throw new Error("Kiro MCP configuration was written but verification failed.");return{installed:!0,changed:!0,configFile:n,serverName:o,command:t,args:["mcp"]}}function Ke(e={}){let n=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",t=Le({binary:n,configFile:e.configFile}),o=$e({binary:n,hooksFile:e.hooksFile});return{installed:t.installed,changed:t.changed||o.changed,mcp:t,hooks:o,files:[t.configFile,o.hooksFile]}}function Be(){return Z()}function En(e={}){let n=e.binary??process.env.TOOLNET_MEMORY_BIN??"toolnet-memory",t=[],o=e.detections??Be(),s=new Map(o.map(i=>[i.agent,i.detected]));if(!(e.force===!0||s.get("agy")===!0))t.push({agent:"agy",detected:!1,installed:!1,targets:[]});else try{let r=le({binary:n});t.push({agent:"agy",detected:!0,installed:!0,targets:r.files})}catch(r){t.push({agent:"agy",detected:!0,installed:!1,targets:[],error:r instanceof Error?r.message:String(r)})}if(!(e.force===!0||s.get("opencode")===!0))t.push({agent:"opencode",detected:!1,installed:!1,targets:[]});else try{let r=pe({binary:n}),c=ve({binary:n});t.push({agent:"opencode",detected:!0,installed:!0,targets:[r,c.configFile,`mcp:${c.serverName}`]})}catch(r){t.push({agent:"opencode",detected:!0,installed:!1,targets:[],error:r instanceof Error?r.message:String(r)})}if(!(e.force===!0||s.get("claude")===!0))t.push({agent:"claude",detected:!1,installed:!1,targets:[]});else try{let r=Re({binary:n});t.push({agent:"claude",detected:!0,installed:!0,targets:[r.hooks.settingsFile,r.mcp.configFile,`mcp:${r.mcp.serverName}`]})}catch(r){t.push({agent:"claude",detected:!0,installed:!1,targets:[],error:r instanceof Error?r.message:String(r)})}if(!(e.force===!0||s.get("kiro")===!0))t.push({agent:"kiro",detected:!1,installed:!1,targets:[]});else try{let r=Ke({...e.kiro??{},binary:n});t.push({agent:"kiro",detected:!0,installed:!0,targets:[r.mcp.configFile,`mcp:${r.mcp.serverName}`,r.hooks.hooksFile]})}catch(r){t.push({agent:"kiro",detected:!0,installed:!1,targets:[],error:r instanceof Error?r.message:String(r)})}if(!(e.force===!0||s.get("codex")===!0))t.push({agent:"codex",detected:!1,installed:!1,targets:[]});else try{let r=Se({binary:n}),c=Ie({binary:n}),l=je({binary:n});if(!l.installed)throw new Error(l.error??"Codex MCP registration failed");let u=[r.configFile,c,`mcp:${l.serverName}`];r.preservedPrevious&&u.push(r.previousFile),t.push({agent:"codex",detected:!0,installed:!0,targets:u})}catch(r){t.push({agent:"codex",detected:!0,installed:!1,targets:[],error:r instanceof Error?r.message:String(r)})}return t}function Ue(e){switch(e){case"agy":return"Agy / Antigravity";case"opencode":return"OpenCode";case"claude":return"Claude Code";case"kiro":return"Kiro CLI";case"codex":return"Codex"}}function jn(e){console.log(""),console.log("ToolNet Memory Integration Detection"),console.log("===================================="),console.log("");for(let n of e){let t=Ue(n.agent);if(!n.detected){console.log(`\u25CB ${t}: not detected`);continue}console.log(`\u2713 ${t}: detected`);for(let o of n.evidence)console.log(` ${o}`)}console.log("")}function Tn(e){console.log(""),console.log("ToolNet Memory AI Integrations"),console.log("=============================="),console.log("");for(let n of e){let t=Ue(n.agent);if(!n.detected){console.log(`- ${t}: not detected`);continue}if(n.installed){console.log(`\u2713 ${t}: automatic memory enabled`);continue}console.log(`\u2717 ${t}: integration failed`),n.error&&console.log(` ${n.error}`)}console.log("")}async function An(){let e=process.argv.slice(2),n=e.includes("--all"),t=e.includes("--json");if(e.includes("--detect-only")){let i=Be();if(t){console.log(JSON.stringify(i,null,2));return}jn(i);return}let s=En({force:n});if(t){console.log(JSON.stringify(s,null,2));return}Tn(s)}var Mn=process.argv[1]&&(process.argv[1].endsWith("auto-integrate.js")||process.argv[1].endsWith("auto-integrate.ts"));Mn&&An().catch(e=>{console.error(e instanceof Error?e.message:String(e)),process.exitCode=1});export{Be as detectAutoIntegrations,En as installAutoIntegrations};
|
|
@@ -47,4 +47,4 @@ Answer the coding agent directly.
|
|
|
47
47
|
`):e.trim(),l=C(e),d=y(n,p,{maxFacts:8,maxChars:1800}).facts.map(b=>({kind:b.kind,value:b.value,source:b.source})),g=St(a&&i?[...d,...i.focus]:d);return Et(n,{schema:"toolnet.memory-conversation.v1",version:1,projectId:n.id,updatedAt:new Date(r).toISOString(),lastIntent:l,focus:g}),{question:p,originalQuestion:e,usedPriorFocus:a,previousIntent:i?.lastIntent,currentIntent:l,priorFocus:i?.focus??[],focusCount:g.length}}var Dr={question:pe.string().min(2).max(4e3).describe("Question about previous project work, unfinished tasks, handoff, blockers, decisions, files or next actions."),mode:pe.enum(["ai","local"]).optional().describe("ai uses ToolNet Memory Agent with configured LLM fallback chain. local returns deterministic local memory only.")};async function fe(n,e){let t=me(n.project,e.question);if(e.mode==="local"){let o=H(t);if(o)return{answer:o.answer,mode:"local",usedAi:!1,source:o.source,intent:o.intent};let i=M(n.project,t.originalQuestion);return{answer:i.answer,mode:"local",usedAi:!1,source:i.source,intent:i.intent}}let r=await le(n.project,t.question);if(!r.usedAi){let o=H(t);if(o)return{answer:o.answer,mode:"ai",usedAi:!1,provider:r.provider,model:r.model}}return{answer:r.answer,mode:"ai",usedAi:r.usedAi,provider:r.provider,model:r.model}}var ge="RAW_TRANSCRIPT_MUST_NEVER_ENTER_CONTINUITY_CONTEXT_X1";function ye(n,e){he(n,JSON.stringify(e,null,2)+`
|
|
48
48
|
`,"utf8")}function Rt(n,e,t,r,o,i,a){return{continuity:{schema:"toolnet.handoff.v2",version:2,project:{id:n,name:e},source:{agent:t,nativeSessionId:`${t}-x1-source`,sessionKey:`${t}:${t}-x1-source`,sequence:42,reason:"checkpoint"},capturedAt:"2026-08-13T05:30:00.000Z",current:{phase:{id:"x1",title:"Cross-Agent Continuity E2E",status:"in_progress"},task:{id:"x1-cross-agent",title:r,status:"in_progress"},file:o},completed:{phases:["A1 OpenCode Adapter","A2 Agy Adapter","A3 Claude Code Adapter"],tasks:["Build canonical handoff schema","Build intelligent memory retrieval"]},remaining:{phases:["X1 Cross-Agent Continuity E2E"],tasks:[r],todos:[i]},nextAction:a,blockers:[],decisions:["Canonical handoff must override stale session state","Never replay raw transcripts during continuity recovery"],files:{current:o,recent:[o]},tests:{status:"passing",recent:["A1-A3 adapter tests passed"]},attention:[],progress:{phasesTotal:3,phasesCompleted:2,tasksTotal:4,tasksCompleted:3,blocked:0},stateDigest:"a".repeat(64)}}}async function L(n,e){return fe({project:n},{question:e,mode:"local"})}async function Ft(n,e){let t=Tt(k(Ot(),`toolnet-x1-${n}-${e}-`));try{let r=`x1-${n}-${e}`,o=`x1-${n}-to-${e}`,i={id:r,name:o,rootPath:t,createdAt:"2026-08-13T05:30:00.000Z",updatedAt:"2026-08-13T05:30:00.000Z",graphVersion:1,memoryVersion:1},a=k(t,".toolnet","work"),p=k(t,".toolnet","context"),l=k(t,".toolnet","sessions",n,"raw-session-x1");G(a,{recursive:!0}),G(p,{recursive:!0}),G(l,{recursive:!0});let f=`X1 ${n} to ${e} canonical continuity`,d=`src/x1/${n}-to-${e}.ts`,g=`Implement ${e} continuation step`,b=`Continue ${f} in ${d}`;ye(k(a,"handoff-latest.json"),Rt(r,o,n,f,d,g,b)),ye(k(p,"session-origin.json"),{version:1,projectId:r,agent:"stale-agent",nativeSessionId:"stale-session",updatedAt:"2026-01-01T00:00:00.000Z",currentTask:"STALE TASK MUST NOT WIN",currentPhase:"STALE PHASE",lastTouchedFile:"src/stale/old.ts",latestNextAction:"STALE NEXT ACTION"}),he(k(l,"events.jsonl"),JSON.stringify({text:ge})+`
|
|
49
49
|
`,"utf8");let be=y(i,"T\xF4i ph\u1EA3i l\xE0m g\xEC ti\u1EBFp?",{maxFacts:12,maxChars:3200}),D=await L(i,"Task hi\u1EC7n t\u1EA1i \u0111ang l\xE0m l\xE0 g\xEC?"),K=await L(i,"File hi\u1EC7n t\u1EA1i l\xE0 file n\xE0o?"),$=await L(i,"TODO c\xF2n l\u1EA1i l\xE0 g\xEC?"),U=await L(i,"T\xF4i ph\u1EA3i l\xE0m g\xEC ti\u1EBFp?"),ve=[D.answer,K.answer,$.answer,U.answer].join(`
|
|
50
|
-
`),j=[D,K,$,U],Y={canonicalHandoffPreferred:be.facts[0]?.source==="handoff",taskRecovered:D.answer.includes(f),fileRecovered:K.answer.includes(d),todoRecovered:$.answer.includes(g),nextActionRecovered:U.answer.includes(b),localModeOnly:j.every(A=>A.mode==="local"),noAiRequired:j.every(A=>A.usedAi===!1),rawTranscriptIsolated:!ve.includes(ge),compact:j.every(A=>A.answer.length<1600)};return{from:n,to:e,passed:Object.values(Y).every(Boolean),checks:Y}}finally{Pt(t,{recursive:!0,force:!0})}}async function ke(){let n=[["agy","codex"],["codex","opencode"],["opencode","claude"],["claude","agy"]],e=[];for(let[r,o]of n)e.push(await Ft(r,o));let t=e.filter(r=>r.passed).length;return{passed:t===e.length,total:e.length,passedCount:t,cases:e}}var m={reset:"\x1B[0m",green:"\x1B[32m",red:"\x1B[31m",cyan:"\x1B[36m",gray:"\x1B[90m",white:"\x1B[97m"};function Nt(n){return n?`${m.green}\u2713${m.reset}`:`${m.red}\u2717${m.reset}`}function Lt(n){let e=`${n.from.padEnd(8)} \u2192 ${n.to.padEnd(8)}`;if(console.log(`\u2502 ${Nt(n.passed)} ${e}`),!n.passed)for(let[t,r]of Object.entries(n.checks))r||console.log(`\u2502 ${m.red}\u2717${m.reset} ${t}`)}async function Dt(){console.log(""),console.log(`${m.cyan}\u25C7${m.reset} ${m.white}ToolNet Cross-Agent Continuity Certification${m.reset}`),console.log(`${m.gray}\u2502${m.reset}`);let n=await ke();for(let e of n.cases)Lt(e);if(console.log(`${m.gray}\u2502${m.reset}`),n.passed){console.log(`${m.green}\u25C6 PASS${m.reset} ${n.passedCount}/${n.total} cross-agent transitions`),console.log(`${m.green}\u2713${m.reset} canonical handoff`),console.log(`${m.green}\u2713${m.reset} memory_agent_ask`),console.log(`${m.green}\u2713${m.reset} task / file / TODO / next action`),console.log(`${m.green}\u2713${m.reset} raw transcripts isolated`),console.log(`${m.green}\u2713${m.reset} AI not required for direct continuity`);return}console.log(`${m.red}\u25C6 FAIL${m.reset} ${n.passedCount}/${n.total} cross-agent transitions`),process.exitCode=1}Dt().catch(n=>{console.error(n instanceof Error?n.message:String(n)),process.exitCode=1});
|
|
50
|
+
`),j=[D,K,$,U],Y={canonicalHandoffPreferred:be.facts[0]?.source==="handoff",taskRecovered:D.answer.includes(f),fileRecovered:K.answer.includes(d),todoRecovered:$.answer.includes(g),nextActionRecovered:U.answer.includes(b),localModeOnly:j.every(A=>A.mode==="local"),noAiRequired:j.every(A=>A.usedAi===!1),rawTranscriptIsolated:!ve.includes(ge),compact:j.every(A=>A.answer.length<1600)};return{from:n,to:e,passed:Object.values(Y).every(Boolean),checks:Y}}finally{Pt(t,{recursive:!0,force:!0})}}async function ke(){let n=[["agy","codex"],["codex","opencode"],["opencode","claude"],["claude","kiro"],["kiro","agy"]],e=[];for(let[r,o]of n)e.push(await Ft(r,o));let t=e.filter(r=>r.passed).length;return{passed:t===e.length,total:e.length,passedCount:t,cases:e}}var m={reset:"\x1B[0m",green:"\x1B[32m",red:"\x1B[31m",cyan:"\x1B[36m",gray:"\x1B[90m",white:"\x1B[97m"};function Nt(n){return n?`${m.green}\u2713${m.reset}`:`${m.red}\u2717${m.reset}`}function Lt(n){let e=`${n.from.padEnd(8)} \u2192 ${n.to.padEnd(8)}`;if(console.log(`\u2502 ${Nt(n.passed)} ${e}`),!n.passed)for(let[t,r]of Object.entries(n.checks))r||console.log(`\u2502 ${m.red}\u2717${m.reset} ${t}`)}async function Dt(){console.log(""),console.log(`${m.cyan}\u25C7${m.reset} ${m.white}ToolNet Cross-Agent Continuity Certification${m.reset}`),console.log(`${m.gray}\u2502${m.reset}`);let n=await ke();for(let e of n.cases)Lt(e);if(console.log(`${m.gray}\u2502${m.reset}`),n.passed){console.log(`${m.green}\u25C6 PASS${m.reset} ${n.passedCount}/${n.total} cross-agent transitions`),console.log(`${m.green}\u2713${m.reset} canonical handoff`),console.log(`${m.green}\u2713${m.reset} memory_agent_ask`),console.log(`${m.green}\u2713${m.reset} task / file / TODO / next action`),console.log(`${m.green}\u2713${m.reset} raw transcripts isolated`),console.log(`${m.green}\u2713${m.reset} AI not required for direct continuity`);return}console.log(`${m.red}\u25C6 FAIL${m.reset} ${n.passedCount}/${n.total} cross-agent transitions`),process.exitCode=1}Dt().catch(n=>{console.error(n instanceof Error?n.message:String(n)),process.exitCode=1});
|
package/bundle/help-cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{readFileSync as G}from"node:fs";import{dirname as D,resolve as E}from"node:path";import{fileURLToPath as j}from"node:url";var
|
|
1
|
+
import{readFileSync as G}from"node:fs";import{dirname as D,resolve as E}from"node:path";import{fileURLToPath as j}from"node:url";var R={spinner:["\xB7","\u2722","\u2733","\u2736","\u273B","\u273D"],barFilled:"\u2588",barEmpty:"\u2591",phaseDone:"\u25C6",phaseActive:"\u25C7",rail:"\u2502",branch:"\u251C",corner:"\u2514",dash:"\u2014"},U={spinner:[".","*","+","x","*","+"],barFilled:"#",barEmpty:"-",phaseDone:"[OK]",phaseActive:"[>>]",rail:"|",branch:"|",corner:"\\",dash:"-"};function A(){if(process.env.TOOLNET_ASCII==="1")return!1;if(process.env.TOOLNET_UNICODE==="1")return!0;if(process.platform==="win32"){let t=process.env.TERM_PROGRAM,e=process.env.WT_SESSION,o=process.env.VSCODE_PID,n=process.env.ConEmuPID;return!!(e||o||n||t==="vscode")}return process.env.TERM!=="linux"}var h;function v(){return h||(h=A()?R:U),h}var d={reset:"\x1B[0m",green:"\x1B[32m",cyan:"\x1B[36m",red:"\x1B[31m",yellow:"\x1B[33m",amber:"\x1B[38;5;214m",white:"\x1B[97m",dim:"\x1B[2m",bold:"\x1B[1m"};function T(t){return t.noColor||process.env.NO_COLOR?!1:t.tty??process.stdout.isTTY??!1}function f(t,e,o){return T(o)?`${e}${t}${d.reset}`:t}function N(t,e){return f(t,d.dim,e)}function M(t,e){return f(t,d.bold,e)}function O(t,e){return f(t,d.cyan,e)}function u(t,e,o){let n=v(),i=e?` ${N(`v${e}`,o)}`:"";return`${O(n.phaseDone,o)} ${t}${i}`}function a(t,e){return M(t,e)}function l(t,e,o,n){let i=" ".repeat(Math.max(0,o-t.length));return` ${O(t,n)}${i} ${e}`}var m=[{name:"setup",description:"Configure ToolNet",category:"core"},{name:"init",description:"Initialize current project",usage:"toolnet-memory init [path]",category:"core"},{name:"doctor",description:"Check system health",category:"core"},{name:"ask",description:"Ask project memory",usage:"toolnet-memory ask <question>",category:"memory"},{name:"context",description:"Show current project context",category:"memory",aliases:["context:print"]},{name:"work",description:"Show current work state",category:"memory",aliases:["work:status"]},{name:"index",description:"Build code intelligence",category:"code",pipeline:["Scanning files","Parsing code","Type Resolution","Rich Graph","Semantic Code Index","Architecture Intelligence","Graph Analysis","3D Visualization Dataset"]},{name:"semantic",description:"Semantic code search",usage:"toolnet-memory semantic <query>",category:"code"},{name:"impact",description:"Analyze change impact",usage:"toolnet-memory impact <file>",category:"code"},{name:"graph",description:"Open code graph UI",category:"code"},{name:"graph:ui",description:"Open code graph UI",category:"code",hidden:!0},{name:"model",description:"View/change AI model",category:"ai"},{name:"provider",description:"Manage AI providers",category:"ai",aliases:["provider:status"]},{name:"status",description:"Show ToolNet status",category:"system"},{name:"update",description:"Update ToolNet Memory",category:"system"},{name:"context:print",description:"Print fast project context",category:"context",hidden:!0},{name:"context:sync",description:"Show context hash/size",category:"context"},{name:"context:refresh",description:"Rebuild deep startup brief cache",category:"context"},{name:"brief",description:"Show full project brief",category:"context"},{name:"brief:json",description:"Show brief as JSON",category:"context"},{name:"profile:show",description:"Show .toolnet/profile.md",category:"context"},{name:"profile:sync",description:"Sync profile to agent files",category:"context"},{name:"work:status",description:"Show current work state",category:"work",hidden:!0},{name:"work:json",description:"Show work state as JSON",category:"work"},{name:"work:reconcile",description:"Reconcile work continuity",category:"work"},{name:"handoff:latest",description:"Show latest session handoff",category:"work"},{name:"handoff:refresh",description:"Refresh handoff data",category:"work"},{name:"index:graph",description:"Build graph index only",category:"code"},{name:"incremental",description:"Incremental code indexing",category:"code"},{name:"config",description:"Manage configuration",usage:"toolnet-memory config <get|set|list|open>",category:"ai"},{name:"provider:list",description:"List available AI providers",category:"ai"},{name:"provider:status",description:"Show AI provider status",category:"ai",hidden:!0},{name:"provider:test",description:"Test AI provider connection",category:"ai"},{name:"integrate:detect",description:"Detect agent integrations",category:"integration"},{name:"integrate:auto",description:"Auto-enable integrations",category:"integration"},{name:"integrate:agy",description:"Install Agy hooks",category:"integration"},{name:"integrate:codex",description:"Install Codex integration",category:"integration"},{name:"integrate:opencode",description:"Install OpenCode plugin",category:"integration"},{name:"integrate:claude",description:"Install Claude Code integration",category:"integration"},{name:"integrate:kiro",description:"Install Kiro CLI integration",usage:"toolnet-memory integrate:kiro [--status] [--json]",category:"integration"},{name:"session:agy-sync",description:"Sync Agy session",category:"session"},{name:"session:agy-recover",description:"Recover Agy sessions",category:"session"},{name:"session:agy-hook",description:"Agy session hook",category:"session",hidden:!0},{name:"session:codex-sync",description:"Sync Codex session",category:"session"},{name:"session:codex-recover",description:"Recover Codex sessions",category:"session"},{name:"session:codex-notify",description:"Codex notification hook",category:"session",hidden:!0},{name:"session:codex-context",description:"Codex context hook",category:"session",hidden:!0},{name:"session:opencode-sync",description:"Sync OpenCode session",category:"session"},{name:"session:opencode-recover",description:"Recover OpenCode sessions",category:"session"},{name:"session:claude-hook",description:"Claude session hook",category:"session",hidden:!0},{name:"session:kiro-hook",description:"Kiro lifecycle hook",category:"session",hidden:!0},{name:"memory:review",description:"Review memory entries",category:"session"},{name:"memory:reconcile",description:"Reconcile memory state",category:"session"},{name:"guard:check",description:"Check project rules",category:"guard"},{name:"guard:explain",description:"Show rules and evidence",category:"guard"},{name:"guard:json",description:"Output guard result as JSON",category:"guard",hidden:!0},{name:"project:manual-init",description:"Initialize project manual",category:"project"},{name:"project:manual-show",description:"Show project manual",category:"project"},{name:"project:manual-sync",description:"Sync project manual",category:"project"},{name:"snapshot:list",description:"List snapshots",category:"snapshot"},{name:"snapshot:create",description:"Create snapshot",category:"snapshot"},{name:"snapshot:restore",description:"Restore snapshot",category:"snapshot"},{name:"recover",description:"Recover latest snapshot",category:"snapshot"},{name:"service",description:"Run daemon in foreground",category:"service"},{name:"service:install",description:"Install/start daemon",category:"service"},{name:"service:start",description:"Start daemon",category:"service"},{name:"service:stop",description:"Stop daemon",category:"service"},{name:"service:restart",description:"Restart daemon",category:"service"},{name:"service:status",description:"Show daemon status",category:"service"},{name:"service:remove",description:"Remove daemon",category:"service"},{name:"mcp",description:"Run MCP server",category:"advanced"},{name:"api",description:"Run API server",category:"advanced"},{name:"run",description:"Run ToolNet runtime",category:"advanced",hidden:!0},{name:"production:certify",description:"Verify production runtime",category:"advanced"},{name:"certify:continuity",description:"Certify work continuity",category:"advanced"},{name:"ask-ai",description:"Ask AI agent (advanced)",category:"advanced",hidden:!0}];function x(t){return{tty:t.tty,noColor:t.noColor}}function S(t){let e=[],o=t.version??"0.0.0",n=x(t);e.push(""),e.push(u("ToolNet Memory",o,n)),e.push(" Persistent memory & code intelligence for AI coding agents"),e.push(""),e.push(a("USAGE",n)),e.push(" toolnet-memory <command> [options]"),e.push("");let i=[{key:"core",title:"GET STARTED"},{key:"memory",title:"MEMORY"},{key:"code",title:"CODE"},{key:"ai",title:"AI"},{key:"system",title:"SYSTEM"}];for(let{key:s,title:g}of i){let c=m.filter(r=>r.category===s&&!r.hidden);if(c.length===0)continue;e.push(a(g,n));let y=Math.max(...c.map(r=>r.name.length));for(let r of c)e.push(l(r.name,r.description,y,n));e.push("")}return e.push(a("MORE",n)),e.push(l("help --all","Show all advanced commands",15,n)),e.push(l("help <command>","Show command details",15,n)),e.push(""),e.join(`
|
|
2
2
|
`)}function k(t){let e=[],o=t.version??"0.0.0",n=x(t);e.push(""),e.push(u("ToolNet Memory",o,n)),e.push(" Persistent memory & code intelligence for AI coding agents"),e.push(""),e.push(a("USAGE",n)),e.push(" toolnet-memory <command> [options]"),e.push("");let i=[{key:"core",title:"PROJECT SETUP"},{key:"memory",title:"MEMORY"},{key:"code",title:"CODE INTELLIGENCE"},{key:"ai",title:"AI / PROVIDERS"},{key:"system",title:"SYSTEM"},{key:"context",title:"CONTEXT & MEMORY"},{key:"work",title:"WORK CONTINUITY"},{key:"integration",title:"AGENT INTEGRATIONS"},{key:"session",title:"SESSIONS"},{key:"guard",title:"GUARD"},{key:"project",title:"PROJECT MANUAL"},{key:"snapshot",title:"SNAPSHOTS & RECOVERY"},{key:"service",title:"BACKGROUND SERVICE"},{key:"advanced",title:"DEVELOPER / PRODUCTION"}];for(let{key:s,title:g}of i){let c=m.filter(r=>r.category===s&&!r.hidden);if(c.length===0)continue;e.push(a(g,n));let y=Math.max(...c.map(r=>r.name.length));for(let r of c)e.push(l(r.name,r.description,y,n));e.push("")}return e.join(`
|
|
3
3
|
`)}function w(t,e){let o=m.find(s=>s.name===t||s.aliases?.includes(t));if(!o)return null;let n=[],i=x(e);if(n.push(""),n.push(u(o.name,void 0,i)),n.push(""),n.push(o.description),n.push(""),o.usage&&(n.push(a("USAGE",i)),n.push(` ${o.usage}`),n.push("")),o.aliases&&o.aliases.length>0){n.push(a("ALIASES",i));for(let s of o.aliases)n.push(` ${s}`);n.push("")}if(o.pipeline&&o.pipeline.length>0){n.push(a("PIPELINE",i));for(let s of o.pipeline)n.push(` ${s}`);n.push("")}if(o.examples&&o.examples.length>0){n.push(a("EXAMPLES",i));for(let s of o.examples)n.push(` ${s}`);n.push("")}return n.join(`
|
|
4
|
-
`)}function b(t){return m.flatMap(n=>[n.name,...n.aliases??[]]).filter(n=>n===t?!1:!!(n.startsWith(t)||t.length>=3&&n.includes(t))).slice(0,3)}function $(){let t=D(j(import.meta.url)),e=[E(t,"../package.json"),E(t,"../../package.json")];for(let o of e)try{let n=JSON.parse(G(o,"utf8"));if(n.version)return n.version}catch{}return process.env.npm_package_version??"unknown"}var p=process.argv.slice(2),C={version:$(),tty:!!process.stdout.isTTY};function
|
|
4
|
+
`)}function b(t){return m.flatMap(n=>[n.name,...n.aliases??[]]).filter(n=>n===t?!1:!!(n.startsWith(t)||t.length>=3&&n.includes(t))).slice(0,3)}function $(){let t=D(j(import.meta.url)),e=[E(t,"../package.json"),E(t,"../../package.json")];for(let o of e)try{let n=JSON.parse(G(o,"utf8"));if(n.version)return n.version}catch{}return process.env.npm_package_version??"unknown"}var p=process.argv.slice(2),C={version:$(),tty:!!process.stdout.isTTY};function I(t){let e=b(t);if(console.error(""),console.error(`\u2715 Unknown command: ${t}`),e.length>0){console.error(""),console.error(" Did you mean:");for(let o of e)console.error(` ${o}`)}console.error(""),console.error(" Run `toolnet-memory help` to see available commands."),console.error("")}if(p[0]==="--unknown")I(p[1]??""),process.exitCode=1;else if(p[0]==="--all")console.log(k(C));else if(p[0]){let t=w(p[0],C);t?console.log(t):(I(p[0]),process.exitCode=1)}else console.log(S(C));
|