Agents kept re-checking the same v4 signatures (renames from Effect 3,
Schedule, CLI flags, MCP, vitest, vscode-jsonrpc failure modes). Record
them once and point to the file from CLAUDE.md.
The process is supervised: on exit after a successful initialize it is
spawned again with exponential backoff (500ms to 30s), open documents are
re-sent as didOpen before the new session is announced, and requests caught
by the crash wait for it and retry. A crash more than a minute after the
previous one starts a fresh streak; reaching the streak limit (default 3)
ends restarting for good, after which every request fails with an LspError
saying so. Restarts and give-ups are logged and forwarded to the MCP client.
Writes to the child's stdin go through a PassThrough so a broken pipe ends
the session instead of surfacing as an unhandled rejection.
Effect 4 MCP server (stdio/HTTP) bridging one LSP process: on-demand document
sync with LRU and disk change detection, push/pull diagnostics reconciliation,
capability-gated tools, diagnostics resources, tests against a fixture server.
2026-09-20 15:36:30 +08:00
17 changed files with 1261 additions and 216 deletions
An [MCP](https://modelcontextprotocol.io/) server that exposes a single [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) server to agents as a headless editor.
`lsp-mcp` starts the language server you provide, keeps its document state in sync with the workspace, and exposes the language server's capabilities through MCP tools and resources. It is written in TypeScript and [Effect](https://effect.website).
## Features
- stdio and Streamable HTTP MCP transports
- Diagnostics exposed both as a tool and subscribable MCP resources
- Preview-by-default edits for rename and formatting, with explicit disk application
- Language-server crash supervision, restart backoff, and document reopening
_A:e=>e,_E:e=>e},...an,[Symbol.iterator](){returnnewWt(this)}},gr=/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(hr),{_tag:`Success`,_op:`Success`,[it](e){returnvr(e)&&br(e)&&at(this.success,e.success)},[Be](){returnUe(Ve(this._tag))(Ve(this.success))},toString(){return`success(${Ot(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:Lt(this.success)}}}),_r=/*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(hr),{_tag:`Failure`,_op:`Failure`,[it](e){returnvr(e)&&yr(e)&&at(this.failure,e.failure)},[Be](){returnUe(Ve(this._tag))(Ve(this.failure))},toString(){return`failure(${Ot(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:Lt(this.failure)}}}),vr=e=>E(e,mr),yr=e=>e._tag===`Failure`,br=e=>e._tag===`Success`,xr=function(e){this.failure=e};xr.prototype=_r;constSr=e=>newxr(e),Cr=function(e){this.success=e};Cr.prototype=gr;constwr=e=>newCr(e);functionTr(e){return(t,n)=>t===n?0:e(t,n)}constEr=/*#__PURE__*/Tr((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),Dr=/*#__PURE__*/C(2,(e,t)=>Tr((n,r)=>e(t(n),t(r)))),Or=e=>C(2,(t,n)=>e(t,n)===-1),kr=e=>C(2,(t,n)=>e(t,n)===1),Ar=e=>C(2,(t,n)=>e(t,n)!==1),jr=e=>C(2,(t,n)=>e(t,n)!==-1),D=()=>dr,O=pr,Mr=cr,Nr=lr,Pr=ur,Fr=/*#__PURE__*/C(2,(e,{onNone:t,onSome:n})=>Nr(e)?t():n(e.value)),Ir=/*#__PURE__*/C(2,(e,t)=>Nr(e)?t():e.value),Lr=e=>e==null?D():O(e),Rr=e=>e===void0?D():O(e),zr=/*#__PURE__*/Ir(fe),Br=e=>(...t)=>{try{returnO(e(...t))}catch{returnD()}},Vr=/*#__PURE__*/C(2,(e,t)=>Nr(e)?D():O(t(e.value))),Hr=/*#__PURE__*/C(2,(e,t)=>Nr(e)?D():t(e.value)),Ur=/*#__PURE__*/C(2,(e,t)=>Nr(e)?D():t(e.value)?O(e.value):D()),Wr=/*#__PURE__*/C(2,(e,t)=>!Nr(e)&&t(e.value)),Gr=wr,Kr=Sr,qr=e=>{if(De(e))try{returnGr(e())}catch(e){returnKr(e)}try{returnGr(e.try())}catch(t){returnKr(e.catch(t))}},Jr=vr,Yr=yr,Xr=br,Zr=/*#__PURE__*/C(2,(e,t)=>Yr(e)?Kr(t(e.failure)):e),Qr=/*#__PURE__*/C(2,(e,t)=>Xr(e)?Gr(t(e.success)):e),$r=/*#__PURE__*/C(2,(e,{onFailure:t,onSuccess:n})=>Yr(e)?t(e.failure):n(e.success)),ei=/*#__PURE__*/(/* @__PURE__ */C(2,(e,t)=>{if(Xr(e))returne.success;throwt(e.failure)}))(w),ti=/*#__PURE__*/C(2,(e,t)=>Yr(e)?Kr(e.failure):t(e.success)),ni=$n,ri=e=>{lett=e[Symbol.iterator]().next();if(t.done)throwError(`headUnsafe: empty iterable`);returnt.value},ii=/*#__PURE__*/C(2,(e,t)=>{letn=0;for(letrofe){lete=t(r,n);if(Ce(e)){if(e)returnO(r)}elseif(Pr(e))returne;n++}returnD()}),ai={[Symbol.iterator](){returnoi}},oi={next(){return{done:!0,value:void0}}},si=()=>ai,ci=e=>Object.keys(e).length===0,li=/*#__PURE__*/C(2,(e,t)=>Object.hasOwn(e,t)),ui=/*#__PURE__*/C(2,(e,t)=>{letn={...e};for(letrofdi(e))Kt(n,r,t(e[r],r));returnn}),di=e=>Object.keys(e),fi=e=>C(2,(t,n)=>{for(letrofdi(t))if(!li(n,r)||!e(t[r],n[r]))return!1;return!0}),pi=e=>{lett=fi(e);return(e,n)=>t(e,n)&&t(n,e)},mi=globalThis.Array,hi=e=>mi.isArray(e)?e:mi.from(e),gi=/*#__PURE__*/C(2,(e,{onEmpty:t,onNonEmpty:n})=>yi(e)?n(e):t()),_i=/*#__PURE__*/C(2,(e,t)=>[...e,t]);mi.isArray;constvi=tr,yi=tr;functionbi(e,t){return!Number.isFinite(e)||e<0||e>=t.length}constxi=/*#__PURE__*/C(2,(e,t)=>{letn=Math.floor(t);if(bi(n,e))throwError(`Index out of bounds: ${n}`);returne[n]}),Si=e=>yi(e)?O(Ci(e)):D(),Ci=e=>e[e.length-1],wi=(e,t)=>Math.min(nr(e),t),Ti=/*#__PURE__*/C(2,(e,t)=>{letn=hi(e);returnn.slice(0,wi(t,n.length))}),Ei=/*#__PURE__*/C(2,(e,t)=>{letn=0;for(letrofe){if(t(r,n))returnO(n);n++}returnD()}),Di=ii,Oi=/*#__PURE__*/C(2,(e,t)=>{letn=hi(e);for(lete=n.length-1;e>=0;e--){letr=n[e],i=t(r,e);if(typeofi==`boolean`){if(i)returnO(r)}elseif(Pr(i))returni}returnD()}),ki=e=>mi.from(e).reverse(),Ai=()=>[],ji=e=>[e],Mi=/*#__PURE__*/C(2,(e,t)=>e.map(t)),Ni=/*#__PURE__*/C(3,(e,t,n)=>hi(e).reduce((e,t,r)=>n(e,t,r),t)),Pi=er,Fi=e=>On({op:e.label,[$t]:e.evaluate}),Ii=`~effect/Context/Service`,Li=function(){functione(){}lett=e;Object.setPrototypeOf(t,Ri);letn=(e,n)=>(t.key=e,n?.defaultValue&&(t[Bi]=Bi,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&zi.add(e),t);returnarguments.length>0?n(arguments[0],arguments[1]):n},Ri={[Ii]:Ii,.../*#__PURE__*/Fi({label:`Service`,evaluate(e){returnjn(sa(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){returne},context(e){returnta(this,e)},use(e){returnLn(t=>e(sa(t.context,this)))},useSync(e){returnLn(t=>jn(e(sa(t.context,this))))}},zi=/*#__PURE__*/newSet,Bi=`~effect/Context/Reference`,Vi=`~effect/Context`,Hi=(e,t,n,r)=>{leti=Object.create(Yi);returni.cacheRoot=e??i,i.base=t,i.overlay=n,i.depth=r,i._flat=void0,i.baseHits=0,i},Ui=(e,t)=>{t&&(Ui(e,t.parent),e.set(t.key,t.value))},Wi=e=>{if(e._flat)returne._flat;if(!e.overlay)returne._flat=e.base;lett=newMap(e.base);returnUi(t,e.overlay),e._flat=t},Gi=(e,t)=>{letn=newMap(e.mapUnsafe);returnt(n),Ji(n)},Ki=/*#__PURE__*/Symbol(),qi=(e,t)=>{letn=e;for(lete=n.overlay;e;e=e.parent)if(e.keLine truncated
`)},Ms=(e,t)=>{let n=t?.get(Mn.key);return n&&(e=`${e}\n${Ps(n)}`),e},Ns=(e,t)=>{let n=[`${e.name}:${e.message}`];for(let e of t){let t=e.fiberId===void 0?`unknown`:`#${e.fiberId}`,r=e.annotations.get(Nn.key);n.push(`atfiber(${t})`),r&&n.push(Ps(r))}return n.join(`
if(t.exports={concat:i,mask:a,toArrayBuffer:s,toBuffer:c,unmask:o},!process.env.WS_NO_BUFFER_UTIL)try{lete=se(`bufferutil`);t.exports.mask=function(t,n,r,i,o){o<48?a(t,n,r,i,o):e.mask(t,n,r,i,o)},t.exports.unmask=function(t,n){t.length<32?o(t,n):e.unmask(t,n)}}catch{}})),SR=/* @__PURE__ */x(((e,t)=>{letn=Symbol(`kDone`),r=Symbol(`kRun`);t.exports=class{constructor(e){this[n]=()=>{this.pending--,this[r]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[r]()}[r](){if(this.pending!==this.concurrency&&this.jobs.length){lete=this.jobs.shift();this.pending++,e(this[n])}}}})),CR=/* @__PURE__ */x(((e,t)=>{letn=se(`zlib`),r=xR(),i=SR(),{kStatusCode:a}=bR(),o=Buffer[Symbol.species],s=Buffer.from([0,0,255,255]),c=Symbol(`permessage-deflate`),l=Symbol(`total-length`),u=Symbol(`callback`),d=Symbol(`buffers`),f=Symbol(`error`),p;t.exports=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold===void0?1024:this._options.threshold,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!p){lete=this._options.concurrencyLimit===void0?10:this._options.concurrencyLimit;p=newi(e)}}staticgetextensionName(){return`permessage-deflate`}offer(){lete={};returnthis._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits??(e.client_max_window_bits=!0),e}accept(e){returne=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&=(this._inflate.close(),null),this._deflate){lete=this._deflate[u];this._deflate.close(),this._deflate=null,e&&e(/* @__PURE__ */Error(`The deflate stream was closed while data was being processed`))}}acceptAsServer(e){lett=this._options,n=e.find(e=>!(t.serverNoContextTakeover===!1&&e.server_no_context_takeover||e.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeoft.serverMaxWindowBits==`number`&&t.serverMaxWindowBits>e.server_max_window_bits)||typeoft.clientMaxWindowBits==`number`&&(typeofe.client_max_window_bits==`number`?t.clientMaxWindowBits>e.client_max_window_bits:!e.client_max_window_bits)));if(!n)throwError(`None of the extension offers can be accepted`);returnt.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeoft.serverMaxWindowBits==`number`&&(n.server_max_window_bits=t.serverMaxWindowBits),typeoft.clientMaxWindowBits==`number`?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&deleten.client_max_window_bits,n}acceptAsClient(e){lett=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throwError(`Unexpected parameter "client_no_context_takeover"`);if(!t.client_max_window_bits)typeofthis._options.clientMaxWindowBits==`number`&&(t.client_max_window_bits=this._options.clientMaxWindowBits);elseif(this._options.clientMaxWindowBits===!1||typeofthis._options.clientMaxWindowBits==`number`&&t.client_max_window_bits>this._options.clientMaxWindowBits)throwError(`Unexpected or invalid parameter "client_max_window_bits"`);returnt}normalizeParams(e){returne.forEach(e=>{Object.keys(e).forEach(t=>{letn=e[t];if(n.length>1)throwError(`Parameter "${t}" must have only a single value`);if(n=n[0],t===`client_max_window_bits`){if(n!==!0){lete=+n;if(!Number.isInteger(e)||e<8||e>15)throwTypeError(`Invalid value for parameter "${t}": ${n}`);n=e}elseif(!this._isServer)throwTypeError(`Invalid value for parameter "${t}": ${n}`)}elseif(t===`server_max_window_bits`){lete=+n;if(!Number.isInteger(e)||e<8||e>15)throwTypeError(`Invalid value for parameter "${t}": ${n}`);n=e}elseif(t===`client_no_context_takeover`||t===`server_no_context_takeover`){if(n!==!0)throwTypeError(`Invalid value for parameter "${t}": ${n}`)}elsethrowError(`Unknown parameter "${t}"`);e[t]=n})}),e}decompress(e,t,n){p.add(r=>{this._decompress(e,t,(e,t)=>{r(),n(e,t)})})}compress(e,t,n){p.add(r=>{this._compress(e,t,(e,t)=>{r(),n(e,t)})})}_decompress(e,t,i){leta=this._isServer?`client`:`server`;if(!this._inflate){lete=`${a}_max_window_bits`,t=typeofthis.params[e]==`number`?this.params[e]:n.Z_DEFAULT_WINDOWBITS;this._inflate=n.createInflateRaw({...this._options.zlibInflateOptions,windowBits:t}),this._inflate[c]=this,this._inflate[l]=0,this._inflate[d]=[],this._inflate.on(`error`,g),this._inflate.on(`data`,h)}this._inflate[u]=i,this._inflate.write(e),t&&this._inflate.write(s),this._inflate.flush(()=>{lete=this._inflate[f];if(e){this._inflate.close(),this._inflate=null,i(e);return}letn=r.concat(this._inflate[d],this._inflate[l]);tLine truncated
/* istanbul ignore else */
(g===void0&&(g=Buffer.alloc(h)),r(g,0,h),_=0),n[0]=g[_++],n[1]=g[_++],n[2]=g[_++],n[3]=g[_++]),o=(n[0]|n[1]|n[2]|n[3])===0,a=6);lets;typeofe==`string`?(!t.mask||o)&&t[p]!==void0?s=t[p]:(e=Buffer.from(e),s=e.length):(s=e.length,i=t.mask&&t.readOnly&&!o);letc=s;s>=65536?(a+=8,c=127):s>125&&(a+=2,c=126);letl=Buffer.allocUnsafe(i?s+a:a);returnl[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(s,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),!t.mask||(l[1]|=128,l[a-4]=n[0],l[a-3]=n[1],l[a-2]=n[2],l[a-1]=n[3],o)?[l,e]:i?(d(e,n,l,a,s),[l]):(d(e,n,e,0,s),[l,e])}close(t,n,r,a){lets;if(t===void0)s=o;elseif(typeoft!=`number`||!u(t))throwTypeError(`First argument must be a valid error code number`);elseif(n===void0||!n.length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(t,0);else{lete=Buffer.byteLength(n);if(e>123)throwRangeError(`The message must not be greater than 123 bytes`);if(s=Buffer.allocUnsafe(2+e),s.writeUInt16BE(t,0),typeofn==`string`)s.write(n,2);elseif(i(n))s.set(n,2);elsethrowTypeError(`Second argument must be a string or a Uint8Array`)}letc={[p]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state===0?this.sendFrame(e.frame(s,c),a):this.enqueue([this.dispatch,s,!1,c,a])}ping(t,n,r){leti,a;if(typeoft==`string`?(i=Buffer.byteLength(t),a=!1):l(t)?(i=t.size,a=!1):(t=f(t),i=t.length,a=f.readOnly),i>125)throwRangeError(`The data size must not be greater than 125 bytes`);leto={[p]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:a,rsv1:!1};l(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}pong(t,n,r){leti,a;if(typeoft==`string`?(i=Buffer.byteLength(t),a=!1):l(t)?(i=t.size,a=!1):(t=f(t),i=t.length,a=f.readOnly),i>125)throwRangeError(`The data size must not be greater than 125 bytes`);leto={[p]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:a,rsv1:!1};l(t)?this._state===0?this.getBlobData(t,!1,o,r):this.enqueue([this.getBlobData,t,!1,o,r]):this._state===0?this.sendFrame(e.frame(t,o),r):this.enqueue([this.dispatch,t,!1,o,r])}send(e,t,n){letr=this._extensions[a.extensionName],i=t.binary?2:1,o=t.compress,s,c;typeofe==`string`?(s=Buffer.byteLength(e),c=!1):l(e)?(s=e.size,c=!1):(e=f(e),s=e.length,c=f.readOnly),this._firstFragment?(this._firstFragment=!1,o&&r&&r.params[r._isServer?`server_no_context_takeover`:`client_no_context_takeover`]&&(o=s>=r._threshold),this._compress=o):(o=!1,i=0),t.fin&&(this._firstFragment=!0);letu={[p]:s,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:c,rsv1:o};l(e)?this._state===0?this.getBlobData(e,this._compress,u,n):this.enqueue([this.getBlobData,e,this._compress,u,n]):this._state===0?this.dispatch(e,this._compress,u,n):this.enqueue([this.dispatch,e,this._compress,u,n])}getBlobData(t,n,r,i){this._bufferedBytes+=r[p],this._state=2,t.arrayBuffer().then(t=>{if(this._socket.destroyed){lete=/* @__PURE__ */Error(`The socket was closed while the blob was being read`);process.nextTick(v,this,e,i);return}this._bufferedBytes-=r[p];leta=f(t);n?this.dispatch(a,n,r,i):(this._state=0,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(e=>{process.nextTick(ee,this,e,i)})}dispatch(t,n,r,i){if(!n){this.sendFrame(e.frame(t,r),i);return}leto=this._extensions[a.extensionName];this._bufferedBytes+=r[p],this._state=1,o.compress(t,r.fin,(t,n)=>{if(this._socket.destroyed){lete=/* @__PURE__ */Error(`The socket was closed while data was being compressed`);v(this,e,i);return}this._bufferedBytes-=r[p],this._state=0,r.readOnly=!1,this.sendFrame(e.frame(n,r),i),this.dequeue()})}dequeue(){for(;this._state===0&&this._queue.length;){lete=this._queue.shift();this._bufferedBytes-=e[3][p],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][p],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};functionv(e,t,n){typeofn==`function`&&n(t);for(letn=0;n<e._queue.length;n++){letr=e._queue[n],i=r[r.length-1];typeofi==`function`&&i(t)}}functionee(e,t,n){v(e,t,n),e.onerror(t)}})),DR=/* @__PURE__ */x(((e,t)=>{let{kForOnEventAttribute:n,kListener:r}=bR(),i=Symbol(`kCode`),a=Symbol(`kData`),o=Symbol(`kError`),s=Symbol(`kMessage`),c=Symbol(`kReason`),l=Symbol(`kTarget`),u=Symbol(`kType`),d=Symbol(`kWasClean`);varf=class{constructor(e){this[l]=null,this[u]=e}gettarget(){returnthis[l]}gettype(){returnthis[u]}};Object.defineProperty(f.prototype,"target",{enumerable:!0}),Object.defineProperty(f.prototype,"type",{enumerable:!0});varp=classextendsf{constructor(e,t={}){super(e),this[i]=t.code===void0?0:t.code,this[c]=t.reason===void0?``:t.reason,this[d]=t.wasClean!==void0&&t.wasClLine truncated
/* istanbul ignore next */
getonclose(){returnnull}
/* istanbul ignore next */
getonerror(){returnnull}
/* istanbul ignore next */
getonopen(){returnnull}
/* istanbul ignore next */
getonmessage(){returnnull}getprotocol(){returnthis._protocol}getreadyState(){returnthis._readyState}geturl(){returnthis._url}setSocket(t,n,r){leti=newp({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),a=newm(t,this._extensions,r.generateMask);this._receiver=i,this._sender=a,this._socket=t,i[ne]=this,a[ne]=this,t[ne]=this,i.on(`conclude`,ge),i.on(`drain`,_e),i.on(`error`,ve),i.on(`message`,be),i.on(`ping`,xe),i.on(`pong`,Se),a.onerror=we,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on(`close`,Ee),t.on(`data`,De),t.on(`end`,Oe),t.on(`error`,ke),this._readyState=e.OPEN,this.emit(`open`)}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage);return}this._extensions[f.extensionName]&&this._extensions[f.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit(`close`,this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){me(this,this._req,`WebSocket was closed before the connection was established`);return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,n,!this._isServer,e=>{e||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Te(this)}}pause(){this.readyState!==e.CONNECTING&&this.readyState!==e.CLOSED&&(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throwError(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeoft==`function`?(r=t,t=n=void0):typeofn==`function`&&(r=n,n=void0),typeoft==`number`&&(t=t.toString()),this.readyState!==e.OPEN){he(this,t,r);return}n===void0&&(n=!this._isServer),this._sender.ping(t||v,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throwError(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeoft==`function`?(r=t,t=n=void0):typeofn==`function`&&(r=n,n=void0),typeoft==`number`&&(t=t.toString()),this.readyState!==e.OPEN){he(this,t,r);return}n===void0&&(n=!this._isServer),this._sender.pong(t||v,n,r)}resume(){this.readyState!==e.CONNECTING&&this.readyState!==e.CLOSED&&(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throwError(`WebSocket is not open: readyState 0 (CONNECTING)`);if(typeofn==`function`&&(r=n,n={}),typeoft==`number`&&(t=t.toString()),this.readyState!==e.OPEN){he(this,t,r);return}leti={binary:typeoft!=`string`,mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[f.extensionName]||(i.compress=!1),this._sender.send(t||v,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){me(this,this._req,`WebSocket was closed before the connection was established`);return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(T,"CONNECTING",{enumerable:!0,value:C.indexOf(`CONNECTING`)}),Object.defineProperty(T.prototype,"CONNECTING",{enumerable:!0,value:C.indexOf(`CONNECTING`)}),Object.defineProperty(T,"OPEN",{enumerable:!0,value:C.indexOf(`OPEN`)}),Object.defineProperty(T.prototype,"OPEN",{enumerable:!0,value:C.indexOf(`OPEN`)}),Object.defineProperty(T,"CLOSING",{enumerable:!0,value:C.indexOf(`CLOSING`)}),Object.defineProperty(T.prototype,"CLOSING",{enumerable:!0,value:C.indexOf(`CLOSING`)}),Object.defineProperty(T,"CLOSED",{enumerable:!0,value:C.indexOf(`CLOSED`)}),Object.defineProperty(T.prototype,"CLOSED",{enumerable:!0,value:C.indexOf(`CLOSED`)}),[`binaryType`,`bufferedAmount`,`extensions`,`isPaused`,`protocol`,`readyState`,`url`].forEach(e=>{Object.defineProperty(T.prototype,e,{enumerable:!0})}),[`open`,`error`,`close`,`message`].forEach(e=>{Object.defineProperty(T.prototype,`on${e}`,{enumerable:!0,get(){for(lettofthis.listeners(e))if(t[y])returnt[te];returnnull},set(t){for(lettofthis.listeners(e))if(t[y]){this.removeListener(e,t);break}typeoft==`function`&&this.addEventListener(e,t,{[y]:!0})}})}),T.prototype.addEventListener=re,T.prototype.removeEventListener=ie,t.exports=T;functionue(e,t,n,a){leto={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:_,protocolVersion:le[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...a,socketPath:void0,hostname:void0,protocol:void0,timeout:void0,method:`GET`,host:void0,path:void0,port:void0};if(e._autoPong=o.autoPong,e._closeTimeout=o.closeTimeout,!le.includes(o.protocolVersion))throwRangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${le.join(`, `)})`);lLine truncated
`).join(`\r
`)),i.removeListener(`error`,g),p.setSocket(i,c,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(p),p.on(`close`,()=>{this.clients.delete(p),this._shouldEmitClose&&!this.clients.size&&process.nextTick(h,this)})),l(p,r)}};function m(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return function(){for(let n of Object.keys(t))e.removeListener(n,t[n])}}function h(e){e._state=2,e.emit(`close`)}function g(){this.destroy()}function _(e,t,n,i){n||=r.STATUS_CODES[t],i={Connection:`close`,"Content-Type":`text/html`,"Content-Length":Buffer.byteLength(n),...i},e.once(`finish`,e.destroy),e.end(`HTTP/1.1${t}${r.STATUS_CODES[t]}\r\n`+Object.keys(i).map(e=>`${e}:${i[e]}`).join(`\r
`)}`:``;return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(``)}`:`Unrecognized flag: ${this.option}`)+e}},uV=classextends(/*#__PURE__*/IM(`${sV}/DuplicateOption`)(`DuplicateOption`,{option:V,parentCommand:V,childCommand:V})){[sV]=sV;getmessage(){return`Duplicate flag name "${this.option}" in parent command "${this.parentCommand}" and subcommand "${this.childCommand}". Parent will always claim this flag (Mode A semantics). Consider renaming one of them to avoid confusion.`}},dV=classextends(/*#__PURE__*/IM(`${sV}/MissingOption`)(`MissingOption`,{option:V})){[sV]=sV;getmessage(){return`Missing required flag: --${this.option}`}},fV=classextends(/*#__PURE__*/IM(`${sV}/MissingArgument`)(`MissingArgument`,{argument:V})){[sV]=sV;getmessage(){return`Missing required argument: ${this.argument}`}},pV=classextends(/*#__PURE__*/IM(`${sV}/UnexpectedArgument`)(`UnexpectedArgument`,{arguments:/*#__PURE__*/U(V)})){[sV]=sV;getmessage(){return`Unexpected positional ${this.arguments.length===1?`argument`:`arguments`}: ${this.arguments.map(e=>JSON.stringify(e)).join(`, `)}`}},mV=classextends(/*#__PURE__*/IM(`${sV}/InvalidValue`)(`InvalidValue`,{option:V,value:V,expected:V,kind:/*#__PURE__*/W([/*#__PURE__*/B(`flag`),/*#__PURE__*/B(`argument`)])})){[sV]=sV;getmessage(){lete=this.expected.startsWith(`Expected `)||this.expected.startsWith(`Expected:`)?this.expected:`Expected: ${this.expected}`;returnthis.kind===`argument`?`Invalid value for argument <${this.option}>: "${this.value}". ${e}`:this.value.length===0?`Missing value for flag --${this.option}. ${e}`:`Invalid value for flag --${this.option}: "${this.value}". ${e}`}},hV=classextends(/*#__PURE__*/IM(`${sV}/UnknownSubcommand`)(`UnknownSubcommand`,{subcommand:V,parent:/*#__PURE__*/pj(/*#__PURE__*/U(V)),suggestions:/*#__PURE__*/U(V)})){[sV]=sV;getmessage(){lete=this.suggestions.length>0?`\n\n Did you mean this?\n${this.suggestions.join(`
`)}`:``;returnthis.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(``)}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}};constgV=/*#__PURE__*/W([lV,uV,dV,fV,pV,mV,hV,classextends(/*#__PURE__*/IM(`${sV}/UserError`)(`UserError`,{cause:/*#__PURE__*/uM(),userMessage:/*#__PURE__*/fj(V)})){[sV]=sV;[gB]=!0;getmessage(){returnthis.userMessage?this.userMessage:typeofthis.cause==`string`&&this.cause?this.cause:this.causeinstanceofError&&this.cause.message?this.cause.message:`An error occurred`}}]);var_V=classextends(/*#__PURE__*/IM(`${sV}/ShowHelp`)(`ShowHelp`,{commandPath:/*#__PURE__*/U(V),errors:/*#__PURE__*/U(gV)})){[sV]=sV;[mB]=+!!this.errors.length;[gB]=!1;getmessage(){return`Help requested`}};constvV={"~effect/cli/Primitive":{_A:w}},yV=/*#__PURE__*/tj(Bj),bV=/*#__PURE__*/tj(Vj),xV=e=>e._tag===`Boolean`,SV=(e,t)=>Object.assign(Object.create(vV),{_tag:e,parse:t}),CV=(e,t)=>{letn=nj(zM(t));returnSV(e,e=>R(n(e),e=>e.message))},wV=/*#__PURE__*/CV(`Boolean`,Hj),TV=/*#__PURE__*/CV(`Int`,oM),EV=/*#__PURE__*/SV(`String`,e=>j(e)),DV=e=>{lett=newMap(e),n=e.map(([e])=>Ot(e)).join(` | `),r=SV(`Choice`,e=>t.has(e)?j(t.get(e)):F(n));returnObject.assign(r,{choiceKeys:e.map(([e])=>e)})},OV=(e,t)=>{letn=SV(`Path`,z(function*(n){letr=yield*px,i=yield*vx,a=i.isAbsolute(n)?n:i.resolve(n),o=yield*R(r.exists(a),e=>`Failed to check path existence: ${e.message}`);if(t===!0&&!o)returnyield*F(`Path does not exist: ${a}`);if(o&&e!==`either`){lett=yield*R(r.stat(a),e=>`Failed to stat path: ${e.message}`);if(e===`file`&&t.type!==`File`)returnyield*F(`Path is not a file: ${a}`);if(e===`directory`&&t.type!==`Directory`)returnyield*F(`Path is not a directory: ${a}`)}returna}));returnObject.assign(n,{pathType:e})},kV=/*#__PURE__*/SV(`KeyValuePair`,/*#__PURE__*/z(function*(e){lett=e.indexOf(`=`);if(t===-1)returnyield*F(`Invalid key=value format. Expected format: key=value, got: ${e}`);letn=e.slice(0,t),r=e.slice(t+1);return!n||!r?yield*F(`Invalid key=value format. Both key and value must be non-empty. Got: ${e}`):{[n]:r}})),AV=e=>{switch(e._tag){case`Boolean`:return`boolean`;case`String`:return`string`;case`Int`:return`integer`;case`Finite`:return`number`;case`Date`:return`date`;case`Path`:return`path`;case`Choice`:return`choice`;case`Redacted`:return`string`;case`FileText`:return`file`;case`FileParse`:return`file`;case`FileSchema`:return`file`;case`KeyValuePair`:return`key=value`;case`Never`:return`none`;default:return`value`}},jV=e=>e._tag===`Choice`?e.choiceKeys:void0,MV=e=>e._tag===`Path`?e.pathType:void0,NV=`\x1B[1m`,PV=`\x1B[4m`,FV=`\x1B[?25l`,IV=`\x1B[31m`,LV=`\x1B[32m`,RV=`\x1B[37m`,zV=`\x1B[90m`,BV=`\x1B[96m`,VV=(e,...t)=>`${t.flat().join(``)}${e}[0m`,HV=(...e)=>e,UV=(e,t)=>t===void0?`[${Math.max(e+1,0)}G`:`[${t+1};${Math.max(e+1,0)}H`,WV=(e=1)=>`[${e}B`,GV=(e,t=0)=>{letn=``;returnt<0&&(n+=`[${-t}A`),t>0&&(n+=`[${t}B`),e>0&&(n+=`[${e}C`),e<0&&(n+=`[${-e}D`),n},KV=e=>{lett=``;for(letn=0;n<e;n++)t+=`\x1B[2K`+(n<e-1?`\x1B[1A`:``);returne>0&&(t+=`\x1B[G`),t},qV={prefix:`?`,arrowUp:`↑`,arrowDown:`↓`,checkboxOn:`☒`,checkboxOff:`☐`,tick:`✔`,ellipsis:`…`,pointerSmall:`›`,pointer:`❯`,descriptionSeparator:`- `,passwordMask:`*`,toggleSeparator:`/`,primaryColor:BV,mutedColor:zV,successColor:LV,errorColor:IV,submittedColor:RV},JV={...qV,checkboxOn:`[*]`,checkboxOff:`[ ]`,tick:`√`,ellipsis:`...`,pointerSmall:`»`,pointer:`>`},YV=/*#__PURE__*/ma(`effect/unstable/cli/Prompt/Theme`,{defaultValue:e=>({...process.platform===`win32`?JV:qV,...e})}),XV=e=>L(YV,t=>({...t,...e.theme})),ZV=e=>VV(e,NV),QV=(e,t)=>VV(e,HV(`\x1B[3m`,t)),$V=(e,...t)=>e.length===0?``:VV(e,...t),eH=(e,t)=>e.length===0?t:e+``+t,tH=(e,t,n)=>{letr=Math.max(e.arrowUp.length,e.arrowDown.length);returnt?e.arrowUp.padEnd(r):n?e.arrowDown.padEnd(r):``.repeat(r)},nH=e=>{lett={initial:!1,...e,label:{confirm:`yes`,deny:`no`,...e.label},placeholder:{defaultConfirm:`(Y/n)`,defaultDeny:`(y/N)`,...e.placeholder}},n={value:t.initial};returnrH(n,{render:DH(t),process:e=>AH(e,t.initial),clear:CH(t)})},rH=(e,...t)=>{let[n,r]=t.length===1?[void0,t[0]]:[t[0],t[1]],i=Object.create(gH);returni._tag=`Loop`,i.initialState=e,i.render=r.render,i.process=r.process,i.clear=r.clear,i.events=n,i},iH=e=>{lett={initial:newglobalThis.Date,dateMask:`YYYY-MM-DD HH:mm:ss`,validate:j,...e,locales:{...UH,...e.locales}},n=JH(t.dateMask,t.initial,t.locales),r={dateParts:n,typed:``,cursor:n.findIndex(e=>!e.isToken()),value:t.initial,error:D()};returnrH(r,{render:WH(t),process:GH(t),clear:jH(t)})},aH=/*#__PURE__*/C(2,(e,t)=>{letn=Object.create(gH);returnn._tag=`OnSuccess`,n.prompt=e,n.onSuccess=t,n}),oH=e=>{lett={default:0,min:globalThis.Number.NEGATIVE_INFINITY,max:globalThis.Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,precision:2,validate:e=>e<t.min?F(`${e} must be greater than or equal to ${t.min}`):e>t.max?F(`${e} must be less than or equal to ${t.max}`):j(e),...e},n=e.default===void0?`Line truncated
`)},iG=(e,t)=>t?`${e},${t}`:e,aG=(e,t)=>{let n=[];if(e.description&&(n.push(t.bold(`DESCRIPTION`)),n.push(`${e.description}`),n.push(``)),n.push(t.bold(`USAGE`)),n.push(`${t.cyan(e.usage)}`),n.push(``),e.args&&e.args.length>0){n.push(t.bold(`ARGUMENTS`));let r=e.args.map(e=>{let n=e.name;e.variadic&&(n+=`...`);let r=`${t.green(n)}${t.dim(e.type)}`,i=e.required?``:t.dim(`(optional)`);return{left:r,right:Ir(e.description,()=>``)+i}});n.push(rG(r,25)),n.push(``)}if(e.flags.length>0){n.push(t.bold(`FLAGS`));let r=e.flags.map(e=>{let n=[];n.push(t.green(`--${e.name}`));for(let r of e.aliases)n.push(t.green(r));return{left:n.join(`,`)+(e.type===`boolean`?``:`${t.dim(e.type)}`),right:Ir(e.description,()=>``)}});n.push(rG(r)),n.push(``)}if(e.globalFlags&&e.globalFlags.length>0){n.push(t.bold(`GLOBALFLAGS`));let r=e.globalFlags.map(e=>{let n=[];n.push(t.green(`--${e.name}`));for(let r of e.aliases)n.push(t.green(r));return{left:n.join(`,`)+(e.type===`boolean`?``:`${t.dim(e.type)}`),right:Ir(e.description,()=>``)}});n.push(rG(r)),n.push(``)}if(e.subcommands&&e.subcommands.length>0){let r=e.subcommands.find(e=>e.group===void 0);r&&(n.push(t.bold(`SUBCOMMANDS`)),n.push(rG(r.commands.map(e=>({left:t.cyan(iG(e.name,e.alias)),right:e.shortDescription??e.description})),20)),e.subcommands.length>1&&n.push(``));for(let r of e.subcommands)r.group!==void 0&&(n.push(t.bold(`${r.group}:`)),n.push(rG(r.commands.map(e=>({left:t.cyan(iG(e.name,e.alias)),right:e.shortDescription??e.description})),20)),n.push(``))}if(e.examples&&e.examples.length>0){n.push(t.bold(`EXAMPLES`));let r=!0,i=!1;for(let a of e.examples)a.description?(r||n.push(``),n.push(`${t.dim(`# ${a.description}`)}`)):i&&n.push(``),n.push(`${t.cyan(a.command)}`),r=!1,i=!!a.description;n.push(``)}return n[n.length-1]===``&&n.pop(),n.join(`
`)},oG=e=>e.replace(/'/g,`'\\''`),sG=e=>e.replace(/[^a-zA-Z0-9_]/g,`_`),cG=e=>{let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);return e.type._tag===`Boolean`&&t.push(`--no-${e.name}`),t},lG=(e,t)=>{if(e.length===0)return;let n=e.map(cG);t.push(` local ${n.map((e,t)=>`_used_${t}=""`).join(` `)}`),t.push(` for ((i = 1; i < cword; i++)); do`),t.push('case"${words[i]%%=*}"in'),n.forEach((e,n)=>{t.push(` ${e.join(`|`)}) _used_${n}=1 ;;`)}),t.push(` esac`),t.push(` done`),t.push(` local _filtered_flags=""`),n.forEach((e,n)=>{t.push(` [[ -n "$_used_${n}" ]] || _filtered_flags+=" ${e.join(` `)}"`)}),t.push(``)},uG=(e,t)=>{t.push(`${e}()`),t.push(`{`),t.push(` local _cur="$1" _word="$2"; shift 2`),t.push(``),t.push('local_head="${_cur%"$_word"}"'),t.push(` local _open=""`),t.push(` case "$_head" in`),t.push(` *\\')_open="'";;`),t.push(`*\\") _open='"' ;;`),t.push(` esac`),t.push(``),t.push(` local _prefix="$_cur" _committed="$_head"`),t.push(" _prefix=${_prefix//\\\\/}; _prefix=${_prefix//\\\"/}; _prefix=${_prefix//\\'/}"),t.push("_committed=${_committed//\\\\/}; _committed=${_committed//\\\"/}; _committed=${_committed//\\'/}"),t.push(``),t.push(` COMPREPLY=()`),t.push(` local _choice _rest _match`),t.push(` for _choice in "$@"; do`),t.push(` [[ "$_choice" == "$_prefix"* ]] || continue`),t.push(' _rest="${_choice#"$_committed"}"'),t.push(` case "$_open" in`),t.push(` "'")`),t.push(` if [[ "$_head" == "'" ]]; then`),t.push(" _match=${_rest//\\'/\\'\\\\\\'\\'}"),t.push(` else`),t.push(` [[ "$_rest" == *\\'* ]] && continue`),t.push(` _match="$_rest"`),t.push(` fi`),t.push(` ;;`),t.push(` '"')`),t.push(' _match="${_rest//\\\\/\\\\\\\\}"'),t.push(' _match="${_match//\\$/\\\\$}"'),t.push(' _match="${_match//\\`/\\\\\\`}"'),t.push(' _match="${_match//\\"/\\\\\\"}"'),t.push(` ;;`),t.push(` *)`),t.push(` printf -v _match '%q' "$_rest"`),t.push(` [[ -z "$_head" && "$_match" == '~'* ]] && _match="\\\\$_match"`),t.push(` ;;`),t.push(` esac`),t.push(` [[ -n "$_open" && "$_match" == *"$_open" ]] && _match+="$_open"`),t.push(` COMPREPLY+=("$_match")`),t.push(` done`),t.push(`}`),t.push(``)},dG=(e,t)=>`${e} "$cur" "$_comp_word" ${t.map(e=>`'${oG(e)}'`).join(` `)}`,fG=(e,t)=>{switch(e._tag){case`Boolean`:return;case`Choice`:return dG(t,e.values);case`Path`:return e.pathType===`directory`?`COMPREPLY=( $(compgen -d -- "$cur") )`:`COMPREPLY=( $(compgen -f -- "$cur") )`;default:return}},pG=(e,t)=>{switch(e._tag){case`Choice`:return dG(t,e.values);case`Path`:return e.pathType===`directory`?`COMPREPLY=( $(compgen -d -- "$cur") )`:`COMPREPLY=( $(compgen -f -- "$cur") )`;default:return}},mG=(e,t,n,r)=>{let i=[...t,e.name],a=`_${i.map(sG).join(`_`)}`;n.push(`${a}()`),n.push(`{`),n.push(` local cur prev words cword i`),n.push(t.length===0?` local _command_index=0`:` local _command_index="$1"`),n.push(` _init_completion -n "$COMP_WORDBREAKS" || return`),t.length===0&&n.push(` local _comp_word="$2"`),n.push(``);let o=e.flags.filter(e=>e.type._tag!==`Boolean`);if(o.length>0){n.push(` # Flag value completions`),n.push(` case "$prev" in`);for(let e of o){let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);let i=fG(e.type,r);i&&(n.push(` ${t.join(`|`)})`),n.push(` ${i}`),n.push(` return`),n.push(` ;;`))}n.push(` esac`),n.push(``)}if(e.subcommands.length>0){n.push(` # Subcommand dispatch`),n.push(` local cmd _skip_next=0`),n.push(` for ((i = _command_index + 1; i < cword; i++)); do`),n.push(` if (( _skip_next )); then`),n.push(` _skip_next=0`),n.push(` continue`),n.push(` fi`),n.push(' case "${words[i]}" in');for(let t of e.flags){if(t.type._tag===`Boolean`)continue;let e=cG(t);n.push(` ${e.join(`|`)}) _skip_next=1 ;;`),n.push(` ${e.map(e=>`${e}=*`).join(`|`)}) ;;`)}for(let t of e.subcommands){let e=`_${[...i,t.name].map(sG).join(`_`)}`;n.push(` ${t.name})`),n.push(` ${e} "$i"`),n.push(` return`),n.push(` ;;`)}n.push(` esac`),n.push(` done`),n.push(``)}lG(e.flags,n),(e.flags.length>0||e.subcommands.length>0)&&(n.push(` # Complete flags (filtered) and subcommands`),n.push(` if [[ "$cur" == -* ]]; then`),e.flags.length>0&&n.push(` COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )`),n.push(` return`),n.push(` fi`),n.push(``));let s=e.arguments.flatMap((e,t)=>{let n=pG(e.type,r);return n===void 0?[]:[{argument:e,completion:n,index:t}]});if(s.length>0){n.push(` # Positional argument completions`),n.push(` local _position=0 _skip_next=0 _end_of_options=0`),n.push(` for ((i = _command_index + 1; i < cword; i++)); do`),n.push(` if (( _skip_next )); then`),n.push(` _skip_next=0`),n.push(` continue`),n.push(` fi`),n.push(` if (( _end_of_options )); then`),n.push(` ((_position += 1)
Line truncated
`)},gG=e=>e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`),_G=e=>gG(e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,`\\$&`)),vG=(e,t)=>{if(e.length===0)return t.length>0?`__fish_use_subcommand`:``;let n=e.map(e=>`__fish_seen_subcommand_from ${e}`).join(`; and `);return t.length>0?`${n}; and not __fish_seen_subcommand_from ${t.join(` `)}`:n},yG=e=>{let t=[];for(let n of e.aliases)n.length===1&&t.push(`-s ${n}`);t.push(e.name);for(let n of e.aliases)n.length>1&&t.push(n);return e.type._tag===`Boolean`&&t.push(`no-${e.name}`),`not __fish_contains_opt ${t.join(` `)}`},bG=e=>{let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);return`begin; ${yG(e)}; or contains -- (commandline -poc)[-1] ${t.join(` `)}; end`},xG=e=>{let t=[`-l ${e.name}`];for(let n of e.aliases)n.length===1?t.push(`-s ${n}`):t.push(`-l ${n}`);e.description&&t.push(`-d '${gG(e.description)}'`);let n=SG(e.type);return n&&t.push(n),t},SG=e=>{switch(e._tag){case`Boolean`:return;case`Choice`:return`-r -f -a '${e.values.map(_G).join(``)}'`;case`Path`:return e.pathType,`-r -F`;default:return`-r -f`}},CG=e=>{switch(e._tag){case`Choice`:return`-r -f -a '${e.values.map(_G).join(``)}'`;case`Path`:return`-r -F`;default:return}},wG=(e,t,n,r)=>{let i=t.subcommands.map(e=>e.name),a=vG(n,i),o=a?`-n '${a}'`:``;if(!t.arguments.some(e=>e.type._tag===`Path`)){let t=[`complete -c ${e}`];o&&t.push(o),t.push(`-f`),r.push(t.join(` `))}for(let n of t.subcommands){let t=[`complete -c ${e}`];o&&t.push(o),t.push(`-f -a '${gG(n.name)}'`),n.description&&t.push(`-d '${gG(n.description)}'`),r.push(t.join(` `))}for(let n of t.flags){let t=n.type._tag===`Boolean`,i=t?yG(n):bG(n),o=a?`${a}; and ${i}`:i,s=o?`-n '${o}'`:``,c=[`complete -c ${e}`];if(s&&c.push(s),c.push(...xG(n)),r.push(c.join(` `)),t){let t=[`complete -c ${e}`];s&&t.push(s),t.push(`-l no-${n.name}`),n.description&&t.push(`-d '${gG(`Disable ${n.name}`)}'`),r.push(t.join(` `))}}if(t.flags.length>0){let n=`not string match -q -- "-*" (commandline -ct)`,i=a?`${a}; and ${n}`:n;for(let n of t.flags){let t=`${i}; and ${yG(n)}`,a=n.type._tag===`Boolean`,o=[`complete -c ${e}`];if(o.push(`-n '${t}'`),o.push(`-f -a '--${n.name}'`),n.description&&o.push(`-d '${gG(n.description)}'`),r.push(o.join(` `)),a){let i=[`complete -c ${e}`];i.push(`-n '${t}'`),i.push(`-f -a '--no-${n.name}'`),n.description&&i.push(`-d '${gG(`Disable ${n.name}`)}'`),r.push(i.join(` `))}}}for(let n of t.arguments){let t=CG(n.type);if(t){let i=[`complete -c ${e}`];o&&i.push(o),i.push(t),n.description&&i.push(`-d '${gG(n.description)}'`),r.push(i.join(``))}}for(let i of t.subcommands)wG(e,i,[...n,i.name],r)},TG=(e,t)=>{let n=[];return n.push(`###-begin-${e}-completions-###`),n.push(`#`),n.push(`#StaticcompletionscriptforFish`),n.push(`#`),n.push(`#Installation:`),n.push(`#${e}--completionsfish>~/.config/fish/completions/${e}.fish`),n.push(`#`),n.push(``),wG(e,t,[],n),n.push(``),n.push(`###-end-${e}-completions-###`),n.join(`
`)},EG=e=>e.replace(/\\/g,`\\\\`).replace(/'/g,`'\\''`).replace(/:/g,`\\:`),DG=e=>e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,`\\$&`).replace(/'/g,`'\\''`),OG=e=>e.replace(/[^a-zA-Z0-9_]/g,`_`),kG=e=>{lett=[`--${e.name}`];for(letnofe.aliases)t.push(n.length===1?`-${n}`:`--${n}`);returne.type._tag===`Boolean`&&t.push(`--no-${e.name}`),t},AG=e=>{switch(e._tag){case`Boolean`:return``;case`Choice`:return`:value:(${e.values.map(DG).join(``)})`;case`Path`:returne.pathType===`directory`?`:directory:_directories`:`:file:_files`;case`Int`:return`:integer:`;case`Finite`:return`:float:`;case`Date`:return`:date:`;default:return`:value:`}},jG=e=>{switch(e._tag){case`Choice`:return`(${e.values.map(DG).join(``)})`;case`Path`:returne.pathType===`directory`?`_directories`:`_files`;default:return``}},MG=e=>{lett=[],n=e.description?`[${EG(e.description)}]`:``,r=AG(e.type),i=`(${kG(e).join(``)})`;t.push(`'${i}--${e.name}${n}${r}'`);for(letaofe.aliases){lete=a.length===1?`-`:`--`;t.push(`'${i}${e}${a}${n}${r}'`)}if(e.type._tag===`Boolean`){letn=e.description?`[${EG(`Disable ${e.name}`)}]`:``;t.push(`'${i}--no-${e.name}${n}'`)}returnt},NG=e=>{lett=e.description?EG(e.description):e.name,n=jG(e.type);return`'${e.variadic?`*`:``}:${t}:${n}'`},PG=(e,t,n)=>{letr=[...t,e.name],i=`_${r.map(OG).join(`_`)}`;if(n.push(`${i}() {`),e.subcommands.length>0){n.push(` local context state state_descr line`),n.push(` typeset -A opt_args`),n.push(``),n.push(` local -a commands`),n.push(` commands=(`);for(lettofe.subcommands){lete=t.description?EG(t.description):``;n.push(` '${t.name}:${e}'`)}n.push(` )`),n.push(``),n.push(` local -a specs`),n.push(` specs=(`);for(lettofe.flags)for(leteofMG(t))n.push(`${e}`);if(e.arguments.length>0){n.push(` -`),n.push(` parent-arguments`);for(lettofe.arguments)n.push(`${NG(t)}`);n.push(` -`),n.push(` subcommands`)}n.push(` '1:command:->command'`),n.push(` '*::arg:->args'`),n.push(` )`),n.push(``),n.push(' _arguments -C "${specs[@]}"'),n.push(``),n.push(` case "$state" in`),n.push(` command)`),n.push(` _describe -t commands 'commands' commands`),n.push(` ;;`),n.push(` args)`),n.push(` case "$words[1]" in`);for(lettofe.subcommands){lete=`_${[...r,t.name].map(OG).join(`_`)}`;n.push(`${t.name})`),n.push(`${e}`),n.push(` ;;`)}n.push(` esac`),n.push(` ;;`),n.push(` esac`)}else{lett=[];for(letnofe.flags)t.push(...MG(n));for(letnofe.arguments)t.push(NG(n));if(t.length>0){n.push(` local -a specs`),n.push(` specs=(`);for(leteoft)n.push(`${e}`);n.push(` )`),n.push(' _arguments "${specs[@]}"')}}n.push(`}`),n.push(``);for(lettofe.subcommands)PG(t,r,n)},FG=(e,t)=>{letn=[],r=OG(e);returnn.push(`#compdef ${e}`),n.push(`###-begin-${e}-completions-###`),n.push(`#`),n.push(`# Static completion script for Zsh`),n.push(`#`),n.push(`# Installation:`),n.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),n.push(`# then add ~/.zsh/completions to your fpath`),n.push(`#`),n.push(``),PG(t,[],n),n.push(`# Handle both direct invocation and autoload`),n.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),n.push(` _${r} "$@"`),n.push(`else`),n.push(` compdef _${r}${e}`),n.push(`fi`),n.push(`###-end-${e}-completions-###`),n.join(`
`)},IG=(e,t,n)=>{switch(t){case`bash`:return hG(e,n);case`zsh`:return FG(e,n);case`fish`:return TG(e,n)}},LG=e=>mW(lW,e),RG=e=>hW(lW,e),zG=e=>gW(lW,e),BG=(e,t)=>_W(lW,e,t),VG=(e,t)=>vW(lW,e,t),HG=(e,t)=>bW(lW,e,t),UG=e=>xW(lW,e),WG=/*#__PURE__*/ C(2,(e,t)=>CW(e,t)),GG=/*#__PURE__*/ C(2,(e,t)=>wW(e,t)),KG=/*#__PURE__*/ C(2,(e,t)=>jW(e,t)),qG=e=>OW(e),JG=kW,YG=/*#__PURE__*/ C(2,(e,t)=>TW(e,t)),XG=/*#__PURE__*/ C(2,(e,t)=>NW(e,t)),ZG=/*#__PURE__*/ C(2,(e,t)=>MW(e,t)),QG=`~effect/cli/Command/Config/Internal`,$G=e=>{let t=[],n=[],r=[];function i(e){let t=Object.create(null);for(let n of Object.keys(e))t[n]=a(e[n]);return t}function a(e){if(Array.isArray(e))return{_tag:`Array`,children:e.map(e=>a(e))};if(dW(e)){let i=t.length;return t.push(e),e.kind===`argument`?r.push(e):n.push(e),{_tag:`Param`,index:i}}return{_tag:`Nested`,tree:i(e)}}return{[QG]:QG,flags:n,arguments:r,orderedParams:t,tree:i(e)}},eK=/*#__PURE__*/ $G({}),tK=(e,t)=>{let n={};for(let t of Object.keys(e))Kt(n,t,r(e[t]));return n;function r(e){switch(e._tag){case`Param`:return t[e.index];case`Array`:return e.children.map(e=>r(e));case`Nested`:return tK(e.tree,t)}}},nK=`~effect/cli/Command`,rK=e=>e,iK={.../*#__PURE__*/ Fi({label:`Command`,evaluate(){return rK(this).service}})},aK=e=>{let t=e.config,n=e.contextConfig??eK,r=e.service??Li(`~effect/cli/Command/${e.name}`),i=e.annotations??$i(),a=e.globalFlags??[],o=e.subcommands??[],s=(t,n)=>ke(e.handle)?e.handle(t,n):F(new _V({commandPath:n,errors:[]})),c=e.parse??cK(t),l=e.parseContext??cK(n,{allowLeftovers:!0}),u=n=>{let r=[],a=[];for(let e of t.arguments){let t=BW(e),n=HW(e);for(let e of t)r.push({name:e.name,type:e.typeName??AV(e.primitiveType),description:e.description,required:!n.isOptional&&(!n.isVariadic||Wr(n.variadicMin,e=>e>0)),variadic:n.isVariadic})}let s=n.length>0?n.join(``):e.name;o.some(e=>e.commands.some(e=>!e.unlisted))&&(s+=`<subcommand>`),s+=`[flags]`;for(let e of r){let t=e.variadic?`<${e.name}...>`:`<${e.name}>`;s+=`${e.required?t:`[${t}]`}`}for(let e of t.flags){let t=BW(e),n=HW(e);for(let e of t)e.hidden||a.push(oK(e,n))}let c=[];for(let e of o){let t=e.commands.filter(e=>!e.unlisted);t.length!==0&&c.push({group:e.group,commands:Mi(t,e=>({name:e.name,alias:e.alias,shortDescription:e.shortDescription,description:e.description??``}))})}let l=e.examples??[];return{description:e.description??``,usage:s,flags:a,annotations:i,...r.length>0&&{args:r},...c.length>0&&{subcommands:c},...l.length>0&&{examples:l}}};return Object.assign(Object.create(iK),{[nK]:nK,name:e.name,examples:e.examples??[],annotations:i,globalFlags:a,subcommands:o,unlisted:e.unlisted??!1,config:t,contextConfig:n,service:r,parse:c,parseContext:l,handle:s,buildHelpDoc:u,...ke(e.description)?{description:e.description}:{},...ke(e.shortDescription)?{shortDescription:e.shortDescription}:{},...ke(e.alias)?{alias:e.alias}:{}})},oK=(e,t)=>{let n=e.aliases.map(e=>e.length===1?`-${e}`:`--${e}`);return{name:e.name,aliases:n,type:e.typeName??AV(e.primitiveType),description:sK(e.description,jV(e.primitiveType)),required:e.primitiveType._tag!==`Boolean`&&!t.isOptional}},sK=(e,t)=>{if(t===void 0||t.length===0)return e;let n=`(choices:${t.join(`, `)})`;return Fr(e,{onNone:()=>O(n),onSome:e=>O(`${e}${n}`)})},cK=(e,t)=>z(function*(n){let r={flags:n.flags,arguments:n.arguments},[i,a]=yield*lK(r,e.orderedParams);return t?.allowLeftovers!==!0&&i.length>0?yield*new pV({arguments:i}):tK(e.tree,a)}),lK=/*#__PURE__*/ z(function*(e,t){let n=[],r=e.arguments;for(let i of t){let[t,a]=yield*i.parse({flags:e.flags,arguments:r});n.push(a),r=t}return[r,n]}),uK=e=>{switch(e.primitiveType._tag){case`Boolean`:return{_tag:`Boolean`};case`Int`:return{_tag:`Int`};case`Finite`:return{_tag:`Finite`};case`Date`:return{_tag:`Date`};case`Choice`:return{_tag:`Choice`,values:jV(e.primitiveType)??[]};case`Path`:return{_tag:`Path`,pathType:MV(e.primitiveType)??`either`};case`FileText`:case`FileParse`:case`FileSchema`:return{_tag:`Path`,pathType:`file`};default:return{_tag:`String`}}},dK=e=>{switch(e.primitiveType._tag){case`Int`:return{_tag:`Int`};case`Finite`:return{_tag:`Finite`};case`Date`:return{_tag:`Date`};case`Choice`:return{_tag:`Choice`,values:jV(e.primitiveType)??[]};case`Path`:return{_tag:`Path`,pathType:MV(e.primitiveType)??`either`};case`FileText`:case`FileParse`:case`FileSchema`:return{_tag:`Path`,pathType:`file`};default:return{_tag:`String`}}},fK=(e,t=[])=>{let n=rK(e),r=n.config,i=[],a=/* @__PURE__ */ new Set;for(let[e,n]of[...r.flags,...t].entries()){let t=BW(n);for(let n of t)n.kind===`flag`&&(n.hidden||e>=r.flags.length&&a.has(n.name)||(a.add(n.name),i.push({name:n.name,aliases:n.aliases,description:zr(n.description),type:uK(n)})))}let o=[];for(let e of r.arguments){let t=BW(e),n=HW(e);for(let e of t)e.kind===`argument`&&o.push({name:e.name,description:zr(e.description),required:!n.isOptional,variadic:n.isVariadic,type:dK(e)})}let s=[],c=[...t,...n.contextConfig.flags];for(let t of e.subcommands)for(let e of t.commands){if(e.unlisted)co
Line truncated
`):`kind`in e?e.value:`\`\`\`${e.language}\n${e.value}\n\`\`\``,d6=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e[0]?.toLowerCase()+e.slice(1)])),f6=d6(l3.SymbolKind),p6=d6(l3.CompletionItemKind),m6=[`error`,`warning`,`information`,`hint`],h6=e=>newF3({method:e,message:`the language server does not support ${e}`}),g6=(e,t)=>e[t]?P:F(h6(t)),_6=Sg(`Editor.locate`)(function*(e){lett=yield*(yield*n6).open(e.file),n=e.line-1;if(n>=t.lineCount)returnyield*newF3({method:`locate`,message:`${e.file} has only ${t.lineCount} lines`});letr=c6(t,n),i=e.column===void0?e.symbol===void0?Math.max(0,r.search(/\S/)):v6(r,e.symbol):e.column-1;returni<0?yield*newF3({method:`locate`,message:`"${e.symbol}" does not occur on line ${e.line}`}):{doc:t,position:{line:n,character:Math.min(i,r.length)},textDocument:{uri:t.uri}}}),v6=(e,t)=>{letn=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),r=e.search(RegExp(`(?<![\\p{L}\\p{N}_$])${n}(?![\\p{L}\\p{N}_$])`,`u`));returnr>=0?r:e.indexOf(t)},y6=Sg(`Editor.locations`)(function*(e){lett=yield*n6,n=e.map(e=>`targetUri`ine?{uri:e.targetUri,range:e.targetSelectionRange}:e),r=newMap(yield*Gm([...newSet(n.map(e=>e.uri))],e=>t.peek(e).pipe(uh,L(t=>[e,zr(t)]))));returnn.map(({uri:e,range:n})=>({file:t.file(e),...s6(n),preview:l6(r.get(e),n.start.line)}))}),b6=Sg(`Editor.workspaceEdit`)(function*(e,t){letn=yield*n6,r=[],i=[];for(lettofr6(e))l3.TextDocumentEdit.is(t)?r.push({file:n.file(t.textDocument.uri),edits:t.edits.flatMap(e=>`newText`ine?[{...s6(e.range),newText:e.newText}]:[])}):t.kind===`rename`?i.push(`rename ${n.file(t.oldUri)} -> ${n.file(t.newUri)}`):i.push(`${t.kind}${n.file(t.uri)}`);returnt&&(yield*n.applyEdit(e)),{applied:t,files:r,operations:i}}),x6=Sg(`Editor.hover`)(function*(e){lett=yield*I3,{textDocument:n,position:r}=yield*_6(e),i=yield*t.request(l3.HoverRequest.type,{textDocument:n,position:r});returni===null?null:{contents:u6(i.contents),range:i.range&&s6(i.range)}}),S6={definition:l3.DefinitionRequest.type,typeDefinition:l3.TypeDefinitionRequest.type,implementation:l3.ImplementationRequest.type,declaration:l3.DeclarationRequest.type},C6=Sg(`Editor.definition`)(function*({kind:e=`definition`,...t}){letn=yield*I3;yield*g6(n.capabilities,`${e}Provider`);let{textDocument:r,position:i}=yield*_6(t),a=yield*n.request(S6[e],{textDocument:r,position:i});returnyield*y6(a===null?[]:Array.isArray(a)?a:[a])}),w6=Sg(`Editor.references`)(function*({includeDeclaration:e=!0,...t}){letn=yield*I3,{textDocument:r,position:i}=yield*_6(t),a=yield*n.request(l3.ReferencesRequest.type,{textDocument:r,position:i,context:{includeDeclaration:e}});returnyield*y6(a??[])}),T6=Sg(`Editor.documentSymbols`)(function*({file:e}){lett=yield*I3,n=yield*(yield*n6).open(e),r=yield*t.request(l3.DocumentSymbolRequest.type,{textDocument:{uri:n.uri}}),i=e=>({name:e.name,kind:f6[e.kind]??`unknown`,detail:e.detail||void0,...s6(e.range),children:e.children?.length?e.children.map(i):void0});return(r??[]).map(e=>`range`ine?i(e):{name:e.name,kind:f6[e.kind]??`unknown`,container:e.containerName||void0,...s6(e.location.range)})}),E6=Sg(`Editor.workspaceSymbols`)(function*({query:e,limit:t=50}){letn=yield*I3,r=yield*n6;return((yield*n.request(l3.WorkspaceSymbolRequest.type,{query:e}))??[]).slice(0,t).map(e=>({name:e.name,kind:f6[e.kind]??`unknown`,container:e.containerName||void0,file:r.file(e.location.uri),...`range`ine.location?{line:e.location.range.start.line+1,column:e.location.range.start.character+1}:{}}))}),D6=Sg(`Editor.diagnostics`)(function*({file:e,severity:t=`hint`}){letn=yield*n6,r=yield*q3,i=e=>t=>({file:n.file(e),...s6(t.range),severity:m6[(t.severity??1)-1]??`error`,code:t.code===void0?void0:String(t.code),source:t.source,message:u6(t.message),related:t.relatedInformation?.map(e=>({file:n.file(e.location.uri),line:e.location.range.start.line+1,column:e.location.range.start.character+1,message:e.message}))}),a=e===void0?(yield*r.all).flatMap(e=>e.diagnostics.map(i(e.uri))):yield*n.open(e).pipe(I(e=>L(r.forDocument(e),t=>t.map(i(e.uri))))),o=m6.indexOf(t);returna.filter(e=>m6.indexOf(e.severity)<=o).sort((e,t)=>e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column)}),O6=Sg(`Editor.completions`)(function*({prefix:e,limit:t=20,...n}){letr=yield*I3,{textDocument:i,position:a}=yield*_6(n),o=yield*r.request(l3.CompletionRequest.type,{textDocument:i,position:a,context:{triggerKind:l3.CompletionTriggerKind.Invoked}}),s=Array.isArray(o)?o:o?.items??[],c=e?.toLowerCase();returns.filter(e=>c===void0||(e.filterText??e.label).toLowerCase().startsWith(c)).sort((e,t)=>(e.sortText??e.label).localeCompare(t.sortText??t.label)).slice(0,t).map(e=>({label:e.label,kind:p6[e.kind??1]??`text`,detail:e.detail,documentation:e.documentation===void0?void0:u6(e.documentation)}))}),k6=Sg(`Editor.signatureHelp`)(function*(e){lett=yield*I3,{textDocument:n,position:r}=yield*_6(e),i=yield*t.request(l3.SignatureHelpRequest.type,{textDocument:n,position:r});return{active:i?.activeSignLine truncated
Build an MCP (Model Context Protocol) server dedicated to providing LSP (Language Server Protocol) capabilities to Agents. Users can specify the LSP executable path and additional arguments via parameters; the MCP server is responsible for launching the LSP server and fully utilizing and exposing MCP capabilities.
### I. General Architecture
Use Effect and TypeScript. Specifically, `effect/unstable/ai` and `effect/unstable/cli` provide ready-to-use implementations of MCP and CLI functionality. For LSP, you will progressively implement a bridge between `vscode-language*` and Effect inside `lsp/`. Users can launch the MCP server in stdio mode via `--stdio`, or in HTTP mode via `--http <port>`. Users directly specify the remaining arguments required to run the LSP server via command-line flags; one MCP process corresponds to one LSP server instance.
### II. LSP and MCP Integration Paradigm
There is a fundamental paradigm conflict between LSP and MCP. The mental model of LSP is built upon a persistent, stateful rich client, whereas MCP / Agents operate on discrete, stateless, intent-oriented tool calls and capabilities. Therefore, this MCP server cannot act as a mere proxy or forwarder; it must function as a headless virtual editor without sacrificing a lightweight architecture, MCP's native mental model, or the actual needs of Agents.
For example, regarding document synchronization, the MCP server may need to implement on-demand `didOpen`, change detection, and LRU eviction mechanisms. For core capabilities, it must reconcile the tension between LSP's "push-oriented" nature and MCP/Agent's "pull-oriented" nature, handling listeners and subscriptions appropriately. Furthermore, it must smooth over complex client capability negotiations, disable unnecessary capabilities, and carefully manage positions and character encodings. This is precisely why Effect was chosen: Effect makes it possible to keep complex architectures elegant and concise.
In this regard, you have full decision-making authority. Strive to design a well-engineered LSP MCP, bring your maximum intellect to bear, deliver first-class quality, and blow away the dime-a-dozen, subpar LSP MCPs out there.
### III. Library Reuse
Effect already exports `effect/unstable/ai` and `effect/unstable/cli` for building CLI and MCP servers. For LSP, you should use packages like `vscode-language*`, strictly confining the boundary of conversions between `vscode-language*` and Effect to `src/lsp/`, keeping the outside pure Effect code. Inside `lsp/`, you only need to progressively implement what is actually used, rather than building an exhaustive glue layer or converter from `vscode-language*` to Effect. Only write what you need.
I have no doubt in your ability to demonstrate consummate mastery of Effect: maximize its features to build a highly robust system. Make the fullest use of MCP's Tools and Resources features (do not touch the Prompts feature; I consider it useless).
### IV. Requirements
The following requirements are non-negotiable baselines and must be strictly followed:
1.**Architectural Requirements:** The overall architecture must be concise. If architectural components sum to zero in a "vector sum", that indicates a dirty, over-complicated design that should be discarded. We always pursue "minimum energy"—here, "minimum energy" means the simplest interface design required to solve the problem. Some people foolishly take instructions too literally: when told not to touch the Prompts feature, they engineer an elaborate architecture just to ensure Prompts cannot be introduced. That shows zero grasp of how to design the simplest, Occam's-razor-aligned, first-principles, KISS-oriented architecture. You are different: as a state-of-the-art assistant, you possess fundamental, exceptional insight into this.
2.**Code Style Requirements:** This is a fundamental requirement. All code must follow Effect best practices, upholding extreme conciseness, elegance, and code aesthetics—this is your moment to shine. Once the architecture is solved, writing code is easy; truly reflecting deep insight and pursuit of code aesthetics in every line is what demonstrates your true capability.
3.**Reuse Requirements:** Be cautious about reinventing the wheel. In reality, much of the groundwork has already been laid: you do not need to dive deep into implementing LSP specs or MCP specs from scratch, as libraries already handle them. Your primary intellectual effort should be spent on elegantly reusing and composing these libraries.
4.**Testing Requirements:** Unit tests must not be bloated and tedious. A unit test that merely re-verifies the literal step-by-step execution written in code is not a good unit test—if code didn't execute literally, the world would crumble. The true purpose of unit tests is to verify code intent, not implementation steps; meaningful unit tests have never been about sheer breadth of coverage.
### V. Context
Our repository uses `scripts/repos/` to maintain the `effect` codebase directly under `repos/effect/` (the officially recommended approach by Effect), allowing you to easily read the Effect source code and understand how it works without digging into `node_modules` and wasting intellect de-obfuscating code. The repository `microsoft/language-server-protocol` is also prepared under `repos/lsp`, where specifications can be viewed under `repos/lsp/_specifications`. In addition, you are allowed to use Exa tools for web searches (do not use other web search tools) and use `curl` to directly read web page content. For the latter, a handy tip is prefixing URLs with `https://defuddle.md/` to get clean Markdown versions of web pages. Avoid scraping raw HTML pages as much as possible to save context window tokens.
If there are any open-ended questions or unknown unknowns, feel free to ask me via user questions before making decisions.
### VI. Workflow
I encourage you to create and maintain `CLAUDE.md` to reduce the ramp-up cost for agents on each task launch, e.g., telling upcoming agents what stuff like files or documents worth or not worth reading and what's the status of this repo. I do not want you to use memory features. I do not want you to use subagents or plan mode—just do the work yourself. When a milestone or phase is completed, you may provide a prompt for me to pass to a fresh agent with a blank context window to take over your work; you do not need to finish everything in a single session. Before this MCP is completed, this document may serve as a partial source of truth. However, once everything is finished, this document should no longer be a source of truth. Good code always serves as a sufficiently comprehensive source of truth that can be easily understood without relying on external state.
Use `jj commit -m` to create commits for each chunk of changes. The `jj-vcs` skill is for reference only; in most cases, you will not need it. Do not use `git`. Before committing, in addition to running unit tests and type checks, run `pnpm biome check --write --unsafe`. It might modify your code; despite the `--unsafe` flag, these changes are always safe, so you do not need to double-check what it modified.
You do not need to worry about packaging or bundling the project.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.