@maind-dev/mcp-bridge 0.124.0 → 0.124.1

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/build/index.js CHANGED
@@ -139,7 +139,7 @@ CREATE TABLE IF NOT EXISTS embeddings (
139
139
  `)){let[r,o]=n.split(" ");r&&o?.trim()==="[gone]"&&t.add(r.trim())}return t}function BT(e,t){let n=UT(t);return HT(e).filter(r=>n.has(r.branch)).sort((r,o)=>r.path.localeCompare(o.path))}function FT(e,t,n){try{return tG("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:n})}catch{return null}}function xh(e,t={}){let n=t.timeoutMs??2e3,r=FT(e,["worktree","list","--porcelain"],n);if(r===null)return null;let o=FT(e,["for-each-ref","--format=%(refname:short)%09%(upstream:track)","refs/heads/"],n);return o===null?null:BT(r,o)}var GT=w(()=>{"use strict";s(HT,"parseLinkedWorktrees");s(UT,"parseGoneBranches");s(BT,"goneBranchWorktrees");s(FT,"gitQuick");s(xh,"listGoneBranchWorktrees")});var nG,fse,KT=w(()=>{"use strict";Pe();nG=["Accepted","Proposed","Superseded","Rejected","Deprecated","Angenommen","Akzeptiert","Vorschlag","Abgel\xF6st","Draft"],fse=new RegExp(nG.join("|"),"g")});import{existsSync as Eh,readdirSync as rG,readFileSync as oG}from"node:fs";import{spawnSync as iG}from"node:child_process";import{dirname as sG,join as Pc,posix as Th}from"node:path";function VT(e){let t=[],n={host:"127.0.0.1",port:e.config.source==="missing"?null:e.config.port,configSource:e.config.source,reachable:null,ledgerCount:null};if(e.config.source==="missing")return t.push({id:`db.config_missing:${e.dir}`,status:"open",project:e.dir,title:"supabase/config.toml nirgends auffindbar \u2014 DB-Ziel unbekannt",detail:`Weder dieser Tree noch der Haupt-Worktree tragen eine config.toml f\xFCr ${e.dir}. Die Supabase-CLI w\xFCrde hier still auf ihren Default-Port ${Ah} ausweichen \u2014 dorthin schreibt ein Werkzeug ohne Fehlermeldung, ggf. in die Datenbank eines FREMDEN Projekts (real passiert 2026-08-26: 'INSERT 0 1' in den falschen Ledger). Dieses Tool r\xE4t deshalb NIE einen Port und hat keine Verbindung versucht.`,hint:"config.toml aus dem Haupt-Checkout kopieren (sie ist bewusst gitignored \u2014 Ports/Keys sind lokal), dann erneut pr\xFCfen. `.maind/worktree-requirements` deklariert die Datei bereits f\xFCr check_divergence."}),{dir:e.dir,verdict:"blind",findings:t,db:n};e.config.source==="main_worktree"&&t.push({id:`db.config_missing_here:${e.dir}`,status:"open",project:e.dir,title:`config.toml fehlt in DIESEM Tree \u2014 Vergleich lief \xFCber den Haupt-Worktree (Port ${e.config.port})`,detail:`Der Ledger-Vergleich nutzt die config.toml des Haupt-Worktrees und ist damit aussagekr\xE4ftig. Aber jedes Supabase-CLI-Kommando, das HIER l\xE4uft, sieht keine config.toml und weicht still auf Port ${Ah} aus \u2014 die Silent-Redirect-Falle vom 2026-08-26.`,hint:"config.toml aus dem Haupt-Checkout in diesen Worktree kopieren, bevor irgendein `supabase \u2026`-Kommando l\xE4uft."});let r=e.ledger;if(r===null||r.ok===!1){n.reachable=r===null?null:!1;let p=r===null?"unreachable":r.reason,f=r!==null&&r.ok===!1?r.detail:void 0,h={psql_missing:{title:"psql nicht im PATH \u2014 Ledger nicht lesbar",detailText:"Ohne psql kann der lokale Ledger nicht gelesen werden. Kein Urteil \xFCber Drift m\xF6glich.",hint:"psql installieren (z. B. `brew install libpq` + PATH) oder den lokalen Stack-Client nachr\xFCsten."},unreachable:{title:`lokale Datenbank auf 127.0.0.1:${e.config.port} nicht erreichbar`,detailText:"Der Port aus config.toml antwortet nicht \u2014 der Stack schl\xE4ft vermutlich. Scheitert wenigstens laut (anders als die Default-Port-Falle); ein Urteil \xFCber Drift ist trotzdem nicht m\xF6glich.",hint:"`npx supabase start` im Projekt, dann erneut pr\xFCfen."},no_ledger:{title:`Port ${e.config.port} antwortet, tr\xE4gt aber KEINEN Supabase-Ledger`,detailText:"supabase_migrations.schema_migrations existiert dort nicht. Mutma\xDFlich lauscht auf diesem Port eine FREMDE Datenbank \u2014 dieselbe Verwechslungsklasse wie die 54322-Panne, nur von der anderen Seite gesehen.",hint:"Pr\xFCfen, wer auf dem Port lauscht (`lsof -nP -iTCP:<port> -sTCP:LISTEN`), und die config.toml gegen das Projekt halten."},query_failed:{title:"Ledger-Abfrage fehlgeschlagen",detailText:`Die SELECT-Abfrage gegen supabase_migrations.schema_migrations scheiterte${f?`: ${f}`:"."}`,hint:"psql-Fehlertext pr\xFCfen; das Tool liest ausschlie\xDFlich (SELECT) und r\xE4t nie einen anderen Port."}}[p];return t.push({id:`db.${p}:${e.dir}`,status:"warn",project:e.dir,title:h.title,detail:h.detailText,hint:h.hint}),{dir:e.dir,verdict:"blind",findings:t,db:n}}n.reachable=!0,n.ledgerCount=r.versions.length;let o=new Set(r.versions),i=new Set(e.fileVersions),a=e.fileVersions.filter(p=>!o.has(p)).sort(pt);a.length>0&&t.push({id:`ledger.behind:${e.dir}`,status:"open",project:e.dir,title:`lokales Schema hinter dem Repo \u2014 ${a.length} Migration(en) nicht angewandt`,detail:`Die verbundene Datenbank (127.0.0.1:${e.config.port}) kennt diese Repo-Migrationen nicht: ${a.join(", ")}. Jeder Lauf gegen dieses Schema pr\xFCft die Garantien von gestern; genau so wurde der SQL-Assertion-Gate zweimal still \xFCbersprungen (2026-08-26).`,hint:(e.projectRoot?`cd ${e.projectRoot} && npx supabase migration up`:"`npx supabase migration up` im Projektverzeichnis")+" (bzw. `--include-all` bei \xE4lteren Slots), dann erneut pr\xFCfen. Meldet der Lauf nichts Angewendetes, war es das falsche Verzeichnis ODER die Migration lief bereits \u2014 diese Pruefung sagt, was davon.",versions:a});let l=r.versions.filter(p=>!i.has(p)).sort(pt),c=new Map,u=[];for(let p of l){let f=e.siblingVersions.get(p);if(f){let m=c.get(f)??[];m.push(p),c.set(f,m)}else u.push(p)}for(let[p,f]of c)t.push({id:`ledger.sibling_wip:${e.dir}#${p}`,status:"info",project:e.dir,title:`${f.length} Ledger-Zeile(n) geh\xF6ren dem Geschwister-Worktree ${p}`,detail:`Angewandt, aber ohne Datei in DIESEM Tree: ${f.join(", ")}. Die Dateien liegen in ${p} \u2014 dessen WIP auf der geteilten lokalen Datenbank. Auf einer Maschine mit Feature-Branches ist das der erwartete Dauerzustand (local \u2287 trunk), kein Defekt und nichts zu reparieren.`,hint:"Nichts tun. Insbesondere KEIN `migration repair --status reverted` \u2014 das w\xFCrde die Arbeit der Parallel-Session un-verbuchen.",versions:f});if(u.length>0&&t.push({id:`ledger.phantom:${e.dir}`,status:"warn",project:e.dir,title:`${u.length} Ledger-Zeile(n) ohne Datei \u2014 nirgends, auch in keinem Worktree`,detail:`Angewandt laut Ledger, aber die Datei existiert weder hier noch in einem Geschwister-Worktree: ${u.join(", ")}. Entweder wurde eine angewandte Migration gel\xF6scht/umbenannt, oder der Ledger geh\xF6rt einem anderen Stand.`,hint:"Herkunft kl\xE4ren, bevor irgendetwas repariert wird \u2014 ein Repair auf Verdacht war die teurere H\xE4lfte der 2026-08-26-Panne.",versions:u}),e.remote!==null)if(e.remote.ok===!1)t.push({id:`remote.unreadable:${e.dir}`,status:"warn",project:e.dir,title:"Remote-Ledger nicht lesbar",detail:`Die \xFCbergebene Remote-Quelle war nicht abfragbar (${e.remote.reason}). NICHT als "kein Drift" werten.`,hint:"Connection-String/Netz pr\xFCfen; ohne Remote-Quelle bleibt der Remote-Vergleich aus (bewusst)."});else{let p=new Set(e.remote.versions),f=e.fileVersions.filter(h=>!p.has(h)).sort(pt),m=e.remote.versions.filter(h=>!i.has(h)).sort(pt);f.length>0&&t.push({id:`remote.behind:${e.dir}`,status:"warn",project:e.dir,title:`Remote-Ledger hinter dem Repo \u2014 ${f.length} Migration(en) nicht gepusht`,detail:`Im Repo, aber nicht im Remote-Ledger: ${f.join(", ")}.`,hint:"Push \xFCber den Push-Wrapper dieses Repos fahren (er protokolliert den Absender), nie roh.",versions:f}),m.length>0&&t.push({id:`remote.ahead:${e.dir}`,status:"warn",project:e.dir,title:`Remote-Ledger tr\xE4gt ${m.length} Version(en) ohne Datei im Repo`,detail:`Im Remote-Ledger, aber nicht im Repo: ${m.join(", ")}. Herkunft kl\xE4ren (Push an master vorbei?).`,hint:"Herkunft kl\xE4ren: wer hat diesen Stand in die Remote-DB gebracht? Ein Push-Log (falls vorhanden) nennt den Absender.",versions:m})}let d=t.some(p=>p.status==="open"||p.status==="warn")?"drift":"in_sync";return{dir:e.dir,verdict:d,findings:t,db:n}}function qT(e){return e.length===0?"no_opinion":e.includes("blind")?"blind":e.includes("drift")?"drift":"in_sync"}function JT(e,t){if(t==="enoent")return{ok:!1,reason:"psql_missing"};let n=e.toLowerCase();return n.includes("does not exist")&&n.includes("schema_migrations")?{ok:!1,reason:"no_ledger"}:n.includes("connection refused")||n.includes("could not connect")||n.includes("timeout expired")||n.includes("server closed the connection")||n.includes("connection timed out")?{ok:!1,reason:"unreachable"}:{ok:!1,reason:"query_failed",detail:e.split(`
140
140
  `).filter(Boolean).slice(-1)[0]}}function WT(e,t,n){let r=e(t,aG,n);return r.ok===!1?JT(r.stderr,r.code):{ok:!0,versions:r.stdout.split(`
141
141
  `).map(o=>o.trim()).filter(Boolean)}}function YT(e){for(let t of e.split(/^\[/m)){if(!/^db\]/.test(t))continue;let n=/^\s*port\s*=\s*(\d+)/m.exec(t.slice(t.indexOf("]")+1));if(n)return Number(n[1])}return null}function lG(e){let t=I(e,["rev-parse","--path-format=absolute","--git-common-dir"])?.trim();if(!t)return null;let n=sG(t);return n===e?null:n}function cG(e,t,n){let r=Th.dirname(t),i=[{path:Pc(e,r,"config.toml"),source:"worktree"}],a=lG(e);a&&i.push({path:Pc(a,r,"config.toml"),source:"main_worktree"});for(let l of i)if(Eh(l.path))try{let c=YT(oG(l.path,"utf8"));if(c===null){n.push(`${l.path}: kein [db].port lesbar \u2014 Kandidat \xFCbersprungen`);continue}return{source:l.source,port:c}}catch{n.push(`${l.path}: nicht lesbar \u2014 Kandidat \xFCbersprungen`)}return{source:"missing"}}function uG(e,t){let n=new Map,r=I(e,["worktree","list","--porcelain"]);if(r===null)return n;let o=I(e,["rev-parse","--show-toplevel"])?.trim();for(let i of r.split(`
142
- `)){if(!i.startsWith("worktree "))continue;let a=i.slice(9).trim();if(!a||a===o||!Eh(a))continue;let l=Pc(a,t);if(Eh(l))try{for(let c of rG(l)){let u=ni(c);u!==null&&!n.has(u)&&n.set(u,a)}}catch{}}return n}function Rh(e,t={}){let n=t.runPsql??zT,r=t.timeoutMs??15e3,o=[],i=zr(e,t.dirs);if(i.length===0)return{ok:!1,verdict:"no_opinion",findings:[],facts:{projects:[],remoteConsulted:t.remoteDbUrl!==void 0,skipped:o}};let a=[],l=[],c=[];for(let p of i){let f=cG(e,p.dir,o),m=f.source==="missing"?null:WT(n,`postgresql://postgres:postgres@127.0.0.1:${f.port}/postgres`,r),h=t.remoteDbUrl!==void 0?WT(n,t.remoteDbUrl,r):null,g=VT({dir:p.dir,projectRoot:Pc(e,Th.dirname(Th.dirname(p.dir))),fileVersions:p.files.map(_=>_.version),config:f,ledger:m,siblingVersions:uG(e,p.dir),remote:h});a.push(...g.findings),c.push(g.verdict),l.push({dir:p.dir,migrationCount:p.files.length,verdict:g.verdict,db:g.db})}let u=qT(c),d={open:0,warn:1,info:2};return a.sort((p,f)=>d[p.status]-d[f.status]||p.id.localeCompare(f.id)),{ok:u==="in_sync",verdict:u,findings:a,facts:{projects:l,remoteConsulted:t.remoteDbUrl!==void 0,skipped:o}}}var Ah,zT,aG,XT=w(()=>{"use strict";Pe();Yr();Ah=54322;s(VT,"evaluateLedgerProject");s(qT,"deriveLedgerVerdict");zT=s((e,t,n)=>{let r=iG("psql",[e,"-tAc",t],{encoding:"utf8",timeout:n,env:{...process.env,PGCONNECT_TIMEOUT:"5"}});return r.error&&r.error.code==="ENOENT"?{ok:!1,code:"enoent",stderr:""}:r.status!==0?{ok:!1,code:"error",stderr:(r.stderr??"").trim()}:{ok:!0,stdout:r.stdout??""}},"defaultRunPsql"),aG="select version from supabase_migrations.schema_migrations order by version";s(JT,"classifyLedgerError");s(WT,"readLedger");s(YT,"parseDbPort");s(lG,"mainWorktreeRoot");s(cG,"resolveConfig");s(uG,"gatherSiblingVersions");s(Rh,"checkMigrationLedgerDrift")});function At(e){return typeof e=="string"?e:String(e??"")}function oa(e){return typeof e=="number"?e:Number(typeof e=="bigint"?e:e??0)}function Ch(e){return{nodeKey:At(e.node_key),kind:At(e.kind),name:At(e.name),qualifiedName:At(e.qualified_name),filePath:At(e.file_path),startLine:oa(e.start_line),endLine:oa(e.end_line),signature:typeof e.signature=="string"?e.signature:null}}function eA(e){return{path:At(e.path),language:At(e.language),contentHash:At(e.content_hash),mtimeMs:oa(e.mtime_ms),size:oa(e.size),indexedAt:oa(e.indexed_at)}}function Ih(e){let t=new Map,n=s(o=>{let i=t.get(o);return i===void 0&&(i=e.prepare(o),t.set(o,i)),i},"stmt"),r=s(o=>{let i=n(Jn.meta).get(o);return i===void 0?null:At(i.value)},"metaValue");return{meta(){let o=r(zn),i=r(na);return{schemaVersion:o,schemaCurrent:o===qn,edgesDirty:r(ci)==="1",lastIndexedAt:i===null?null:Number(i)}},file(o){let i=n(Jn.file).get(o);return i===void 0?null:eA(i)},files(o){let i=new Map;for(let a of new Set(o)){let l=n(Jn.file).get(a);l!==void 0&&i.set(a,eA(l))}return i},symbolsInFile(o,i=dG){return n(Jn.symbolsInFile).all(o,i).map(Ch)},symbolsNamed(o,i=pG){let a=new Map;for(let l of new Set(o)){let c=n(Jn.symbolsNamed).all(l,i);c.length>0&&a.set(l,c.map(Ch))}return a},callersOfFile(o,i=fG){return n(Jn.callersOfFile).all(o,o,i).map(l=>({calleeKey:At(l.callee_key),kind:At(l.edge_kind),caller:Ch(l)}))},importersOf(o,i=mG){let a=n(Jn.importersOf).all(rn(o),i),l=[];for(let c of a){let u=At(c.src_key),d=u.endsWith(QT)?u.slice(0,-QT.length):u;d!==o&&!l.includes(d)&&l.push(d)}return l},close(){e.close()}}}function ia(e,t){return Math.floor(t.mtimeMs)===e.mtimeMs&&t.size===e.size}var ZT,Jn,dG,pG,fG,mG,QT,Nh=w(()=>{"use strict";qr();ui();ZT="node_key, kind, name, qualified_name, file_path, start_line, end_line, signature",Jn={meta:"SELECT key, value FROM meta WHERE key = ?",file:"SELECT path, language, content_hash, mtime_ms, size, indexed_at FROM files WHERE path = ?",symbolsInFile:`SELECT ${ZT} FROM nodes WHERE file_path = ? AND kind <> 'module' ORDER BY start_line LIMIT ?`,symbolsNamed:`SELECT ${ZT} FROM nodes WHERE name = ? AND kind <> 'module' ORDER BY file_path, start_line LIMIT ?`,callersOfFile:"SELECT e.dst_key AS callee_key, e.kind AS edge_kind, c.node_key, c.kind, c.name, c.qualified_name, c.file_path, c.start_line, c.end_line, c.signature FROM nodes n JOIN edges e ON e.dst_key = n.node_key AND e.kind IN ('calls', 'extends', 'implements') JOIN nodes c ON c.node_key = e.src_key WHERE n.file_path = ? AND c.file_path <> ? LIMIT ?",importersOf:"SELECT src_key FROM edges WHERE dst_key = ? AND kind = 'imports' LIMIT ?"},dG=400,pG=8,fG=600,mG=200,QT="#<module>";s(At,"str");s(oa,"num");s(Ch,"toSymbol");s(eA,"toFileRow");s(Ih,"createIndexReader");s(ia,"isFileCurrent")});var Oh,Dh=w(()=>{"use strict";Oh="0.2.0"});function Ph(e,t){return{since:e??void 0,includeUncommitted:e?t:!0,limit:Kn,attest:!0}}function Mh(e,t){let n=0,r=[];for(let i of e.symbols){let a=i.qualifiedName?i.qualifiedName:void 0;if(i.name.length===0||i.name.length>Mc||a!==void 0&&a.length>$c){n+=1;continue}r.push({name:i.name,...a!==void 0?{qualified_name:a}:{},...i.kind&&i.kind.length<=nA?{kind:i.kind}:{},...i.language&&i.language.length<=rA?{language:i.language}:{},change:i.change,changed_line_count:Math.min(Math.max(0,i.changedLineCount),oA)})}return{payload:{changed_symbols:r,risk_flags:[...e.riskFlags],detector_findings:t.findings,detector_runs:t.engines.map(i=>({detector_id:i.detector_id,detector_version:i.detector_version,state:i.state})),diff_stats:{base_kind:e.baseKind,changed_file_count:e.changedFiles,stale_file_count:e.staleFiles,unindexed_file_count:e.changedFiles-e.indexedFiles,truncated:e.truncated||n>0,hunk_coverage:e.hunkCoverage,detector_coverage:t.coverage},...e.headSha?{commit_sha:e.headSha}:{},...e.baseSha?{base_sha:e.baseSha}:{},...typeof e.mergeBaseSha=="string"?{merge_base_sha:e.mergeBaseSha}:{},dirty:e.dirty,code_index_version:Oh},dropped:n}}function $h(e,t,n){return e?{persist:!1,skipped:"no_report"}:n.headSha?t?n.baseKind==="ref"&&typeof n.mergeBaseSha!="string"?{persist:!1,skipped:"no_merge_base"}:{persist:!0,skipped:null}:{persist:!1,skipped:"no_project_key"}:{persist:!1,skipped:"no_head"}}function Lh(e,t,n){let r=t,o=[];r===0?o.push("No code_review conventions apply to this repository \u2014 nothing was checked at convention level. This is an abstention, not a clean bill."):o.push(`Matched by the server (attest mode) against the repository's code_review set${typeof r=="number"?` (${r} convention(s))`:""} \u2014 ${e.symbols.length-n} changed symbol(s), no session filter, no cap.`),e.hunkCoverage!=="full"&&o.push(`Hunk coverage ${e.hunkCoverage}: some symbols could not be line-graded and count as co_located.`),e.staleFiles>0&&o.push(`${e.staleFiles} changed file(s) had a stale index \u2014 their symbols degraded to co_located.`);let i=e.changedFiles-e.indexedFiles;return i>0&&o.push(`${i} changed file(s) have no index rows \u2014 invisible to symbol matching (risk flags still cover them).`),e.truncated&&o.push(`Symbol list truncated at ${Kn} (co_located dropped first) \u2014 not attestation-grade.`),n>0&&o.push(`${n} symbol(s) with a name beyond the server schema were left out \u2014 not attestation-grade.`),o.join(" ")}function di(e){let t=/^MCP error (-?\d+):\s*([\s\S]*)$/.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=t[2]??"";return n===tA&&/\bTool \S+ not found\b/.test(r)?{kind:"unknown_tool",code:n,detail:r,issues:[]}:n===tA?{kind:"invalid_params",code:n,detail:r,issues:hG(r)}:{kind:"tool_error",code:n,detail:r,issues:[]}}function hG(e){let t=e.indexOf("[");if(t===-1)return[];try{let n=JSON.parse(e.slice(t));return Array.isArray(n)?n.filter(r=>typeof r=="object"&&r!==null):[]}catch{return[]}}function jh(e){if(e.kind!=="invalid_params"||e.issues.length!==1)return!1;let t=e.issues[0],n=t.path??[];return n.length===1&&n[0]==="findings"&&t.code==="invalid_type"&&(t.received===void 0||t.received==="undefined")}var Mc,$c,nA,rA,oA,tA,gG,iA=w(()=>{"use strict";nn();Dh();Mc=200,$c=512,nA=64,rA=32,oA=1e4;s(Ph,"attestReviewOptions");s(Mh,"buildAttestPayload");s($h,"attestPersistDecision");s(Lh,"attestCoverageNote");tA=-32602;s(di,"classifyMcpErrorText");s(hG,"parseIssues");s(jh,"isLegacyAttestRejection");gG=`MCP error -32602: Input validation error: Invalid arguments for tool review_verdict: ${JSON.stringify([{code:"invalid_type",expected:"array",received:"undefined",path:["findings"],message:"Required"}],null,2)}`});import{execFileSync as yG}from"node:child_process";import{existsSync as _G,readFileSync as bG,readdirSync as kG}from"node:fs";import{basename as wG,join as sA}from"node:path";function Lc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function cA(e,t){let n=new Set,r=new Set,o=0;for(let i of e){if(i.split("/").includes("node_modules"))continue;let a=wG(i);for(let[u,d]of SG)a===u&&r.add(d);if(xG.test(i)&&(n.add("supabase"),n.add("postgres")),a!=="package.json"||o>=lA)continue;o+=1;let l=t(i);if(!Lc(l))continue;r.add("javascript");let c={...Lc(l.dependencies)?l.dependencies:{},...Lc(l.devDependencies)?l.devDependencies:{},...Lc(l.peerDependencies)?l.peerDependencies:{}};Object.prototype.hasOwnProperty.call(c,"typescript")&&r.add("typescript");for(let[u,d]of vG)Object.prototype.hasOwnProperty.call(c,u)&&n.add(d)}return{platforms:[...n].sort(),languages:[...r].sort()}}function ao(e){return[...e.platforms,...e.languages]}function aA(e,t){try{return yG("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3,maxBuffer:64*1024*1024})}catch{return null}}function Tn(e){let t=aA(e,["rev-parse","--show-toplevel"])?.trim()||null,n=e,r,o=t===null?null:aA(t,["ls-files","-z"]);if(t!==null&&o!==null)n=t,r=o.split("\0").filter(i=>i.length>0);else{try{r=kG(e)}catch{return{platforms:[],languages:[]}}_G(sA(e,"supabase","migrations"))&&r.push("supabase/migrations/")}return cA(r,i=>{try{return JSON.parse(bG(sA(n,i),"utf8"))}catch{return null}})}var lA,vG,SG,xG,uA=w(()=>{"use strict";lA=200,vG=[["next","nextjs"],["react","react"],["react-dom","react"],["react-native","react-native"],["expo","expo"],["@supabase/supabase-js","supabase"],["@supabase/ssr","supabase"],["supabase","supabase"],["tailwindcss","tailwind"],["stripe","stripe"],["@stripe/stripe-js","stripe"],["pg","postgres"],["postgres","postgres"],["@modelcontextprotocol/sdk","mcp"]],SG=[["tsconfig.json","typescript"],["pyproject.toml","python"],["requirements.txt","python"],["go.mod","go"],["Cargo.toml","rust"]],xG=/(^|\/)supabase\/(config\.toml$|migrations\/)/;s(Lc,"isRecord");s(cA,"inferRepoStack");s(ao,"repoStackSlugs");s(aA,"git");s(Tn,"detectRepoStack")});var Me=w(()=>{"use strict";nw();Sh();Wf();yh();Pe();_c();Dm();xm();Rm();Im();tm();jT();GT();KT();Jf();qs();Sc();Qm();rh();sh();Xs();Yr();ea();XT();gm();mh();qs();Xs();Sc();ea();tc();Df();ui();Nh();rc();Dh();iA();uA()});import{homedir as EG}from"node:os";import{join as TG}from"node:path";function Fc(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!="object")continue;let r=n,o=sa(r.id),i=sa(r.key),a=sa(r.title),l=sa(r.status);if(!o||!i||!a||!l)continue;let c=r.here===!1?!1:void 0,u=sa(r.where);if(t.push({id:o,key:i,title:a,status:l,...c===!1?{here:c}:{},...u?{where:u}:{}}),t.length>=AG)break}return t}function Fh(e){if(e.length===0)return null;let t=e.map(r=>`${r.key} "${r.title}"${r.status==="warn"?" (blocked)":""}`+(r.here===!1?` (in ${r.where?`${r.where}/`:"a repository below this one"})`:"")).join(", "),n=e.length===1;return`Assigned to your user and not taken yet: ${t}. Their own agents may take ${n?"it":"these"} (take_work_object). Mention ${n?"it":"them"} to your user and offer to take ${n?"it":"one"} \u2014 do not start unasked.`}function Hh(e=EG()){return TG(e,".maind","assigned-told")}function dA(e,t){if(!e||typeof e!="object")return e;let n=e;return Array.isArray(n.assigned_to_you)?{...n,assigned_to_you:n.assigned_to_you.map(r=>{if(!r||typeof r!="object")return r;let o=r;if(o.here!==!1||typeof o.project_key!="string")return r;let i=t(o.project_key);return i?{...o,where:i}:r})}:e}function pA(e){return e==="claude-code"}var AG,sa,jc,aa=w(()=>{"use strict";AG=5,sa=s(e=>typeof e=="string"&&e.length>0?e:null,"str");s(Fc,"parseAssignedList");s(Fh,"assignedNoticeText");s(Hh,"assignedToldDir");jc=class{static{s(this,"AssignedInbox")}current=[];told=new Set;update(t){if(!t||typeof t!="object")return;let n=t;n.ok===!0&&(this.current=Fc(n.assigned_to_you))}takeNote(){let t=this.current.filter(n=>!this.told.has(n.id));for(let n of t)this.told.add(n.id);return Fh(t)}};s(dA,"labelNestedItems");s(pA,"clientHasHooks")});function gA(e){let t;try{t=JSON.parse(e)}catch{return{kind:"opaque"}}if(typeof t!="object"||t===null||Array.isArray(t))return{kind:"opaque"};let n=t;if(n.jsonrpc!=="2.0")return{kind:"opaque"};let r=typeof n.id=="number"||typeof n.id=="string"?n.id:void 0,o=typeof n.method=="string"?n.method:void 0;if(o!==void 0){let i={kind:r!==void 0?"request":"notification",method:o,id:r};if(o==="tools/call"){let a=n.params;if(typeof a=="object"&&a!==null){let l=a.name;typeof l=="string"&&(i.toolName=l)}}return i}return r!==void 0&&("result"in n||"error"in n)?{kind:"response",id:r}:{kind:"opaque"}}function pi(e,t,n){return JSON.stringify({jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:n??`maind gateway: tool '${t}' is denied by local gateway policy. The call was not forwarded to the server. Remove the --deny-tool flag (or adjust the gateway policy) to allow it.`}],isError:!0}})}function Gh(e,t,n,r){return{at:r,event:e,server:t,tool:n}}function Kh(e,t,n,r,o,i){return{at:r,event:e,server:t,tool:n,convention_id:o,convention_version:i}}function Wh(e,t,n,r){return{at:r,event:e,server:t,tool:n}}var Vh=w(()=>{"use strict";s(gA,"parseFrame");s(pi,"denyResult");s(Gh,"toolEvent");s(Kh,"policyEvent");s(Wh,"shaEvent")});import{execFileSync as bA}from"node:child_process";function kA(e){return e.verdict==="fabricated"&&(e.matchedPrefixLen??0)>=jG}function FG(e){let t;try{t=JSON.parse(e)}catch{return[]}if(typeof t!="object"||t===null)return[];let n=t.params;if(typeof n!="object"||n===null)return[];let r=n.arguments;if(typeof r!="object"||r===null)return[];let o=[];for(let i of MG){let a=r[i];typeof a=="string"&&yA.test(a)&&o.push({field:i,sha:a})}for(let[i,a]of $G){let l=r[i];if(typeof l!="object"||l===null)continue;let c=l[a];typeof c=="string"&&yA.test(c)&&o.push({field:`${i}.${a}`,sha:c})}return o}function HG(e,t){let n=t(e);if(n===e)return{field:"",sha:e,verdict:"proven"};if(n!==null)return{field:"",sha:e,verdict:"unknown"};let r=e.slice(0,_A);for(let o=_A;o>=LG;o--){let i=r.slice(0,o),a=t(i);if(a!==null&&a.startsWith(i))return{field:"",sha:e,verdict:"fabricated",matchedPrefixOf:a,matchedPrefixLen:o}}return{field:"",sha:e,verdict:"unknown"}}function fi(e,t){return e.verdict==="fabricated"?[`${t?"DENIED":"WARNING"}: the ${e.field} you passed (${e.sha}) does not exist in this repository,`,`but its prefix resolves to a real commit (${e.matchedPrefixOf}).`,"That combination cannot come from an unfetched object \u2014 it comes from completing an abbreviated hash.","Read the full hash instead of reconstructing it: `git rev-parse HEAD`, `git rev-parse <ref>`,","or `gh pr view <n> --json mergeCommit --jq .mergeCommit.oid`.",t?"The call was not forwarded.":"The call was forwarded \u2014 the record will carry an unverifiable hash."].join(" "):[`NOTE: the ${e.field} you passed (${e.sha}) could not be resolved in this repository.`,"That is often harmless \u2014 a fresh squash-merge commit, an unfetched branch, or a different repo in this workspace.","If you reconstructed it from an abbreviated hash, read the full one instead (`git rev-parse`, `gh --json`).","The call was forwarded."].join(" ")}function wA(){let e={...process.env};for(let t of["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE"])delete e[t];return e}function Uc(e=process.cwd()){try{let n=bA("git",["rev-parse","--show-toplevel"],{cwd:e,env:wA(),encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim();return n.length>0?n:null}catch{return null}}function UG(e){return t=>{try{let r=bA("git",["rev-parse","--verify","--quiet",`${t}^{commit}`],{cwd:e,env:wA(),encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim();return r.length>0?r:null}catch{return null}}}function Bc(e,t){if(t===null)return[];let n=FG(e);if(n.length===0)return[];let r=UG(t),o=[];for(let{field:i,sha:a}of n){let l=HG(a,r);l.verdict!=="proven"&&o.push({...l,field:i})}return o}var MG,$G,yA,LG,_A,jG,qh=w(()=>{"use strict";MG=["commit_sha","base_sha","head_sha"],$G=[["diff_stats","head_sha"],["diff_stats","base_sha"],["attest","commit_sha"],["attest","base_sha"],["attest","merge_base_sha"]],yA=/^[a-f0-9]{40}$|^[a-f0-9]{64}$/,LG=7,_A=12,jG=10;s(kA,"isDenyGrade");s(FG,"extractShaArgs");s(HG,"classifySha");s(fi,"shaFindingText");s(wA,"cleanGitEnv");s(Uc,"resolveRepoRootForSha");s(UG,"gitShaResolver");s(Bc,"inspectLineForShas")});import{execFileSync as BG}from"node:child_process";import{createHash as GG}from"node:crypto";import{mkdirSync as KG,readFileSync as WG,renameSync as VG,writeFileSync as qG}from"node:fs";import{dirname as SA,join as xA}from"node:path";function mt(e=process.cwd()){try{let t=BG("git",["rev-parse","--show-toplevel"],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim();return t.length>0?t:e}catch{return e}}function Xn(e){return GG("sha256").update(e).digest("hex").slice(0,16)}function Gc(e){return xA(e,zG)}function EA(e){return!!e&&typeof e.instructions=="string"&&e.instructions.trim().length>0}function TA(e,t,n,r=new Date().toISOString()){try{if(!EA(n))return;let o={version:Jh,cached_at:r,mcp_url:t.mcpUrl,key_fp:t.keyFp,client_family:t.clientFamily??null,result:n},i=Gc(e);KG(SA(i),{recursive:!0}),Bs(SA(i));let a=`${i}.${process.pid}.tmp`;qG(a,JSON.stringify(o,null,2),"utf8"),VG(a,i)}catch{}}function Kc(e,t){try{let n=WG(Gc(e),"utf8"),r=JSON.parse(n);return r.version!==Jh||r.mcp_url!==t.mcpUrl||r.key_fp!==t.keyFp||(r.client_family??null)!==(t.clientFamily??null)||typeof r.cached_at!="string"||!EA(r.result)?null:{version:Jh,cached_at:r.cached_at,mcp_url:r.mcp_url,key_fp:r.key_fp,client_family:r.client_family??null,result:r.result}}catch{return null}}function AA(e,t,n=new Date){let r=JG(t.cached_at,n),o=t.result.instructions??"",i={...t.result,instructions:`${r}
142
+ `)){if(!i.startsWith("worktree "))continue;let a=i.slice(9).trim();if(!a||a===o||!Eh(a))continue;let l=Pc(a,t);if(Eh(l))try{for(let c of rG(l)){let u=ni(c);u!==null&&!n.has(u)&&n.set(u,a)}}catch{}}return n}function Rh(e,t={}){let n=t.runPsql??zT,r=t.timeoutMs??15e3,o=[],i=zr(e,t.dirs);if(i.length===0)return{ok:!1,verdict:"no_opinion",findings:[],facts:{projects:[],remoteConsulted:t.remoteDbUrl!==void 0,skipped:o}};let a=[],l=[],c=[];for(let p of i){let f=cG(e,p.dir,o),m=f.source==="missing"?null:WT(n,`postgresql://postgres:postgres@127.0.0.1:${f.port}/postgres`,r),h=t.remoteDbUrl!==void 0?WT(n,t.remoteDbUrl,r):null,g=VT({dir:p.dir,projectRoot:Pc(e,Th.dirname(Th.dirname(p.dir))),fileVersions:p.files.map(_=>_.version),config:f,ledger:m,siblingVersions:uG(e,p.dir),remote:h});a.push(...g.findings),c.push(g.verdict),l.push({dir:p.dir,migrationCount:p.files.length,verdict:g.verdict,db:g.db})}let u=qT(c),d={open:0,warn:1,info:2};return a.sort((p,f)=>d[p.status]-d[f.status]||p.id.localeCompare(f.id)),{ok:u==="in_sync",verdict:u,findings:a,facts:{projects:l,remoteConsulted:t.remoteDbUrl!==void 0,skipped:o}}}var Ah,zT,aG,XT=w(()=>{"use strict";Pe();Yr();Ah=54322;s(VT,"evaluateLedgerProject");s(qT,"deriveLedgerVerdict");zT=s((e,t,n)=>{let r=iG("psql",[e,"-tAc",t],{encoding:"utf8",timeout:n,env:{...process.env,PGCONNECT_TIMEOUT:"5"}});return r.error&&r.error.code==="ENOENT"?{ok:!1,code:"enoent",stderr:""}:r.status!==0?{ok:!1,code:"error",stderr:(r.stderr??"").trim()}:{ok:!0,stdout:r.stdout??""}},"defaultRunPsql"),aG="select version from supabase_migrations.schema_migrations order by version";s(JT,"classifyLedgerError");s(WT,"readLedger");s(YT,"parseDbPort");s(lG,"mainWorktreeRoot");s(cG,"resolveConfig");s(uG,"gatherSiblingVersions");s(Rh,"checkMigrationLedgerDrift")});function At(e){return typeof e=="string"?e:String(e??"")}function oa(e){return typeof e=="number"?e:Number(typeof e=="bigint"?e:e??0)}function Ch(e){return{nodeKey:At(e.node_key),kind:At(e.kind),name:At(e.name),qualifiedName:At(e.qualified_name),filePath:At(e.file_path),startLine:oa(e.start_line),endLine:oa(e.end_line),signature:typeof e.signature=="string"?e.signature:null}}function eA(e){return{path:At(e.path),language:At(e.language),contentHash:At(e.content_hash),mtimeMs:oa(e.mtime_ms),size:oa(e.size),indexedAt:oa(e.indexed_at)}}function Ih(e){let t=new Map,n=s(o=>{let i=t.get(o);return i===void 0&&(i=e.prepare(o),t.set(o,i)),i},"stmt"),r=s(o=>{let i=n(Jn.meta).get(o);return i===void 0?null:At(i.value)},"metaValue");return{meta(){let o=r(zn),i=r(na);return{schemaVersion:o,schemaCurrent:o===qn,edgesDirty:r(ci)==="1",lastIndexedAt:i===null?null:Number(i)}},file(o){let i=n(Jn.file).get(o);return i===void 0?null:eA(i)},files(o){let i=new Map;for(let a of new Set(o)){let l=n(Jn.file).get(a);l!==void 0&&i.set(a,eA(l))}return i},symbolsInFile(o,i=dG){return n(Jn.symbolsInFile).all(o,i).map(Ch)},symbolsNamed(o,i=pG){let a=new Map;for(let l of new Set(o)){let c=n(Jn.symbolsNamed).all(l,i);c.length>0&&a.set(l,c.map(Ch))}return a},callersOfFile(o,i=fG){return n(Jn.callersOfFile).all(o,o,i).map(l=>({calleeKey:At(l.callee_key),kind:At(l.edge_kind),caller:Ch(l)}))},importersOf(o,i=mG){let a=n(Jn.importersOf).all(rn(o),i),l=[];for(let c of a){let u=At(c.src_key),d=u.endsWith(QT)?u.slice(0,-QT.length):u;d!==o&&!l.includes(d)&&l.push(d)}return l},close(){e.close()}}}function ia(e,t){return Math.floor(t.mtimeMs)===e.mtimeMs&&t.size===e.size}var ZT,Jn,dG,pG,fG,mG,QT,Nh=w(()=>{"use strict";qr();ui();ZT="node_key, kind, name, qualified_name, file_path, start_line, end_line, signature",Jn={meta:"SELECT key, value FROM meta WHERE key = ?",file:"SELECT path, language, content_hash, mtime_ms, size, indexed_at FROM files WHERE path = ?",symbolsInFile:`SELECT ${ZT} FROM nodes WHERE file_path = ? AND kind <> 'module' ORDER BY start_line LIMIT ?`,symbolsNamed:`SELECT ${ZT} FROM nodes WHERE name = ? AND kind <> 'module' ORDER BY file_path, start_line LIMIT ?`,callersOfFile:"SELECT e.dst_key AS callee_key, e.kind AS edge_kind, c.node_key, c.kind, c.name, c.qualified_name, c.file_path, c.start_line, c.end_line, c.signature FROM nodes n JOIN edges e ON e.dst_key = n.node_key AND e.kind IN ('calls', 'extends', 'implements') JOIN nodes c ON c.node_key = e.src_key WHERE n.file_path = ? AND c.file_path <> ? LIMIT ?",importersOf:"SELECT src_key FROM edges WHERE dst_key = ? AND kind = 'imports' LIMIT ?"},dG=400,pG=8,fG=600,mG=200,QT="#<module>";s(At,"str");s(oa,"num");s(Ch,"toSymbol");s(eA,"toFileRow");s(Ih,"createIndexReader");s(ia,"isFileCurrent")});var Oh,Dh=w(()=>{"use strict";Oh="0.2.0"});function Ph(e,t){return{since:e??void 0,includeUncommitted:e?t:!0,limit:Kn,attest:!0}}function Mh(e,t){let n=0,r=[];for(let i of e.symbols){let a=i.qualifiedName?i.qualifiedName:void 0;if(i.name.length===0||i.name.length>Mc||a!==void 0&&a.length>$c){n+=1;continue}r.push({name:i.name,...a!==void 0?{qualified_name:a}:{},...i.kind&&i.kind.length<=nA?{kind:i.kind}:{},...i.language&&i.language.length<=rA?{language:i.language}:{},change:i.change,changed_line_count:Math.min(Math.max(0,i.changedLineCount),oA)})}return{payload:{changed_symbols:r,risk_flags:[...e.riskFlags],detector_findings:t.findings,detector_runs:t.engines.map(i=>({detector_id:i.detector_id,detector_version:i.detector_version,state:i.state})),diff_stats:{base_kind:e.baseKind,changed_file_count:e.changedFiles,stale_file_count:e.staleFiles,unindexed_file_count:e.changedFiles-e.indexedFiles,truncated:e.truncated||n>0,hunk_coverage:e.hunkCoverage,detector_coverage:t.coverage},...e.headSha?{commit_sha:e.headSha}:{},...e.baseSha?{base_sha:e.baseSha}:{},...typeof e.mergeBaseSha=="string"?{merge_base_sha:e.mergeBaseSha}:{},dirty:e.dirty,code_index_version:Oh},dropped:n}}function $h(e,t,n){return e?{persist:!1,skipped:"no_report"}:n.headSha?t?n.baseKind==="ref"&&typeof n.mergeBaseSha!="string"?{persist:!1,skipped:"no_merge_base"}:{persist:!0,skipped:null}:{persist:!1,skipped:"no_project_key"}:{persist:!1,skipped:"no_head"}}function Lh(e,t,n){let r=t,o=[];r===0?o.push("No code_review conventions apply to this repository \u2014 nothing was checked at convention level. This is an abstention, not a clean bill."):o.push(`Matched by the server (attest mode) against the repository's code_review set${typeof r=="number"?` (${r} convention(s))`:""} \u2014 ${e.symbols.length-n} changed symbol(s), no session filter, no cap.`),e.hunkCoverage!=="full"&&o.push(`Hunk coverage ${e.hunkCoverage}: some symbols could not be line-graded and count as co_located.`),e.staleFiles>0&&o.push(`${e.staleFiles} changed file(s) had a stale index \u2014 their symbols degraded to co_located.`);let i=e.changedFiles-e.indexedFiles;return i>0&&o.push(`${i} changed file(s) have no index rows \u2014 invisible to symbol matching (risk flags still cover them).`),e.truncated&&o.push(`Symbol list truncated at ${Kn} (co_located dropped first) \u2014 not attestation-grade.`),n>0&&o.push(`${n} symbol(s) with a name beyond the server schema were left out \u2014 not attestation-grade.`),o.join(" ")}function di(e){let t=/^MCP error (-?\d+):\s*([\s\S]*)$/.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=t[2]??"";return n===tA&&/\bTool \S+ not found\b/.test(r)?{kind:"unknown_tool",code:n,detail:r,issues:[]}:n===tA?{kind:"invalid_params",code:n,detail:r,issues:hG(r)}:{kind:"tool_error",code:n,detail:r,issues:[]}}function hG(e){let t=e.indexOf("[");if(t===-1)return[];try{let n=JSON.parse(e.slice(t));return Array.isArray(n)?n.filter(r=>typeof r=="object"&&r!==null):[]}catch{return[]}}function jh(e){if(e.kind!=="invalid_params"||e.issues.length!==1)return!1;let t=e.issues[0],n=t.path??[];return n.length===1&&n[0]==="findings"&&t.code==="invalid_type"&&(t.received===void 0||t.received==="undefined")}var Mc,$c,nA,rA,oA,tA,gG,iA=w(()=>{"use strict";nn();Dh();Mc=200,$c=512,nA=64,rA=32,oA=1e4;s(Ph,"attestReviewOptions");s(Mh,"buildAttestPayload");s($h,"attestPersistDecision");s(Lh,"attestCoverageNote");tA=-32602;s(di,"classifyMcpErrorText");s(hG,"parseIssues");s(jh,"isLegacyAttestRejection");gG=`MCP error -32602: Input validation error: Invalid arguments for tool review_verdict: ${JSON.stringify([{code:"invalid_type",expected:"array",received:"undefined",path:["findings"],message:"Required"}],null,2)}`});import{execFileSync as yG}from"node:child_process";import{existsSync as _G,readFileSync as bG,readdirSync as kG}from"node:fs";import{basename as wG,join as sA}from"node:path";function Lc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function cA(e,t){let n=new Set,r=new Set,o=0;for(let i of e){if(i.split("/").includes("node_modules"))continue;let a=wG(i);for(let[u,d]of SG)a===u&&r.add(d);if(xG.test(i)&&(n.add("supabase"),n.add("postgres")),a!=="package.json"||o>=lA)continue;o+=1;let l=t(i);if(!Lc(l))continue;r.add("javascript");let c={...Lc(l.dependencies)?l.dependencies:{},...Lc(l.devDependencies)?l.devDependencies:{},...Lc(l.peerDependencies)?l.peerDependencies:{}};Object.prototype.hasOwnProperty.call(c,"typescript")&&r.add("typescript");for(let[u,d]of vG)Object.prototype.hasOwnProperty.call(c,u)&&n.add(d)}return{platforms:[...n].sort(),languages:[...r].sort()}}function ao(e){return[...e.platforms,...e.languages]}function aA(e,t){try{return yG("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3,maxBuffer:64*1024*1024})}catch{return null}}function Tn(e){let t=aA(e,["rev-parse","--show-toplevel"])?.trim()||null,n=e,r,o=t===null?null:aA(t,["ls-files","-z"]);if(t!==null&&o!==null)n=t,r=o.split("\0").filter(i=>i.length>0);else{try{r=kG(e)}catch{return{platforms:[],languages:[]}}_G(sA(e,"supabase","migrations"))&&r.push("supabase/migrations/")}return cA(r,i=>{try{return JSON.parse(bG(sA(n,i),"utf8"))}catch{return null}})}var lA,vG,SG,xG,uA=w(()=>{"use strict";lA=200,vG=[["next","nextjs"],["react","react"],["react-dom","react"],["react-native","react-native"],["expo","expo"],["@supabase/supabase-js","supabase"],["@supabase/ssr","supabase"],["supabase","supabase"],["tailwindcss","tailwind"],["stripe","stripe"],["@stripe/stripe-js","stripe"],["pg","postgres"],["postgres","postgres"],["@modelcontextprotocol/sdk","mcp"]],SG=[["tsconfig.json","typescript"],["pyproject.toml","python"],["requirements.txt","python"],["go.mod","go"],["Cargo.toml","rust"]],xG=/(^|\/)supabase\/(config\.toml$|migrations\/)/;s(Lc,"isRecord");s(cA,"inferRepoStack");s(ao,"repoStackSlugs");s(aA,"git");s(Tn,"detectRepoStack")});var Me=w(()=>{"use strict";nw();Sh();Wf();yh();Pe();_c();Dm();xm();Rm();Im();tm();jT();GT();KT();Jf();qs();Sc();Qm();rh();sh();Xs();Yr();ea();XT();gm();mh();qs();Xs();Sc();ea();tc();Df();ui();Nh();rc();Dh();iA();uA()});import{homedir as EG}from"node:os";import{join as TG}from"node:path";function Fc(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!="object")continue;let r=n,o=sa(r.id),i=sa(r.key),a=sa(r.title),l=sa(r.status);if(!o||!i||!a||!l)continue;let c=r.here===!1?!1:void 0,u=sa(r.where);if(t.push({id:o,key:i,title:a,status:l,...c===!1?{here:c}:{},...u?{where:u}:{}}),t.length>=AG)break}return t}function Fh(e){if(e.length===0)return null;let t=e.map(r=>`${r.key} "${r.title}"${r.status==="warn"?" (blocked)":""}`+(r.here===!1?` (in ${r.where?`${r.where}/`:"a repository below this one"})`:"")).join(", "),n=e.length===1;return`Assigned to your user and not taken yet: ${t}. Their own agents may take ${n?"it":"these"} (take_work_object). Mention ${n?"it":"them"} to your user and offer to take ${n?"it":"one"} \u2014 do not start unasked. This lists what is ASSIGNED to your user, not the newest or most urgent work: when your user asks for something else (e.g. the newest object), answer that question \u2014 list_available_work({order:'newest'}).`}function Hh(e=EG()){return TG(e,".maind","assigned-told")}function dA(e,t){if(!e||typeof e!="object")return e;let n=e;return Array.isArray(n.assigned_to_you)?{...n,assigned_to_you:n.assigned_to_you.map(r=>{if(!r||typeof r!="object")return r;let o=r;if(o.here!==!1||typeof o.project_key!="string")return r;let i=t(o.project_key);return i?{...o,where:i}:r})}:e}function pA(e){return e==="claude-code"}var AG,sa,jc,aa=w(()=>{"use strict";AG=5,sa=s(e=>typeof e=="string"&&e.length>0?e:null,"str");s(Fc,"parseAssignedList");s(Fh,"assignedNoticeText");s(Hh,"assignedToldDir");jc=class{static{s(this,"AssignedInbox")}current=[];told=new Set;update(t){if(!t||typeof t!="object")return;let n=t;n.ok===!0&&(this.current=Fc(n.assigned_to_you))}takeNote(){let t=this.current.filter(n=>!this.told.has(n.id));for(let n of t)this.told.add(n.id);return Fh(t)}};s(dA,"labelNestedItems");s(pA,"clientHasHooks")});function gA(e){let t;try{t=JSON.parse(e)}catch{return{kind:"opaque"}}if(typeof t!="object"||t===null||Array.isArray(t))return{kind:"opaque"};let n=t;if(n.jsonrpc!=="2.0")return{kind:"opaque"};let r=typeof n.id=="number"||typeof n.id=="string"?n.id:void 0,o=typeof n.method=="string"?n.method:void 0;if(o!==void 0){let i={kind:r!==void 0?"request":"notification",method:o,id:r};if(o==="tools/call"){let a=n.params;if(typeof a=="object"&&a!==null){let l=a.name;typeof l=="string"&&(i.toolName=l)}}return i}return r!==void 0&&("result"in n||"error"in n)?{kind:"response",id:r}:{kind:"opaque"}}function pi(e,t,n){return JSON.stringify({jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:n??`maind gateway: tool '${t}' is denied by local gateway policy. The call was not forwarded to the server. Remove the --deny-tool flag (or adjust the gateway policy) to allow it.`}],isError:!0}})}function Gh(e,t,n,r){return{at:r,event:e,server:t,tool:n}}function Kh(e,t,n,r,o,i){return{at:r,event:e,server:t,tool:n,convention_id:o,convention_version:i}}function Wh(e,t,n,r){return{at:r,event:e,server:t,tool:n}}var Vh=w(()=>{"use strict";s(gA,"parseFrame");s(pi,"denyResult");s(Gh,"toolEvent");s(Kh,"policyEvent");s(Wh,"shaEvent")});import{execFileSync as bA}from"node:child_process";function kA(e){return e.verdict==="fabricated"&&(e.matchedPrefixLen??0)>=jG}function FG(e){let t;try{t=JSON.parse(e)}catch{return[]}if(typeof t!="object"||t===null)return[];let n=t.params;if(typeof n!="object"||n===null)return[];let r=n.arguments;if(typeof r!="object"||r===null)return[];let o=[];for(let i of MG){let a=r[i];typeof a=="string"&&yA.test(a)&&o.push({field:i,sha:a})}for(let[i,a]of $G){let l=r[i];if(typeof l!="object"||l===null)continue;let c=l[a];typeof c=="string"&&yA.test(c)&&o.push({field:`${i}.${a}`,sha:c})}return o}function HG(e,t){let n=t(e);if(n===e)return{field:"",sha:e,verdict:"proven"};if(n!==null)return{field:"",sha:e,verdict:"unknown"};let r=e.slice(0,_A);for(let o=_A;o>=LG;o--){let i=r.slice(0,o),a=t(i);if(a!==null&&a.startsWith(i))return{field:"",sha:e,verdict:"fabricated",matchedPrefixOf:a,matchedPrefixLen:o}}return{field:"",sha:e,verdict:"unknown"}}function fi(e,t){return e.verdict==="fabricated"?[`${t?"DENIED":"WARNING"}: the ${e.field} you passed (${e.sha}) does not exist in this repository,`,`but its prefix resolves to a real commit (${e.matchedPrefixOf}).`,"That combination cannot come from an unfetched object \u2014 it comes from completing an abbreviated hash.","Read the full hash instead of reconstructing it: `git rev-parse HEAD`, `git rev-parse <ref>`,","or `gh pr view <n> --json mergeCommit --jq .mergeCommit.oid`.",t?"The call was not forwarded.":"The call was forwarded \u2014 the record will carry an unverifiable hash."].join(" "):[`NOTE: the ${e.field} you passed (${e.sha}) could not be resolved in this repository.`,"That is often harmless \u2014 a fresh squash-merge commit, an unfetched branch, or a different repo in this workspace.","If you reconstructed it from an abbreviated hash, read the full one instead (`git rev-parse`, `gh --json`).","The call was forwarded."].join(" ")}function wA(){let e={...process.env};for(let t of["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE"])delete e[t];return e}function Uc(e=process.cwd()){try{let n=bA("git",["rev-parse","--show-toplevel"],{cwd:e,env:wA(),encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim();return n.length>0?n:null}catch{return null}}function UG(e){return t=>{try{let r=bA("git",["rev-parse","--verify","--quiet",`${t}^{commit}`],{cwd:e,env:wA(),encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim();return r.length>0?r:null}catch{return null}}}function Bc(e,t){if(t===null)return[];let n=FG(e);if(n.length===0)return[];let r=UG(t),o=[];for(let{field:i,sha:a}of n){let l=HG(a,r);l.verdict!=="proven"&&o.push({...l,field:i})}return o}var MG,$G,yA,LG,_A,jG,qh=w(()=>{"use strict";MG=["commit_sha","base_sha","head_sha"],$G=[["diff_stats","head_sha"],["diff_stats","base_sha"],["attest","commit_sha"],["attest","base_sha"],["attest","merge_base_sha"]],yA=/^[a-f0-9]{40}$|^[a-f0-9]{64}$/,LG=7,_A=12,jG=10;s(kA,"isDenyGrade");s(FG,"extractShaArgs");s(HG,"classifySha");s(fi,"shaFindingText");s(wA,"cleanGitEnv");s(Uc,"resolveRepoRootForSha");s(UG,"gitShaResolver");s(Bc,"inspectLineForShas")});import{execFileSync as BG}from"node:child_process";import{createHash as GG}from"node:crypto";import{mkdirSync as KG,readFileSync as WG,renameSync as VG,writeFileSync as qG}from"node:fs";import{dirname as SA,join as xA}from"node:path";function mt(e=process.cwd()){try{let t=BG("git",["rev-parse","--show-toplevel"],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim();return t.length>0?t:e}catch{return e}}function Xn(e){return GG("sha256").update(e).digest("hex").slice(0,16)}function Gc(e){return xA(e,zG)}function EA(e){return!!e&&typeof e.instructions=="string"&&e.instructions.trim().length>0}function TA(e,t,n,r=new Date().toISOString()){try{if(!EA(n))return;let o={version:Jh,cached_at:r,mcp_url:t.mcpUrl,key_fp:t.keyFp,client_family:t.clientFamily??null,result:n},i=Gc(e);KG(SA(i),{recursive:!0}),Bs(SA(i));let a=`${i}.${process.pid}.tmp`;qG(a,JSON.stringify(o,null,2),"utf8"),VG(a,i)}catch{}}function Kc(e,t){try{let n=WG(Gc(e),"utf8"),r=JSON.parse(n);return r.version!==Jh||r.mcp_url!==t.mcpUrl||r.key_fp!==t.keyFp||(r.client_family??null)!==(t.clientFamily??null)||typeof r.cached_at!="string"||!EA(r.result)?null:{version:Jh,cached_at:r.cached_at,mcp_url:r.mcp_url,key_fp:r.key_fp,client_family:r.client_family??null,result:r.result}}catch{return null}}function AA(e,t,n=new Date){let r=JG(t.cached_at,n),o=t.result.instructions??"",i={...t.result,instructions:`${r}
143
143
 
144
144
  ${o}`};return JSON.stringify({jsonrpc:"2.0",id:e,result:i})}function JG(e,t){return`NOTE (MAIND cache fallback): the MAIND MCP server was unreachable, so these project conventions were served from a local snapshot taken ${YG(e,t)}. They may be stale, and MAIND tools are unavailable until the server is reachable again.`}function YG(e,t){let n=Date.parse(e);if(Number.isNaN(n))return"at an unknown time";let r=t.getTime()-n,o=Math.floor(r/6e4);if(o<1)return"just now";if(o<60)return`${o} minute${o===1?"":"s"} ago`;let i=Math.floor(o/60);if(i<24)return`${i} hour${i===1?"":"s"} ago`;let a=Math.floor(i/24);return`${a} day${a===1?"":"s"} ago`}var Jh,zG,jt=w(()=>{"use strict";Me();Jh=1,zG=xA(".maind","conventions-cache.json");s(mt,"resolveRepoRoot");s(Xn,"keyFingerprint");s(Gc,"cachePath");s(EA,"hasInstructions");s(TA,"writeConventionsCache");s(Kc,"readConventionsCache");s(AA,"buildCachedInitializeResponse");s(JG,"fallbackMarker");s(YG,"relativeAge")});import{existsSync as zc,mkdirSync as cK,readFileSync as IA,writeFileSync as eg,chmodSync as NA}from"node:fs";import{homedir as uK,hostname as dK,platform as Qh,release as pK}from"node:os";import{randomUUID as fK}from"node:crypto";import{join as lo}from"node:path";function Ft(){let e=uK(),t=process.env;if(Qh()==="darwin")return lo(e,"Library","Application Support","maind");if(Qh()==="win32"){let r=t.APPDATA&&t.APPDATA.length>0?t.APPDATA:lo(e,"AppData","Roaming");return lo(r,"maind")}let n=t.XDG_CONFIG_HOME&&t.XDG_CONFIG_HOME.length>0?t.XDG_CONFIG_HOME:lo(e,".config");return lo(n,"maind")}function OA(e){zc(e)||cK(e,{recursive:!0,mode:448})}function be(){let e=Ft();OA(e);let t=lo(e,mK);if(zc(t)){let r=IA(t,"utf8").trim();if(yK(r))return r}let n=fK();eg(t,n+`
145
145
  `,{encoding:"utf8",mode:384});try{NA(t,384)}catch{}return n}function yK(e){return gK.test(e)}function tg(){return lo(Ft(),hK)}function co(e){let t=Ft();OA(t);let n=tg();eg(n,e+`
@@ -151,7 +151,7 @@ ${o}`};return JSON.stringify({jsonrpc:"2.0",id:e,result:i})}function JG(e,t){ret
151
151
  `),null}async function wK(e,t){let n=await fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({device_code:t})});if(!n.ok){let r=await n.text();throw new Error(`poll ${n.status}: ${r}`)}return await n.json()}function vK(e){return new Promise(t=>setTimeout(t,e))}function SK(e,t){let n=[""," \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"," \u2502 \u2502"," \u2502 maind-mcp-bridge \u2014 first-time setup \u2502"," \u2502 \u2502"," \u2502 Approve this bridge to bind it to your maind account: \u2502"," \u2502 \u2502",` \u2502 Open: ${PA(e.verification_uri,56)} \u2502`,` \u2502 Code: ${PA(e.user_code,56)} \u2502`," \u2502 \u2502",` \u2502 (expires in ${Math.round(e.expires_in/60)} minutes)`.padEnd(67)+"\u2502"," \u2502 \u2502"," \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518",""];t.write(n.join(`
152
152
  `)+`
153
153
  `)}function PA(e,t){return e.length>=t?e.slice(0,t):e+" ".repeat(t-e.length)}async function xK(e){let t,n;switch(kK()){case"darwin":t="open",n=[e];break;case"win32":t="cmd",n=["/c","start","",e];break;default:t="xdg-open",n=[e];break}return new Promise((r,o)=>{try{let i=bK(t,n,{stdio:"ignore",detached:!0});i.on("error",o),i.unref(),r()}catch(i){o(i)}})}var ng=w(()=>{"use strict";ke();gi();s(yi,"runDeviceFlow");s(wK,"pollOnce");s(vK,"sleep");s(SK,"printAuthInstructions");s(PA,"pad");s(xK,"openExternalBrowser")});import{mkdirSync as EK,readFileSync as TK,renameSync as AK,writeFileSync as RK}from"node:fs";import{join as CK}from"node:path";function MA(e=Ft()){return CK(e,NK)}function DK(e){return e.replace(/mnd_[a-f0-9]{8}_[a-f0-9]{56}/gi,"mnd_\u2026").slice(0,OK)}function uo(e,t,n){try{let r=n.dir??Ft();EK(r,{recursive:!0,mode:448});let o={v:1,at:(n.now??new Date).toISOString(),outcome:e,detail:t===null?null:DK(t),bridge_version:n.version},i=MA(r),a=`${i}.${process.pid}.tmp`;RK(a,JSON.stringify(o)+`
154
- `,{encoding:"utf8",mode:384}),AK(a,i)}catch{}}function $A(e=Ft()){try{let t=JSON.parse(TK(MA(e),"utf8"));return t.v!==1||typeof t.at!="string"||!IK.includes(t.outcome)?null:{v:1,at:t.at,outcome:t.outcome,detail:typeof t.detail=="string"?t.detail:null,bridge_version:typeof t.bridge_version=="string"?t.bridge_version:"?"}}catch{return null}}var IK,NK,OK,rg=w(()=>{"use strict";ke();IK=["ok","paired","auth_failed","not_paired"],NK="connection-state.json",OK=200;s(MA,"connectionStatePath");s(DK,"redactDetail");s(uo,"writeConnectionState");s($A,"readConnectionState")});var K,Je=w(()=>{"use strict";K="0.124.0"});import{execFileSync as LA}from"node:child_process";import{createHash as PK}from"node:crypto";function og(e){return PK("sha256").update(e).digest("hex")}function ig(e){let t=e.trim();if(!t)return null;let n=/^[a-z][a-z0-9+.-]*:\/\//i.exec(t);if(n)t=t.slice(n[0].length),t=t.replace(/^[^@/]+@/,""),t=t.replace(/^([^/:]+):\d+(?=\/)/,"$1");else{t=t.replace(/^[^@/]+@/,"");let r=t.indexOf(":");r>=0&&(t=`${t.slice(0,r)}/${t.slice(r+1)}`)}return t=t.replace(/\.git$/i,"").replace(/\/+$/,"").toLowerCase(),t.length>0?t:null}function Zn(e){let t=ig(e);return t?og(t):null}function ne(){let e=process.env.MAIND_PROJECT_KEY?.trim().toLowerCase();if(e&&MK.test(e))return e;let t;try{t=LA("git",["config","--get","remote.origin.url"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim()}catch{return null}return t?Zn(t):null}function nt(e){let t;try{t=LA("git",["config","--get","remote.origin.url"],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim()}catch{return null}return t?Zn(t):null}var MK,_e=w(()=>{"use strict";s(og,"sha256Hex");s(ig,"normalizeRemoteUrl");s(Zn,"projectKeyFromRemote");MK=/^[a-f0-9]{64}$/;s(ne,"computeProjectKey");s(nt,"projectKeyForRepo")});import $K from"node:path";import{fileURLToPath as LK}from"node:url";function jK(e,t=$K.sep){return e.split(t).includes("_npx")}function xe(e){let t=e.extraArgs??[],n=s(r=>({command:"npx",args:["-y",FA,...t],env:{},fallbackReason:r}),"npx");return e.entryPath===null?n("bridge entry path could not be resolved"):jK(e.entryPath,e.sep)?n("bridge is running from the npx cache (install it globally to pin a path)"):e.nodePath?{command:e.nodePath,args:[e.entryPath,...t],env:e.isElectron?{ELECTRON_RUN_AS_NODE:"1"}:{},fallbackReason:null}:n("node executable path unavailable")}function se(){try{let e=LK(import.meta.url);return e.endsWith(".js")?e:null}catch{return null}}function rt(e){let t=Object.entries(e.env).map(([n,r])=>`${n}=${jA(r)}`);return[...t,e.command,...e.args].map((n,r)=>r<t.length?n:jA(n)).join(" ")}function Rt(e){return/(^|\s)npx(\s|$)/.test(e)&&e.includes(FA)}function Yc(e){return/(^|[\s/])maind-hook(\s|$)/.test(e)?!0:/claude-code-hook[/\\]build[/\\]/.test(e)}function jA(e){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}var FA,ot=w(()=>{"use strict";FA="@maind-dev/mcp-bridge";s(jK,"isEphemeralEntry");s(xe,"resolveBridgeLaunch");s(se,"currentBridgeEntry");s(rt,"launchToShellCommand");s(Rt,"isNpxForm");s(Yc,"isLegacyHookForm");s(jA,"shellQuote")});import{readFileSync as FK}from"node:fs";import*as H from"node:path";function BA(e){let t=e.launch??xe({entryPath:se(),nodePath:process.execPath,isElectron:process.versions.electron!==void 0});return{command:t.command,args:t.args,env:{...t.env,MAIND_CLIENT_FAMILY:e.clientFamily,MAIND_MCP_URL:e.mcpUrl}}}function KA(e){return eu(e,"Claude")}function UK(e){return H.join(KA(e),GA)}function eu(e,t){switch(e.platform){case"darwin":return H.join(e.homeDir,"Library","Application Support",t);case"win32":{let n=e.appData??H.join(e.homeDir,"AppData","Roaming");return H.join(n,t)}default:{let n=e.xdgConfigHome??H.join(e.homeDir,".config");return H.join(n,t)}}}function BK(e){return H.join(eu(e,"Code"),"User")}function Zc(e,t,n=[]){return{kind:"foreign-entries",dir:eu(e,t),ours:["User",...n]}}function HA(e){return e.localAppData??H.join(e.homeDir,"AppData","Local")}function KK(e){let t=[{kind:"foreign-entries",dir:KA(e),ours:[GA]}];return e.platform==="darwin"?t.push({kind:"dir",path:H.join("/Applications","Claude.app")},{kind:"dir",path:H.join(e.homeDir,"Applications","Claude.app")}):e.platform==="win32"&&t.push({kind:"dir",path:H.join(HA(e),"AnthropicClaude")},{kind:"dir",path:H.join(HA(e),"Packages",GK)}),{evidence:t,skipDetail:"Claude Desktop not found (no Claude app, no Claude Desktop app data beyond our config file)"}}function An(e){return{evidence:[Zc(e,"Cursor"),{kind:"foreign-entries",dir:H.join(e.homeDir,".cursor"),ours:["mcp.json","hooks.json"]}],skipDetail:"Cursor not found (no Cursor app data, nothing of Cursor's in ~/.cursor)"}}function WA(e){if(e.platform==="win32"){let t=e.appData??H.join(e.homeDir,"AppData","Roaming");return H.join(t,"devin")}return H.join(e.xdgConfigHome??H.join(e.homeDir,".config"),"devin")}function WK(e){return H.join(WA(e),"mcp_config.json")}function VA(e){return H.join(e.homeDir,".codeium","windsurf","mcp_config.json")}function Qc(e){let t=[Zc(e,"Devin",["mcp_config.json"]),{kind:"dir",path:H.join(e.homeDir,".devin")}];return e.platform!=="win32"&&t.push({kind:"foreign-entries",dir:WA(e),ours:["mcp_config.json"]}),t.push(Zc(e,"Windsurf"),{kind:"foreign-entries",dir:H.dirname(VA(e)),ours:["mcp_config.json"]}),{evidence:t,skipDetail:"Devin Desktop (formerly Windsurf) not found (no Devin or Windsurf app data, nothing of theirs in ~/.devin, Devin's config dir or ~/.codeium/windsurf)"}}function YK(e){return e===null?null:JK.exec(e)?.[1]??null}function zA(e,t){let n=qA.map(r=>H.join(e.homeDir,r.dataFolder,"extensions"));if(e.bundleAppRoot&&n.push(H.join(e.bundleAppRoot,"extensions")),e.platform==="darwin")for(let r of zK)for(let o of["/Applications",H.join(e.homeDir,"Applications")])n.push(H.join(o,`${r}.app`,"Contents","Resources","app","extensions"));return[...new Set(n)].map(r=>({kind:"extension",dir:r,id:t}))}function JA(e){return e.clineDataDir?e.clineDataDir:H.join(e.clineDir??H.join(e.homeDir,".cline"),"data")}function XK(e){return e.clineMcpSettingsPath??H.join(JA(e),"settings","cline_mcp_settings.json")}function sg(e){return{evidence:[{kind:"foreign-entries",dir:JA(e),ours:["settings"]},...VK.map(t=>({kind:"dir",path:H.join(eu(e,t),"User","globalStorage",UA)})),...zA(e,UA)],skipDetail:"Cline not found (no Cline data in ~/.cline, no Cline extension or storage in any editor)"}}function tu(e){return e.continueGlobalDir??H.join(e.homeDir,".continue")}function ZK(e){return H.join(tu(e),"mcpServers","maind.json")}function ag(e){return{evidence:[{kind:"foreign-entries",dir:tu(e),ours:["mcpServers","rules"]},...zA(e,qK)],skipDetail:"Continue not found (nothing of Continue's in ~/.continue, no Continue extension in any editor)"}}function Qn(e){return e.codexHome??H.join(e.homeDir,".codex")}function po(e){return H.join(Qn(e),"config.toml")}function bi(e){let t=Qn(e),n=H.join(e.homeDir,".codex"),r=[{kind:"foreign-entries",dir:t,ours:["config.toml"]}];return t!==n&&r.push({kind:"foreign-entries",dir:n,ours:["config.toml"]}),{evidence:r,skipDetail:t===n?"Codex not found (nothing of Codex's in ~/.codex)":"Codex not found (nothing of Codex's in $CODEX_HOME or ~/.codex)"}}function YA(e){return H.join(e.geminiCliHome??e.homeDir,".gemini")}function ki(e){return H.join(YA(e),"settings.json")}function wi(e){let t=YA(e),n=H.join(e.homeDir,".gemini"),r=[{kind:"foreign-entries",dir:t,ours:["settings.json"]}];return t!==n&&r.push({kind:"foreign-entries",dir:n,ours:["settings.json"]}),{evidence:r,skipDetail:t===n?"Gemini CLI not found (nothing of Gemini's in ~/.gemini)":"Gemini CLI not found (nothing of Gemini's in $GEMINI_CLI_HOME/.gemini or ~/.gemini)"}}function da(e){return{evidence:[Zc(e,"Code")],skipDetail:"VS Code not found (no VS Code app data)"}}function QK(e){return H.join(BK(e),"mcp.json")}function pa(e){return[{key:"claude-code-project",label:"Claude Code (project-scoped .mcp.json)",clientFamilyEnv:"claude-code",scope:"project",path:H.join(e.projectRoot,".mcp.json"),kind:"json"},{key:"claude-code-user",label:"Claude Code (user-scoped ~/.claude.json)",clientFamilyEnv:"claude-code",scope:"user",path:H.join(e.homeDir,".claude.json"),kind:"json"},{key:"claude-desktop",label:"Claude Desktop",clientFamilyEnv:"claude-desktop",scope:"user",path:UK(e),kind:"json",presence:KK(e)},{key:"cursor",label:"Cursor (~/.cursor/mcp.json)",clientFamilyEnv:"cursor",scope:"user",path:H.join(e.homeDir,".cursor","mcp.json"),kind:"json",presence:An(e)},{key:"windsurf",label:"Devin Desktop (formerly Windsurf)",clientFamilyEnv:"windsurf",scope:"user",path:WK(e),kind:"json",presence:Qc(e)},{key:"windsurf-legacy",label:"Devin Desktop (formerly Windsurf), legacy ~/.codeium/windsurf/mcp_config.json",clientFamilyEnv:"windsurf",scope:"user",path:VA(e),kind:"json",presence:Qc(e),refreshOnly:{skipDetail:"no maind entry here to keep current \u2014 Devin Desktop's own file is the windsurf row"}},{key:"vscode-copilot",label:"GitHub Copilot (VS Code user mcp.json)",clientFamilyEnv:"copilot",scope:"user",path:QK(e),kind:"json",jsonShape:{serversKey:"servers",entryType:"stdio"},presence:da(e)},{key:"cline",label:"Cline (~/.cline/data/settings/cline_mcp_settings.json)",clientFamilyEnv:"cline",scope:"user",path:XK(e),kind:"json",jsonShape:{serversKey:"mcpServers",clientKeys:{defaults:{disabled:!1},drop:["transport","type","transportType","url","headers"]}},presence:sg(e)},{key:"continue",label:"Continue (~/.continue/mcpServers/maind.json)",clientFamilyEnv:"continue",scope:"user",path:ZK(e),kind:"json",presence:ag(e)},{key:"gemini-cli",label:"Gemini CLI (~/.gemini/settings.json)",clientFamilyEnv:"gemini-cli",scope:"user",path:ki(e),kind:"json",presence:wi(e)},{key:"codex-cli",label:"Codex CLI (~/.codex/config.toml)",clientFamilyEnv:"codex",scope:"user",path:po(e),kind:"toml",presence:bi(e)}]}function XA(e,t){return t===null?e:e.filter(n=>n.clientFamilyEnv===t)}function ZA(e){return e.jsonShape??HK}function QA(e){let{homeDir:t,platform:n,env:r}=e,o=H.join(t,"Documents");if(n==="win32"){let c=["OneDrive","OneDriveConsumer","OneDriveCommercial"].map(u=>r[u]?.trim()).filter(u=>typeof u=="string"&&u.length>0&&H.win32.isAbsolute(u)).map(u=>H.join(u,"Documents"));return[...new Set([o,...c])]}if(n==="darwin")return[o];let i=r.XDG_CONFIG_HOME?.trim()||H.join(t,".config"),a=e.readText?.(H.join(i,"user-dirs.dirs"))??null,l=a===null?null:eR(a,t);return l!==null&&l!==o?[l,o]:[o]}function eR(e,t){for(let n of e.split(/\r?\n/)){let r=/^\s*XDG_DOCUMENTS_DIR\s*=\s*"?([^"]*)"?\s*$/.exec(n);if(!r)continue;let o=r[1].replace(/^\$HOME(?=\/|$)/,t).replace(/^\$\{HOME\}(?=\/|$)/,t);return H.isAbsolute(o)&&o.length>1?H.normalize(o):null}return null}function Ht(e){return{projectRoot:e.projectRoot,homeDir:e.homeDir,platform:e.platform,xdgConfigHome:Xc(e.env.XDG_CONFIG_HOME),appData:Xc(e.env.APPDATA),localAppData:Xc(e.env.LOCALAPPDATA),clineDir:_i(e.env.CLINE_DIR),clineDataDir:_i(e.env.CLINE_DATA_DIR),clineMcpSettingsPath:_i(e.env.CLINE_MCP_SETTINGS_PATH),continueGlobalDir:_i(e.env.CONTINUE_GLOBAL_DIR),codexHome:_i(e.env.CODEX_HOME),geminiCliHome:_i(e.env.GEMINI_CLI_HOME),bundleAppRoot:YK(e.bridgeEntry??null),documentsDirs:QA({homeDir:e.homeDir,platform:e.platform,env:e.env,readText:s(t=>{try{return FK(t,"utf8")}catch{return null}},"readText")})}}function Xc(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function _i(e){let t=Xc(e);return t!==null&&H.isAbsolute(t)?t:null}var HK,GA,GK,qA,VK,UA,qK,zK,JK,lg,Ge=w(()=>{"use strict";ot();HK={serversKey:"mcpServers"};s(BA,"buildMaindServerEntry");GA="claude_desktop_config.json";s(KA,"claudeDesktopAppDataDir");s(UK,"claudeDesktopConfigPath");s(eu,"editorAppDataDir");s(BK,"vsCodeUserDir");s(Zc,"editorRan");s(HA,"localAppDataDir");GK="Claude_pzs8sxrjxfjjc";s(KK,"claudeDesktopPresence");s(An,"cursorPresence");s(WA,"devinConfigDir");s(WK,"devinMcpConfigPath");s(VA,"windsurfLegacyMcpConfigPath");s(Qc,"devinDesktopPresence");qA=[{appData:"Code",dataFolder:".vscode"},{appData:"Code - Insiders",dataFolder:".vscode-insiders"},{appData:"Cursor",dataFolder:".cursor"},{appData:"VSCodium",dataFolder:".vscode-oss"},{appData:"Windsurf",dataFolder:".windsurf"},{appData:"Devin",dataFolder:".devin"},{appData:"AgentComposer",dataFolder:".agentcomposer"}],VK=qA.map(e=>e.appData),UA="saoudrizwan.claude-dev",qK="continue.continue",zK=["AgentComposer"],JK=/^(.+)[\\/]maind-bridge[\\/]node_modules[\\/]@maind-dev[\\/]mcp-bridge[\\/]build[\\/]index\.js$/;s(YK,"bundleAppRootOf");s(zA,"agentExtensionEvidence");s(JA,"clineDataDir");s(XK,"clineMcpSettingsPath");s(sg,"clinePresence");s(tu,"continueGlobalDir");s(ZK,"continueMcpConfigPath");s(ag,"continuePresence");s(Qn,"codexHomeDir");s(po,"codexConfigPath");s(bi,"codexPresence");s(YA,"geminiDir");s(ki,"geminiSettingsPath");s(wi,"geminiPresence");s(da,"vsCodePresence");s(QK,"vsCodeUserMcpPath");s(pa,"getClientTargets");s(XA,"filterTargetsByFamily");s(ZA,"jsonShapeOf");lg=[...new Set(pa({projectRoot:"/",homeDir:"/",platform:"linux",xdgConfigHome:null,appData:null}).map(e=>e.clientFamilyEnv))];s(QA,"documentsDirCandidates");s(eR,"parseXdgDocumentsDir");s(Ht,"makeDefaultContext");s(Xc,"nonEmpty");s(_i,"absoluteOrNull")});function cg(){return lg.map(e=>{let t=Object.keys(nu).filter(n=>nu[n]===e);return t.length>0?`${e} (or ${t.join(", ")})`:e}).join(", ")}function tR(e){let t={projectRoot:null,full:!1,team:!1,noRules:!1,noPreamble:!1,noHook:!1,nonInteractive:!1,token:null,oneClickToken:null,oneClickExchangeUrl:null,telemetry:!1,client:null,skipCodex:!1,dryRun:!1,autoWorkingPaths:!1,agentActivity:!1,hooksOnly:!1,help:!1,notices:[]};for(let n=0;n<e.length;n++){let r=e[n];switch(r){case"-h":case"--help":t.help=!0;break;case"--full":t.full=!0;break;case"--team":t.team=!0;break;case"--no-rules":t.noRules=!0;break;case"--no-preamble":t.noPreamble||t.notices.push(eW),t.noPreamble=!0;break;case"--no-hook":t.noHook=!0;break;case"--non-interactive":t.nonInteractive=!0;break;case"--telemetry":t.telemetry=!0;break;case"--skip-codex":t.skipCodex=!0;break;case"--dry-run":t.dryRun=!0;break;case"--auto-working-paths":t.autoWorkingPaths=!0;break;case"--agent-activity":t.agentActivity=!0;break;case"--hooks-only":t.hooksOnly=!0;break;case"--project-root":{let o=e[n+1];if(o===void 0||o.startsWith("--"))throw new Ct("--project-root requires a path argument");t.projectRoot=o,n++;break}case"--token":{let o=e[n+1];if(o===void 0||o.startsWith("--"))throw new Ct("--token requires a token argument");t.token=o,n++;break}case"--one-click-token":{let o=e[n+1];if(o===void 0||o.startsWith("--"))throw new Ct("--one-click-token requires a token argument");t.oneClickToken=o,n++;break}case"--one-click-exchange-url":{let o=e[n+1];if(o===void 0||o.startsWith("--"))throw new Ct("--one-click-exchange-url requires a URL argument");t.oneClickExchangeUrl=o,n++;break}case"--client":{let o=e[n+1];if(o===void 0||o.startsWith("--"))throw new Ct(`--client requires a family argument (${cg()})`);let i=o.trim().toLowerCase(),a=Object.hasOwn(nu,i)?nu[i]:i;if(!lg.includes(a))throw new Ct(`--client "${o}" is not a known client family. Known: ${cg()}`);t.client=a,n++;break}default:throw new Ct(`Unknown flag: ${r} \u2014 run \`install --help\` for supported flags`)}}if(t.full&&(t.nonInteractive=!0),t.hooksOnly){let n=[t.noHook&&"--no-hook",t.projectRoot!==null&&"--project-root",t.team&&"--team",t.token!==null&&"--token",t.oneClickToken!==null&&"--one-click-token",t.oneClickExchangeUrl!==null&&"--one-click-exchange-url",t.client!==null&&"--client",t.skipCodex&&"--skip-codex",t.telemetry&&"--telemetry",t.autoWorkingPaths&&"--auto-working-paths",t.agentActivity&&"--agent-activity"].filter(r=>typeof r=="string");if(n.length>0)throw new Ct(`--hooks-only sets up the user-level channels and nothing else \u2014 drop ${n.join(", ")}`)}return t}function nR(){process.stdout.write(tW())}function tW(){return["","@maind-dev/mcp-bridge install \u2014 one-shot setup for the MAIND MCP server.","","Pairs this device with MAIND and merges the MCP-server entry into every","supported AI-client config it finds (user level). Then it sets up the","channels that bring the MAIND hint and your project conventions into each","session \u2014 each with its own consent, only for clients that are installed:","hooks for Claude Code (~/.claude/settings.json), Cursor (~/.cursor/hooks.json)","and Codex (config.toml), user-level rule files for GitHub Copilot, Cline and","Continue. It writes nothing into your repository unless you pass --team.","Idempotent \u2014 re-running is safe.","","Usage:"," npx -y @maind-dev/mcp-bridge install [flags]","","Common flags:"," --project-root <path> Override project-root detection (default: walk up from cwd)"," --full Non-interactive full setup (consents to the hooks and rule files)"," --team Also write into the repository, deliberately: the conventions"," block in AGENTS.md (kept current by the bridge) and the project"," .mcp.json \u2014 for teams whose colleagues should get the rules with"," the repository; recommended for teams that work mostly in Cursor"," --no-hook Never write hooks (Claude Code, Cursor, Codex; overrides --full)"," --no-rules Never write the user-level rule files (Copilot, Cline, Continue)"," --non-interactive Skip every TTY prompt (used by CI / Dashboard-One-Click)"," --token <key> Use a pre-issued mnd_ api-key instead of browser pairing"," --one-click-token <jwt> Exchange the dashboard one-click token for a device-bound"," key \u2014 no browser (needs --one-click-exchange-url; ADR-267)"," --one-click-exchange-url <url> Exchange endpoint (set by the launcher scripts)"," --client <family> Install only for one client family \u2014 one of:",` ${cg()}`," (windsurf = Devin Desktop, formerly Windsurf)"," --skip-codex Skip Codex (its config.toml and hook) even where Codex is installed",' --dry-run Compute the plan but do not write anything (status "would-\u2026")'," --hooks-only Only the user-level channels: the hooks (Claude Code; Cursor and"," Codex where installed) and the rule files (Copilot, Cline,"," Continue where installed) \u2014 no pairing, no MCP configs; adds"," what an existing install is missing; with --full, without prompts"," --agent-activity Opt-in: Claude Code sessions bound to one work object report their"," agent activity (plan, action counts, questions, answers) to it \u2014"," never paths or commands; not implied by --full"," --telemetry Opt-in: post anonymous install_completed event"," --no-preamble No effect since 0.100.0 (accepted for old scripts)"," -h, --help Show this help text","","Examples:"," npx -y @maind-dev/mcp-bridge install # interactive default"," npx -y @maind-dev/mcp-bridge install --dry-run # preview without writing anything"," npx -y @maind-dev/mcp-bridge install --full --telemetry # full setup, opt-in telemetry"," npx -y @maind-dev/mcp-bridge install --team # also AGENTS.md + .mcp.json in the repo"," npx -y @maind-dev/mcp-bridge install --client cursor # only Cursor target","","Blocks earlier versions wrote into a repository (CLAUDE.md, AGENTS.md, \u2026) stay","until you remove them: maind-mcp-bridge doctor --migrate-repo-blocks lists them.","","After it finishes, restart your MCP client so the new server entry takes effect.",""].join(`
154
+ `,{encoding:"utf8",mode:384}),AK(a,i)}catch{}}function $A(e=Ft()){try{let t=JSON.parse(TK(MA(e),"utf8"));return t.v!==1||typeof t.at!="string"||!IK.includes(t.outcome)?null:{v:1,at:t.at,outcome:t.outcome,detail:typeof t.detail=="string"?t.detail:null,bridge_version:typeof t.bridge_version=="string"?t.bridge_version:"?"}}catch{return null}}var IK,NK,OK,rg=w(()=>{"use strict";ke();IK=["ok","paired","auth_failed","not_paired"],NK="connection-state.json",OK=200;s(MA,"connectionStatePath");s(DK,"redactDetail");s(uo,"writeConnectionState");s($A,"readConnectionState")});var K,Je=w(()=>{"use strict";K="0.124.1"});import{execFileSync as LA}from"node:child_process";import{createHash as PK}from"node:crypto";function og(e){return PK("sha256").update(e).digest("hex")}function ig(e){let t=e.trim();if(!t)return null;let n=/^[a-z][a-z0-9+.-]*:\/\//i.exec(t);if(n)t=t.slice(n[0].length),t=t.replace(/^[^@/]+@/,""),t=t.replace(/^([^/:]+):\d+(?=\/)/,"$1");else{t=t.replace(/^[^@/]+@/,"");let r=t.indexOf(":");r>=0&&(t=`${t.slice(0,r)}/${t.slice(r+1)}`)}return t=t.replace(/\.git$/i,"").replace(/\/+$/,"").toLowerCase(),t.length>0?t:null}function Zn(e){let t=ig(e);return t?og(t):null}function ne(){let e=process.env.MAIND_PROJECT_KEY?.trim().toLowerCase();if(e&&MK.test(e))return e;let t;try{t=LA("git",["config","--get","remote.origin.url"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim()}catch{return null}return t?Zn(t):null}function nt(e){let t;try{t=LA("git",["config","--get","remote.origin.url"],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim()}catch{return null}return t?Zn(t):null}var MK,_e=w(()=>{"use strict";s(og,"sha256Hex");s(ig,"normalizeRemoteUrl");s(Zn,"projectKeyFromRemote");MK=/^[a-f0-9]{64}$/;s(ne,"computeProjectKey");s(nt,"projectKeyForRepo")});import $K from"node:path";import{fileURLToPath as LK}from"node:url";function jK(e,t=$K.sep){return e.split(t).includes("_npx")}function xe(e){let t=e.extraArgs??[],n=s(r=>({command:"npx",args:["-y",FA,...t],env:{},fallbackReason:r}),"npx");return e.entryPath===null?n("bridge entry path could not be resolved"):jK(e.entryPath,e.sep)?n("bridge is running from the npx cache (install it globally to pin a path)"):e.nodePath?{command:e.nodePath,args:[e.entryPath,...t],env:e.isElectron?{ELECTRON_RUN_AS_NODE:"1"}:{},fallbackReason:null}:n("node executable path unavailable")}function se(){try{let e=LK(import.meta.url);return e.endsWith(".js")?e:null}catch{return null}}function rt(e){let t=Object.entries(e.env).map(([n,r])=>`${n}=${jA(r)}`);return[...t,e.command,...e.args].map((n,r)=>r<t.length?n:jA(n)).join(" ")}function Rt(e){return/(^|\s)npx(\s|$)/.test(e)&&e.includes(FA)}function Yc(e){return/(^|[\s/])maind-hook(\s|$)/.test(e)?!0:/claude-code-hook[/\\]build[/\\]/.test(e)}function jA(e){return/^[A-Za-z0-9_@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}var FA,ot=w(()=>{"use strict";FA="@maind-dev/mcp-bridge";s(jK,"isEphemeralEntry");s(xe,"resolveBridgeLaunch");s(se,"currentBridgeEntry");s(rt,"launchToShellCommand");s(Rt,"isNpxForm");s(Yc,"isLegacyHookForm");s(jA,"shellQuote")});import{readFileSync as FK}from"node:fs";import*as H from"node:path";function BA(e){let t=e.launch??xe({entryPath:se(),nodePath:process.execPath,isElectron:process.versions.electron!==void 0});return{command:t.command,args:t.args,env:{...t.env,MAIND_CLIENT_FAMILY:e.clientFamily,MAIND_MCP_URL:e.mcpUrl}}}function KA(e){return eu(e,"Claude")}function UK(e){return H.join(KA(e),GA)}function eu(e,t){switch(e.platform){case"darwin":return H.join(e.homeDir,"Library","Application Support",t);case"win32":{let n=e.appData??H.join(e.homeDir,"AppData","Roaming");return H.join(n,t)}default:{let n=e.xdgConfigHome??H.join(e.homeDir,".config");return H.join(n,t)}}}function BK(e){return H.join(eu(e,"Code"),"User")}function Zc(e,t,n=[]){return{kind:"foreign-entries",dir:eu(e,t),ours:["User",...n]}}function HA(e){return e.localAppData??H.join(e.homeDir,"AppData","Local")}function KK(e){let t=[{kind:"foreign-entries",dir:KA(e),ours:[GA]}];return e.platform==="darwin"?t.push({kind:"dir",path:H.join("/Applications","Claude.app")},{kind:"dir",path:H.join(e.homeDir,"Applications","Claude.app")}):e.platform==="win32"&&t.push({kind:"dir",path:H.join(HA(e),"AnthropicClaude")},{kind:"dir",path:H.join(HA(e),"Packages",GK)}),{evidence:t,skipDetail:"Claude Desktop not found (no Claude app, no Claude Desktop app data beyond our config file)"}}function An(e){return{evidence:[Zc(e,"Cursor"),{kind:"foreign-entries",dir:H.join(e.homeDir,".cursor"),ours:["mcp.json","hooks.json"]}],skipDetail:"Cursor not found (no Cursor app data, nothing of Cursor's in ~/.cursor)"}}function WA(e){if(e.platform==="win32"){let t=e.appData??H.join(e.homeDir,"AppData","Roaming");return H.join(t,"devin")}return H.join(e.xdgConfigHome??H.join(e.homeDir,".config"),"devin")}function WK(e){return H.join(WA(e),"mcp_config.json")}function VA(e){return H.join(e.homeDir,".codeium","windsurf","mcp_config.json")}function Qc(e){let t=[Zc(e,"Devin",["mcp_config.json"]),{kind:"dir",path:H.join(e.homeDir,".devin")}];return e.platform!=="win32"&&t.push({kind:"foreign-entries",dir:WA(e),ours:["mcp_config.json"]}),t.push(Zc(e,"Windsurf"),{kind:"foreign-entries",dir:H.dirname(VA(e)),ours:["mcp_config.json"]}),{evidence:t,skipDetail:"Devin Desktop (formerly Windsurf) not found (no Devin or Windsurf app data, nothing of theirs in ~/.devin, Devin's config dir or ~/.codeium/windsurf)"}}function YK(e){return e===null?null:JK.exec(e)?.[1]??null}function zA(e,t){let n=qA.map(r=>H.join(e.homeDir,r.dataFolder,"extensions"));if(e.bundleAppRoot&&n.push(H.join(e.bundleAppRoot,"extensions")),e.platform==="darwin")for(let r of zK)for(let o of["/Applications",H.join(e.homeDir,"Applications")])n.push(H.join(o,`${r}.app`,"Contents","Resources","app","extensions"));return[...new Set(n)].map(r=>({kind:"extension",dir:r,id:t}))}function JA(e){return e.clineDataDir?e.clineDataDir:H.join(e.clineDir??H.join(e.homeDir,".cline"),"data")}function XK(e){return e.clineMcpSettingsPath??H.join(JA(e),"settings","cline_mcp_settings.json")}function sg(e){return{evidence:[{kind:"foreign-entries",dir:JA(e),ours:["settings"]},...VK.map(t=>({kind:"dir",path:H.join(eu(e,t),"User","globalStorage",UA)})),...zA(e,UA)],skipDetail:"Cline not found (no Cline data in ~/.cline, no Cline extension or storage in any editor)"}}function tu(e){return e.continueGlobalDir??H.join(e.homeDir,".continue")}function ZK(e){return H.join(tu(e),"mcpServers","maind.json")}function ag(e){return{evidence:[{kind:"foreign-entries",dir:tu(e),ours:["mcpServers","rules"]},...zA(e,qK)],skipDetail:"Continue not found (nothing of Continue's in ~/.continue, no Continue extension in any editor)"}}function Qn(e){return e.codexHome??H.join(e.homeDir,".codex")}function po(e){return H.join(Qn(e),"config.toml")}function bi(e){let t=Qn(e),n=H.join(e.homeDir,".codex"),r=[{kind:"foreign-entries",dir:t,ours:["config.toml"]}];return t!==n&&r.push({kind:"foreign-entries",dir:n,ours:["config.toml"]}),{evidence:r,skipDetail:t===n?"Codex not found (nothing of Codex's in ~/.codex)":"Codex not found (nothing of Codex's in $CODEX_HOME or ~/.codex)"}}function YA(e){return H.join(e.geminiCliHome??e.homeDir,".gemini")}function ki(e){return H.join(YA(e),"settings.json")}function wi(e){let t=YA(e),n=H.join(e.homeDir,".gemini"),r=[{kind:"foreign-entries",dir:t,ours:["settings.json"]}];return t!==n&&r.push({kind:"foreign-entries",dir:n,ours:["settings.json"]}),{evidence:r,skipDetail:t===n?"Gemini CLI not found (nothing of Gemini's in ~/.gemini)":"Gemini CLI not found (nothing of Gemini's in $GEMINI_CLI_HOME/.gemini or ~/.gemini)"}}function da(e){return{evidence:[Zc(e,"Code")],skipDetail:"VS Code not found (no VS Code app data)"}}function QK(e){return H.join(BK(e),"mcp.json")}function pa(e){return[{key:"claude-code-project",label:"Claude Code (project-scoped .mcp.json)",clientFamilyEnv:"claude-code",scope:"project",path:H.join(e.projectRoot,".mcp.json"),kind:"json"},{key:"claude-code-user",label:"Claude Code (user-scoped ~/.claude.json)",clientFamilyEnv:"claude-code",scope:"user",path:H.join(e.homeDir,".claude.json"),kind:"json"},{key:"claude-desktop",label:"Claude Desktop",clientFamilyEnv:"claude-desktop",scope:"user",path:UK(e),kind:"json",presence:KK(e)},{key:"cursor",label:"Cursor (~/.cursor/mcp.json)",clientFamilyEnv:"cursor",scope:"user",path:H.join(e.homeDir,".cursor","mcp.json"),kind:"json",presence:An(e)},{key:"windsurf",label:"Devin Desktop (formerly Windsurf)",clientFamilyEnv:"windsurf",scope:"user",path:WK(e),kind:"json",presence:Qc(e)},{key:"windsurf-legacy",label:"Devin Desktop (formerly Windsurf), legacy ~/.codeium/windsurf/mcp_config.json",clientFamilyEnv:"windsurf",scope:"user",path:VA(e),kind:"json",presence:Qc(e),refreshOnly:{skipDetail:"no maind entry here to keep current \u2014 Devin Desktop's own file is the windsurf row"}},{key:"vscode-copilot",label:"GitHub Copilot (VS Code user mcp.json)",clientFamilyEnv:"copilot",scope:"user",path:QK(e),kind:"json",jsonShape:{serversKey:"servers",entryType:"stdio"},presence:da(e)},{key:"cline",label:"Cline (~/.cline/data/settings/cline_mcp_settings.json)",clientFamilyEnv:"cline",scope:"user",path:XK(e),kind:"json",jsonShape:{serversKey:"mcpServers",clientKeys:{defaults:{disabled:!1},drop:["transport","type","transportType","url","headers"]}},presence:sg(e)},{key:"continue",label:"Continue (~/.continue/mcpServers/maind.json)",clientFamilyEnv:"continue",scope:"user",path:ZK(e),kind:"json",presence:ag(e)},{key:"gemini-cli",label:"Gemini CLI (~/.gemini/settings.json)",clientFamilyEnv:"gemini-cli",scope:"user",path:ki(e),kind:"json",presence:wi(e)},{key:"codex-cli",label:"Codex CLI (~/.codex/config.toml)",clientFamilyEnv:"codex",scope:"user",path:po(e),kind:"toml",presence:bi(e)}]}function XA(e,t){return t===null?e:e.filter(n=>n.clientFamilyEnv===t)}function ZA(e){return e.jsonShape??HK}function QA(e){let{homeDir:t,platform:n,env:r}=e,o=H.join(t,"Documents");if(n==="win32"){let c=["OneDrive","OneDriveConsumer","OneDriveCommercial"].map(u=>r[u]?.trim()).filter(u=>typeof u=="string"&&u.length>0&&H.win32.isAbsolute(u)).map(u=>H.join(u,"Documents"));return[...new Set([o,...c])]}if(n==="darwin")return[o];let i=r.XDG_CONFIG_HOME?.trim()||H.join(t,".config"),a=e.readText?.(H.join(i,"user-dirs.dirs"))??null,l=a===null?null:eR(a,t);return l!==null&&l!==o?[l,o]:[o]}function eR(e,t){for(let n of e.split(/\r?\n/)){let r=/^\s*XDG_DOCUMENTS_DIR\s*=\s*"?([^"]*)"?\s*$/.exec(n);if(!r)continue;let o=r[1].replace(/^\$HOME(?=\/|$)/,t).replace(/^\$\{HOME\}(?=\/|$)/,t);return H.isAbsolute(o)&&o.length>1?H.normalize(o):null}return null}function Ht(e){return{projectRoot:e.projectRoot,homeDir:e.homeDir,platform:e.platform,xdgConfigHome:Xc(e.env.XDG_CONFIG_HOME),appData:Xc(e.env.APPDATA),localAppData:Xc(e.env.LOCALAPPDATA),clineDir:_i(e.env.CLINE_DIR),clineDataDir:_i(e.env.CLINE_DATA_DIR),clineMcpSettingsPath:_i(e.env.CLINE_MCP_SETTINGS_PATH),continueGlobalDir:_i(e.env.CONTINUE_GLOBAL_DIR),codexHome:_i(e.env.CODEX_HOME),geminiCliHome:_i(e.env.GEMINI_CLI_HOME),bundleAppRoot:YK(e.bridgeEntry??null),documentsDirs:QA({homeDir:e.homeDir,platform:e.platform,env:e.env,readText:s(t=>{try{return FK(t,"utf8")}catch{return null}},"readText")})}}function Xc(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function _i(e){let t=Xc(e);return t!==null&&H.isAbsolute(t)?t:null}var HK,GA,GK,qA,VK,UA,qK,zK,JK,lg,Ge=w(()=>{"use strict";ot();HK={serversKey:"mcpServers"};s(BA,"buildMaindServerEntry");GA="claude_desktop_config.json";s(KA,"claudeDesktopAppDataDir");s(UK,"claudeDesktopConfigPath");s(eu,"editorAppDataDir");s(BK,"vsCodeUserDir");s(Zc,"editorRan");s(HA,"localAppDataDir");GK="Claude_pzs8sxrjxfjjc";s(KK,"claudeDesktopPresence");s(An,"cursorPresence");s(WA,"devinConfigDir");s(WK,"devinMcpConfigPath");s(VA,"windsurfLegacyMcpConfigPath");s(Qc,"devinDesktopPresence");qA=[{appData:"Code",dataFolder:".vscode"},{appData:"Code - Insiders",dataFolder:".vscode-insiders"},{appData:"Cursor",dataFolder:".cursor"},{appData:"VSCodium",dataFolder:".vscode-oss"},{appData:"Windsurf",dataFolder:".windsurf"},{appData:"Devin",dataFolder:".devin"},{appData:"AgentComposer",dataFolder:".agentcomposer"}],VK=qA.map(e=>e.appData),UA="saoudrizwan.claude-dev",qK="continue.continue",zK=["AgentComposer"],JK=/^(.+)[\\/]maind-bridge[\\/]node_modules[\\/]@maind-dev[\\/]mcp-bridge[\\/]build[\\/]index\.js$/;s(YK,"bundleAppRootOf");s(zA,"agentExtensionEvidence");s(JA,"clineDataDir");s(XK,"clineMcpSettingsPath");s(sg,"clinePresence");s(tu,"continueGlobalDir");s(ZK,"continueMcpConfigPath");s(ag,"continuePresence");s(Qn,"codexHomeDir");s(po,"codexConfigPath");s(bi,"codexPresence");s(YA,"geminiDir");s(ki,"geminiSettingsPath");s(wi,"geminiPresence");s(da,"vsCodePresence");s(QK,"vsCodeUserMcpPath");s(pa,"getClientTargets");s(XA,"filterTargetsByFamily");s(ZA,"jsonShapeOf");lg=[...new Set(pa({projectRoot:"/",homeDir:"/",platform:"linux",xdgConfigHome:null,appData:null}).map(e=>e.clientFamilyEnv))];s(QA,"documentsDirCandidates");s(eR,"parseXdgDocumentsDir");s(Ht,"makeDefaultContext");s(Xc,"nonEmpty");s(_i,"absoluteOrNull")});function cg(){return lg.map(e=>{let t=Object.keys(nu).filter(n=>nu[n]===e);return t.length>0?`${e} (or ${t.join(", ")})`:e}).join(", ")}function tR(e){let t={projectRoot:null,full:!1,team:!1,noRules:!1,noPreamble:!1,noHook:!1,nonInteractive:!1,token:null,oneClickToken:null,oneClickExchangeUrl:null,telemetry:!1,client:null,skipCodex:!1,dryRun:!1,autoWorkingPaths:!1,agentActivity:!1,hooksOnly:!1,help:!1,notices:[]};for(let n=0;n<e.length;n++){let r=e[n];switch(r){case"-h":case"--help":t.help=!0;break;case"--full":t.full=!0;break;case"--team":t.team=!0;break;case"--no-rules":t.noRules=!0;break;case"--no-preamble":t.noPreamble||t.notices.push(eW),t.noPreamble=!0;break;case"--no-hook":t.noHook=!0;break;case"--non-interactive":t.nonInteractive=!0;break;case"--telemetry":t.telemetry=!0;break;case"--skip-codex":t.skipCodex=!0;break;case"--dry-run":t.dryRun=!0;break;case"--auto-working-paths":t.autoWorkingPaths=!0;break;case"--agent-activity":t.agentActivity=!0;break;case"--hooks-only":t.hooksOnly=!0;break;case"--project-root":{let o=e[n+1];if(o===void 0||o.startsWith("--"))throw new Ct("--project-root requires a path argument");t.projectRoot=o,n++;break}case"--token":{let o=e[n+1];if(o===void 0||o.startsWith("--"))throw new Ct("--token requires a token argument");t.token=o,n++;break}case"--one-click-token":{let o=e[n+1];if(o===void 0||o.startsWith("--"))throw new Ct("--one-click-token requires a token argument");t.oneClickToken=o,n++;break}case"--one-click-exchange-url":{let o=e[n+1];if(o===void 0||o.startsWith("--"))throw new Ct("--one-click-exchange-url requires a URL argument");t.oneClickExchangeUrl=o,n++;break}case"--client":{let o=e[n+1];if(o===void 0||o.startsWith("--"))throw new Ct(`--client requires a family argument (${cg()})`);let i=o.trim().toLowerCase(),a=Object.hasOwn(nu,i)?nu[i]:i;if(!lg.includes(a))throw new Ct(`--client "${o}" is not a known client family. Known: ${cg()}`);t.client=a,n++;break}default:throw new Ct(`Unknown flag: ${r} \u2014 run \`install --help\` for supported flags`)}}if(t.full&&(t.nonInteractive=!0),t.hooksOnly){let n=[t.noHook&&"--no-hook",t.projectRoot!==null&&"--project-root",t.team&&"--team",t.token!==null&&"--token",t.oneClickToken!==null&&"--one-click-token",t.oneClickExchangeUrl!==null&&"--one-click-exchange-url",t.client!==null&&"--client",t.skipCodex&&"--skip-codex",t.telemetry&&"--telemetry",t.autoWorkingPaths&&"--auto-working-paths",t.agentActivity&&"--agent-activity"].filter(r=>typeof r=="string");if(n.length>0)throw new Ct(`--hooks-only sets up the user-level channels and nothing else \u2014 drop ${n.join(", ")}`)}return t}function nR(){process.stdout.write(tW())}function tW(){return["","@maind-dev/mcp-bridge install \u2014 one-shot setup for the MAIND MCP server.","","Pairs this device with MAIND and merges the MCP-server entry into every","supported AI-client config it finds (user level). Then it sets up the","channels that bring the MAIND hint and your project conventions into each","session \u2014 each with its own consent, only for clients that are installed:","hooks for Claude Code (~/.claude/settings.json), Cursor (~/.cursor/hooks.json)","and Codex (config.toml), user-level rule files for GitHub Copilot, Cline and","Continue. It writes nothing into your repository unless you pass --team.","Idempotent \u2014 re-running is safe.","","Usage:"," npx -y @maind-dev/mcp-bridge install [flags]","","Common flags:"," --project-root <path> Override project-root detection (default: walk up from cwd)"," --full Non-interactive full setup (consents to the hooks and rule files)"," --team Also write into the repository, deliberately: the conventions"," block in AGENTS.md (kept current by the bridge) and the project"," .mcp.json \u2014 for teams whose colleagues should get the rules with"," the repository; recommended for teams that work mostly in Cursor"," --no-hook Never write hooks (Claude Code, Cursor, Codex; overrides --full)"," --no-rules Never write the user-level rule files (Copilot, Cline, Continue)"," --non-interactive Skip every TTY prompt (used by CI / Dashboard-One-Click)"," --token <key> Use a pre-issued mnd_ api-key instead of browser pairing"," --one-click-token <jwt> Exchange the dashboard one-click token for a device-bound"," key \u2014 no browser (needs --one-click-exchange-url; ADR-267)"," --one-click-exchange-url <url> Exchange endpoint (set by the launcher scripts)"," --client <family> Install only for one client family \u2014 one of:",` ${cg()}`," (windsurf = Devin Desktop, formerly Windsurf)"," --skip-codex Skip Codex (its config.toml and hook) even where Codex is installed",' --dry-run Compute the plan but do not write anything (status "would-\u2026")'," --hooks-only Only the user-level channels: the hooks (Claude Code; Cursor and"," Codex where installed) and the rule files (Copilot, Cline,"," Continue where installed) \u2014 no pairing, no MCP configs; adds"," what an existing install is missing; with --full, without prompts"," --agent-activity Opt-in: Claude Code sessions bound to one work object report their"," agent activity (plan, action counts, questions, answers) to it \u2014"," never paths or commands; not implied by --full"," --telemetry Opt-in: post anonymous install_completed event"," --no-preamble No effect since 0.100.0 (accepted for old scripts)"," -h, --help Show this help text","","Examples:"," npx -y @maind-dev/mcp-bridge install # interactive default"," npx -y @maind-dev/mcp-bridge install --dry-run # preview without writing anything"," npx -y @maind-dev/mcp-bridge install --full --telemetry # full setup, opt-in telemetry"," npx -y @maind-dev/mcp-bridge install --team # also AGENTS.md + .mcp.json in the repo"," npx -y @maind-dev/mcp-bridge install --client cursor # only Cursor target","","Blocks earlier versions wrote into a repository (CLAUDE.md, AGENTS.md, \u2026) stay","until you remove them: maind-mcp-bridge doctor --migrate-repo-blocks lists them.","","After it finishes, restart your MCP client so the new server entry takes effect.",""].join(`
155
155
  `)}var nu,eW,Ct,rR=w(()=>{"use strict";Ge();nu={devin:"windsurf"};s(cg,"familyChoices");eW="note: --no-preamble has no effect since bridge 0.100.0 \u2014 install writes no preamble files into the repository any more (ADR-364).";s(tR,"parseInstallFlags");Ct=class extends Error{static{s(this,"InstallFlagError")}constructor(t){super(t),this.name="InstallFlagError"}};s(nR,"printInstallHelp");s(tW,"installHelpText")});var fa,oR=w(()=>{"use strict";fa=class{static{s(this,"InstallReport")}results=[];add(t){this.results.push(t)}results_(){return this.results}summary(){let t=0,n=0,r=0;for(let o of this.results)o.status==="created"||o.status==="merged"||o.status==="skipped"||o.status==="would-create"||o.status==="would-merge"||o.status==="would-pair"?t++:o.status==="needs-user-decision"?n++:o.status==="failed"&&r++;return{total:this.results.length,ok:t,needsDecision:n,failed:r}}hasFailures(){return this.results.some(t=>t.status==="failed")}hasUserDecisionPending(){return this.results.some(t=>t.status==="needs-user-decision")}exitCode(){return this.hasFailures()||this.hasUserDecisionPending()?1:0}toMarkdownTable(){if(this.results.length===0)return`_no steps were attempted_
156
156
  `;let t=["Target","Action","Status","Detail"],n=Math.max(t[0].length,...this.results.map(u=>u.target.length)),r=Math.max(t[1].length,...this.results.map(u=>u.action.length)),o=Math.max(t[2].length,...this.results.map(u=>u.status.length)),i=Math.max(t[3].length,...this.results.map(u=>(u.detail??"").length)),a=s((u,d)=>u+" ".repeat(Math.max(0,d-u.length)),"pad"),l=`| ${"-".repeat(n)} | ${"-".repeat(r)} | ${"-".repeat(o)} | ${"-".repeat(i)} |`,c=[];c.push(`| ${a(t[0],n)} | ${a(t[1],r)} | ${a(t[2],o)} | ${a(t[3],i)} |`),c.push(l);for(let u of this.results)c.push(`| ${a(u.target,n)} | ${a(u.action,r)} | ${a(u.status,o)} | ${a(u.detail??"",i)} |`);return c.join(`
157
157
  `)+`