@cachly-dev/mcp-server 0.10.181 → 0.10.183
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 +7 -3
- package/dist/src/ambient-hook.js +2 -2
- package/dist/src/ambient-hooks.js +9 -9
- package/dist/src/codex-hook.js +1 -0
- package/dist/src/copilot-hook.js +1 -0
- package/dist/src/gemini-hook.js +1 -0
- package/dist/src/hook-zugang.js +1 -1
- package/dist/src/index.js +138 -137
- package/dist/src/rangfolge-stellschrauben.js +1 -1
- package/glama.json +1 -1
- package/hooks/cachly-ambient-einblendung.mjs +20 -17
- package/package.json +1 -1
- package/server.json +2 -2
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|

|
|
11
11
|
|
|
12
12
|
`@cachly-dev/mcp-server` connects [cachly](https://cachly.dev) to Claude Code, Cursor,
|
|
13
|
-
GitHub Copilot, Windsurf, Cline, Continue.dev and
|
|
13
|
+
GitHub Copilot, Windsurf, Cline, Continue.dev, Zed, Codex CLI and Gemini CLI over
|
|
14
14
|
[MCP](https://modelcontextprotocol.io). It offers 124 MCP tools. Your AI stores a
|
|
15
15
|
lesson after a fix, and finds it again when the same problem returns. Your Brain
|
|
16
16
|
(the store of your lessons) lives on EU servers.
|
|
@@ -104,6 +104,8 @@ entry points at this npm package.
|
|
|
104
104
|
|-------|---------------------|
|
|
105
105
|
| [Claude Code hooks: which event to use when](https://cachly.dev/docs/claude-code-hooks) | `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `Stop` and more, sorted by when they fire. What each one can block, add and change. |
|
|
106
106
|
| [A UserPromptSubmit hook for Claude Code](https://cachly.dev/docs/claude-code-hooks/userpromptsubmit) | The stdin JSON, `additionalContext`, a working Node script and five traps to avoid. |
|
|
107
|
+
| The same hooks in [VS Code and Copilot CLI](https://cachly.dev/docs/claude-code-hooks#vscode), [Codex CLI](https://cachly.dev/docs/claude-code-hooks#codex) and [Gemini CLI](https://cachly.dev/docs/claude-code-hooks#gemini) | Which event takes context in each editor, and the exact file `setup` writes there. |
|
|
108
|
+
| Comparisons: [Supermemory](https://cachly.dev/docs/cachly-vs-supermemory), [Zep](https://cachly.dev/docs/cachly-vs-zep), [claude-mem](https://cachly.dev/docs/cachly-vs-claude-mem), [Basic Memory](https://cachly.dev/docs/cachly-vs-basic-memory), [mem0](https://cachly.dev/docs/cachly-vs-mem0), [Letta](https://cachly.dev/docs/cachly-vs-letta) | Side by side, each row with its source and a visible date, including when the other product fits better. |
|
|
107
109
|
| [EU-hosted MCP server: what leaves your machine](https://cachly.dev/docs/eu-hosted-mcp-memory-server) | Where data lands: storage in Germany, embeddings in the EU, the network edge, and a checklist. |
|
|
108
110
|
| [Lessons learned for coding agents](https://cachly.dev/docs/coding-agent-lessons-learned) | How to write a lesson your agent finds again: symptom, decisive fact first, what failed, files, a check. With examples and a `LESSONS.md`. |
|
|
109
111
|
| [JetBrains plugin guide](https://cachly.dev/docs/jetbrains) | What the plugin does, and how Claude Code, Junie and JetBrains AI Assistant use the Brain. |
|
|
@@ -309,9 +311,11 @@ Manual snippets are in [Manual Setup](#manual-setup).
|
|
|
309
311
|
| Editor / client | Auto-setup | Config file written | Global config | Notes |
|
|
310
312
|
|---|---|---|---|---|
|
|
311
313
|
| **Claude Code** | yes | `~/.claude/mcp.json` + `.mcp.json` | yes, always | Without a key: test Brain on the first tool call; browser sign-in only as fallback |
|
|
312
|
-
| **Cursor** | yes, detected via `.cursor/` | `.cursor/mcp.json` | no | Project-level; restart Cursor after setup |
|
|
314
|
+
| **Cursor** | yes, detected via `.cursor/` | `.cursor/mcp.json`, hooks in `.cursor/hooks.json` | no | Project-level; restart Cursor after setup. Lessons arrive with the first tool call of a turn |
|
|
313
315
|
| **Windsurf** | yes, detected via `.windsurf/` | `.windsurf/mcp.json` | no | Project-level; restart Windsurf after setup |
|
|
314
|
-
| **VS Code + Copilot** | yes, detected via `.vscode/` | `.vscode/mcp.json` | no | Needs the VS Code MCP support or Copilot chat |
|
|
316
|
+
| **VS Code + Copilot** | yes, detected via `.vscode/` | `.vscode/mcp.json`, hooks in `.github/hooks/cachly-ambient.json` | no | Needs the VS Code MCP support or Copilot chat. Briefing at session start, lessons before each prompt |
|
|
317
|
+
| **Codex CLI** | hooks yes, detected via `~/.codex` | hooks in `.codex/hooks.json` | no | Trust `.codex/` and confirm the hook once in `/hooks`. For the tools, `init --editor codex` prints the `codex mcp add` line |
|
|
318
|
+
| **Gemini CLI** | hooks yes, detected via `~/.gemini` | `hooks` in `.gemini/settings.json` | no | Lessons are appended to the prompt (`BeforeAgent`). For the tools, `init --editor gemini` prints the `gemini mcp add` line |
|
|
315
319
|
| **Cline** | yes, detected via VS Code | `.vscode/mcp.json` | no | Shares the config with Copilot; restart VS Code |
|
|
316
320
|
| **Continue.dev** | yes, detected via `.continue/` | `.continue/config.json` | no | Uses the `modelContextProtocolServers` key |
|
|
317
321
|
| **Zed** | yes, detected via `.zed/` | `.zed/settings.json` | no | Uses the `context_servers` key |
|
package/dist/src/ambient-hook.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readFileSync as
|
|
2
|
-
`),
|
|
1
|
+
import{readFileSync as P}from"node:fs";import{parseHookPayload as g,runEinblendung as U,stopLernanfrage as k,stopObservation as y}from"./ambient-cli.js";import{stopAntwort as O}from"./schreibbeleg.js";import{holeBestand as I}from"./einblendung.js";import{appendLedgerEntry as T,reportLedgerEntry as E}from"./ambient-ledger.js";import{copilotHatHook as F,cursorHatHook as C,findeInstanz as S,findeSchluessel as _,hookUmfeld as h,projektHatHook as v}from"./hook-zugang.js";import{CURSOR_FLAG as l,cursorEreignis as w,cursorHookAntwort as R,cursorLeer as j,istCursorNutzlast as x}from"./cursor-hook.js";import{COPILOT_FLAG as b,copilotEreignis as N,copilotHookAntwort as G,istFremdeLaufzeit as z}from"./copilot-hook.js";import{CODEX_FLAG as B,codexHookAntwort as D}from"./codex-hook.js";import{GEMINI_FLAG as A,geminiEreignis as Y,geminiHookAntwort as K}from"./gemini-hook.js";const M="https://api.cachly.dev",$="ambient-auffrischen",H=new Set(["SessionStart","UserPromptSubmit","PreToolUse","Stop"]);async function J(t,e){if(!t.args.includes(l)&&(w(e,t.args)!=="sessionStart"||C(t.umfeld)))return"";const o=t.args.filter(n=>n==="--plugin");return R({payload:e,args:t.args,claudeLauf:(n,u)=>p({...t,raw:n,args:[u,...o]}),ablageOrdner:t.cursorAblage})}function V(t,e){const r=(o,n)=>p({...t,raw:o,args:[n]});return t.args.includes(b)?G({payload:e,args:t.args,claudeLauf:r,ablageOrdner:t.copilotAblage}):t.args.includes(B)?D({payload:e,args:t.args,claudeLauf:r}):t.args.includes(A)?K({payload:e,args:t.args,claudeLauf:r}):null}async function p(t){try{const e=g(t.raw);if(t.args.includes(l)||x(e))return await J(t,e);const r=V(t,e);if(r)return await r;const o=e?.hook_event_name??t.args.find(i=>H.has(i))??t.umfeld.env.CACHLY_HOOK_EVENT??"";if(z(e)&&(o!=="SessionStart"&&o!=="UserPromptSubmit"||F(t.umfeld))||t.args.includes("--plugin")&&o&&v(o,t.umfeld))return"";if(o==="Stop"&&e?.transcript_path)try{const i=P(e.transcript_path,"utf-8").split(`
|
|
2
|
+
`),f=O(i,e.stop_hook_active===!0);if(f)return f}catch{}const n=_(t.umfeld),u=S(t.umfeld);if(!n||!u)return"";const c={apiUrl:t.apiUrl,jwt:n,instanceId:u};if(o==="Stop"){const i=e?y(e):null;return i&&await(t.fetchFn??fetch)(`${c.apiUrl}/api/v1/instances/${c.instanceId}/learn`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c.jwt}`},body:JSON.stringify(k(i)),signal:AbortSignal.timeout(8e3)}).catch(()=>{}),""}let a;const s=await(t.einblenden??U)(t.raw,{cfg:c,nebenlauf:t.selbst?[t.selbst,$]:void 0,fetchFn:t.fetchFn,onInject:(i,f)=>{const m={ts:new Date().toISOString(),event:f,injected:i,prevented:0};T(m),a=E(c,m,t.fetchFn)}});return a&&await Promise.race([a,new Promise(i=>setTimeout(i,500))]),s}catch{return""}}async function X(){if(process.stdin.isTTY)return"";const t=[];for await(const e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function L(){return process.env.CACHLY_API_URL||M}const d={SessionStart:25e3,UserPromptSubmit:8e3,PreToolUse:8e3,Stop:5e4,sessionStart:25e3,beforeSubmitPrompt:8e3,postToolUse:3e3,userPromptSubmitted:8e3,PostToolUse:3e3,BeforeAgent:8e3};function q(t,e){return t.includes(l)?j(w(e,t)):t.includes(b)?N(e,t)?"{}":"":t.includes(A)&&Y(e,t)?"{}":""}async function ct(t,e){try{const r=await X(),o=g(r),n=o?.hook_event_name??t.find(s=>H.has(s)||Object.hasOwn(d,s))??"",u=Number(process.env.CACHLY_HOOK_FRIST_MS)||d[n]||d.UserPromptSubmit,c=q(t,o),a=await Promise.race([p({args:t,raw:r,umfeld:h(),apiUrl:L(),selbst:e}),new Promise(s=>setTimeout(()=>s(c),u))]);a&&await new Promise(s=>process.stdout.write(a,()=>s()))}catch{}process.exit(0)}async function ut(){try{const t=h(),e=_(t),r=S(t);e&&r&&await I({apiUrl:L(),jwt:e,instanceId:r},{force:!0})}catch{}process.exit(0)}export{$ as AUFFRISCHEN,d as HOOK_FRIST_MS,M as STANDARD_API_URL,ut as auffrischenHauptlauf,p as hookAntwort,ct as hookHauptlauf};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{existsSync as
|
|
2
|
-
`)}function
|
|
3
|
-
`&&(
|
|
4
|
-
`,"utf-8"),await
|
|
5
|
-
`,"utf-8")),{sessionStartPath:
|
|
6
|
-
`)}function
|
|
7
|
-
`,c=async p=>{try{return await
|
|
8
|
-
`,"utf-8")
|
|
9
|
-
`}export{
|
|
1
|
+
import{existsSync as H,readFileSync as R}from"node:fs";import{readFile as A,writeFile as k,chmod as D,mkdir as y}from"node:fs/promises";import{dirname as j,resolve as l}from"node:path";import{fileURLToPath as et}from"node:url";import{CURSOR_FLAG as rt}from"./cursor-hook.js";import{COPILOT_FLAG as nt,COPILOT_HOOK_EVENTS as st}from"./copilot-hook.js";import{CODEX_FLAG as it,CODEX_HOOK_EVENTS as ct}from"./codex-hook.js";import{GEMINI_FLAG as at,GEMINI_HOOK_EVENTS as ut}from"./gemini-hook.js";import{istCachlyEintrag as L}from"./hook-zugang.js";const G="v5",Zt="ambient-recall",S="cachly-ambient-einblendung.mjs";function E(t){return t.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function P(t,o){return["#!/usr/bin/env node",`// cachly Ambient Recall \u2014 ${t} ${G}`,"// Pushes relevant memory into context automatically. Cross-platform Node hook","// (no shell script \u2014 runs identically on Windows/macOS/Linux). Never blocks","// the agent: every failure path exits 0 with no output (graceful degrade).",`// Runs the hook bundle next to this file (${S}) in this process.`,`process.env.CACHLY_BRAIN_INSTANCE_ID = '${E(o.instanceId)}';`,`process.env.CACHLY_HOOK_EVENT = '${E(t)}';`,`process.argv.splice(2, process.argv.length, '${E(t)}');`,"try {",` await import('./${S}');`,"} catch {"," process.exit(0);","}"].join(`
|
|
2
|
+
`)}function M(){const t=j(et(import.meta.url));for(const o of[l(t,"..",w,S),l(t,"..","..",w,S)])if(H(o))return o;return null}function mt(t){return P("SessionStart",t)}function pt(t){return P("UserPromptSubmit",t)}function lt(t){return P("PreToolUse",t)}function St(t){return P("Stop",t)}const ft={SessionStart:30,UserPromptSubmit:10,PreToolUse:10,Stop:60},ht="Edit|Write|MultiEdit|NotebookEdit";function v(t,o){const e=(r,s,u)=>({...u?{matcher:u}:{},hooks:[{type:"command",command:`node "${s}"${o?` ${o(r)}`:""}`,timeout:ft[r]}]}),n={SessionStart:[e("SessionStart",t.sessionStart)],UserPromptSubmit:[e("UserPromptSubmit",t.userPromptSubmit)]};return t.preToolUse&&(n.PreToolUse=[e("PreToolUse",t.preToolUse,ht)]),t.stop&&(n.Stop=[e("Stop",t.stop)]),n}const K=".claude/hooks",dt=".claude/settings.json",J={SessionStart:"cachly-ambient-session-start.mjs",UserPromptSubmit:"cachly-ambient-prompt-submit.mjs",PreToolUse:"cachly-ambient-pre-tool.mjs",Stop:"cachly-ambient-stop.mjs"},bt=".claude/hooks/cachly-ambient-";function kt(t,o){const e=t.hooks??[];return e.length>0&&e.every(n=>{const r=n.command??"";return r.includes(bt)||o.has(r)||[...o].some(s=>r.includes(`"${s}"`))})}function gt(t,o){const e={...t,hooks:{...t.hooks??{}}},n=e.hooks,r=v(o),s=new Set([o.sessionStart,o.userPromptSubmit,o.preToolUse,o.stop].filter(c=>!!c));for(const[c,i]of Object.entries(r)){const a=(Array.isArray(n[c])?n[c]:[]).filter(f=>!kt(f,s));n[c]=[...a,...i]}const u=JSON.stringify(e)!==JSON.stringify(t);return{settings:e,changed:u}}async function qt(t,o,e,n={}){const r=l(t,K);await y(r,{recursive:!0});const s={instanceId:o,apiKey:e},u=["SessionStart","UserPromptSubmit","PreToolUse","Stop"],c={SessionStart:mt(s),UserPromptSubmit:pt(s),PreToolUse:lt(s),Stop:St(s)},i=m=>l(r,J[m]),a=M();if(!a)throw new Error(`cachly hook bundle ${S} missing from the package`);const f=R(a,"utf-8"),b=l(r,S),g=async m=>{try{return await A(m,"utf-8")}catch{return""}};let N=!1,O=await g(b)===f;for(const m of u){const $=await g(i(m));$&&(N=!0),$!==c[m]+`
|
|
3
|
+
`&&(O=!1)}const d=O?"unchanged":N?"upgraded":"written";if(d!=="unchanged"){await k(b,f,"utf-8");for(const m of u)await k(i(m),c[m]+`
|
|
4
|
+
`,"utf-8"),await D(i(m),493).catch(()=>{})}const p=l(t,dt),h=H(p);let U={};if(h)try{U=JSON.parse(await A(p,"utf-8"))}catch{U={}}const _=m=>n.portable?`$CLAUDE_PROJECT_DIR/${K}/${J[m]}`:i(m),{settings:tt,changed:ot}=gt(U,{sessionStart:_("SessionStart"),userPromptSubmit:_("UserPromptSubmit"),preToolUse:_("PreToolUse"),stop:_("Stop")});let T;return h?ot?T="merged":T="unchanged":T="written",T!=="unchanged"&&(await y(l(t,".claude"),{recursive:!0}),await k(p,JSON.stringify(tt,null,2)+`
|
|
5
|
+
`,"utf-8")),{sessionStartPath:i("SessionStart"),promptSubmitPath:i("UserPromptSubmit"),preToolUsePath:i("PreToolUse"),stopPath:i("Stop"),bundlePath:b,scripts:d,settings:T}}const B=".cursor/hooks",Ot=".cursor/hooks.json",F="cachly-ambient-cursor.mjs",Tt={sessionStart:30,beforeSubmitPrompt:10,postToolUse:5};function I(t,o,e,n){return["#!/usr/bin/env node",`// cachly Ambient Recall \u2014 ${t} ${G}`,`// Einblendung fuer ${t}: ${e.join(", ")}.`,"// Blockiert nie: jeder Fehler endet mit Exit 0. Ruft das Buendel daneben",`// (${S}) in diesem Prozess.`,`process.env.CACHLY_BRAIN_INSTANCE_ID = '${E(n.instanceId)}';`,`process.argv.push('${o}');`,"try {",` await import('./${S}');`,"} catch {"," process.exit(0);","}"].join(`
|
|
6
|
+
`)}function _t(t){return I("Cursor",rt,["sessionStart","beforeSubmitPrompt","postToolUse"],t)}function yt(){const t=o=>[{command:`node ${B}/${F} ${o}`,timeout:Tt[o]}];return{sessionStart:t("sessionStart"),beforeSubmitPrompt:t("beforeSubmitPrompt"),postToolUse:t("postToolUse")}}function Et(t){return V(t,yt())}function V(t,o){const e={...t.hooks??{}};for(const[r,s]of Object.entries(o)){Y(e[r],r);const u=(e[r]??[]).filter(c=>!L(c));e[r]=[...u,...s]}const n={...t,version:typeof t.version=="number"?t.version:1,hooks:e};return{datei:n,changed:JSON.stringify(n)!==JSON.stringify(t)}}function X(t,o){const e={...t.hooks??{}};for(const[r,s]of Object.entries(o)){Y(e[r],r);const u=(e[r]??[]).flatMap(c=>{const i=c?.hooks;if(!Array.isArray(i))return[c];const a=i.filter(f=>!L(f));return a.length===i.length?[c]:a.length?[{...c,hooks:a}]:[]});e[r]=[...u,...s]}const n={...t,hooks:e};return{datei:n,changed:JSON.stringify(n)!==JSON.stringify(t)}}async function x(t){const o=l(t.projectDir,t.hookDir),e=M();if(!e)throw new Error(`cachly hook bundle ${S} missing from the package`);const n=R(e,"utf-8"),r=l(o,S),s=l(o,t.skriptName),u=t.skript+`
|
|
7
|
+
`,c=async p=>{try{return await A(p,"utf-8")}catch{return""}},i=l(t.projectDir,t.configDatei),a=H(i)?await c(i):"",f=!a.trim();let b;try{const p=a.charCodeAt(0)===65279?a.slice(1):a,h=f?{}:JSON.parse(p);if(!z(h))throw new C("is not a JSON object");if(h.hooks!==void 0&&!z(h.hooks))throw new C('has a "hooks" field that is not an object');b=t.merge(h,s)}catch(p){const h=p instanceof C?p.message:/^\s*\/\/|\/\*/m.test(a)?"has comments, and cachly only rewrites plain JSON":"is not valid JSON";return{scriptPath:s,bundlePath:r,hooksPath:i,scripts:"unchanged",hooks:"skipped",grund:h}}await y(o,{recursive:!0});const g=await c(s),O=g===u&&await c(r)===n?"unchanged":g?"upgraded":"written";O!=="unchanged"&&(await k(r,n,"utf-8"),await k(s,u,"utf-8"),await D(s,493).catch(()=>{}));let d;if(f?d="written":b.changed?d="merged":d="unchanged",d!=="unchanged"){const p=/^([ \t]+)"/m.exec(a)?.[1]??2;await y(j(i),{recursive:!0}),await k(i,JSON.stringify(b.datei,null,p)+`
|
|
8
|
+
`,"utf-8")}return{scriptPath:s,bundlePath:r,hooksPath:i,scripts:O,hooks:d}}function z(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}class C extends Error{}function Y(t,o){if(t!==void 0&&!Array.isArray(t))throw new C(`has a "hooks.${o}" entry that is not a list`)}async function to(t,o){return x({projectDir:t,hookDir:B,skriptName:F,skript:_t({instanceId:o}),configDatei:Ot,merge:e=>Et(e)})}const W=".github/hooks",Pt=".github/hooks/cachly-ambient.json",Q="cachly-ambient-copilot.mjs",It={sessionStart:30,userPromptSubmitted:10,postToolUse:5};function xt(t){return I("VS Code / Copilot",nt,st,t)}function Ct(){const t=o=>[{type:"command",command:`node ${W}/${Q} ${o}`,cwd:".",timeoutSec:It[o]}];return{sessionStart:t("sessionStart"),userPromptSubmitted:t("userPromptSubmitted"),postToolUse:t("postToolUse")}}function Nt(t){return V(t,Ct())}async function oo(t,o){return x({projectDir:t,hookDir:W,skriptName:Q,skript:xt({instanceId:o}),configDatei:Pt,merge:e=>Nt(e)})}const Ut=".codex/hooks",Ht=".codex/hooks.json",At="cachly-ambient-codex.mjs",wt={SessionStart:30,UserPromptSubmit:10};function $t(t){return I("Codex",it,ct,t)}function Rt(t){const o=e=>[{hooks:[{type:"command",command:`node "${t}" ${e}`,timeout:wt[e]}]}];return{SessionStart:o("SessionStart"),UserPromptSubmit:o("UserPromptSubmit")}}function Dt(t,o){return X(t,Rt(o))}async function eo(t,o){return x({projectDir:t,hookDir:Ut,skriptName:At,skript:$t({instanceId:o}),configDatei:Ht,merge:(e,n)=>Dt(e,n)})}const Z=".gemini/hooks",jt=".gemini/settings.json",q="cachly-ambient-gemini.mjs",Lt={SessionStart:3e4,BeforeAgent:1e4},Gt={SessionStart:"cachly-briefing",BeforeAgent:"cachly-recall"};function Mt(t){return I("Gemini CLI",at,ut,t)}function vt(){const t=o=>[{hooks:[{name:Gt[o],type:"command",command:`node ${Z}/${q} ${o}`,timeout:Lt[o]}]}];return{SessionStart:t("SessionStart"),BeforeAgent:t("BeforeAgent")}}function Kt(t){return X(t,vt())}async function ro(t,o){return x({projectDir:t,hookDir:Z,skriptName:q,skript:Mt({instanceId:o}),configDatei:jt,merge:e=>Kt(e)})}const no=["SessionStart","UserPromptSubmit","Stop"],w="hooks";function so(){const t=`\${CLAUDE_PLUGIN_ROOT}/${w}/${S}`,o=v({sessionStart:t,userPromptSubmit:t,stop:t},e=>`${e} --plugin`);return JSON.stringify({hooks:o},null,2)+`
|
|
9
|
+
`}export{Zt as AMBIENT_CLI_SUBCOMMAND,G as AMBIENT_HOOK_VERSION,Ht as CODEX_HOOKS_DATEI,Ut as CODEX_HOOK_DIR,At as CODEX_SKRIPT,wt as CODEX_TIMEOUTS,Pt as COPILOT_HOOKS_DATEI,W as COPILOT_HOOK_DIR,Q as COPILOT_SKRIPT,It as COPILOT_TIMEOUTS,B as CURSOR_HOOK_DIR,F as CURSOR_SKRIPT,Tt as CURSOR_TIMEOUTS,Z as GEMINI_HOOK_DIR,jt as GEMINI_SETTINGS_DATEI,q as GEMINI_SKRIPT,Lt as GEMINI_TIMEOUTS_MS,S as HOOK_BUENDEL,w as PLUGIN_HOOK_DIR,no as PLUGIN_HOOK_EVENTS,ht as PRE_TOOL_USE_MATCHER,v as buildAmbientSettingsHooks,$t as buildCodexHook,Rt as buildCodexHooks,xt as buildCopilotHook,Ct as buildCopilotHooks,_t as buildCursorHook,yt as buildCursorHooks,Mt as buildGeminiHook,vt as buildGeminiHooks,so as buildPluginHooksJson,lt as buildPreToolUseHook,mt as buildSessionStartHook,St as buildStopHook,pt as buildUserPromptSubmitHook,M as hookBuendelQuelle,qt as installAmbientHooks,eo as installCodexHooks,oo as installCopilotHooks,to as installCursorHooks,ro as installGeminiHooks,gt as mergeAmbientSettings,Dt as mergeCodexHooks,Nt as mergeCopilotHooks,Et as mergeCursorHooks,Kt as mergeGeminiHooks};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{kontextAus as s}from"./cursor-hook.js";import{hookAusgabe as i}from"./einblendung.js";const f="--codex",a=["SessionStart","UserPromptSubmit"],m=2500,r=new Set(a);function c(o,t){const e=o?.hook_event_name??t.find(n=>r.has(n));return e&&r.has(e)?e:null}function u(o,t){const e=typeof t.session_id=="string"?t.session_id:void 0,n=typeof t.cwd=="string"?t.cwd:void 0;return o==="SessionStart"?{hook_event_name:"SessionStart",source:typeof t.source=="string"?t.source:"startup",session_id:e,cwd:n}:{hook_event_name:"UserPromptSubmit",prompt:typeof t.prompt=="string"?t.prompt:"",session_id:e,cwd:n}}async function _(o){const t=c(o.payload,o.args);if(!t)return"";try{const e=u(t,o.payload??{});return i(t,s(await o.claudeLauf(JSON.stringify(e),t)))}catch{return""}}export{f as CODEX_FLAG,a as CODEX_HOOK_EVENTS,m as CODEX_KONTEXT_GRENZE_TOKEN,u as claudeNutzlast,c as codexEreignis,_ as codexHookAntwort};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{tmpdir as l}from"node:os";import{join as S}from"node:path";import{abholen as b,ablagePfad as i,ablegen as m,kontextAus as g}from"./cursor-hook.js";const U="--copilot",k=["sessionStart","userPromptSubmitted","postToolUse"],u={sessionStart:"sessionStart",SessionStart:"sessionStart",userPromptSubmitted:"userPromptSubmitted",UserPromptSubmit:"userPromptSubmitted",postToolUse:"postToolUse",PostToolUse:"postToolUse"};function _(o,t){const e=o?.hook_event_name??t.find(n=>Object.hasOwn(u,n));return e&&Object.hasOwn(u,e)?u[e]:null}function O(o){return typeof o?.hook_event_name=="string"&&o.hook_event_name!==""?"vscode":"cli"}function d(o){const t=o.session_id??o.sessionId;return typeof t=="string"&&t!==""?t:void 0}function P(o,t){const e=d(t),n=typeof t.cwd=="string"?t.cwd:void 0;return o==="sessionStart"?{hook_event_name:"SessionStart",source:typeof t.source=="string"?t.source:"startup",session_id:e,cwd:n}:{hook_event_name:"UserPromptSubmit",prompt:typeof t.prompt=="string"?t.prompt:"",session_id:e,cwd:n}}const y={sessionStart:"SessionStart",userPromptSubmitted:"UserPromptSubmit",postToolUse:"PostToolUse"};function f(o,t,e){return e?t==="cli"?o==="userPromptSubmitted"?"{}":JSON.stringify({additionalContext:e}):JSON.stringify({hookSpecificOutput:{hookEventName:y[o],additionalContext:e}}):"{}"}function v(o){const t=o?.timestamp;return typeof t=="string"&&t!==""||typeof t=="number"}const h=S(l(),"cachly-copilot-einblendung");async function E(o){const t=_(o.payload,o.args);if(!t)return"";try{const e=o.payload??{},n=O(e),s=d(e),r=o.ablageOrdner??h;if(t==="postToolUse")return n==="vscode"||!s?"{}":f(t,n,b(i(s,r),void 0));const a=t==="userPromptSubmitted"&&n==="cli";if(a){if(!s)return"{}";m(i(s,r),void 0,"")}const c=P(t,e),p=g(await o.claudeLauf(JSON.stringify(c),c.hook_event_name));return a&&m(i(s,r),void 0,p),f(t,n,p)}catch{return"{}"}}export{h as COPILOT_ABLAGE_ORDNER,U as COPILOT_FLAG,k as COPILOT_HOOK_EVENTS,P as claudeNutzlast,f as copilotAusgabe,_ as copilotEreignis,E as copilotHookAntwort,O as copilotLaufzeit,v as istFremdeLaufzeit};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{kontextAus as i}from"./cursor-hook.js";const f="--gemini",s=["SessionStart","BeforeAgent"],r=new Set(s);function a(e,t){const n=e?.hook_event_name??t.find(o=>r.has(o));return n&&r.has(n)?n:null}function u(e,t){const n=typeof t.session_id=="string"?t.session_id:void 0,o=typeof t.cwd=="string"?t.cwd:void 0;return e==="SessionStart"?{hook_event_name:"SessionStart",source:typeof t.source=="string"?t.source:"startup",session_id:n,cwd:o}:{hook_event_name:"UserPromptSubmit",prompt:typeof t.prompt=="string"?t.prompt:"",session_id:n,cwd:o}}function c(e,t){return t?JSON.stringify({hookSpecificOutput:{hookEventName:e,additionalContext:t}}):"{}"}async function m(e){const t=a(e.payload,e.args);if(!t)return"";try{const n=u(t,e.payload??{});return c(t,i(await e.claudeLauf(JSON.stringify(n),n.hook_event_name)))}catch{return"{}"}}export{f as GEMINI_FLAG,s as GEMINI_HOOK_EVENTS,u as claudeNutzlast,c as geminiAusgabe,a as geminiEreignis,m as geminiHookAntwort};
|
package/dist/src/hook-zugang.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as
|
|
1
|
+
import{readdirSync as u,readFileSync as f}from"node:fs";import{homedir as l}from"node:os";import{join as n}from"node:path";import{readInstanceId as j,resolveApiKey as k}from"./credentials.js";import{echterWert as d}from"./zugang.js";function E(o=process.env){return{env:o,heim:o.HOME||o.USERPROFILE||l(),projekt:o.CLAUDE_PROJECT_DIR||process.cwd()}}function i(o){try{return JSON.parse(f(o,"utf8"))}catch{return null}}function a(o){return[n(o.heim,".claude","mcp.json"),n(o.projekt,".mcp.json"),n(o.heim,".cursor","mcp.json"),n(o.heim,".codeium","windsurf","mcp_config.json")].map(e=>{const r=i(e)?.mcpServers?.cachly?.env;return r&&typeof r=="object"?r:{}})}function h(...o){for(const e of o){const r=d(e);if(r)return r}return""}function H(o){return h(o.env.CLAUDE_PLUGIN_OPTION_API_KEY,k({env:o.env,home:o.heim,cwd:o.projekt}),...a(o).map(e=>e.CACHLY_JWT))}function N(o){return h(o.env.CLAUDE_PLUGIN_OPTION_INSTANCE_ID,o.env.CACHLY_BRAIN_INSTANCE_ID,j({home:o.heim}),...a(o).map(e=>e.CACHLY_BRAIN_INSTANCE_ID))}const m="cachly-ambient-";function S(o){return[n(o.projekt,".cursor","hooks.json"),n(o.heim,".cursor","hooks.json")].some(e=>{const r=i(e)?.hooks;return!!r&&typeof r=="object"&&Object.values(r).some(t=>Array.isArray(t)&&t.some(s=>String(s?.command??"").includes(m)))})}function A(o){const e=o;return[e?.command,e?.bash,e?.powershell].some(r=>String(r??"").includes(m))}function g(o){const e=o.env.COPILOT_HOME?n(o.env.COPILOT_HOME,"hooks"):n(o.heim,".copilot","hooks");return[n(o.projekt,".github","hooks"),e].some(r=>{let t;try{t=u(r).filter(s=>s.endsWith(".json"))}catch{return!1}return t.some(s=>{const c=i(n(r,s))?.hooks;return!!c&&typeof c=="object"&&Object.values(c).some(p=>Array.isArray(p)&&p.some(A))})})}function v(o,e){return[n(e.projekt,".claude","settings.json"),n(e.projekt,".claude","settings.local.json"),n(e.heim,".claude","settings.json")].some(r=>{const t=i(r)?.hooks?.[o];return Array.isArray(t)&&t.some(s=>Array.isArray(s?.hooks)&&s.hooks.some(c=>String(c?.command??"").includes(m)))})}export{m as PROJEKT_HOOK_MARKE,g as copilotHatHook,S as cursorHatHook,N as findeInstanz,H as findeSchluessel,E as hookUmfeld,A as istCachlyEintrag,v as projektHatHook};
|