@hermenics/deepseek-code 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,5 +69,5 @@ File a [GitHub issue](https://github.com/Hermenics/deepseek-code/issues) or use
|
|
|
69
69
|
---
|
|
70
70
|
|
|
71
71
|
<div align="center">
|
|
72
|
-
<p>Made with ❤️ by <a href="https://github.com/
|
|
72
|
+
<p>Made with ❤️ by <a href="https://github.com/Hermenics">Hermenics Team</a></p>
|
|
73
73
|
</div>
|
package/dist/cli.mjs
CHANGED
|
@@ -1019,7 +1019,7 @@ ${f}`,w++}else Ye0(j,C,v)?O=j.slice(j.charCodeAt(C+6)===wX?C+7:C+6,S)||void 0:V(
|
|
|
1019
1019
|
`,C),y=-1;if(S!==-1&&v!==-1?y=S<v?S:v:S!==-1?S===j.length-1?y=-1:y=S:v!==-1&&(y=v),y===-1)break;V(j,C,y),C=y+1,j.charCodeAt(C-1)===dZ1&&j.charCodeAt(C)===Je0&&C++}return j.slice(C)}function V(j,C,S){if(C===S){_();return}let v=j.charCodeAt(C);if(qe0(j,C,v)){let z0=j.charCodeAt(C+5)===wX?C+6:C+5,c=j.slice(z0,S);H=w===0?c:`${H}
|
|
1020
1020
|
${c}`,w++;return}if(Ye0(j,C,v)){O=j.slice(j.charCodeAt(C+6)===wX?C+7:C+6,S)||void 0;return}if(v===105&&j.charCodeAt(C+1)===100&&j.charCodeAt(C+2)===58){let z0=j.slice(j.charCodeAt(C+3)===wX?C+4:C+3,S);W=z0.includes("\x00")?void 0:z0;return}if(v===58){if(J){let z0=j.slice(C,S);J(z0.slice(j.charCodeAt(C+1)===wX?2:1))}return}let y=j.slice(C,S),f=y.indexOf(":");if(f===-1){T(y,"",y);return}let m=y.slice(0,f),g=y.charCodeAt(f+1)===wX?2:1,u=y.slice(f+g);T(m,u,y)}function T(j,C,S){switch(j){case"event":O=C||void 0;break;case"data":H=w===0?C:`${H}
|
|
1021
1021
|
${C}`,w++;break;case"id":W=C.includes("\x00")?void 0:C;break;case"retry":/^\d+$/.test(C)?z(parseInt(C,10)):K(new $80(`Invalid \`retry\` value: "${C}"`,{type:"invalid-retry",value:C,line:S}));break;default:K(new $80(`Unknown field "${j.length>20?`${j.slice(0,20)}\u2026`:j}"`,{type:"unknown-field",field:j,value:C,line:S}));break}}function _(){w>0&&$({id:W,event:O,data:H}),W=void 0,H="",w=0,O=void 0}function F(j={}){if(j.consume&&q.length>0){let C=q.join("");V(C,0,C.length)}X=!0,W=void 0,H="",w=0,O=void 0,q.length=0}return{feed:N,reset:F}}function qe0(D,$,K){return K===100&&D.charCodeAt($+1)===97&&D.charCodeAt($+2)===116&&D.charCodeAt($+3)===97&&D.charCodeAt($+4)===58}function Ye0(D,$,K){return K===101&&D.charCodeAt($+1)===118&&D.charCodeAt($+2)===101&&D.charCodeAt($+3)===110&&D.charCodeAt($+4)===116&&D.charCodeAt($+5)===58}var $80,Je0=10,dZ1=13,wX=32;var Ze0=R(()=>{$80=class $80 extends Error{constructor(D,$){super(D),this.name="ParseError",this.type=$.type,this.field=$.field,this.value=$.value,this.line=$.line}}});var K80;var We0=R(()=>{Ze0();K80=class K80 extends TransformStream{constructor({onError:D,onRetry:$,onComment:K}={}){let z;super({start(J){z=Xe0({onEvent:(q)=>{J.enqueue(q)},onError(q){D==="terminate"?J.error(q):typeof D=="function"&&D(q)},onRetry:$,onComment:K})},transform(J){z.feed(J)}})}}});class z80{constructor(D,$){this._hasCompletedAuthFlow=!1,this._url=D,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=$?.requestInit,this._authProvider=$?.authProvider,this._fetch=$?.fetch,this._fetchWithInit=gs0($?.fetch,$?.requestInit),this._sessionId=$?.sessionId,this._reconnectionOptions=$?.reconnectionOptions??nZ1}async _authThenStart(){if(!this._authProvider)throw new Bq("No auth provider");let D;try{D=await BP(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch($){throw this.onerror?.($),$}if(D!=="AUTHORIZED")throw new Bq;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let D={};if(this._authProvider){let K=await this._authProvider.tokens();if(K)D.Authorization=`Bearer ${K.access_token}`}if(this._sessionId)D["mcp-session-id"]=this._sessionId;if(this._protocolVersion)D["mcp-protocol-version"]=this._protocolVersion;let $=TI(this._requestInit?.headers);return new Headers({...D,...$})}async _startOrAuthSse(D){let{resumptionToken:$}=D;try{let K=await this._commonHeaders();if(K.set("Accept","text/event-stream"),$)K.set("last-event-id",$);let z=await(this._fetch??fetch)(this._url,{method:"GET",headers:K,signal:this._abortController?.signal});if(!z.ok){if(await z.body?.cancel(),z.status===401&&this._authProvider)return await this._authThenStart();if(z.status===405)return;throw new OX(z.status,`Failed to open SSE stream: ${z.statusText}`)}this._handleSseStream(z.body,D,!0)}catch(K){throw this.onerror?.(K),K}}_getNextReconnectionDelay(D){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let $=this._reconnectionOptions.initialReconnectionDelay,K=this._reconnectionOptions.reconnectionDelayGrowFactor,z=this._reconnectionOptions.maxReconnectionDelay;return Math.min($*Math.pow(K,D),z)}_scheduleReconnection(D,$=0){let K=this._reconnectionOptions.maxRetries;if($>=K){this.onerror?.(Error(`Maximum reconnection attempts (${K}) exceeded.`));return}let z=this._getNextReconnectionDelay($);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(D).catch((J)=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${J instanceof Error?J.message:String(J)}`)),this._scheduleReconnection(D,$+1)})},z)}_handleSseStream(D,$,K){if(!D)return;let{onresumptiontoken:z,replayMessageId:J}=$,q,X=!1,W=!1;(async()=>{try{let w=D.pipeThrough(new TextDecoderStream).pipeThrough(new K80({onRetry:(A)=>{this._serverRetryMs=A}})).getReader();while(!0){let{value:A,done:V}=await w.read();if(V)break;if(A.id)q=A.id,X=!0,z?.(A.id);if(!A.data)continue;if(!A.event||A.event==="message")try{let T=ZG.parse(JSON.parse(A.data));if($X(T)){if(W=!0,J!==void 0)T.id=J}this.onmessage?.(T)}catch(T){this.onerror?.(T)}}if((K||X)&&!W&&this._abortController&&!this._abortController.signal.aborted)this._scheduleReconnection({resumptionToken:q,onresumptiontoken:z,replayMessageId:J},0)}catch(w){if(this.onerror?.(Error(`SSE stream disconnected: ${w}`)),(K||X)&&!W&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:q,onresumptiontoken:z,replayMessageId:J},0)}catch(A){this.onerror?.(Error(`Failed to reconnect: ${A instanceof Error?A.message:String(A)}`))}}})()}async start(){if(this._abortController)throw Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(D){if(!this._authProvider)throw new Bq("No auth provider");if(await BP(this._authProvider,{serverUrl:this._url,authorizationCode:D,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Bq("Failed to authorize")}async close(){if(this._reconnectionTimeout)clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0;this._abortController?.abort(),this.onclose?.()}async send(D,$){try{let{resumptionToken:K,onresumptiontoken:z}=$||{};if(K){this._startOrAuthSse({resumptionToken:K,replayMessageId:rV(D)?D.id:void 0}).catch((N)=>this.onerror?.(N));return}let J=await this._commonHeaders();J.set("content-type","application/json"),J.set("accept","application/json, text/event-stream");let q={...this._requestInit,method:"POST",headers:J,body:JSON.stringify(D),signal:this._abortController?.signal},X=await(this._fetch??fetch)(this._url,q),W=X.headers.get("mcp-session-id");if(W)this._sessionId=W;if(!X.ok){let N=await X.text().catch(()=>null);if(X.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new OX(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:A,scope:V}=s00(X);if(this._resourceMetadataUrl=A,this._scope=V,await BP(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Bq;return this._hasCompletedAuthFlow=!0,this.send(D)}if(X.status===403&&this._authProvider){let{resourceMetadataUrl:A,scope:V,error:T}=s00(X);if(T==="insufficient_scope"){let _=X.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===_)throw new OX(403,"Server returned 403 after trying upscoping");if(V)this._scope=V;if(A)this._resourceMetadataUrl=A;if(this._lastUpscopingHeader=_??void 0,await BP(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Bq;return this.send(D)}}throw new OX(X.status,`Error POSTing to endpoint: ${N}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,X.status===202){if(await X.body?.cancel(),ki0(D))this._startOrAuthSse({resumptionToken:void 0}).catch((N)=>this.onerror?.(N));return}let w=(Array.isArray(D)?D:[D]).filter((N)=>("method"in N)&&("id"in N)&&N.id!==void 0).length>0,O=X.headers.get("content-type");if(w)if(O?.includes("text/event-stream"))this._handleSseStream(X.body,{onresumptiontoken:z},!1);else if(O?.includes("application/json")){let N=await X.json(),A=Array.isArray(N)?N.map((V)=>ZG.parse(V)):[ZG.parse(N)];for(let V of A)this.onmessage?.(V)}else throw await X.body?.cancel(),new OX(-1,`Unexpected content type: ${O}`);else await X.body?.cancel()}catch(K){throw this.onerror?.(K),K}}get sessionId(){return this._sessionId}async terminateSession(){if(!this._sessionId)return;try{let D=await this._commonHeaders(),$={...this._requestInit,method:"DELETE",headers:D,signal:this._abortController?.signal},K=await(this._fetch??fetch)(this._url,$);if(await K.body?.cancel(),!K.ok&&K.status!==405)throw new OX(K.status,`Failed to terminate session: ${K.statusText}`);this._sessionId=void 0}catch(D){throw this.onerror?.(D),D}}setProtocolVersion(D){this._protocolVersion=D}get protocolVersion(){return this._protocolVersion}async resumeStream(D,$){await this._startOrAuthSse({resumptionToken:D,onresumptiontoken:$?.onresumptiontoken})}}var nZ1,OX;var He0=R(()=>{JX();ze0();We0();nZ1={initialReconnectionDelay:1000,maxReconnectionDelay:30000,reconnectionDelayGrowFactor:1.5,maxRetries:2};OX=class OX extends Error{constructor(D,$){super(`Streamable HTTP error: ${$}`);this.code=D}}});import{readFile as iZ1,writeFile as Ge0,readdir as rZ1}from"fs/promises";async function t4(D){return JSON.parse(await iZ1(D,"utf-8"))}async function CG(D,$){await Ge0(D,JSON.stringify($,null,2),"utf-8")}async function Rq(D,$){await Ge0(D,$,"utf-8")}async function fI(D,$){try{return(await rZ1($)).filter((z)=>D.test(z))}catch{return[]}}var r5=()=>{};import{join as Oe0}from"path";import{homedir as oZ1}from"os";import{mkdir as tZ1,appendFile as aZ1}from"fs/promises";import{randomBytes as sZ1}from"crypto";async function $W1(){if(we0)return;await tZ1(Ne0,{recursive:!0}),we0=!0}async function G9(D){try{await $W1();let $=JSON.stringify({ts:new Date().toISOString(),...D})+`
|
|
1022
|
-
`;await aZ1(DW1,$,"utf-8")}catch{}}var Ne0,eZ1,DW1,we0=!1;var J80=R(()=>{Ne0=Oe0(oZ1(),".deepseek","logs"),eZ1=`${Date.now()}-${sZ1(3).toString("hex")}`,DW1=Oe0(Ne0,`session-${eZ1}.jsonl`)});var u7;var UG=R(()=>{u7={name:"@hermenics/deepseek-code",version:"0.1.
|
|
1022
|
+
`;await aZ1(DW1,$,"utf-8")}catch{}}var Ne0,eZ1,DW1,we0=!1;var J80=R(()=>{Ne0=Oe0(oZ1(),".deepseek","logs"),eZ1=`${Date.now()}-${sZ1(3).toString("hex")}`,DW1=Oe0(Ne0,`session-${eZ1}.jsonl`)});var u7;var UG=R(()=>{u7={name:"@hermenics/deepseek-code",version:"0.1.10",description:"An AI-powered coding assistant that lives in your terminal",keywords:["ai","cli","deepseek","coding-assistant","terminal","tui"],license:"Apache-2.0",type:"module",bin:{deepseek:"dist/deepseek"},files:["dist/","README.md","LICENSE"],repository:{type:"git",url:"git+https://github.com/Hermenics/deepseek-code.git"},bugs:{url:"https://github.com/Hermenics/deepseek-code/issues"},homepage:"https://github.com/Hermenics/deepseek-code#readme",publishConfig:{access:"public"},engines:{node:">=18",bun:">=1.0"},scripts:{start:"NODE_ENV=development bun src/index.tsx",dev:"NODE_ENV=development bun --watch src/index.tsx",build:"bun run build.ts",typecheck:"bunx tsc --noEmit",test:"bun test"},dependencies:{"@alcalzone/ansi-tokenize":"^0.3.0","@aws-crypto/sha256-js":"^5.2.0","@aws-sdk/client-bedrock":"^3.1048.0","@aws-sdk/credential-providers":"^3.1048.0","@hono/node-server":"^1.14.0","@modelcontextprotocol/sdk":"^1.29.0","@smithy/protocol-http":"^5.3.14","@smithy/signature-v4":"^5.3.14","@types/semver":"^7.7.1","auto-bind":"^5.0.1","bidi-js":"^1.0.3","bignumber.js":"^11.1.0",chalk:"^5.6.2","cli-boxes":"^4.0.1","code-excerpt":"^4.0.0","ecdsa-sig-formatter":"^1.0.11","emoji-regex":"^10.6.0",execa:"^9.6.1","fast-glob":"^3.3.3","fuse.js":"^7.0.0","get-east-asian-width":"^1.6.0","google-auth-library":"^10.6.2",hono:"^4.12.21","indent-string":"^5.0.0","lodash-es":"^4.18.1",openai:"^6.34.0",playwright:"^1.50.0",react:"^19.2.0","react-reconciler":"^0.33.0",semver:"^7.8.1","signal-exit":"^4.1.0","stack-utils":"^2.0.6","strip-ansi":"^7.2.0","supports-hyperlinks":"^4.4.0","type-fest":"^5.6.0","usehooks-ts":"^3.1.1","wrap-ansi":"^10.0.0"},devDependencies:{"@types/bun":"^1.3.12","@types/react":"^19.2.0","@types/stack-utils":"^2.0.3","react-devtools-core":"^7.0.1",typescript:"^5.9.3",vitest:"^4.1.6"}}});import{join as zW1}from"path";function XW1(D,$){let K={...D};for(let[z,J]of Object.entries($)){if(JW1.has(z))continue;K[z]=J}return K}function ZW1(D){if(D.trim()==="")throw Error("MCP command cannot be empty");if(YW1.test(D))throw Error(`MCP command contains path traversal: ${D}`);if(qW1.test(D))throw Error(`MCP command contains shell injection characters: ${D}`)}function WW1(D,$){return{type:"mcp_server_load",serverName:D,transport:$}}async function HW1(){let D=zW1(process.cwd(),".deepseek","mcp.json");try{return await t4(D)}catch{return null}}async function Me0(){let D=await HW1();if(!D?.servers)return{tools:[],errors:[]};let $=[],K=[];for(let[z,J]of Object.entries(D.servers))try{if(J.transport==="stdio")ZW1(J.command);let q=new g00({name:"deepseek-code",version:u7.version}),X=J.transport==="stdio"?new p00({command:J.command,args:J.args??[],env:XW1(Object.fromEntries(Object.entries(process.env).filter((H)=>H[1]!==void 0)),J.env??{})}):new z80(new URL(J.url));await q.connect(X),await G9(WW1(z,J.transport));let{tools:W}=await q.listTools();for(let H of W)$.push({name:`${z}__${H.name}`,description:`[MCP:${z}] ${H.description??""}`,parameters:H.inputSchema,async execute(w){return(await Promise.race([q.callTool({name:H.name,arguments:w}),new Promise((V,T)=>setTimeout(()=>T(Error(`MCP tool '${H.name}' timed out after 30s`)),30000))])).content.filter((V)=>V.type==="text"&&V.text).map((V)=>V.text).join(`
|
|
1023
1023
|
`)}})}catch(q){let X=`MCP server '${z}': ${q.message}`;K.push(X)}return{tools:$,errors:K}}var JW1,qW1,YW1;var Ae0=R(()=>{bs0();us0();He0();r5();J80();UG();JW1=new Set(["PATH","LD_PRELOAD","LD_LIBRARY_PATH","DYLD_INSERT_LIBRARIES","DYLD_LIBRARY_PATH","HOME","USER","SHELL","PYTHONPATH","NODE_OPTIONS","NODE_PATH","BUN_INSTALL"]),qW1=/[;|`<>]|&&|\|\||\$\(|>>|<</,YW1=/\.\.[/\\]/});import{readFile as GW1}from"fs/promises";async function Pe0(D){if(!D.length)return"";let $=await Ve0.default(D,{cwd:process.cwd(),ignore:["**/node_modules/**","**/.git/**"],dot:!0,absolute:!0}),K=[];for(let z of $)try{let J=await GW1(z,"utf-8"),X=J.length>q80?J.slice(0,q80)+`
|
|
1024
1024
|
|
|
1025
1025
|
...(truncated \u2014 file exceeds ${q80} chars)`:J;K.push(`// File: ${z}
|