MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / q36

Function q36

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

Source from the content-addressed store, hash-verified

8095- Preserve frontmatter (--- block) exactly as-is
8096- Preserve the overall format and style
8097- Do not remove existing content unless an improvement explicitly replaces it
8098- Output the complete updated file inside <updated_file> tags`})],systemPrompt:iK(["You edit skill definition files to incorporate user preferences. Output only the updated file content."]),thinkingConfig:{type:"disabled"},tools:[],signal:P3().signal,options:{getToolPermissionContext:async()=>MX(),model:PH(),toolChoice:void 0,isNonInteractiveSession:!1,hasAppendSystemPrompt:!1,temperatureOverride:0,agents:[],querySource:"skill_improvement_apply",mcpTools:[]}}),w=L3(O.message.content).trim(),j=o4(w,"updated_file");if(!j){H6(Error("Skill improvement apply: no updated_file tag in response"));return}try{await z.writeFile(Y,j,"utf-8")}catch(H){H6(x1(H))}}var P$7=y(()=>{v8();o1();k8();ew();Bq();B2();I7();y8();E8();i1();aq();l8();MrK();Br6()});function WrK(q){let K=P8((w)=>w.skillImprovement.suggestion),_=s7(),[z,Y]=_M6.useState(!1),$=_M6.useRef(K),A=_M6.useRef(!1);if(K)$.current=K;if(K&&!z){if(Y(!0),!A.current)A.current=!0,d("tengu_skill_improvement_survey",{event_type:"appeared",_PROTO_skill_name:K.skillName??"unknown"})}let O=_M6.useCallback((w)=>{let j=$.current;if(!j)return;let H=w!=="dismissed";if(d("tengu_skill_improvement_survey",{event_type:"responded",response:H?"applied":"dismissed",_PROTO_skill_name:j.skillName}),H)PrK(j.skillName,j.updates).then(()=>{q((J)=>[...J,fw(`Skill "${j.skillName}" updated with improvements.`,"suggestion")])});Y(!1),A.current=!1,_((J)=>{if(!J.skillImprovement.suggestion)return J;return{...J,skillImprovement:{suggestion:null}}})},[_,q]);return{isOpen:z,suggestion:$.current,handleSelect:O}}var _M6;var DrK=y(()=>{k8();C7();P$7();i1();_M6=O6(D6(),1)});function frK(q){return{onBeforeQuery:async()=>!0,onTurnComplete:async()=>{},render:()=>null}}import{join as DZ}from"path";function q36(){let _=((Z7()||{}).cleanupPeriodDays??mUY)*24*60*60*1000;return new Date(Date.now()-_)}function pUY(q,K){return{messages:q.messages+K.messages,errors:q.errors+K.errors}}function BUY(q){let K=q.split(".")[0].replace(/T(\d{2})-(\d{2})-(\d{2})-(\d{3})Z/,"T$1:$2:$3.$4Z");return new Date(K)}async function ZrK(q,K,_){let z={messages:0,errors:0};try{let Y=await X8().readdir(q);for(let $ of Y)try{if(BUY($.name)<K)if(await X8().unlink(DZ(q,$.name)),_)z.messages++;else z.errors++}catch(A){H6(A)}}catch(Y){if(Y instanceof Error&&"code"in Y&&Y.code!=="ENOENT")H6(Y)}return z}async function gUY(){let q=X8(),K=q36(),_=$_6.errors(),z=$_6.baseLogs(),Y=await ZrK(_,K,!1);try{let $;try{$=await q.readdir(z)}catch{return Y}let A=$.filter((O)=>O.isDirectory()&&O.name.startsWith("mcp-logs-")).map((O)=>DZ(z,O.name));for(let O of A)Y=pUY(Y,await ZrK(O,K,!0)),await cs(O,q)}catch($){if($ instanceof Error&&"code"in $&&$.code!=="ENOENT")H6($)}return Y}async function u48(q,K,_){if((await _.stat(q)).mtime<K)return await _.unlink(q),!0;return!1}async function cs(q,K){try{await K.rmdir(q)}catch{}}async function FUY(){let q=q36(),K={messages:0,errors:0},_=Rp(),z=X8(),Y;try{Y=await z.readdir(_)}catch{return K}for(let $ of Y){if(!$.isDirectory())continue;let A=DZ(_,$.name),O;try{O=await z.readdir(A)}catch{K.errors++;continue}for(let w of O)if(w.isFile()){if(!w.name.endsWith(".jsonl")&&!w.name.endsWith(".cast"))continue;try{if(await u48(DZ(A,w.name),q,z))K.messages++}catch{K.errors++}}else if(w.isDirectory()){let j=DZ(A,w.name),H=DZ(j,FB1),J;try{J=await z.readdir(H)}catch{await cs(j,z);continue}for(let M of J)if(M.isFile())try{if(await u48(DZ(H,M.name),q,z))K.messages++}catch{K.errors++}else if(M.isDirectory()){let X=DZ(H,M.name),P;try{P=await z.readdir(X)}catch{continue}for(let W of P){if(!W.isFile())continue;try{if(await u48(DZ(X,W.name),q,z))K.messages++}catch{K.errors++}}await cs(X,z)}await cs(H,z),await cs(j,z)}await cs(A,z)}return K}async function UUY(q,K,_=!0){let z=q36(),Y={messages:0,errors:0},$=X8(),A;try{A=await $.readdir(q)}catch{return Y}for(let O of A){if(!O.isFile()||!O.name.endsWith(K))continue;try{if(await u48(DZ(q,O.name),z,$))Y.messages++}catch{Y.errors++}}if(_)await cs(q,$);return Y}function QUY(){let q=DZ(c1(),"plans");return UUY(q,".md")}async function dUY(){let q=q36(),K={messages:0,errors:0},_=X8();try{let z=c1(),Y=DZ(z,"file-history"),$;try{$=await _.readdir(Y)}catch{return K}let A=$.filter((O)=>O.isDirectory()).map((O)=>DZ(Y,O.name));await Promise.all(A.map(async(O)=>{try{if((await _.stat(O)).mtime<q)await _.rm(O,{recursive:!0,force:!0}),K.messages++}catch{K.errors++}})),await cs(Y,_)}catch(z){H6(z)}return K}async function cUY(){let q=q36(),K={messages:0,errors:0},_=X8();try{let z=c1(),Y=DZ(z,"session-env"),$;try{$=await _.readdir(Y)}catch{return K}let A=$.filter((O)=>O.isDirectory()).map((O)=>DZ(Y,O.name));for(let O of A)try{if((await _.stat(O)).mtime<q)await _.rm(O,{recursive:!0,force:!0}),K.messages++}catch{K.errors++}await cs(Y,_)}catch(z){H6(z)}return K}async function lUY(){let q=q36(),K={messages:0,errors:0},_=X8(),z=DZ(c1(),"debug"),Y;try{Y=await _.readdir(z)}catch{return K}for(let $ of Y){if(!$.isFile()||!$.name.endsWith(".txt")||$.name==="latest")continue;try{if(await u48(DZ(z,$.name),q,_))K.messages++}catch{K.errors++}}return K}async function GrK(){let{errors:q}=bo();if(q.length>0&&US7("cleanupPeriodDays")){N("Skipping cleanup: settings have validation errors but cleanupPeriodDays was explicitly set. Fix settings errors to enable cleanup.");return}await gUY(),await FUY(),await QUY(),await dUY(),await cUY(),await lUY(),await zC4(),await KGK(q36());let K=await G_7(q36());if(K>0)d("tengu_worktree_cleanup",{removed:K})}var mUY=30;var TrK=y(()=>{k8();v$8();_8();m8();e7();Ko();E8();PQ();o77();_K();Bt6();U1();IG();d0()});function vrK(q){for(let K=0;K<q.length;K++){let _=q.charCodeAt(K);if(_<=31||_===127)return!0}return!1}function NrK(q){let K=q.startsWith(`${Cy}://`)?q:q.startsWith(`${Cy}:`)?q.replace(`${Cy}:`,`${Cy}://`):null;if(!K)throw Error(`Invalid deep link: expected ${Cy}:// scheme, got "${q}"`);let _;try{_=new URL(K)}catch{throw Error(`Invalid deep link URL: "${q}"`)}if(_.hostname!=="open")throw Error(`Unknown deep link action: "${_.hostname}"`);let z=_.searchParams.get("cwd")??void 0,Y=_.searchParams.get("repo")??void 0,$=_.searchParams.get("q");if(z&&!z.startsWith("/")&&!/^[a-zA-Z]:[/\\]/.test(z))throw Error(`Invalid cwd in deep link: must be an absolute path, got "${z}"`);if(z&&vrK(z))throw Error("Deep link cwd contains disallowed control characters");if(z&&z.length>VrK)throw Error(`Deep link cwd exceeds ${VrK} characters (got ${z.length})`);if(Y&&!nUY.test(Y))throw Error(`Invalid repo in deep link: expected "owner/repo", got "${Y}"`);let A;if($&&$.trim().length>0){if(A=Og1($.trim()),vrK(A))throw Error("Deep link query contains disallowed control characters");if(A.length>krK)throw Error(`Deep link query exceeds ${krK} characters (got ${A.length})`)}return{query:A,cwd:z,repo:Y}}var Cy="claude-cli",nUY,krK=5000,VrK=4096;var W$7=y(()=>{nUY=/^[\w.-]+\/[\w.-]+$/});var xrK={};T8(xrK,{registerProtocolHandler:()=>SrK,isProtocolHandlerCurrent:()=>brK,ensureDeepLinkProtocolRegistered:()=>tUY,MACOS_BUNDLE_ID:()=>Dc8});import{promises as hR}from"fs";import*as yrK from"os";import*as xp from"path";function Wc8(){return xp.join(hS8(),"applications",ErK)}function RrK(q){return`Exec="${q}" --handle-uri %u`}function hrK(q){return`"${q}" --handle-uri "%1"`}async function oUY(q){let K=xp.join(m48,"Contents");try{await hR.rm(m48,{recursive:!0})}catch(Y){if(s1(Y)!=="ENOENT")throw Y}await hR.mkdir(xp.dirname(D$7),{recursive:!0});let _=`<?xml version="1.0" encoding="UTF-8"?>
8099<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
8100<plist version="1.0">

Callers 7

gUYFunction · 0.85
FUYFunction · 0.85
UUYFunction · 0.85
dUYFunction · 0.85
cUYFunction · 0.85
lUYFunction · 0.85
GrKFunction · 0.85

Calls 1

nowMethod · 0.80

Tested by

no test coverage detected