MCPcopy Create free account
hub / github.com/ChinaSiro/claude-code-sourcemap / mOY

Function mOY

package/cli.js:5261–5310  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5259`),P=encodeURIComponent(w),W=_TK-j.length-J.length-M.length-X.length;if(W<=0){let T=encodeURIComponent("…"),v=50,V=_TK-j.length-T.length-X.length-50,E=A+w+"\n```\n",S=encodeURIComponent(E);if(S.length>V){S=S.slice(0,V);let R=S.lastIndexOf("%");if(R>=S.length-2)S=S.slice(0,R)}return j+S+T+X}if(P.length<=W)return j+J+P+M;let D=encodeURIComponent("…"),f=50,G=P.slice(0,W-D.length-f),Z=G.lastIndexOf("%");if(Z>=G.length-2)G=G.slice(0,Z);return j+J+G+D+M+X}async function WOY(q,K){try{let _=await RG({systemPrompt:iK(["Generate a concise, technical issue title (max 80 chars) for a public GitHub issue based on this bug report for Claude Code.","Claude Code is an agentic coding CLI based on the Anthropic API.","The title should:","- Include the type of issue [Bug] or [Feature Request] as the first thing in the title","- Be concise, specific and descriptive of the actual problem","- Use technical terminology appropriate for a software issue",'- For error messages, extract the key error (e.g., "Missing Tool Result Block" rather than the full message)',"- Be direct and clear for developers to understand the problem",'- If you cannot determine a clear issue, use "Bug Report: [brief description]"',"- Any LLM API errors are from the Anthropic API, not from any other model provider","Your response will be directly used as the title of the Github issue, and as such should not contain any other commentary or explaination",'Examples of good titles include: "[Bug] Auto-Compact triggers to soon", "[Bug] Anthropic API Error: Missing Tool Result Block", "[Bug] Error: Invalid Model Name for Opus"']),userPrompt:q,signal:K,options:{hasAppendSystemPrompt:!1,toolChoice:void 0,isNonInteractiveSession:!1,agents:[],querySource:"feedback",mcpTools:[]}}),z=_.message.content[0]?.type==="text"?_.message.content[0].text:"Bug Report";if(so(z))return YTK(q);return z}catch(_){return H6(_),YTK(q)}}function YTK(q){let K=q.split(`
5260`)[0]||"";if(K.length<=60&&K.length>5)return K;let _=K.slice(0,60);if(K.length>60){let z=_.lastIndexOf(" ");if(z>30)_=_.slice(0,z);_+="..."}return _.length<10?"Bug Report":_}function jg8(q){if(q instanceof Error){let K=Error(aa(q.message));if(q.stack)K.stack=aa(q.stack);H6(K)}else{let K=aa(String(q));H6(Error(K))}}async function DOY(q,K){if(iA())return{success:!1};try{await k$();let _=DJ();if(_.error)return{success:!1};let z={"Content-Type":"application/json","User-Agent":hS(),..._.headers},Y=await $1.post("https://api.anthropic.com/api/claude_cli_feedback",{content:g6(q)},{headers:z,timeout:30000,signal:K});if(Y.status===200){let $=Y.data;if($?.feedback_id)return{success:!0,feedbackId:$.feedback_id};return jg8(Error("Failed to submit feedback: request did not return feedback_id")),{success:!1}}return jg8(Error("Failed to submit feedback:"+Y.status)),{success:!1}}catch(_){if($1.isCancel(_))return{success:!1};if($1.isAxiosError(_)&&_.response?.status===403){let z=_.response.data;if(z?.error?.type==="permission_error"&&z?.error?.message?.includes("Custom data retention settings"))return jg8(Error("Cannot submit feedback because custom data retention settings are enabled")),{success:!1,isZdrOrg:!0}}return jg8(_),{success:!1}}}var K4,HR,_TK=7250,MOY="https://github.com/anthropics/claude-code/issues";var Jq7=y(()=>{CK();v8();Hi();k8();i1();t4();s6();Oq();ew();SC();G7();hH();_8();y_();E5();jG();E8();_K();l8();a5();QK();e4();rK();CH();K4=O6(D6(),1),HR=O6(D6(),1)});var OTK={};T8(OTK,{renderFeedbackComponent:()=>ATK,call:()=>fOY});function ATK(q,K,_,z="",Y={}){return Pq7.createElement($TK,{abortSignal:K,messages:_,initialDescription:z,onDone:q,backgroundTasks:Y})}async function fOY(q,K,_){let z=_||"";return ATK(q,K.abortController.signal,K.messages,z)}var Pq7;var wTK=y(()=>{Jq7();Pq7=O6(D6(),1)});var ZOY,Wq7;var jTK=y(()=>{ZD();m8();ZOY={aliases:["bug"],type:"local-jsx",name:"feedback",description:"Submit feedback about Claude Code",argumentHint:"[report]",isEnabled:()=>!(i6(process.env.CLAUDE_CODE_USE_BEDROCK)||i6(process.env.CLAUDE_CODE_USE_VERTEX)||i6(process.env.CLAUDE_CODE_USE_FOUNDRY)||i6(process.env.DISABLE_FEEDBACK_COMMAND)||i6(process.env.DISABLE_BUG_COMMAND)||iA()||!1||!OO("allow_product_feedback")),load:()=>Promise.resolve().then(() => (wTK(),OTK))},Wq7=ZOY});class Dq7{paths=[];lowerPaths=[];charBits=new Int32Array(0);pathLens=new Uint16Array(0);topLevelCache=null;readyCount=0;loadFromFileList(q){let K=new Set,_=[];for(let z of q)if(z.length>0&&!K.has(z))K.add(z),_.push(z);this.buildIndex(_)}loadFromFileListAsync(q){let K=()=>{},_=new Promise((Y)=>{K=Y}),z=this.buildAsync(q,K);return{queryable:_,done:z}}async buildAsync(q,K){let _=new Set,z=[],Y=performance.now();for(let A=0;A<q.length;A++){let O=q[A];if(O.length>0&&!_.has(O))_.add(O),z.push(O);if((A&255)===255&&performance.now()-Y>4)await Jg8(),Y=performance.now()}this.resetArrays(z),Y=performance.now();let $=!0;for(let A=0;A<z.length;A++)if(this.indexPath(A),(A&255)===255&&performance.now()-Y>4){if(this.readyCount=A+1,$)K(),$=!1;await Jg8(),Y=performance.now()}this.readyCount=z.length,K()}buildIndex(q){this.resetArrays(q);for(let K=0;K<q.length;K++)this.indexPath(K);this.readyCount=q.length}resetArrays(q){let K=q.length;this.paths=q,this.lowerPaths=Array(K),this.charBits=new Int32Array(K),this.pathLens=new Uint16Array(K),this.readyCount=0,this.topLevelCache=kOY(q,100)}indexPath(q){let K=this.paths[q].toLowerCase();this.lowerPaths[q]=K;let _=K.length;this.pathLens[q]=_;let z=0;for(let Y=0;Y<_;Y++){let $=K.charCodeAt(Y);if($>=97&&$<=122)z|=1<<$-97}this.charBits[q]=z}search(q,K){if(K<=0)return[];if(q.length===0){if(this.topLevelCache)return this.topLevelCache.slice(0,K);return[]}let _=q!==q.toLowerCase(),z=_?q:q.toLowerCase(),Y=Math.min(z.length,64),$=Array(Y),A=0;for(let G=0;G<Y;G++){let Z=z.charAt(G);$[G]=Z;let T=Z.charCodeAt(0);if(T>=97&&T<=122)A|=1<<T-97}let O=Y*24+8+32,w=[],j=-1/0,{paths:H,lowerPaths:J,charBits:M,pathLens:X,readyCount:P}=this;q:for(let G=0;G<P;G++){if((M[G]&A)!==A)continue;let Z=_?H[G]:J[G],T=Z.indexOf($[0]);if(T===-1)continue;Hg8[0]=T;let v=0,V=0,E=T;for(let I=1;I<Y;I++){if(T=Z.indexOf($[I],E+1),T===-1)continue q;Hg8[I]=T;let B=T-E-1;if(B===0)V+=4;else v+=3+B*1;E=T}if(w.length===K&&O+V-v<=j)continue;let S=H[G],R=X[G],x=Y*16+V-v;x+=HTK(S,Hg8[0],!0);for(let I=1;I<Y;I++)x+=HTK(S,Hg8[I],!1);if(x+=Math.max(0,32-(R>>2)),w.length<K){if(w.push({path:S,fuzzScore:x}),w.length===K)w.sort((I,B)=>I.fuzzScore-B.fuzzScore),j=w[0].fuzzScore}else if(x>j){let I=0,B=w.length;while(I<B){let p=I+B>>1;if(w[p].fuzzScore<x)I=p+1;else B=p}w.splice(I,0,{path:S,fuzzScore:x}),w.shift(),j=w[0].fuzzScore}}w.sort((G,Z)=>Z.fuzzScore-G.fuzzScore);let W=w.length,D=Math.max(W,1),f=Array(W);for(let G=0;G<W;G++){let Z=w[G].path,T=G/D,v=Z.includes("test")?Math.min(T*1.05,1):T;f[G]={path:Z,score:v}}return f}}function HTK(q,K,_){if(K===0)return _?8:0;let z=q.charCodeAt(K-1);if(GOY(z))return 8;if(TOY(z)&&vOY(q.charCodeAt(K)))return 6;return 0}function GOY(q){return q===47||q===92||q===45||q===95||q===46||q===32}function TOY(q){return q>=97&&q<=122}function vOY(q){return q>=65&&q<=90}function Jg8(){return new Promise((q)=>setImmediate(q))}function kOY(q,K){let _=new Set;for(let Y of q){let $=Y.length;for(let O=0;O<Y.length;O++){let w=Y.charCodeAt(O);if(w===47||w===92){$=O;break}}let A=Y.slice(0,$);if(A.length>0){if(_.add(A),_.size>=K)break}}let z=Array.from(_);return z.sort((Y,$)=>{let A=Y.length-$.length;if(A!==0)return A;return Y<$?-1:Y>$?1:0}),z.slice(0,K).map((Y)=>({path:Y,score:0}))}var JTK=4,Hg8;var MTK=y(()=>{Hg8=new Int32Array(64)});import{statSync as VOY}from"fs";import*as YT from"path";function fq7(){if(!sa)sa=new Dq7;return sa}function fTK(){sa=null,Ih6=null,uh6++,Mg8=null,A78=[],Eq7=[],Lq7=[],yq7.clear(),Zq7=null,Gq7=null,Tq7=0,vq7=null,kq7=null,Xg8=null}function ZTK(q){let K=q.length,_=Math.max(1,Math.floor(K/500)),z=-2128831035;for(let Y=0;Y<K;Y+=_){let $=q[Y];for(let A=0;A<$.length;A++)z=(z^$.charCodeAt(A))*16777619|0;z=z*16777619|0}if(K>0){let Y=q[K-1];for(let $=0;$<Y.length;$++)z=(z^Y.charCodeAt($))*16777619|0}return`${K}:${(z>>>0).toString(16)}`}function NOY(){let q=hY(Z8());if(!q)return null;try{return VOY(YT.join(q,".git","index")).mtimeMs}catch{return null}}function XTK(q,K,_){if(_===K)return q;return q.map((z)=>{let Y=YT.join(K,z);return YT.relative(_,Y)})}async function yOY(q){if(q.length===0)return;if(!sa||A78.length===0)return;let K=await GTK(q),_=[...A78,...Eq7,...Lq7,...q,...K],z=ZTK(_);if(z===Xg8){N("[FileIndex] skipped index rebuild — merged paths unchanged");return}await sa.loadFromFileListAsync(_).done,Xg8=z,N(`[FileIndex] rebuilt index with ${A78.length} tracked + ${q.length} untracked files`)}async function PTK(q,K){let _=`${q}:${K}`;if(Gq7===_)return Zq7;let z=X8(),Y=[".ignore",".rgignore"],$=[...new Set([q,K])],A=WTK.default(),O=!1,w=$.flatMap((J)=>Y.map((M)=>YT.join(J,M))),j=await Promise.all(w.map((J)=>z.readFile(J,{encoding:"utf8"}).catch(()=>null)));for(let[J,M]of j.entries()){if(M===null)continue;A.add(M),O=!0,N(`[FileIndex] loaded ignore patterns from ${w[J]}`)}let H=O?A:null;return Zq7=H,Gq7=_,H}async function EOY(q,K){let _=Date.now();N("[FileIndex] getFilesUsingGit called");let z=hY(Z8());if(!z)return N("[FileIndex] not a git repo, returning null"),null;try{let Y=Z8(),$=Date.now(),A=await S7(L7(),["-c","core.quotepath=false","ls-files","--recurse-submodules"],{timeout:5000,abortSignal:q,cwd:z});if(N(`[FileIndex] git ls-files (tracked) took ${Date.now()-$}ms`),A.code!==0)return N(`[FileIndex] git ls-files failed (code=${A.code}, stderr=${A.stderr}), falling back to ripgrep`),null;let O=A.stdout.trim().split(`
5261`).filter(Boolean),w=XTK(O,z,Y),j=await PTK(z,Y);if(j){let J=w.length;w=j.filter(w),N(`[FileIndex] applied ignore patterns: ${J} -> ${w.length} files`)}A78=w;let H=Date.now()-_;if(N(`[FileIndex] git ls-files: ${w.length} tracked files in ${H}ms`),d("tengu_file_suggestions_git_ls_files",{file_count:w.length,tracked_count:w.length,untracked_count:0,duration_ms:H}),!Mg8){let J=K?["-c","core.quotepath=false","ls-files","--others","--exclude-standard"]:["-c","core.quotepath=false","ls-files","--others"],M=uh6;Mg8=S7(L7(),J,{timeout:1e4,cwd:z}).then(async(X)=>{if(M!==uh6)return;if(X.code===0){let P=X.stdout.trim().split(`
5262`).filter(Boolean),W=XTK(P,z,Y),D=await PTK(z,Y);if(D&&W.length>0){let f=W.length;W=D.filter(W),N(`[FileIndex] applied ignore patterns to untracked: ${f} -> ${W.length} files`)}N(`[FileIndex] background untracked fetch: ${W.length} files`),yOY(W)}}).catch((X)=>{N(`[FileIndex] background untracked fetch failed: ${X}`)}).finally(()=>{Mg8=null})}return w}catch(Y){return N(`[FileIndex] git ls-files error: ${d6(Y)}`),null}}async function GTK(q){let K=new Set,_=performance.now();for(let z=0;z<q.length;z++)if(LOY(q,z,z+1,K),(z&255)===255&&performance.now()-_>JTK)await Jg8(),_=performance.now();return[...K].map((z)=>z+YT.sep)}function LOY(q,K,_,z){for(let Y=K;Y<_;Y++){let $=YT.dirname(q[Y]);while($!=="."&&!z.has($)){let A=YT.dirname($);if(A===$)break;z.add($),$=A}}}async function ROY(q){return(await Promise.all(OK4.map((_)=>ii(_,q)))).flatMap((_)=>_.map((z)=>z.filePath))}async function hOY(q,K){N(`[FileIndex] getProjectFiles called, respectGitignore=${K}`);let _=await EOY(q,K);if(_!==null)return N(`[FileIndex] using git ls-files result (${_.length} files)`),_;N("[FileIndex] git ls-files returned null, falling back to ripgrep");let z=Date.now(),Y=["--files","--follow","--hidden","--glob","!.git/","--glob","!.svn/","--glob","!.hg/","--glob","!.bzr/","--glob","!.jj/","--glob","!.sl/"];if(!K)Y.push("--no-ignore-vcs");let A=(await LF(Y,".",q)).map((w)=>YT.relative(Z8(),w)),O=Date.now()-z;return N(`[FileIndex] ripgrep: ${A.length} files in ${O}ms`),d("tengu_file_suggestions_ripgrep",{file_count:A.length,duration_ms:O}),A}async function SOY(){let q=AbortSignal.timeout(1e4),K=fq7();try{let _=N7(),z=j8(),Y=_.respectGitignore??z.respectGitignore??!0,$=Z8(),[A,O]=await Promise.all([hOY(q,Y),ROY($)]);Eq7=O;let w=[...A,...O],j=await GTK(w);Lq7=j;let H=[...j,...w],J=ZTK(H);if(J!==kq7)await K.loadFromFileListAsync(H).done,kq7=J,Xg8=null;else N("[FileIndex] skipped index rebuild — tracked paths unchanged")}catch(_){H6(_)}return K}function COY(q,K){let _=Math.min(q.length,K.length),z=0;while(z<_&&q[z]===K[z])z++;return q.substring(0,z)}function TTK(q){if(q.length===0)return"";let K=q.map((z)=>z.displayText),_=K[0];for(let z=1;z<K.length;z++){let Y=K[z];if(_=COY(_,Y),_==="")return""}return _}function Vq7(q,K){return{id:`file-${q}`,displayText:q,metadata:K!==void 0?{score:K}:void 0}}function bOY(q,K){return q.search(K,Nq7).map((z)=>Vq7(z.path,z.score))}function Pg8(){if(Ih6)return;let q=NOY();if(sa){if(!(q!==null&&q!==vq7)&&Date.now()-Tq7<xOY)return}let K=uh6,_=Date.now();fq7(),Ih6=SOY().then((z)=>{if(K!==uh6)return z;return Ih6=null,yq7.emit(),vq7=q,Tq7=Date.now(),N(`[FileIndex] cache refresh completed in ${Date.now()-_}ms`),z}).catch((z)=>{if(N(`[FileIndex] Cache refresh failed: ${d6(z)}`),H6(z),K===uh6)Ih6=null;return fq7()})}async function IOY(){let q=X8(),K=Z8();try{return(await q.readdir(K)).map((z)=>{let Y=YT.join(K,z.name),$=YT.relative(K,Y);return z.isDirectory()?$+YT.sep:$})}catch(_){return H6(_),[]}}async function Rq7(q,K=!1){if(!q&&!K)return[];if(N7().fileSuggestion?.type==="command"){let z={...C$(),query:q};return(await hq7(z)).slice(0,Nq7).map(Vq7)}if(q===""||q==="."||q==="./"){let z=await IOY();return Pg8(),z.slice(0,Nq7).map(Vq7)}let _=Date.now();try{let z=Ih6!==null;Pg8();let Y=q,$="."+YT.sep;if(q.startsWith($))Y=q.substring(2);if(Y.startsWith("~"))Y=lq(Y);let A=sa?bOY(sa,Y):[],O=Date.now()-_;return N(`[FileIndex] generateFileSuggestions: ${A.length} results in ${O}ms (${z?"partial":"full"} index)`),d("tengu_file_suggestions_query",{duration_ms:O,cache_hit:!z,result_count:A.length,query_length:q.length}),A}catch(z){return H6(z),[]}}function Wg8(q,K,_,z,Y,$){let A=typeof q==="string"?q:q.displayText,O=K.substring(0,z)+A+K.substring(z+_.length);Y(O);let w=z+A.length;$(w)}var WTK,sa=null,Ih6=null,yq7,DTK,uh6=0,Mg8=null,A78,Eq7,Lq7,Zq7=null,Gq7=null,Tq7=0,vq7=null,kq7=null,Xg8=null,Nq7=15,xOY=5000;var O78=y(()=>{ri();MTK();k8();V1();I7();_8();y8();XK();e7();E5();y$();E8();dz();KC();U1();WTK=O6(n$6(),1);yq7=Dz(),DTK=yq7.subscribe,A78=[],Eq7=[],Lq7=[]});import{join as uOY}from"path";function mOY(){return`IMPORTANT: This message and these instructions are NOT part of the actual user conversation. Do NOT include any references to "documentation updates", "magic docs", or these update instructions in the document content.
5263
5264Based on the user conversation above (EXCLUDING this documentation update instruction message), update the Magic Doc file to incorporate any NEW learnings, insights, or information that would be valuable to preserve.
5265
5266The file {{docPath}} has already been read for you. Here are its current contents:
5267<current_doc_content>
5268{{docContents}}
5269</current_doc_content>
5270
5271Document title: {{docTitle}}
5272{{customInstructions}}
5273
5274Your ONLY task is to use the Edit tool to update the documentation file if there is substantial new information to add, then stop. You can make multiple edits (update multiple sections as needed) - make all Edit tool calls in parallel in a single message. If there's nothing substantial to add, simply respond with a brief explanation and do not call any tools.
5275
5276CRITICAL RULES FOR EDITING:
5277- Preserve the Magic Doc header exactly as-is: # MAGIC DOC: {{docTitle}}
5278- If there's an italicized line immediately after the header, preserve it exactly as-is
5279- Keep the document CURRENT with the latest state of the codebase - this is NOT a changelog or history
5280- Update information IN-PLACE to reflect the current state - do NOT append historical notes or track changes over time
5281- Remove or replace outdated information rather than adding "Previously..." or "Updated to..." notes
5282- Clean up or DELETE sections that are no longer relevant or don't align with the document's purpose
5283- Fix obvious errors: typos, grammar mistakes, broken formatting, incorrect information, or confusing statements
5284- Keep the document well organized: use clear headings, logical section order, consistent formatting, and proper nesting
5285
5286DOCUMENTATION PHILOSOPHY - READ CAREFULLY:
5287- BE TERSE. High signal only. No filler words or unnecessary elaboration.
5288- Documentation is for OVERVIEWS, ARCHITECTURE, and ENTRY POINTS - not detailed code walkthroughs
5289- Do NOT duplicate information that's already obvious from reading the source code
5290- Do NOT document every function, parameter, or line number reference
5291- Focus on: WHY things exist, HOW components connect, WHERE to start reading, WHAT patterns are used
5292- Skip: detailed implementation steps, exhaustive API docs, play-by-play narratives
5293
5294What TO document:
5295- High-level architecture and system design
5296- Non-obvious patterns, conventions, or gotchas
5297- Key entry points and where to start reading code
5298- Important design decisions and their rationale
5299- Critical dependencies or integration points
5300- References to related files, docs, or code (like a wiki) - help readers navigate to relevant context
5301
5302What NOT to document:
5303- Anything obvious from reading the code itself
5304- Exhaustive lists of files, functions, or parameters
5305- Step-by-step implementation details
5306- Low-level code mechanics
5307- Information already in CLAUDE.md or other project docs
5308
5309Use the Edit tool with file_path: {{docPath}}
5310
5311REMEMBER: Only update if there is substantial new information. The Magic Doc header (# MAGIC DOC: {{docTitle}}) must remain unchanged.`}async function pOY(){let q=X8(),K=uOY(c1(),"magic-docs","prompt.md");try{return await q.readFile(K,{encoding:"utf-8"})}catch{return mOY()}}function BOY(q,K){return q.replace(/\{\{(\w+)\}\}/g,(_,z)=>Object.prototype.hasOwnProperty.call(K,z)?K[z]:_)}async function vTK(q,K,_,z){let Y=await pOY(),$=z?`
5312
5313DOCUMENT-SPECIFIC UPDATE INSTRUCTIONS:

Callers 1

pOYFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected