@github/copilot 0.0.334-3 → 0.0.334-4
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/index.js +1 -1
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1929,7 +1929,7 @@ Run `+al.cyan("{updateCommand}")+" to update",r=e.message||n;e.boxenOptions??={p
|
|
|
1929
1929
|
`).map(l=>l.trim()).filter(l=>l&&!l.startsWith("#")).map(l=>l.endsWith("/")?l.slice(0,-1)+"/**":l)}shouldIgnore(e){try{let l=WcI(this.rootPath,e);return l==="."||l.startsWith("..")?!1:this.ig.ignores(l)}catch{return!1}}getDirectoryFilter(){return e=>{if(!e||e===".")return!1;let l=e.startsWith("./")?e.slice(2):e;return!l||l==="."?!1:this.ig.ignores(l)}}getFileFilter(){return e=>{if(!e||e===".")return!1;let l=e.startsWith("./")?e.slice(2):e;return!l||l==="."?!1:this.ig.ignores(l)}}updateFingerprint(){this.fingerprint=JSON.stringify(this.patterns)}getFingerprint(){return this.fingerprint}getPatterns(){return[...this.patterns]}};var SOt=2e4,$Te=class extends Error{constructor(e="Search aborted"){super(e),this.name="AbortError"}};async function BOt(t,e,l,I){let n=(0,TOt.default)(e,{dot:!0,contains:!0,nocase:!0}),r=[];for(let[a,s]of t.entries()){if(a%1e3===0&&(await new Promise(o=>setImmediate(o)),l?.aborted))throw new $Te;if(n(s)&&r.push(s),r.length>=I)break}return r.sort((a,s)=>{let o=a.endsWith(I9),d=s.endsWith(I9);return o&&!d?-1:!o&&d?1:a<s?-1:a>s?1:0}),r}var vae=class{rootPath;ignorePatterns;maxResults;cacheTimeout;indexFileStats;maxStatConcurrency;includeDirsInIndex;allFiles=[];visiblePaths=[];fileCache=[];fileByRelative=new Map;lastCacheUpdate=0;isIndexing=!1;indexingPromise=null;isIndexed=!1;strategy="v2";fzf;onIndexingStart;onIndexingComplete;logger;constructor(e={}){this.rootPath=e.rootPath||process.cwd(),this.ignorePatterns=new Qae(this.rootPath),this.maxResults=e.maxResults||50,this.cacheTimeout=e.cacheTimeout??5*6e4,this.indexFileStats=e.indexFileStats??!1,this.maxStatConcurrency=e.maxStatConcurrency??64,this.includeDirsInIndex=e.includeDirsInIndex??!1,this.onIndexingStart=e.onIndexingStart,this.onIndexingComplete=e.onIndexingComplete,this.logger=e.logger||new Ch}async search(e){if(await this.ensureFileIndex(),this.fileCache.length===0)return[];if(!e.trim()){let l=this.fileCache;return l.slice(0,this.maxResults).map((I,n)=>({path:I.path,score:1-n/Math.max(l.length,1),relativePath:I.relativePath}))}if(e.includes("*")){let l=await BOt(this.visiblePaths,e,void 0,this.maxResults),I=[],n=this.fileByRelative;for(let[r,a]of l.entries()){if(r%1e3===0&&await new Promise(o=>setImmediate(o)),I.length>=this.maxResults)break;if(a===".")continue;let s=n.get(a);if(s){let o=this.calculateScore(s.relativePath,e);I.push({path:s.path,score:o,relativePath:s.relativePath})}}return I.sort((r,a)=>a.score-r.score),I}else{this.fzf||(this.fzf=new $ye(this.visiblePaths,{fuzzy:this.visiblePaths.length>SOt?"v1":"v2"}));let l=[];try{l=await this.fzf.find(e)}catch{l=(await BOt(this.visiblePaths,e,void 0,this.maxResults)).map(a=>({item:a,score:1,start:0,end:0,positions:new Set}))}let I=l.slice(0,this.maxResults).map((r,a)=>({rel:r.item,idx:a})),n=[];for(let{rel:r,idx:a}of I){if(r===".")continue;let s=this.fileByRelative.get(r);s&&n.push({file:s,idx:a,bucket:this.exactBucket(s.relativePath,e),score:this.calculateScore(s.relativePath,e)})}return n.sort((r,a)=>a.bucket-r.bucket||r.idx-a.idx),n.map(r=>({path:r.file.path,relativePath:r.file.relativePath,score:r.score}))}}exactBucket(e,l){let I=e.toLowerCase(),n=l.toLowerCase();if(I===n)return 3;let r=I.lastIndexOf(I9),a=r===-1?I:I.slice(r+1);return a===n?2:a.startsWith(n)?1:0}calculateScore(e,l){let I=e.toLowerCase(),n=l.toLowerCase();if(I===n)return 1;let r=e.lastIndexOf(I9),s=(r===-1?e:e.slice(r+1)).toLowerCase();if(s===n)return .95;if(s.startsWith(n))return .85;if(I.startsWith(n))return .75;let o=I.indexOf(n);return o===-1?.5:Math.max(.1,.7-o/I.length)}async refresh(){this.invalidateCache(),await this.ensureFileIndex()}invalidateCache(){this.lastCacheUpdate=0,this.isIndexed=!1,this.indexingPromise=null,this.fileCache=[],this.allFiles=[],this.fzf=void 0,this.visiblePaths=[],this.fileByRelative.clear()}getCacheInfo(){return{fileCount:this.fileCache.length,lastUpdated:this.lastCacheUpdate,isIndexing:this.isIndexing,strategy:this.strategy,isIndexed:this.isIndexed}}async ensureFileIndex(){let e=Date.now();if(!(this.isIndexed&&this.fileCache.length>0&&e-this.lastCacheUpdate<this.cacheTimeout))return this.indexingPromise?this.indexingPromise:(this.isIndexing=!0,this.indexingPromise=this.buildFileIndex().finally(()=>{this.isIndexing=!1,this.indexingPromise=null}),this.indexingPromise)}async buildFileIndex(){let e=Date.now();this.onIndexingStart?.();try{await this.ignorePatterns.loadPatterns(),this.allFiles=await this.performCrawl();let l=await this.filterFilesConcurrently(this.allFiles),I=l.map(r=>({path:AcI(this.rootPath,r),relativePath:r,lastModified:0}));this.indexFileStats&&I.length&&await this.fillStatsConcurrently(I,this.maxStatConcurrency),I.sort((r,a)=>r.relativePath.localeCompare(a.relativePath)),this.fileCache=I,this.visiblePaths=l,this.fileByRelative=new Map(I.map(r=>[r.relativePath,r])),this.lastCacheUpdate=Date.now(),this.isIndexed=!0,this.strategy=this.visiblePaths.length>SOt?"v1":"v2";let n=Date.now()-e;this.onIndexingComplete?.(this.fileCache.length,n)}catch(l){this.logger.error(`Error building file index: ${l}`),this.fileCache=[],this.allFiles=[],this.visiblePaths=[],this.fileByRelative.clear(),this.isIndexed=!1;let I=Date.now()-e;this.onIndexingComplete?.(0,I)}}async fillStatsConcurrently(e,l){let I=0,n=new Array(Math.min(l,e.length)).fill(0).map(async()=>{for(;;){let r=I++;if(r>=e.length)break;let a=e[r];try{let s=await gcI(a.path);a.lastModified=s.mtime.getTime()}catch{}r%2e3===0&&await new Promise(s=>setImmediate(s))}});await Promise.all(n)}async filterFilesConcurrently(e,l=50){let I=this.ignorePatterns.getFileFilter(),n=[];for(let r=0;r<e.length;r+=l){let a=e.slice(r,r+l),s=a.map(o=>!I(o));a.forEach((o,d)=>{s[d]&&n.push(o)}),await new Promise(o=>setImmediate(o))}return n}async performCrawl(){let e=this.ignorePatterns.getDirectoryFilter(),l=new OOt.fdir().withRelativePaths().withPathSeparator(I9).exclude((I,n)=>{let r=ycI(this.rootPath,n);if(r==="."||r==="")return!1;let a=r.endsWith(I9)?r:`${r}${I9}`;return e(a)});return this.includeDirsInIndex&&l.withDirs(),l.crawl(this.rootPath).withPromise()}getRootPath(){return this.rootPath}async setRootPath(e){this.rootPath=e,this.ignorePatterns=new Qae(e),this.invalidateCache()}},qTe=null;function UOt(){return qTe||(qTe=new vae),qTe}function _Ot(t,e,l){let[I,n]=(0,i5.useState)([]),[r,a]=(0,i5.useState)(0),[s,o]=(0,i5.useState)(new Map),d=e||UOt(),G=(0,i5.useMemo)(()=>{let{text:f,cursorPosition:S}=t,B=-1;for(let D=S-1;D>=0;D--){let te=f[D];if(te==="@"){if(D===0||f[D-1]===" "||f[D-1]===`
|
|
1930
1930
|
`||f[D-1]===" "){B=D;break}}else if(te===" "||te===`
|
|
1931
1931
|
`||te===" ")break}if(B===-1)return{isAtMention:!1,atPosition:-1,query:""};let T=f.slice(B+1,S);return T.includes(" ")||T.includes(`
|
|
1932
|
-
`)||T.includes(" ")?{isAtMention:!1,atPosition:-1,query:""}:{isAtMention:!0,atPosition:B,query:T}},[t.text,t.cursorPosition]);(0,i5.useEffect)(()=>{if(!G.isAtMention){n([]),a(0);return}let f=!1,S=async()=>{try{let T=await d.search(G.query),D=[...T];G.query===""&&l&&(D=[...l.getDirectories().map(U=>({path:U,relativePath:`[DIR] ${U}`,score:1})),...T]),f||(n(D),a(0))}catch{f||(n([]),a(0))}},B=setTimeout(()=>{S()},200);return()=>{f=!0,clearTimeout(B)}},[G.query,G.isAtMention,d]);let u=()=>{I.length!==0&&a(f=>f>0?f-1:I.length-1)},h=()=>{I.length!==0&&a(f=>f<I.length-1?f+1:0)},W=()=>{if(!G.isAtMention||I.length===0)return null;let f=I[r];if(!f)return null;let S=`@${f.relativePath}`,B=`${S} `,{text:T,cursorPosition:D}=t,te=T.slice(0,G.atPosition),ae=T.slice(D),U=te+B+ae,$={displayText:S,fullPath:f.path,type:f.relativePath.startsWith("[DIR]")?"directory":"file",startIndex:G.atPosition};return o(Ge=>{let ue=new Map(Ge);return ue.set($.startIndex,$),ue}),t.setText(U),t.setCursorPosition(G.atPosition+B.length),f.relativePath},y=()=>{n([]),a(0)},R=()=>{o(new Map)};return[{isActive:G.isAtMention&&I.length>0,query:G.query,suggestions:I,selectedIndex:r,atPosition:G.atPosition,storedMentions:s},{navigateUp:u,navigateDown:h,complete:W,reset:y,clearStoredMentions:R}]}c();var hy=Gt(ul(),1);function zOt(t){let{cliModel:e,sessionManager:l,currentWorkingDirectory:I,stdoutColumns:n,models:r}=t,[a,s]=(0,hy.useState)({gitRoot:"",found:!1}),[o,d]=(0,hy.useState)(null);(0,hy.useEffect)(()=>{(async()=>{d(null);let V=await jGe(I);s(V)})()},[I]);let G=(0,hy.useCallback)(async()=>{if(!a.found){d(null);return}let R=await Hot(a.gitRoot);if(!R){d(null);return}let V=await Xot(a.gitRoot);d(Q=>Q?.branch===R&&Q?.hasChanges===V?Q:{branch:R,hasChanges:V})},[a]),u=(0,hy.useMemo)(()=>PGe(I),[I]),[h,W]=(0,hy.useState)("");(0,hy.useEffect)(()=>{(async()=>{if(!r)return;let V=await Zx(e,l,r);W(Q=>Q===V?Q:V)})()},[e,l,r]);let y=(0,hy.useMemo)(()=>{if(!o||!o.branch)return null;let R=n||80,V=h.length,Q=u.length,f=o.hasChanges?6:5,B=V+Q+f+4,D=Math.max(8,R-B)-3;return`[\u2387 ${o.branch.length>D?o.branch.substring(0,D)+"...":o.branch}${o.hasChanges?"*":""}]`},[o,n,u,h]);return{displayCwd:u,gitBranchInfo:y,selectedModel:h,setSelectedModel:W,updateGitStatus:G}}c();var qh=Gt(ul(),1),RcI=3*1e3;function MOt(){let[t,e]=(0,qh.useState)("idle"),[l,I]=(0,qh.useState)(0),[n,r]=(0,qh.useState)(0),[a,s]=(0,qh.useState)(!1),o=(0,qh.useRef)(null);(0,qh.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]);let d=(0,qh.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),e("indexing"),I(0),r(0),s(!0)},[]),G=(0,qh.useCallback)((y,R)=>{e("completed"),I(y),r(R),s(!0),o.current=setTimeout(()=>{s(!1),o.current=null},RcI)},[]),u=(0,qh.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),e("idle"),I(0),r(0),s(!1)},[]),h={state:t,fileCount:l,durationMs:n,isVisible:a},W=(0,qh.useMemo)(()=>({startIndexing:d,completeIndexing:G,reset:u}),[d,G,u]);return[h,W]}c();var I0e=Gt(ul(),1);function DOt(t,e,l,I){let[n,r]=(0,I0e.useState)();return(0,I0e.useEffect)(()=>{async function a(){if(!l)return;let s=await eUe(t,e,l,I);r(s)}a()},[l,e,I]),{models:n}}async function eUe(t,e,l,I){try{if(l.type==="hmac")return await X3.createWithHmac(t,aVe,I,l.hmac,e).listModels();let n=await GD(l);if(!n)return;let r=await sD(l.host,n);return await X3.createWithOAuthToken(t,r,I,n,e).listModels()}catch(n){t.error(`Error fetching models list: ${n}`)}}c();var N1=Gt(ul(),1);function jOt(t=3){let[e,l]=(0,N1.useState)(!1),I=(0,N1.useRef)(null),n=(0,N1.useRef)(t*1e3);(0,N1.useEffect)(()=>{n.current=t*1e3},[t]),(0,N1.useEffect)(()=>()=>{I.current&&clearTimeout(I.current)},[]);let r=(0,N1.useCallback)(a=>{I.current&&(clearTimeout(I.current),I.current=null),l(!0);let s=a!==void 0?a*1e3:n.current;I.current=setTimeout(()=>{l(!1),I.current=null},s)},[]);return[e,r]}c();var d5=Gt(ul(),1);function POt(t,e){let[l,I]=(0,d5.useState)(null),n=(0,d5.useRef)("");return(0,d5.useEffect)(()=>{t.text!==n.current&&(l?.availableOptions.some(s=>t.text===s.name)||I(null),n.current=t.text)},[t.text,l]),{handleTabCompletion:(0,d5.useCallback)(()=>{if(l){let
|
|
1932
|
+
`)||T.includes(" ")?{isAtMention:!1,atPosition:-1,query:""}:{isAtMention:!0,atPosition:B,query:T}},[t.text,t.cursorPosition]);(0,i5.useEffect)(()=>{if(!G.isAtMention){n([]),a(0);return}let f=!1,S=async()=>{try{let T=await d.search(G.query),D=[...T];G.query===""&&l&&(D=[...l.getDirectories().map(U=>({path:U,relativePath:`[DIR] ${U}`,score:1})),...T]),f||(n(D),a(0))}catch{f||(n([]),a(0))}},B=setTimeout(()=>{S()},200);return()=>{f=!0,clearTimeout(B)}},[G.query,G.isAtMention,d]);let u=()=>{I.length!==0&&a(f=>f>0?f-1:I.length-1)},h=()=>{I.length!==0&&a(f=>f<I.length-1?f+1:0)},W=()=>{if(!G.isAtMention||I.length===0)return null;let f=I[r];if(!f)return null;let S=`@${f.relativePath}`,B=`${S} `,{text:T,cursorPosition:D}=t,te=T.slice(0,G.atPosition),ae=T.slice(D),U=te+B+ae,$={displayText:S,fullPath:f.path,type:f.relativePath.startsWith("[DIR]")?"directory":"file",startIndex:G.atPosition};return o(Ge=>{let ue=new Map(Ge);return ue.set($.startIndex,$),ue}),t.setText(U),t.setCursorPosition(G.atPosition+B.length),f.relativePath},y=()=>{n([]),a(0)},R=()=>{o(new Map)};return[{isActive:G.isAtMention&&I.length>0,query:G.query,suggestions:I,selectedIndex:r,atPosition:G.atPosition,storedMentions:s},{navigateUp:u,navigateDown:h,complete:W,reset:y,clearStoredMentions:R}]}c();var hy=Gt(ul(),1);function zOt(t){let{cliModel:e,sessionManager:l,currentWorkingDirectory:I,stdoutColumns:n,models:r}=t,[a,s]=(0,hy.useState)({gitRoot:"",found:!1}),[o,d]=(0,hy.useState)(null);(0,hy.useEffect)(()=>{(async()=>{d(null);let V=await jGe(I);s(V)})()},[I]);let G=(0,hy.useCallback)(async()=>{if(!a.found){d(null);return}let R=await Hot(a.gitRoot);if(!R){d(null);return}let V=await Xot(a.gitRoot);d(Q=>Q?.branch===R&&Q?.hasChanges===V?Q:{branch:R,hasChanges:V})},[a]),u=(0,hy.useMemo)(()=>PGe(I),[I]),[h,W]=(0,hy.useState)("");(0,hy.useEffect)(()=>{(async()=>{if(!r)return;let V=await Zx(e,l,r);W(Q=>Q===V?Q:V)})()},[e,l,r]);let y=(0,hy.useMemo)(()=>{if(!o||!o.branch)return null;let R=n||80,V=h.length,Q=u.length,f=o.hasChanges?6:5,B=V+Q+f+4,D=Math.max(8,R-B)-3;return`[\u2387 ${o.branch.length>D?o.branch.substring(0,D)+"...":o.branch}${o.hasChanges?"*":""}]`},[o,n,u,h]);return{displayCwd:u,gitBranchInfo:y,selectedModel:h,setSelectedModel:W,updateGitStatus:G}}c();var qh=Gt(ul(),1),RcI=3*1e3;function MOt(){let[t,e]=(0,qh.useState)("idle"),[l,I]=(0,qh.useState)(0),[n,r]=(0,qh.useState)(0),[a,s]=(0,qh.useState)(!1),o=(0,qh.useRef)(null);(0,qh.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]);let d=(0,qh.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),e("indexing"),I(0),r(0),s(!0)},[]),G=(0,qh.useCallback)((y,R)=>{e("completed"),I(y),r(R),s(!0),o.current=setTimeout(()=>{s(!1),o.current=null},RcI)},[]),u=(0,qh.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null),e("idle"),I(0),r(0),s(!1)},[]),h={state:t,fileCount:l,durationMs:n,isVisible:a},W=(0,qh.useMemo)(()=>({startIndexing:d,completeIndexing:G,reset:u}),[d,G,u]);return[h,W]}c();var I0e=Gt(ul(),1);function DOt(t,e,l,I){let[n,r]=(0,I0e.useState)();return(0,I0e.useEffect)(()=>{async function a(){if(!l)return;let s=await eUe(t,e,l,I);r(s)}a()},[l,e,I]),{models:n}}async function eUe(t,e,l,I){try{if(l.type==="hmac")return await X3.createWithHmac(t,aVe,I,l.hmac,e).listModels();let n=await GD(l);if(!n)return;let r=await sD(l.host,n);return await X3.createWithOAuthToken(t,r,I,n,e).listModels()}catch(n){t.error(`Error fetching models list: ${n}`)}}c();var N1=Gt(ul(),1);function jOt(t=3){let[e,l]=(0,N1.useState)(!1),I=(0,N1.useRef)(null),n=(0,N1.useRef)(t*1e3);(0,N1.useEffect)(()=>{n.current=t*1e3},[t]),(0,N1.useEffect)(()=>()=>{I.current&&clearTimeout(I.current)},[]);let r=(0,N1.useCallback)(a=>{I.current&&(clearTimeout(I.current),I.current=null),l(!0);let s=a!==void 0?a*1e3:n.current;I.current=setTimeout(()=>{l(!1),I.current=null},s)},[]);return[e,r]}c();var d5=Gt(ul(),1);function POt(t,e){let[l,I]=(0,d5.useState)(null),n=(0,d5.useRef)("");return(0,d5.useEffect)(()=>{t.text!==n.current&&(l?.availableOptions.some(s=>t.text===s.name)||I(null),n.current=t.text)},[t.text,l]),{handleTabCompletion:(0,d5.useCallback)(()=>{let a=s=>{let o=s.indexOf(" ");return o===-1?!1:s.slice(o+1).trim().length>0};if(l){if(a(t.text)){I(null);return}let s=(l.currentIndex+1)%l.availableOptions.length,o=l.availableOptions[s];t.setText(o.name),I({...l,currentIndex:s}),e.setSlashCommandPickerIndex(s)}else{if(a(t.text))return;let s=Mne(t.text);if(s.length===1){let o=s[0],d=o.name;for(let G=d.length-1;G>=2;G--){let u=d.slice(0,G),h=Mne(u);if(h.length>1){let W=h.findIndex(V=>V.name===o.name);I({originalInput:u,availableOptions:h,currentIndex:W>=0?W:0});let y=(W+1)%h.length,R=h[y];t.setText(R.name),I({originalInput:u,availableOptions:h,currentIndex:y}),e.setSlashCommandPickerIndex(y);return}}}s.length>1?(I({originalInput:t.text,availableOptions:s,currentIndex:0}),t.setText(s[0].name),e.setSlashCommandPickerIndex(0)):s.length===1&&t.setText(s[0].name)}},[l,t,e]),tabCyclingState:l}}c();var UQ=Gt(ul(),1);function KOt(){let[t,e]=(0,UQ.useState)({columns:process.stdout.columns,rows:process.stdout.rows}),l=(0,UQ.useRef)(()=>{}),I=(0,UQ.useCallback)(r=>{l.current=r||(()=>{})},[]),n=(0,UQ.useCallback)(()=>{let{columns:r,rows:a}=process.stdout;e({columns:r,rows:a}),l.current(r,a)},[]);return(0,UQ.useEffect)(()=>(process.stdout.on("resize",n),()=>{process.stdout.off("resize",n)}),[]),{...t,setOnResize:I}}c();var Ej=Gt(ul(),1);var m5=t=>/\s/.test(t);function EcI(t,e){if(e>=t.length)return t.length;let l=e;for(;l<t.length&&m5(t[l]);)l+=t[l].length;for(;l<t.length&&!m5(t[l]);)l+=t[l].length;return l}function qOt(t,e){if(e===0)return 0;let l=e-1;for(;l>=0&&m5(t[l]);)l-=t[l].length;if(l<0)return 0;for(;l>=0&&!m5(t[l]);)l-=t[l].length;return l+1}function YcI(t,e){if(e>=t.length)return t.length;let l=e;for(;l<t.length&&!m5(t[l]);)l+=t[l].length;for(;l<t.length&&m5(t[l]);)l+=t[l].length;return l}function Yj(t,e){if(e<=0)return[t];let l=t.split(`
|
|
1933
1933
|
`).map(n=>n+" "),I=[];for(let n of l){if(n.length<=e){I.push(n);continue}let r=n;for(;r.length>e;){let a=e;if(m5(r.slice(0,e)))for(let o=e-1;o>=Math.max(0,e-20)&&!m5(r[o]);o--)a=o;let s=r.slice(0,a);I.push(s),r=r.slice(a)}r.length>0&&I.push(r)}return I}function Cae(t,e){if(e.length===0)return{line:0,column:0};let l=0;for(let n=0;n<e.length;n++){let r=e[n],a=l+r.length;if(t<a)return{line:n,column:t-l};l=a}let I=e.length-1;return{line:I,column:e[I].length}}function Hae(t,e,l,I){if(t.length===0)return 0;let n=0;for(let r=0;r<Math.min(e,t.length);r++)n+=t[r].length;return e<t.length?n+=Math.min(l,t[e].length):n=I.length,Math.min(n,I.length)}function VcI(t,e){switch(e.type){case"set_text":return{text:e.payload,cursorPosition:e.payload.length,width:t.width};case"set_cursor_position":return{...t,cursorPosition:Math.max(0,Math.min(e.payload,t.text.length))};case"set_cursor_line_position":{let{line:l,column:I}=e.payload,n=Yj(t.text,t.width),r=Hae(n,l,I,t.text);return{...t,cursorPosition:r}}case"set_width":return t.width===e.payload?t:{...t,width:e.payload};case"insert_input":{let{text:l,cursorPosition:I}=t,{input:n,callback:r}=e.payload,a=n.replace(/\r\n/g,`
|
|
1934
1934
|
`).replace(/\r/g,`
|
|
1935
1935
|
`),s=l.slice(0,I),o=l.slice(I),d=s+a+o,G=I+a.length;return r?.(d),{text:d,cursorPosition:G,width:t.width}}case"backspace":return t.cursorPosition===0?t:{text:t.text.slice(0,t.cursorPosition-1)+t.text.slice(t.cursorPosition),cursorPosition:t.cursorPosition-1,width:t.width};case"forward_delete":{if(t.cursorPosition>=t.text.length)return t;let l=t.text.slice(0,t.cursorPosition)+t.text.slice(t.cursorPosition+1);return{...t,text:l}}case"backspace_word":{let{text:l,cursorPosition:I}=t;if(I===0)return t;let n=qOt(l,I);return{text:l.slice(0,n)+l.slice(I),cursorPosition:n,width:t.width}}case"forward_delete_word":{let{text:l,cursorPosition:I}=t;if(I>=l.length)return t;let n=EcI(l,I),r=l.slice(0,I)+l.slice(n);return{...t,text:r}}case"move_word_left":{let{text:l,cursorPosition:I}=t;if(I===0)return t;let n=qOt(l,I);return{...t,cursorPosition:n}}case"move_word_right":{let{text:l,cursorPosition:I}=t;if(I>=l.length)return t;let n=YcI(l,I);return{...t,cursorPosition:n}}case"move_right":return t.cursorPosition===t.text.length?t:{...t,cursorPosition:t.cursorPosition+1};case"move_left":return t.cursorPosition===0?t:{...t,cursorPosition:t.cursorPosition-1};case"move_up":{let{text:l,cursorPosition:I,width:n}=t,r=Yj(l,n),a=Cae(I,r);if(a.line>0){let s=a.line-1,o=Math.min(a.column,r[s].length-1),d=Hae(r,s,o,l);return{...t,cursorPosition:d}}return t}case"move_down":{let{text:l,cursorPosition:I,width:n}=t,r=Yj(l,n),a=Cae(I,r);if(a.line<r.length-1){let s=a.line+1,o=Math.min(a.column,r[s].length-1),d=Hae(r,s,o,l);return{...t,cursorPosition:d}}return t}case"clear":return{text:"",cursorPosition:0,width:t.width};default:return t}}var $Ot=(t,e=80)=>{let[l,I]=(0,Ej.useReducer)(VcI,{text:"",cursorPosition:0,width:e}),{text:n,cursorPosition:r,width:a}=l,s=Yj(n,a),o=Cae(r,s),d=ue=>{I({type:"set_cursor_position",payload:ue})},G=(ue,ye)=>{I({type:"set_cursor_line_position",payload:{line:ue,column:ye}})},u=(0,Ej.useCallback)(ue=>{I({type:"set_width",payload:ue})},[]),h=ue=>{I({type:"set_text",payload:ue})},W=ue=>{I({type:"insert_input",payload:{input:ue,callback:t}})},y=()=>{r!==0&&I({type:"backspace"})},R=()=>{r>=n.length||I({type:"forward_delete"})},V=()=>{r!==0&&I({type:"backspace_word"})},Q=()=>{r>=n.length||I({type:"forward_delete_word"})},f=()=>{r!==0&&I({type:"move_left"})},S=()=>{r>=n.length||I({type:"move_right"})},B=()=>{I({type:"move_up"})},T=()=>{I({type:"move_down"})},D=()=>{r!==0&&I({type:"move_word_left"})},te=()=>{r>=n.length||I({type:"move_word_right"})},ae=()=>{I({type:"clear"})},U=(0,Ej.useCallback)(()=>{let ue=Yj(n,a),ye=Cae(r,ue),ne=Hae(ue,ye.line,0,n);I({type:"set_cursor_position",payload:ne})},[n,a,r]),$=(0,Ej.useCallback)(()=>{let ue=Yj(n,a),ye=Cae(r,ue),ne=ue[ye.line]?.length||0,P=Hae(ue,ye.line,ne-1,n);I({type:"set_cursor_position",payload:P})},[n,a,r]);return{text:n,visualLines:s,cursorPosition:r,cursorLinePosition:o,setCursorPosition:d,setCursorLinePosition:G,setText:h,setWidth:u,insertInput:W,backspace:y,forwardDelete:R,backspaceWord:V,forwardDeleteWord:Q,moveLeft:f,moveRight:S,moveUp:B,moveDown:T,moveWordLeft:D,moveWordRight:te,moveToStartOfCurrentLine:U,moveToEndOfCurrentLine:$,clear:ae,handleCommonKeyPress:(ue,ye)=>{if(ye.ctrl||ye.meta){if(ye.backspace||ye.ctrl&&ue==="w"){V();return}if(ye.delete){Q();return}if(ye.leftArrow||ye.meta&&ue==="b"){D();return}if(ye.rightArrow||ye.meta&&ue==="f"){te();return}if(ye.ctrl&&ue==="a"){U();return}if(ye.ctrl&&ue==="e"){$();return}if(ye.ctrl&&ue==="h"){y();return}if(ye.ctrl&&ue==="d"){R();return}}if(ye.home){U();return}if(ye.end){$();return}if(ye.leftArrow){f();return}if(ye.rightArrow){S();return}if(ye.upArrow){B();return}if(ye.downArrow){T();return}if(ye.backspace){y();return}if(ye.delete){R();return}if(!dAe.includes(ue)&&!ye.ctrl&&!ye.meta){W(ue);return}}}};c();import{realpathSync as eTt}from"fs";import{isAbsolute as tUe,relative as wcI,sep as FcI}from"path";var Xae=class{directories=[];primaryDirectory;constructor(e,l=[]){this.primaryDirectory=this.resolveAndValidateDirectory(e),this.directories=[this.primaryDirectory];for(let I of l){let n=this.resolveAndValidateDirectory(I);this.directories.includes(n)||this.directories.push(n)}}getDirectories(){return[...this.directories]}getPrimaryDirectory(){return this.primaryDirectory}async updatePrimaryDirectory(e){let l=this.resolveAndValidateDirectory(e);if(!await OC(l))throw new Error(`Directory does not exist: ${e}`);this.directories=this.directories.filter(n=>n!==this.primaryDirectory),this.directories.unshift(l),this.primaryDirectory=l}async addDirectory(e){let l=this.resolveAndValidateDirectory(e);if(!await OC(l))throw new Error(`Directory does not exist: ${e}`);this.directories.includes(l)||this.directories.push(l)}isPathWithinAllowedDirectories(e){if(e==="/dev/null")return!0;try{let l=this.fullyResolvedPath(e);for(let I of this.directories)if(this.isPathWithinRoot(l,I))return!0;return!1}catch{return!1}}fullyResolvedPath(e){try{if(!tUe(e))throw new Error(`Path must be absolute: ${e}`);return eTt(e)}catch{return e}}isPathWithinRoot(e,l){let I=wcI(l,e);return!I.startsWith(`..${FcI}`)&&I!==".."&&!tUe(I)}resolveAndValidateDirectory(e){if(!e)throw new Error("Directory path cannot be empty");if(!tUe(e))throw new Error(`Directory path must be absolute: ${e}`);try{return eTt(e)}catch{throw new Error(`Directory does not exist or cannot be accessed: ${e}`)}}};c();var Vj=class{turnStartTimes=new Map;turnModelCallTimes=new Map;turnToolExecutionTimes=new Map;turnToolCallCounts=new Map;startTurn(e,l){this.turnStartTimes.set(e,l),this.turnModelCallTimes.set(e,{}),this.turnToolExecutionTimes.set(e,0),this.turnToolCallCounts.set(e,0)}recordModelCall(e,l){let I=this.turnModelCallTimes.get(e)||{};I.duration=l,this.turnModelCallTimes.set(e,I)}recordToolExecution(e,l){let I=this.turnToolExecutionTimes.get(e)||0;this.turnToolExecutionTimes.set(e,I+l);let n=this.turnToolCallCounts.get(e)||0;this.turnToolCallCounts.set(e,n+1)}finishTurn(e,l){let I=this.turnStartTimes.get(e);if(I===void 0)return this.cleanup(e),null;let n=l-I,r=this.turnModelCallTimes.get(e)||{},a=this.turnToolExecutionTimes.get(e)||0,s=this.turnToolCallCounts.get(e)||0,o=r.duration||0,d={totalDurationMs:n,llmDurationMs:o,toolExecutionMs:a,toolCallCount:s,totalDurationSeconds:(n/1e3).toFixed(2),llmDurationSeconds:(o/1e3).toFixed(2),toolExecutionSeconds:(a/1e3).toFixed(2)};return this.cleanup(e),d}cleanup(e){this.turnStartTimes.delete(e),this.turnModelCallTimes.delete(e),this.turnToolExecutionTimes.delete(e),this.turnToolCallCounts.delete(e)}static formatTimingBreakdown(e){return`LLM: ${e.llmDurationSeconds}s | Tools: ${e.toolExecutionSeconds}s (${e.toolCallCount} calls) | Total: ${e.totalDurationSeconds}s`}};c();var QcI="You are not licensed to use Copilot.",vcI="You are not authorized to use this Copilot feature, it requires an enterprise or organization policy to be enabled.",CcI="The provided personal access token (PAT) does not have Copilot Requests permission. Please generate a new Fine-Grained Access Token with Copilot Requests permission (not a Classic token), or log in using /login";function lUe(t){return t.includes("not licensed to use Copilot")?{kind:"not-licensed",message:QcI}:t.includes("not authorized to use this Copilot feature")?{kind:"not-authorized",message:vcI}:t.includes("Personal Access Token does not have Copilot Requests")?{kind:"not-authorized",message:CcI}:null}c();import{promises as tTt}from"fs";import fae,{join as HcI}from"path";function XcI(t){let e=[],l=/(?<![a-zA-Z0-9])(@[^\s@]+)/g,I;for(;(I=l.exec(t))!==null;)e.push({displayText:I[1],startIndex:I.index,endIndex:I.index+I[0].length});return e}async function fcI(t){try{let e=await tTt.stat(t);return e.isDirectory()?"directory":e.isFile()?_$(fae.basename(t))?"image":"file":null}catch{return null}}async function JcI(t,e=new Map,l=process.cwd()){let I=XcI(t),n=[];for(let r of I){let a=e.get(r.startIndex);if(a?.startIndex===r.startIndex)n.push(a);else{let s=r.displayText.slice(1).replace(/[.,;:!?]+$/,""),o=fae.isAbsolute(s)?s:fae.resolve(l,s),d=await fcI(o);if(d===null)continue;n.push({displayText:r.displayText,fullPath:o,type:d,startIndex:r.startIndex})}}return n}async function lTt(t,e=new Map,l=process.cwd(),I){let n=await JcI(t,e,l),r=n.filter(G=>G.type==="image"),a=n.filter(G=>G.type!=="image"),s=kcI(t,a),o=await LcI(a,l,I),d=await OcI(r,I);return{expandedText:s,mentions:n,syntheticToolCalls:o,imageAttachments:d}}function kcI(t,e){let l=[...e].sort((n,r)=>r.startIndex-n.startIndex),I=t;for(let n of l){let r=I.substring(0,n.startIndex),a=I.substring(n.startIndex+n.displayText.length);I=r+`${n.fullPath}`+a}return I}async function LcI(t,e,l){let I=[],n=[];for(let r of t){let a=fae.isAbsolute(r.fullPath)?r.fullPath:HcI(e,r.fullPath);try{let s=await xcI(a,l);n.push(s)}catch{}}if(n.length>0){let r=n.map(a=>({id:a.id,type:"function",function:{name:a.name,arguments:JSON.stringify(a.arguments)}}));I.push({role:"assistant",content:"I need to read the content of those paths to answer this request.",tool_calls:r}),I.push(...n.map(a=>({role:"tool",tool_call_id:a.id,content:a.result})))}return I}async function xcI(t,e){let l=eA();try{let I=await uFe({command:"view",path:t,view_range:void 0},{properties:{command:"view",resolvedPathAgainstCwd:"false",options:"{}",inputs:"[]"},metrics:{responseTokenLimit:void 0,resultLength:0,resultForLlmLength:0},restrictedProperties:{}},e);return{id:l,name:"str_replace_editor",arguments:{command:"view",path:t},result:I.textResultForLlm||""}}catch(I){return{id:l,name:"str_replace_editor",arguments:{command:"view",path:t},result:`Error reading ${t}: ${I}`}}}function ScI(t){switch(fae.extname(t).toLowerCase()){case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";default:return null}}async function BcI(t,e){try{let l=await tTt.readFile(t),I=ScI(t);if(!I)return e.error(`Unsupported image format: ${t}`),null;let n=new U$,r=await obe(e,n,3145728,B$,I,l);if(!r)return e.error(`Image too large or couldn't be processed: ${t}`),null;let a=r.toString("base64");return`data:${I};base64,${a}`}catch(l){return e.error(`Failed to read image ${t}: ${l}`),null}}async function OcI(t,e){let l=[];for(let I of t)try{let n=await BcI(I.fullPath,e);n&&l.push({type:"image_url",image_url:{url:n}})}catch(n){e.error(`Failed to process image ${I.fullPath}: ${n}`)}return l}var ITt=1,nUe=!1;function _cI(t){nUe=t}var IUe=new Map;function Pa(t,e){if(nUe){if(e.type==="tool_call_requested"){IUe.set(e.callId,{callId:e.callId,name:e.name,toolTitle:e.toolTitle,intentionSummary:e.intentionSummary,arguments:e.arguments}),t.addTimelineEntry(e);return}let l={...e,id:Date.now().toString(),timestamp:new Date},I=oTt(l);I.trim()&&As.stdout.write(I+`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@github/copilot",
|
|
3
3
|
"description": "GitHub Copilot CLI brings the power of Copilot coding agent directly to your terminal.",
|
|
4
|
-
"version": "0.0.334-
|
|
4
|
+
"version": "0.0.334-4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"sdk/**/*"
|
|
34
34
|
],
|
|
35
35
|
"buildMetadata": {
|
|
36
|
-
"gitCommit": "
|
|
36
|
+
"gitCommit": "44f3839"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"node-pty": "npm:@devm33/node-pty@^1.0.8",
|