toolnet-memory 0.3.14 → 0.3.16
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/.env.example +0 -1
- package/.release-target +1 -1
- package/README.md +182 -6
- package/bin/toolnet-memory +5 -0
- package/bundle/agy-hook.js +71 -71
- package/bundle/agy.js +65 -65
- package/bundle/api.js +15 -15
- package/bundle/auto-integrate.js +28 -28
- package/bundle/background-refresh.js +7 -7
- package/bundle/claude-hook.js +51 -50
- package/bundle/codex-context.js +29 -28
- package/bundle/codex.js +77 -77
- package/bundle/context-runtime.js +44 -43
- package/bundle/context.js +15 -15
- package/bundle/continuity-certify.js +13 -13
- package/bundle/copilot-hook.js +88 -86
- package/bundle/copilot.js +4 -4
- package/bundle/cursor-hook.js +88 -86
- package/bundle/cursor.js +4 -4
- package/bundle/doctor.js +4 -4
- package/bundle/full-index.js +21 -21
- package/bundle/gc.js +3 -0
- package/bundle/graph-index.js +4 -4
- package/bundle/graph-ui.js +3 -3
- package/bundle/grok-hook.js +64 -63
- package/bundle/grok.js +5 -5
- package/bundle/handoff-refresh.js +10 -10
- package/bundle/help-cli.js +3 -3
- package/bundle/impact.js +4 -4
- package/bundle/incremental.js +5 -4
- package/bundle/init.js +38 -37
- package/bundle/integration-status.js +4 -4
- package/bundle/kiro-hook.js +93 -92
- package/bundle/learner.js +6 -6
- package/bundle/mcp.js +17 -17
- package/bundle/memory-agent.js +7 -7
- package/bundle/memory-query.js +7 -7
- package/bundle/opencode.js +84 -84
- package/bundle/project-manual.js +7 -7
- package/bundle/recovery-certify.js +15 -15
- package/bundle/runtime.js +13 -12
- package/bundle/semantic.js +5 -5
- package/bundle/snapshot.js +4 -4
- package/bundle/status-cli.js +4 -4
- package/bundle/toolnet-cli.js +60 -60
- package/bundle/work-continuity.js +7 -7
- package/package.json +21 -3
- package/release-manifest.json +104 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as B,readFileSync as Ve}from"node:fs";import{homedir as Ce}from"node:os";import{join as m,resolve as Pe}from"node:path";function Y(e={}){return e.cursorHome??m(e.home??Ce(),".cursor")}function F(e={}){return m(Y(e),"mcp.json")}function w(e={}){return m(Y(e),"hooks.json")}function H(e){return m(Pe(e),".cursor")}function Q(e){return m(H(e),"mcp.json")}function Z(e){return m(H(e),"hooks.json")}function Fe(e){return m(H(e),"rules")}function _(e){return m(Fe(e),"toolnet-memory.mdc")}var ee=`---
|
|
2
2
|
description: ToolNet Memory project continuity and safety rules
|
|
3
3
|
alwaysApply: true
|
|
4
4
|
---
|
|
@@ -25,7 +25,7 @@ Use ToolNet Memory as the continuity source for this project.
|
|
|
25
25
|
- Do not ask the user to repeat project context that ToolNet already provides.
|
|
26
26
|
|
|
27
27
|
Current repository evidence overrides stale memory.
|
|
28
|
-
`;import{spawnSync as we}from"node:child_process";import{existsSync as b,statSync as xe}from"node:fs";import{dirname as Oe,join as Ae,parse as Te,resolve as $}from"node:path";function oe(e){let o=$(e);if(!b(o))throw new Error(`Project path does not exist: ${o}`);if(!xe(o).isDirectory())throw new Error(`Project path is not a directory: ${o}`);return o}function x(e){return Ae(e,".toolnet","project.json")}function qe(e){let o=$(e),t=Te(o).root;for(;;){if(b(x(o)))return o;if(o===t)return;let r=Oe(o);if(r===o)return;o=r}}function M(e){let o=we("git",["rev-parse","--show-toplevel"],{cwd:e,encoding:"utf8",timeout:5e3});if(o.status!==0)return;let t=o.stdout.trim();return t?$(t):void 0}function S(e={}){let o=oe(e.cwd??process.cwd());if(e.project){let n=oe(e.project),i=x(n),s=M(n);return{root:n,source:"explicit",eligible:!0,toolnetProject:b(i),manifestFile:b(i)?i:void 0,gitRoot:s}}let t=qe(o);if(t){let n=x(t);return{root:t,source:"toolnet",eligible:!0,toolnetProject:!0,manifestFile:n,gitRoot:M(t)}}let r=M(o);if(r){let n=x(r);return{root:r,source:"git",eligible:!0,toolnetProject:b(n),manifestFile:b(n)?n:void 0,gitRoot:r}}return{root:o,source:"cwd",eligible:!1,toolnetProject:!1}}function ie(e,o={}){let t=[],r=e.indexOf("--scope");if(r>=0){let i=e[r+1];if(i!=="global"&&i!=="project"&&i!=="both")throw new Error(`Invalid --scope value: ${String(i)}`);t.push(i)}e.includes("--global")&&t.push("global"),e.includes("--both")&&t.push("both");let n=Array.from(new Set(t));if(n.length>1)throw new Error(`Conflicting integration scopes: ${n.join(", ")}`);return n[0]??o.defaultScope??"global"}function te(e,o){return{install:e,effective:o}}function d(e,o){return{surface:e,global:te(o.globalInstall,o.effective==="global"||o.effective==="both"),project:te(o.projectInstall,o.effective==="project"||o.effective==="both"),effective:o.effective,risk:o.risk??"none",dedupeRequired:o.dedupeRequired??!1,trustRequired:o.trustRequired??o.projectInstall,note:o.note}}function Ue(e){return{mcp:d("mcp",{globalInstall:!0,projectInstall:!1,effective:"global"}),hooks:d("hooks",{globalInstall:!0,projectInstall:!1,effective:"global"}),work:d("work",{globalInstall:e==="grok",projectInstall:!1,effective:e==="grok"?"global":"none",note:e==="grok"?"Grok supports a global ToolNet continuity skill.":"Cursor/Copilot work instructions remain project-scoped."})}}function re(e){return{mcp:d("mcp",{globalInstall:!1,projectInstall:!0,effective:"project",trustRequired:!0}),hooks:d("hooks",{globalInstall:!1,projectInstall:!0,effective:"project",trustRequired:!0}),work:d("work",{globalInstall:!1,projectInstall:!0,effective:"project",trustRequired:!1,note:e==="cursor"?"Use .cursor/rules/toolnet-memory.mdc.":e==="copilot"?"Use .github/instructions/toolnet-memory.instructions.md.":"Use .grok/skills/toolnet-continuity/SKILL.md."})}}function ne(e){return{mcp:d("mcp",{globalInstall:!0,projectInstall:!0,effective:"project",risk:e==="cursor"?"precedence-unverified":"shadowed-global",trustRequired:!0,note:e==="cursor"?"Project ToolNet MCP is the intended effective definition; native same-name precedence must be E2E certified before release.":"Global remains useful outside the project; same-name project definition wins inside the project."}),hooks:d("hooks",{globalInstall:!0,projectInstall:!0,effective:"both",risk:"additive-duplicate",dedupeRequired:!0,trustRequired:!0,note:"Global and project hook sources can both execute for the same native event."}),work:d("work",{globalInstall:e==="grok",projectInstall:!0,effective:"project",risk:e==="grok"?"shadowed-global":"none",trustRequired:!1,note:e==="cursor"?"Project rule is authoritative.":e==="copilot"?"Project instruction is authoritative.":"Project skill shadows the same-name global skill inside the project."})}}function I(e){let{agent:o,scope:t,project:r}=e;return(t==="project"||t==="both")&&(!r||!r.eligible)?{agent:o,requestedScope:t,project:r,surfaces:t==="both"?ne(o):re(o),canInstall:!1,reason:"Project scope requires an explicit project, existing ToolNet project, or Git repository root."}:{agent:o,requestedScope:t,project:r,surfaces:t==="global"?Ue(o):t==="project"?re(o):ne(o),canInstall:!0}}import{existsSync as v,readFileSync as B}from"node:fs";import{homedir as Ne}from"node:os";import{join as p,resolve as se}from"node:path";function ce(e={}){return e.copilotHome??process.env.COPILOT_HOME??p(e.home??Ne(),".copilot")}function O(e={}){return p(ce(e),"mcp-config.json")}function Ee(e={}){return p(ce(e),"hooks")}function A(e={}){return p(Ee(e),"toolnet-memory.json")}function G(e){return p(se(e),".github")}function le(e){return p(G(e),"mcp.json")}function ae(e){return p(se(e),".mcp.json")}function He(e){return p(G(e),"hooks")}function ue(e){return p(He(e),"toolnet-memory.json")}function De(e){return p(G(e),"instructions")}function _(e){return p(De(e),"toolnet-memory.instructions.md")}import{homedir as Me}from"node:os";import{join as l,resolve as $e}from"node:path";function L(e={}){return e.grokHome??process.env.GROK_HOME??l(e.home??Me(),".grok")}function T(e={}){return l(L(e),"config.toml")}function Ge(e={}){return l(L(e),"hooks")}function q(e={}){return l(Ge(e),"toolnet-memory.json")}function _e(e={}){return l(L(e),"skills")}function Le(e={}){return l(_e(e),"toolnet-continuity")}function U(e={}){return l(Le(e),"SKILL.md")}function J(e){return l($e(e),".grok")}function pe(e){return l(J(e),"config.toml")}function Je(e){return l(J(e),"hooks")}function fe(e){return l(Je(e),"toolnet-memory.json")}function We(e){return l(J(e),"skills")}function Be(e){return l(We(e),"toolnet-continuity")}function de(e){return l(Be(e),"SKILL.md")}function k(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function P(e){if(!v(e))return{};try{let o=JSON.parse(B(e,"utf8"));return k(o)?{value:o}:{error:"root must be a JSON object"}}catch(o){return{error:o instanceof Error?o.message:String(o)}}}function ge(e,o){if(!e||!k(e.mcpServers))return!1;let t=e.mcpServers["toolnet-memory"];return!k(t)||typeof t.command!="string"||!t.command.trim()||!Array.isArray(t.args)||t.args.length!==1||t.args[0]!=="mcp"?!1:!o||Array.isArray(t.tools)&&t.tools.includes("*")}function me(e,o,t){if(!e||!k(e.hooks))return[];let r=e.hooks;return o.filter(n=>{let i=r[n];return Array.isArray(i)&&i.some(s=>k(s)&&(typeof s.command=="string"&&s.command.includes(t)||typeof s.bash=="string"&&s.bash.includes(t)))})}function Ke(e,o){if(!e||!k(e.hooks))return[];let t=e.hooks;return o.filter(r=>{let n=t[r];return Array.isArray(n)&&n.some(i=>!k(i)||!Array.isArray(i.hooks)?!1:i.hooks.some(s=>k(s)&&typeof s.command=="string"&&s.command.includes("session:grok-hook")))})}function ze(e){if(!v(e))return!1;let o=B(e,"utf8"),t=/\[mcp_servers\.(?:"toolnet-memory"|'toolnet-memory'|toolnet-memory)\]/,r=o.search(t);if(r<0)return!1;let n=o.slice(r),i=n.slice(1).search(/\n\s*\[[^\]]+\]/),s=i>=0?n.slice(0,i+1):n;return/command\s*=\s*"[^"]+"/.test(s)&&/args\s*=\s*\[\s*"mcp"\s*\]/.test(s)&&!/enabled\s*=\s*false/.test(s)}function W(e){let o=[];e.mcpError&&o.push(`MCP config: ${e.mcpError}`),e.hookError&&o.push(`Hooks config: ${e.hookError}`);let t=e.mcpConfigured&&e.hooksConfigured&&(e.skill?.configured??!0),r=v(e.configFile)||v(e.hooksFile)||(e.skill?v(e.skill.skillFile):!1),n=o.length>0?"invalid":t?"ready":r?"partial":"not-installed";return{installed:t,state:n,mcp:{configured:e.mcpConfigured,configFile:e.configFile,error:e.mcpError},hooks:{configured:e.hooksConfigured,hooksFile:e.hooksFile,events:e.events,error:e.hookError},skill:e.skill,errors:o}}function g(e,o={}){if(e==="cursor"){let c=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","afterAgentResponse","stop"],a=o.configFile??F(),j=o.hooksFile??w(),h=P(a),y=P(j),R=y.error?[]:me(y.value,c,"session:cursor-hook");return W({mcpConfigured:!h.error&&ge(h.value,!1),configFile:a,mcpError:h.error,hooksConfigured:c.every(E=>R.includes(E)),hooksFile:j,events:R,hookError:y.error})}if(e==="copilot"){let c=["sessionStart","userPromptSubmitted","userPromptTransformed","preToolUse","postToolUse","agentStop"],a=o.configFile??O(),j=o.hooksFile??A(),h=P(a),y=P(j),R=y.error?[]:me(y.value,c,"session:copilot-hook");return W({mcpConfigured:!h.error&&ge(h.value,!0),configFile:a,mcpError:h.error,hooksConfigured:c.every(E=>R.includes(E)),hooksFile:j,events:R,hookError:y.error})}let t=["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","Stop"],r=o.configFile??T(),n=o.hooksFile??q(),i=o.skillFile??U(),s=P(n),u=s.error?[]:Ke(s.value,t),f=v(i)&&B(i,"utf8").includes("memory_agent_ask");return W({mcpConfigured:ze(r),configFile:r,hooksConfigured:t.every(c=>u.includes(c)),hooksFile:n,events:u,hookError:s.error,skill:{configured:f,skillFile:i}})}function Qe(e){let o=!1;try{o=Xe(e,"utf8")===ee}catch{o=!1}return{configured:o,ruleFile:e}}function Ve(e,o,t){return o.some(n=>n?.state==="invalid")?"invalid":e?"ready":o.some(n=>n&&(n.state==="partial"||n.state==="ready"||K(n.mcp.configFile)||K(n.hooks.hooksFile)))||!!(t&&K(t.ruleFile))?"partial":"not-installed"}function Se(e={}){let o=e.scope??"global",t=o==="global"?void 0:S({project:e.projectRoot}),r=I({agent:"cursor",scope:o,project:t}),n=o==="global"||o==="both"?g("cursor",{configFile:e.globalConfigFile??F(),hooksFile:e.globalHooksFile??w()}):void 0,i;if((o==="project"||o==="both")&&t?.eligible){let a=Qe(e.projectRuleFile??D(t.root));i={...g("cursor",{configFile:e.projectConfigFile??Y(t.root),hooksFile:e.projectHooksFile??Z(t.root)}),rule:a}}let s=o==="project"?!0:n?.installed===!0,u=o==="global"?!0:i?.installed===!0&&i.rule.configured===!0,f=r.canInstall&&s&&u,c=[];return!r.canInstall&&r.reason&&c.push(r.reason),o==="both"&&(c.push("Global + project Cursor hooks are additive; ToolNet runtime dedupe is required and enabled."),c.push("Cursor same-name global/project MCP precedence remains marked for native E2E certification.")),{installed:f,state:Ve(f,[n,i],i?.rule),requestedScope:o,plan:r,project:t,global:n,projectScope:i,dedupeReady:!0,trustRequired:o==="project"||o==="both",warnings:c}}import{existsSync as N,readFileSync as je}from"node:fs";var ke=`---
|
|
28
|
+
`;import{spawnSync as we}from"node:child_process";import{existsSync as b,statSync as xe}from"node:fs";import{dirname as Oe,join as Ae,parse as Ee,resolve as M}from"node:path";function oe(e){let o=M(e);if(!b(o))throw new Error(`Project path does not exist: ${o}`);if(!xe(o).isDirectory())throw new Error(`Project path is not a directory: ${o}`);return o}function x(e){return Ae(e,".toolnet","project.json")}function Te(e){let o=M(e),t=Ee(o).root;for(;;){if(b(x(o)))return o;if(o===t)return;let r=Oe(o);if(r===o)return;o=r}}function D(e){let o=we("git",["rev-parse","--show-toplevel"],{cwd:e,encoding:"utf8",timeout:5e3});if(o.status!==0)return;let t=o.stdout.trim();return t?M(t):void 0}function k(e={}){let o=oe(e.cwd??process.cwd());if(e.project){let n=oe(e.project),i=x(n),s=D(n);return{root:n,source:"explicit",eligible:!0,toolnetProject:b(i),manifestFile:b(i)?i:void 0,gitRoot:s}}let t=Te(o);if(t){let n=x(t);return{root:t,source:"toolnet",eligible:!0,toolnetProject:!0,manifestFile:n,gitRoot:D(t)}}let r=D(o);if(r){let n=x(r);return{root:r,source:"git",eligible:!0,toolnetProject:b(n),manifestFile:b(n)?n:void 0,gitRoot:r}}return{root:o,source:"cwd",eligible:!1,toolnetProject:!1}}function ie(e,o={}){let t=[],r=e.indexOf("--scope");if(r>=0){let i=e[r+1];if(i!=="global"&&i!=="project"&&i!=="both")throw new Error(`Invalid --scope value: ${String(i)}`);t.push(i)}e.includes("--global")&&t.push("global"),e.includes("--both")&&t.push("both");let n=Array.from(new Set(t));if(n.length>1)throw new Error(`Conflicting integration scopes: ${n.join(", ")}`);return n[0]??o.defaultScope??"global"}function te(e,o){return{install:e,effective:o}}function f(e,o){return{surface:e,global:te(o.globalInstall,o.effective==="global"||o.effective==="both"),project:te(o.projectInstall,o.effective==="project"||o.effective==="both"),effective:o.effective,risk:o.risk??"none",dedupeRequired:o.dedupeRequired??!1,trustRequired:o.trustRequired??o.projectInstall,note:o.note}}function Ue(e){return{mcp:f("mcp",{globalInstall:!0,projectInstall:!1,effective:"global"}),hooks:f("hooks",{globalInstall:!0,projectInstall:!1,effective:"global"}),work:f("work",{globalInstall:e==="grok",projectInstall:!1,effective:e==="grok"?"global":"none",note:e==="grok"?"Grok supports a global ToolNet continuity skill.":"Cursor/Copilot work instructions remain project-scoped."})}}function re(e){return{mcp:f("mcp",{globalInstall:!1,projectInstall:!0,effective:"project",trustRequired:!0}),hooks:f("hooks",{globalInstall:!1,projectInstall:!0,effective:"project",trustRequired:!0}),work:f("work",{globalInstall:!1,projectInstall:!0,effective:"project",trustRequired:!1,note:e==="cursor"?"Use .cursor/rules/toolnet-memory.mdc.":e==="copilot"?"Use .github/instructions/toolnet-memory.instructions.md.":"Use .grok/skills/toolnet-continuity/SKILL.md."})}}function ne(e){return{mcp:f("mcp",{globalInstall:!0,projectInstall:!0,effective:"project",risk:e==="cursor"?"precedence-unverified":"shadowed-global",trustRequired:!0,note:e==="cursor"?"Project ToolNet MCP is the intended effective definition; native same-name precedence must be E2E certified before release.":"Global remains useful outside the project; same-name project definition wins inside the project."}),hooks:f("hooks",{globalInstall:!0,projectInstall:!0,effective:"both",risk:"additive-duplicate",dedupeRequired:!0,trustRequired:!0,note:"Global and project hook sources can both execute for the same native event."}),work:f("work",{globalInstall:e==="grok",projectInstall:!0,effective:"project",risk:e==="grok"?"shadowed-global":"none",trustRequired:!1,note:e==="cursor"?"Project rule is authoritative.":e==="copilot"?"Project instruction is authoritative.":"Project skill shadows the same-name global skill inside the project."})}}function I(e){let{agent:o,scope:t,project:r}=e;return(t==="project"||t==="both")&&(!r||!r.eligible)?{agent:o,requestedScope:t,project:r,surfaces:t==="both"?ne(o):re(o),canInstall:!1,reason:"Project scope requires an explicit project, existing ToolNet project, or Git repository root."}:{agent:o,requestedScope:t,project:r,surfaces:t==="global"?Ue(o):t==="project"?re(o):ne(o),canInstall:!0}}import{existsSync as v,readFileSync as K}from"node:fs";import{homedir as Ne}from"node:os";import{join as p,resolve as se}from"node:path";function ce(e={}){return e.copilotHome??process.env.COPILOT_HOME??p(e.home??Ne(),".copilot")}function O(e={}){return p(ce(e),"mcp-config.json")}function qe(e={}){return p(ce(e),"hooks")}function A(e={}){return p(qe(e),"toolnet-memory.json")}function $(e){return p(se(e),".github")}function le(e){return p($(e),"mcp.json")}function ae(e){return p(se(e),".mcp.json")}function He(e){return p($(e),"hooks")}function ue(e){return p(He(e),"toolnet-memory.json")}function _e(e){return p($(e),"instructions")}function G(e){return p(_e(e),"toolnet-memory.instructions.md")}import{homedir as De}from"node:os";import{join as l,resolve as Me}from"node:path";function L(e={}){return e.grokHome??process.env.GROK_HOME??l(e.home??De(),".grok")}function E(e={}){return l(L(e),"config.toml")}function $e(e={}){return l(L(e),"hooks")}function T(e={}){return l($e(e),"toolnet-memory.json")}function Ge(e={}){return l(L(e),"skills")}function Le(e={}){return l(Ge(e),"toolnet-continuity")}function U(e={}){return l(Le(e),"SKILL.md")}function J(e){return l(Me(e),".grok")}function pe(e){return l(J(e),"config.toml")}function Je(e){return l(J(e),"hooks")}function de(e){return l(Je(e),"toolnet-memory.json")}function We(e){return l(J(e),"skills")}function Ke(e){return l(We(e),"toolnet-continuity")}function fe(e){return l(Ke(e),"SKILL.md")}function S(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function P(e){if(!v(e))return{};try{let o=JSON.parse(K(e,"utf8"));return S(o)?{value:o}:{error:"root must be a JSON object"}}catch(o){return{error:o instanceof Error?o.message:String(o)}}}function ge(e,o){if(!e||!S(e.mcpServers))return!1;let t=e.mcpServers["toolnet-memory"];return!S(t)||typeof t.command!="string"||!t.command.trim()||!Array.isArray(t.args)||t.args.length!==1||t.args[0]!=="mcp"?!1:!o||Array.isArray(t.tools)&&t.tools.includes("*")}function me(e,o,t){if(!e||!S(e.hooks))return[];let r=e.hooks;return o.filter(n=>{let i=r[n];return Array.isArray(i)&&i.some(s=>S(s)&&(typeof s.command=="string"&&s.command.includes(t)||typeof s.bash=="string"&&s.bash.includes(t)))})}function Be(e,o){if(!e||!S(e.hooks))return[];let t=e.hooks;return o.filter(r=>{let n=t[r];return Array.isArray(n)&&n.some(i=>!S(i)||!Array.isArray(i.hooks)?!1:i.hooks.some(s=>S(s)&&typeof s.command=="string"&&s.command.includes("session:grok-hook")))})}function ze(e){if(!v(e))return!1;let o=K(e,"utf8"),t=/\[mcp_servers\.(?:"toolnet-memory"|'toolnet-memory'|toolnet-memory)\]/,r=o.search(t);if(r<0)return!1;let n=o.slice(r),i=n.slice(1).search(/\n\s*\[[^\]]+\]/),s=i>=0?n.slice(0,i+1):n;return/command\s*=\s*"[^"]+"/.test(s)&&/args\s*=\s*\[\s*"mcp"\s*\]/.test(s)&&!/enabled\s*=\s*false/.test(s)}function W(e){let o=[];e.mcpError&&o.push(`MCP config: ${e.mcpError}`),e.hookError&&o.push(`Hooks config: ${e.hookError}`);let t=e.mcpConfigured&&e.hooksConfigured&&(e.skill?.configured??!0),r=v(e.configFile)||v(e.hooksFile)||(e.skill?v(e.skill.skillFile):!1),n=o.length>0?"invalid":t?"ready":r?"partial":"not-installed";return{installed:t,state:n,mcp:{configured:e.mcpConfigured,configFile:e.configFile,error:e.mcpError},hooks:{configured:e.hooksConfigured,hooksFile:e.hooksFile,events:e.events,error:e.hookError},skill:e.skill,errors:o}}function g(e,o={}){if(e==="cursor"){let c=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","afterAgentResponse","stop"],a=o.configFile??F(),j=o.hooksFile??w(),y=P(a),h=P(j),C=h.error?[]:me(h.value,c,"session:cursor-hook");return W({mcpConfigured:!y.error&&ge(y.value,!1),configFile:a,mcpError:y.error,hooksConfigured:c.every(q=>C.includes(q)),hooksFile:j,events:C,hookError:h.error})}if(e==="copilot"){let c=["sessionStart","userPromptSubmitted","userPromptTransformed","preToolUse","postToolUse","agentStop"],a=o.configFile??O(),j=o.hooksFile??A(),y=P(a),h=P(j),C=h.error?[]:me(h.value,c,"session:copilot-hook");return W({mcpConfigured:!y.error&&ge(y.value,!0),configFile:a,mcpError:y.error,hooksConfigured:c.every(q=>C.includes(q)),hooksFile:j,events:C,hookError:h.error})}let t=["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","Stop"],r=o.configFile??E(),n=o.hooksFile??T(),i=o.skillFile??U(),s=P(n),u=s.error?[]:Be(s.value,t),d=v(i)&&K(i,"utf8").includes("memory_agent_ask");return W({mcpConfigured:ze(r),configFile:r,hooksConfigured:t.every(c=>u.includes(c)),hooksFile:n,events:u,hookError:s.error,skill:{configured:d,skillFile:i}})}function Xe(e){let o=!1;try{o=Ve(e,"utf8")===ee}catch{o=!1}return{configured:o,ruleFile:e}}function Ye(e,o,t){return o.some(n=>n?.state==="invalid")?"invalid":e?"ready":o.some(n=>n&&(n.state==="partial"||n.state==="ready"||B(n.mcp.configFile)||B(n.hooks.hooksFile)))||!!(t&&B(t.ruleFile))?"partial":"not-installed"}function ke(e={}){let o=e.scope??"global",t=o==="global"?void 0:k({project:e.projectRoot}),r=I({agent:"cursor",scope:o,project:t}),n=o==="global"||o==="both"?g("cursor",{configFile:e.globalConfigFile??F(),hooksFile:e.globalHooksFile??w()}):void 0,i;if((o==="project"||o==="both")&&t?.eligible){let a=Xe(e.projectRuleFile??_(t.root));i={...g("cursor",{configFile:e.projectConfigFile??Q(t.root),hooksFile:e.projectHooksFile??Z(t.root)}),rule:a}}let s=o==="project"?!0:n?.installed===!0,u=o==="global"?!0:i?.installed===!0&&i.rule.configured===!0,d=r.canInstall&&s&&u,c=[];return!r.canInstall&&r.reason&&c.push(r.reason),o==="both"&&(c.push("Global + project Cursor hooks are additive; ToolNet runtime dedupe is required and enabled."),c.push("Cursor same-name global/project MCP precedence remains marked for native E2E certification.")),{installed:d,state:Ye(d,[n,i],i?.rule),requestedScope:o,plan:r,project:t,global:n,projectScope:i,dedupeReady:!0,trustRequired:o==="project"||o==="both",warnings:c}}import{existsSync as N,readFileSync as je}from"node:fs";var Se=`---
|
|
29
29
|
applyTo: "**"
|
|
30
30
|
---
|
|
31
31
|
|
|
@@ -51,5 +51,5 @@ Use ToolNet Memory as the continuity source for this repository.
|
|
|
51
51
|
- Do not ask the user to repeat context ToolNet already provides.
|
|
52
52
|
|
|
53
53
|
Current repository evidence overrides stale memory.
|
|
54
|
-
`;function
|
|
55
|
-
`)}function
|
|
54
|
+
`;function Qe(e){let o=!1;try{o=je(e,"utf8")===Se}catch{o=!1}return{configured:o,instructionFile:e}}function Ze(e){let o=ae(e);if(!N(o))return{file:o,toolnetDefined:!1};try{let t=JSON.parse(je(o,"utf8")),r=t.mcpServers&&typeof t.mcpServers=="object"&&!Array.isArray(t.mcpServers)?t.mcpServers:{};return{file:o,toolnetDefined:r["toolnet-memory"]!==void 0||r.toolnet!==void 0}}catch{return{file:o,toolnetDefined:!1}}}function eo(e,o,t){return o.some(n=>n?.state==="invalid")?"invalid":e?"ready":o.some(n=>n&&(n.state==="partial"||n.state==="ready"||N(n.mcp.configFile)||N(n.hooks.hooksFile)))||!!(t&&N(t.instructionFile))?"partial":"not-installed"}function ye(e={}){let o=e.scope??"global",t=o==="global"?void 0:k({project:e.projectRoot}),r=I({agent:"copilot",scope:o,project:t}),n=o==="global"||o==="both"?g("copilot",{configFile:e.globalConfigFile??O(),hooksFile:e.globalHooksFile??A()}):void 0,i;if((o==="project"||o==="both")&&t?.eligible){let j=Qe(e.projectInstructionFile??G(t.root));i={...g("copilot",{configFile:e.projectConfigFile??le(t.root),hooksFile:e.projectHooksFile??ue(t.root)}),instruction:j}}let s=o==="project"?!0:n?.installed===!0,u=o==="global"?!0:i?.installed===!0&&i.instruction.configured===!0,d=r.canInstall&&s&&u,c=t?.eligible?Ze(t.root):null,a=[];return!r.canInstall&&r.reason&&a.push(r.reason),o==="both"&&(a.push("Global + project Copilot hooks are additive; ToolNet cross-process dedupe is enabled."),a.push("Project toolnet-memory MCP shadows the same-name global definition inside this repository.")),c?.toolnetDefined&&a.push(`Alternate repository MCP file also defines ToolNet: ${c.file}`),{installed:d,state:eo(d,[n,i],i?.instruction),requestedScope:o,plan:r,project:t,global:n,projectScope:i,dedupeReady:!0,trustRequired:o==="project"||o==="both",alternateProjectMcp:c,warnings:a}}import{existsSync as z}from"node:fs";function oo(e,o){return o.some(r=>r?.state==="invalid")?"invalid":e?"ready":o.some(r=>r&&(r.state==="partial"||r.state==="ready"||z(r.mcp.configFile)||z(r.hooks.hooksFile)||!!(r.skill&&z(r.skill.skillFile))))?"partial":"not-installed"}function he(e={}){let o=e.scope??"global",t=o==="global"?void 0:k({project:e.projectRoot}),r=I({agent:"grok",scope:o,project:t}),n=o==="global"||o==="both"?g("grok",{configFile:e.globalConfigFile??E(),hooksFile:e.globalHooksFile??T(),skillFile:e.globalSkillFile??U()}):void 0,i=(o==="project"||o==="both")&&t?.eligible?g("grok",{configFile:e.projectConfigFile??pe(t.root),hooksFile:e.projectHooksFile??de(t.root),skillFile:e.projectSkillFile??fe(t.root)}):void 0,s=o==="project"?!0:n?.installed===!0,u=o==="global"?!0:i?.installed===!0,d=r.canInstall&&s&&u,c=[];return!r.canInstall&&r.reason&&c.push(r.reason),o==="both"&&(c.push("Global + project Grok hooks are layered; ToolNet cross-process dedupe is enabled."),c.push('Project [mcp_servers."toolnet-memory"] fully replaces the same-name global server inside this project.'),c.push("Project toolnet-continuity skill shadows the same-name global skill inside this project.")),{installed:d,state:oo(d,[n,i]),requestedScope:o,plan:r,project:t,global:n,projectScope:i,effective:{mcp:r.surfaces.mcp.effective==="project"?"project":r.surfaces.mcp.effective==="global"?"global":"none",hooks:r.surfaces.hooks.effective==="both"?"both":r.surfaces.hooks.effective==="project"?"project":r.surfaces.hooks.effective==="global"?"global":"none",skill:r.surfaces.work.effective==="project"?"project":r.surfaces.work.effective==="global"?"global":"none"},dedupeReady:!0,trustRequired:o==="project"||o==="both",warnings:c}}var to={cursor:ke,copilot:ye,grok:he},V={cursor:"Cursor CLI",copilot:"GitHub Copilot CLI",grok:"Grok Build"};function R(e,o){if(e)return{configured:e.installed&&(o?.configured??!0),mcp:{configured:e.mcp.configured,file:e.mcp.configFile},hooks:{configured:e.hooks.configured,file:e.hooks.hooksFile,events:e.hooks.events},work:o}}function ro(e){let o=e.projectScope?{kind:"rule",configured:e.projectScope.rule.configured,file:e.projectScope.rule.ruleFile}:void 0;return{agent:"cursor",label:V.cursor,installed:e.installed,state:e.state,requestedScope:e.requestedScope,projectRoot:e.project?.root,global:R(e.global),project:R(e.projectScope,o),effective:{mcp:e.plan.surfaces.mcp.effective,hooks:e.plan.surfaces.hooks.effective,work:e.plan.surfaces.work.effective},risk:{mcp:e.plan.surfaces.mcp.risk,hooks:e.plan.surfaces.hooks.risk,work:e.plan.surfaces.work.risk},trust:{required:e.trustRequired,state:e.trustRequired?"required-unverified":"not-required"},dedupe:{required:e.plan.surfaces.hooks.dedupeRequired,ready:e.dedupeReady},warnings:[...e.warnings]}}function no(e){let o=e.projectScope?{kind:"instruction",configured:e.projectScope.instruction.configured,file:e.projectScope.instruction.instructionFile}:void 0;return{agent:"copilot",label:V.copilot,installed:e.installed,state:e.state,requestedScope:e.requestedScope,projectRoot:e.project?.root,global:R(e.global),project:R(e.projectScope,o),effective:{mcp:e.plan.surfaces.mcp.effective,hooks:e.plan.surfaces.hooks.effective,work:e.plan.surfaces.work.effective},risk:{mcp:e.plan.surfaces.mcp.risk,hooks:e.plan.surfaces.hooks.risk,work:e.plan.surfaces.work.risk},trust:{required:e.trustRequired,state:e.trustRequired?"required-unverified":"not-required"},dedupe:{required:e.plan.surfaces.hooks.dedupeRequired,ready:e.dedupeReady},warnings:[...e.warnings]}}function io(e){let o=e.global?.skill?{kind:"skill",configured:e.global.skill.configured,file:e.global.skill.skillFile}:void 0,t=e.projectScope?.skill?{kind:"skill",configured:e.projectScope.skill.configured,file:e.projectScope.skill.skillFile}:void 0;return{agent:"grok",label:V.grok,installed:e.installed,state:e.state,requestedScope:e.requestedScope,projectRoot:e.project?.root,global:R(e.global,o),project:R(e.projectScope,t),effective:{mcp:e.plan.surfaces.mcp.effective,hooks:e.plan.surfaces.hooks.effective,work:e.plan.surfaces.work.effective},risk:{mcp:e.plan.surfaces.mcp.risk,hooks:e.plan.surfaces.hooks.risk,work:e.plan.surfaces.work.risk},trust:{required:e.trustRequired,state:e.trustRequired?"required-unverified":"not-required"},dedupe:{required:e.plan.surfaces.hooks.dedupeRequired,ready:e.dedupeReady},warnings:[...e.warnings]}}function so(e){return e.some(o=>o.state==="invalid")?"invalid":e.length>0&&e.every(o=>o.installed)?"ready":e.every(o=>o.state==="not-installed")?"not-installed":"partial"}function be(e={},o=to){let t=e.scope??"global",n=(e.agents??["cursor","copilot","grok"]).map(s=>s==="cursor"?ro(o.cursor({scope:t,projectRoot:e.projectRoot})):s==="copilot"?no(o.copilot({scope:t,projectRoot:e.projectRoot})):io(o.grok({scope:t,projectRoot:e.projectRoot}))),i=so(n);return{installed:n.length>0&&n.every(s=>s.installed),state:i,requestedScope:t,projectRoot:e.projectRoot??n.find(s=>s.projectRoot)?.projectRoot,agents:n,summary:{total:n.length,ready:n.filter(s=>s.state==="ready").length,partial:n.filter(s=>s.state==="partial").length,invalid:n.filter(s=>s.state==="invalid").length,missing:n.filter(s=>s.state==="not-installed").length}}}function X(e){return e?"ready":"missing"}function co(e){return e.work?`${e.work.kind} ${X(e.work.configured)} \u2014 ${e.work.file}`:"n/a"}function Ie(e,o){return o?[` ${e}`,` MCP ${X(o.mcp.configured)} \u2014 ${o.mcp.file}`,` Hooks ${X(o.hooks.configured)} \u2014 ${o.hooks.file}`,` Work ${co(o)}`]:[` ${e.padEnd(8)} not selected`]}function lo(e){let o=[];o.push(`${e.label} \u2014 ${e.state.toUpperCase()}`),o.push(...Ie("Global",e.global)),o.push(...Ie("Project",e.project)),o.push(` Effective MCP=${e.effective.mcp} Hooks=${e.effective.hooks} Work=${e.effective.work}`),o.push(` Dedupe ${e.dedupe.ready?"ready":"missing"}${e.dedupe.required?" (required)":" (not required)"}`),o.push(` Trust ${e.trust.state==="required-unverified"?"required / native trust unverified":"not required"}`),o.push(` Risk MCP=${e.risk.mcp} Hooks=${e.risk.hooks} Work=${e.risk.work}`);for(let t of e.warnings)o.push(` Note ${t}`);return o}function ve(e){let o=[];return o.push("ToolNet Scoped Integrations"),o.push("==========================="),o.push(""),o.push(`State : ${e.state}`),o.push(`Scope : ${e.requestedScope}`),e.projectRoot&&o.push(`Project : ${e.projectRoot}`),o.push(""),e.agents.forEach((t,r)=>{o.push(...lo(t)),r<e.agents.length-1&&o.push("")}),o.push(""),o.push(`Summary : ${e.summary.ready}/${e.summary.total} ready | ${e.summary.partial} partial | ${e.summary.invalid} invalid | ${e.summary.missing} missing`),o.push(""),o.join(`
|
|
55
|
+
`)}function Re(e,o){let t=e.indexOf(o);return t>=0?e[t+1]:void 0}function ao(e){let o=Re(e,"--agent");if(o){if(o!=="cursor"&&o!=="copilot"&&o!=="grok")throw new Error(`Invalid --agent value: ${o}`);return[o]}}function uo(){let e=process.argv.slice(2),o=e.includes("--json"),t=ie(e),r=Re(e,"--project"),n=ao(e),i=t==="global"?void 0:k({project:r}),s={scope:t,projectRoot:i?.root,agents:n},u=be(s);console.log(o?JSON.stringify(u,null,2):ve(u)),u.installed||(process.exitCode=1)}try{uo()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}
|