MCPcopy Create free account
hub / github.com/Railly/agentfiles / renderNoSkillkit

Method renderNoSkillkit

main.js:21–21  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19---`,3);if(s===-1)return e.push({from:0,to:3,severity:"error",message:"Unclosed frontmatter block, missing closing ---"}),e;let r=t.slice(4,s).split(`
20`),n=4,o=[];for(let l of r){let O=l.match(/^(\w[\w-]*)\s*:(.*)/);if(O){let c=O[1],d=O[2].trim();o.includes(c)&&e.push({from:n,to:n+c.length,severity:"warning",message:`Duplicate key: "${c}"`}),o.push(c),c==="name"&&(d?d.length>64?e.push({from:n,to:n+l.length,severity:"warning",message:`name exceeds 64 chars (${d.length})`}):wO.test(d)||e.push({from:n+c.length+2,to:n+l.length,severity:"warning",message:"name must be lowercase alphanumeric with single hyphens, no leading/trailing hyphens"}):e.push({from:n,to:n+l.length,severity:"error",message:"name is required"})),c==="description"&&(d?d.length>1024&&e.push({from:n,to:n+l.length,severity:"warning",message:`description exceeds 1024 chars (${d.length})`}):e.push({from:n,to:n+l.length,severity:"warning",message:"description is empty"})),c==="compatibility"&&d.length>500&&e.push({from:n,to:n+l.length,severity:"warning",message:`compatibility exceeds 500 chars (${d.length})`})}n+=l.length+1}return e});var Dr=require("@codemirror/language"),zr=Dr.foldService.of((a,e,t)=>{let s=a.doc.lineAt(e);if(s.number!==1||s.text.trim()!=="---")return null;for(let i=s.number+1;i<=a.doc.lines;i++){let r=a.doc.line(i);if(r.text.trim()==="---")return{from:s.to,to:r.to}}return null});function Vr(a){let{doc:e,parent:t,onSave:s}=a,i=[Rr,(0,q.lineNumbers)(),(0,q.highlightActiveLineGutter)(),(0,q.highlightActiveLine)(),(0,q.highlightSpecialChars)(),(0,we.history)(),(0,pe.foldGutter)(),(0,q.drawSelection)(),(0,pe.indentOnInput)(),(0,pe.bracketMatching)(),(0,Rt.closeBrackets)(),(0,pe.syntaxHighlighting)(Er),q.EditorView.darkTheme.of(activeDocument.body.classList.contains("theme-dark")),Yr,zr,(0,Lt.lintGutter)(),q.EditorView.lineWrapping,q.keymap.of([{key:"Mod-s",run:r=>(s(r.state.doc.toString()),!0)},we.indentWithTab,...Rt.closeBracketsKeymap,...we.defaultKeymap,...we.historyKeymap,...pe.foldKeymap,...Mr.searchKeymap,...Lt.lintKeymap])];return i.push(_r()),new q.EditorView({state:Ar.EditorState.create({doc:e,extensions:i}),parent:t})}function xO(a){return Math.ceil(a.length/4)}function ZO(a){return a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(1)} KB`:`${(a/(1024*1024)).toFixed(1)} MB`}function qr(a){return a>=1e3?`${(a/1e3).toFixed(1)}k`:String(a)}function TO(a){return new Date(a).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}var XO=new M.Component,Yt=class{containerEl;store;settings;saveSettings;currentItem=null;isEditing=!1;app;editorView=null;constructor(e,t,s,i,r){this.containerEl=e,this.store=t,this.settings=s,this.saveSettings=i,this.app=r.app}show(e){this.destroyEditor(),this.currentItem=e,this.isEditing=!1,this.render()}clear(){this.destroyEditor(),this.currentItem=null,this.containerEl.empty(),this.containerEl.addClass("as-detail");let e=this.containerEl.createDiv("as-detail-empty");(0,M.setIcon)(e.createDiv("as-detail-empty-icon"),"file-text"),e.createDiv({text:"Select a skill to view"})}render(){this.containerEl.empty(),this.containerEl.addClass("as-detail");let e=this.currentItem;if(!e)return this.clear();this.renderToolbar(e),this.isEditing?this.renderEditor(e):this.renderPreview(e)}renderToolbar(e){let t=this.containerEl.createDiv("as-detail-toolbar"),s=t.createDiv("as-toolbar-top"),i=s.createDiv("as-toolbar-left");i.createSpan({cls:"as-detail-title",text:e.name});for(let p of e.tools){let u=W.find(f=>f.id===p);if(!u)continue;let g=i.createSpan("as-tool-name-badge");g.setCssProps({"--tool-color":u.color}),I[p]&&ne(g,p,12),g.createSpan({text:u.name})}let r=s.createDiv("as-toolbar-right"),n=r.createEl("button",{cls:"as-toolbar-btn",attr:{"aria-label":"Toggle favorite"}});(0,M.setIcon)(n,e.isFavorite?"star":"star-off"),n.addEventListener("click",()=>{this.store.toggleFavorite(e.id,this.settings),this.saveSettings(),this.render()});let o=r.createEl("button",{cls:"as-toolbar-btn",attr:{"aria-label":this.isEditing?"Preview":"Edit"}});(0,M.setIcon)(o,this.isEditing?"eye":"pencil"),o.addEventListener("click",()=>{this.isEditing=!this.isEditing,this.render()});let l=r.createEl("button",{cls:"as-toolbar-btn",attr:{"aria-label":"Show in system explorer"}});if((0,M.setIcon)(l,"folder-open"),l.addEventListener("click",()=>{ht(e.filePath)}),K()){let p=r.createEl("button",{cls:"as-toolbar-btn as-toolbar-btn-danger",attr:{"aria-label":"Remove skill"}});(0,M.setIcon)(p,"trash-2"),p.addEventListener("click",()=>{_e(this.app,"Remove skill",`Remove "${e.name}"? This will delete the skill files.`,()=>{let u=ze(`prune --skill ${e.name} --yes`);u.success?(new M.Notice(`Removed ${e.name}`,5e3),this.store.refresh(this.settings),this.clear()):new M.Notice(`Failed to remove: ${u.output}`,5e3)})})}let O=t.createDiv("as-detail-meta-bar"),c=xO(e.content),d=e.content.length;if(O.createSpan({cls:"as-meta-item",text:ZO(e.fileSize)}),O.createSpan({cls:"as-meta-item",text:`${qr(d)} chars`}),O.createSpan({cls:"as-meta-item",text:`~${qr(c)} tokens`}),O.createSpan({cls:"as-meta-item",text:TO(e.lastModified)}),O.createSpan({cls:"as-meta-item as-meta-type",text:e.type}),e.usage&&e.usage.uses>0){let p=t.createDiv("as-detail-usage-bar");p.createSpan({cls:"as-usage-stat",text:`${e.usage.uses} uses`}),p.createSpan({cls:"as-usage-stat",text:`last: ${ca(e.usage.lastUsed)}`}),e.usage.isStale&&p.createSpan({cls:"as-badge-stale",text:"stale"}),e.usage.isHeavy&&p.createSpan({cls:"as-badge-heavy",text:"heavy"})}}renderFrontmatter(e,t){let s=Object.keys(t.frontmatter),i=e.createDiv("as-frontmatter");if(t.filePath){let r=i.createDiv("as-fm-prop");r.createSpan({cls:"as-fm-key",text:"path"}),r.createSpan({cls:"as-fm-value",text:t.filePath})}if(!(s.length===0&&!t.filePath))for(let r of s){let n=t.frontmatter[r];if(n==null)continue;let o=i.createDiv("as-fm-prop");o.createSpan({cls:"as-fm-key",text:r});let l=typeof n=="object"?JSON.stringify(n):typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?String(n):JSON.stringify(n);l.length>200?o.createDiv({cls:"as-fm-value-long",text:l}):o.createSpan({cls:"as-fm-value",text:l})}}renderPreview(e){let t=this.containerEl.createDiv("as-detail-body");this.renderFrontmatter(t,e),this.renderWarnings(t,e),this.renderUsageSection(t,e),this.renderConflicts(t,e),this.renderTraces(t,e);let s=t.createDiv("as-detail-preview markdown-rendered");M.MarkdownRenderer.render(this.app,e.content,s,e.filePath,XO)}renderWarnings(e,t){let s=[];if(t.warnings?.oversized&&s.push(`${t.warnings.lineCount} lines (recommended: <500)`),t.warnings?.longDesc&&s.push(`Description is ${t.warnings.descChars} chars (recommended: <1024)`),t.conflicts&&t.conflicts.length>0){let o=t.conflicts.map(l=>l.skillName).join(", ");s.push(`Conflicts with: ${o}`)}if(s.length===0)return;let i=e.createDiv("as-warnings"),r=i.createDiv("as-warnings-icon");(0,M.setIcon)(r,"alert-triangle");let n=i.createDiv("as-warnings-list");for(let o of s)n.createDiv({cls:"as-warnings-item",text:o})}renderUsageSection(e,t){if(!t.usage||t.usage.uses===0)return;let s=e.createDiv("as-usage-section"),i=s.createDiv("as-usage-left");if(i.createSpan({cls:"as-usage-count",text:String(t.usage.uses)}),i.createSpan({cls:"as-usage-label",text:"uses"}),i.createSpan({cls:"as-usage-last",text:ca(t.usage.lastUsed)}),t.usage.daily&&t.usage.daily.length>1){let r=s.createDiv("as-usage-spark");Zs(r,t.usage.daily.map(n=>n.count),80,20)}}renderConflicts(e,t){if(!t.conflicts||t.conflicts.length===0)return;let s=e.createDiv("as-conflicts-section");s.createDiv({cls:"as-section-title",text:`Conflicts (${t.conflicts.length})`});for(let i of t.conflicts){let r=s.createDiv("as-conflict-row");r.createSpan({cls:"as-conflict-name",text:i.skillName}),r.createDiv("as-conflict-bar-wrap").createDiv("as-conflict-bar").setCssProps({"--bar-w":`${(i.similarity*100).toFixed(0)}%`}),r.createSpan({cls:"as-conflict-score",text:`${(i.similarity*100).toFixed(0)}%`})}}renderTraces(e,t){if(!K())return;let s=Ps(t.name);if(s.length===0)return;let i=e.createDiv("as-traces-section");i.createDiv({cls:"as-section-title",text:`Recent traces (${s.length})`});let r=i.createDiv("as-traces-table");for(let n of s){let o=r.createDiv("as-trace-row"),l=new Date(n.timestamp);o.createSpan({cls:"as-trace-date",text:l.toLocaleDateString(void 0,{month:"short",day:"numeric"})}),o.createSpan({cls:"as-trace-model",text:n.model.replace("claude-","").replace("-4-6","")}),o.createSpan({cls:"as-trace-tokens",text:`${(n.tokens/1e3).toFixed(1)}k`}),o.createSpan({cls:"as-trace-cost",text:n.cost>0?`$${n.cost.toFixed(2)}`:""}),o.createSpan({cls:"as-trace-duration",text:`${(n.duration/1e3).toFixed(1)}s`})}i.createDiv({cls:"as-traces-hint",text:"skillkit trace --list --skill "+t.name})}renderPruneAction(e,t){let s=e.createDiv("as-prune-section"),i=s.createEl("button",{cls:"as-prune-btn",text:"Remove this skill"});s.createSpan({cls:"as-prune-hint",text:"This skill hasn't been used in 30+ days"}),i.addEventListener("click",()=>{_e(this.app,"Remove skill",`Remove "${t.name}"? This will delete the skill files.`,()=>{let r=ze(`prune --skill ${t.name} --yes`);r.success?(new M.Notice(`Removed ${t.name}`,5e3),this.store.refresh(this.settings)):new M.Notice(`Failed to remove: ${r.output}`,5e3)})})}renderEditor(e){this.destroyEditor();let t=this.containerEl.createDiv("as-detail-body as-detail-body-editor"),s=t.createDiv("as-editor-cm");this.editorView=Vr({doc:e.content,parent:s,onSave:n=>this.saveFile(e,n)});let i=t.createDiv("as-save-bar");i.createEl("button",{cls:"as-save-btn",text:"Save"}).addEventListener("click",()=>{this.editorView&&this.saveFile(e,this.editorView.state.doc.toString())}),i.createSpan({cls:"as-save-hint",text:"Cmd+S to save"})}destroyEditor(){this.editorView&&(this.editorView.destroy(),this.editorView=null)}saveFile(e,t){try{(0,Wr.writeFileSync)(e.filePath,t,"utf-8"),e.content=t,new M.Notice(`Saved ${e.name}`,5e3)}catch(s){new M.Notice(`Failed to save: ${s instanceof Error?s.message:String(s)}`,5e3)}}};var ue=require("obsidian");var es=require("child_process"),H=require("fs"),X=require("path"),Dt=require("os"),Ot=require("obsidian"),D=(0,Dt.homedir)(),qe=(0,Dt.platform)()==="win32",Ir=(0,X.join)(D,".agents",".skill-lock.json"),_O="https://skills.sh/api";async function ts(a){if(a.length<2)return[];try{let t=(await(0,Ot.requestUrl)({url:`${_O}/search?q=${encodeURIComponent(a)}&limit=30`})).json;if(!t.skills)return[];let s=Hr();return t.skills.map(i=>({...i,installed:s.has(i.name)}))}catch{return[]}}var Gr=new Map;async function CO(a){let e=Gr.get(a);if(e)return e;let i=(await(0,Ot.requestUrl)({url:`https://api.github.com/repos/${a}`})).json.default_branch||"main",o=((await(0,Ot.requestUrl)({url:`https://api.github.com/repos/${a}/git/trees/${i}?recursive=1`})).json.tree??[]).filter(O=>O.path.endsWith("/SKILL.md")).map(O=>O.path),l={branch:i,files:o};return Gr.set(a,l),l}function jO(a,e,t){let s=e.split("/"),i=s[s.length-1]||a,r=new Set([i,a]);for(let n of t.split("/")){a.startsWith(n+"-")&&r.add(a.slice(n.length+1));for(let o of n.split("-"))a.startsWith(o+"-")&&r.add(a.slice(o.length+1))}return r}async function Nr(a,e,t){try{let{branch:s,files:i}=await CO(a),r=jO(e,t,a),n=i.find(O=>{let c=O.replace("/SKILL.md","").split("/").pop()||"";return r.has(c)});n||(n=i.find(O=>{let c=O.replace("/SKILL.md","").split("/").pop()||"";return e.includes(c)||c.includes(e)}));let o=n||`skills/${e}/SKILL.md`;return(await(0,Ot.requestUrl)({url:`https://raw.githubusercontent.com/${a}/${s}/${o}`})).text}catch{return null}}async function Br(){let a=["react","next","clerk","stripe","ai"],e=new Set,t=[];for(let s of a){let i=await ts(s);for(let r of i)e.has(r.id)||(e.add(r.id),t.push(r))}return t.sort((s,i)=>i.installs-s.installs).slice(0,20)}function EO(){let a=[];if(qe){let t=process.env.APPDATA||(0,X.join)(D,"AppData","Roaming");a.push((0,X.join)(t,"npm"),(0,X.join)(D,".bun","bin"),(0,X.join)(D,"AppData","Local","npm"))}else a.push("/usr/local/bin","/opt/homebrew/bin",(0,X.join)(D,".local","bin"),(0,X.join)(D,".bun","bin"));let e=qe?(0,X.join)(D,"AppData","Roaming","nvm"):(0,X.join)(D,".nvm","versions","node");try{for(let t of(0,H.readdirSync)(e))a.push(qe?(0,X.join)(e,t):(0,X.join)(e,t,"bin"))}catch{}return[...a,process.env.PATH||""].join(X.delimiter)}function Ur(){let a=qe?["bunx.cmd","bunx.exe","bunx"]:["bunx"],e=[];if(qe){let t=process.env.APPDATA||(0,X.join)(D,"AppData","Roaming");e.push((0,X.join)(D,".bun","bin"),(0,X.join)(t,"npm"))}else e.push((0,X.join)(D,".bun","bin"),"/usr/local/bin","/opt/homebrew/bin");for(let t of e)for(let s of a)if((0,H.existsSync)((0,X.join)(t,s)))return(0,X.join)(t,s);return"npx"}function as(a="auto"){return a==="npx"?"npx":Ur()}var Fr=[{id:"claude-code",label:"Claude Code"},{id:"cursor",label:"Cursor"},{id:"codex",label:"Codex"},{id:"github-copilot",label:"GitHub Copilot"},{id:"windsurf",label:"Windsurf"},{id:"amp",label:"Amp"},{id:"opencode",label:"OpenCode"},{id:"cline",label:"Cline"},{id:"gemini-cli",label:"Gemini CLI"},{id:"goose",label:"Goose"},{id:"kiro-cli",label:"Kiro"},{id:"roo",label:"Roo Code"},{id:"continue",label:"Continue"},{id:"antigravity",label:"Antigravity"},{id:"warp",label:"Warp"},{id:"pi",label:"Pi"},{id:"replit",label:"Replit"}],zt={"claude-code":"claude-code",cursor:"cursor",codex:"codex",copilot:"github-copilot",windsurf:"windsurf",amp:"amp",opencode:"opencode",antigravity:"antigravity","claude-desktop":"claude-code",pi:"pi","global-agents":"claude-code",aider:"claude-code"};function Hr(){let a=new Set;if(!(0,H.existsSync)(Ir))return a;try{let e=JSON.parse((0,H.readFileSync)(Ir,"utf-8"));if(e.skills)for(let t of Object.keys(e.skills))a.add(t)}catch{}return a}var RO=[(0,X.join)(D,".claude","skills"),(0,X.join)(D,".cursor","skills"),(0,X.join)(D,".codex","skills"),(0,X.join)(D,".codeium","windsurf","skills"),(0,X.join)(D,".config","amp","skills"),(0,X.join)(D,".config","opencode","skills"),(0,X.join)(D,".copilot","skills"),(0,X.join)(D,".agents","skills")];function LO(a){for(let e of RO){let t=(0,X.join)(e,a);if((0,H.existsSync)(t))try{(0,H.rmSync)(t,{recursive:!0,force:!0})}catch{}}YO(a)}function YO(a){let e=(0,X.join)(D,".agents",".skill-lock.json");if((0,H.existsSync)(e))try{let t=JSON.parse((0,H.readFileSync)(e,"utf-8"));t.skills&&t.skills[a]&&(delete t.skills[a],(0,H.writeFileSync)(e,JSON.stringify(t,null,2)+`
21`,"utf-8"))}catch{}}function At(a){let e=Hr();for(let t of a)t.installed=e.has(t.name);return a}function ss(a,e=12e4){return new Promise(t=>{(0,es.exec)(a,{encoding:"utf-8",timeout:e,env:{...process.env,PATH:EO(),NO_COLOR:"1"},shell:qe?"cmd.exe":void 0},(s,i)=>{let r=String(i??"");!s||r.includes("Done")||r.includes("Installed")||r.includes("Removed")||r.includes("Updated")?t({success:!0,output:r}):t({success:!1,output:s?.message??"Command failed"})})})}async function Jr(a,e,t={}){let s=e.length>0?`-a ${e.join(" ")}`:"-a '*'",i=t.globalInstall?"-g":"",r=t.skillName?`-s ${t.skillName}`:"",o=`${as(t.runner||"auto")} skills add ${a} ${s} ${i} ${r} -y`.replace(/\s+/g," ").trim();return ss(o)}async function Kr(a,e="auto"){let s=`${as(e)} skills remove ${a} -y`,i=await ss(s,3e4);return LO(a),{success:!0,output:i.output||`Cleaned ${a}`}}async function en(a="auto"){let t=`${as(a)} skills update`,s=await ss(t),i=s.output.match(/Updated (\d+) skill/);return{...s,count:i?parseInt(i[1]):0}}function is(a){return a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a)}var We=require("fs"),an=require("path"),sn=require("os"),DO=new Set(["Read","Write","Edit","MultiEdit","Bash","Glob","Grep","WebSearch","WebFetch","TodoRead","TodoWrite","Task","Agent","Skill","LSP","NotebookEdit","AskFollowupQuestion","AttemptCompletion","SearchReplace","InsertCodeBlock","ReadImages","ExecuteCommand","ListFiles","SearchFiles","ReadFile","WriteFile","ReplaceInFile","ListCodeDefinitionNames","BrowserAction","UseMcp","shell","shell_command","update_plan","create_plan","read_file","write_file","execute_command","spawn_agent","write_stdin","multi_tool_use.parallel"]);function tn(a){return!(DO.has(a)||a.startsWith("mcp__")||a.startsWith("mcp_"))}function zO(a){let e=a.top_skills.filter(s=>tn(s.name)),t=a.top_skills.filter(s=>!tn(s.name)).reduce((s,i)=>s+i.total,0);return{...a,top_skills:e,total_invocations:Math.max(0,a.total_invocations-t),unique_skills:e.length}}function AO(){let a=De("stats"),e=De("health"),t=De("burn"),s=De("context");return{stats:a,health:e,burn:t&&t.length>0?t[0]:null,context:s}}var rs=(0,an.join)((0,sn.homedir)(),".skillkit","dashboard-cache.json"),he=null,xe=null;function MO(){if(!he&&(0,We.existsSync)(rs))try{let a=JSON.parse((0,We.readFileSync)(rs,"utf-8"));he=a.data,xe=a.cachedAt}catch{}}function VO(){if(he)try{(0,We.writeFileSync)(rs,JSON.stringify({data:he,cachedAt:xe},null,2),"utf-8")}catch{}}MO();var Mt=class{containerEl;app;constructor(e,t){this.containerEl=e,this.app=t}render(){if(this.containerEl.empty(),this.containerEl.addClass("as-dashboard"),!K()){this.renderNoSkillkit();return}if(he)this.renderDashboard(he);else{let e=this.containerEl.createDiv("as-dash-loading");e.createDiv("as-dash-spinner"),e.createDiv({cls:"as-dash-loading-text",text:"Loading analytics..."}),window.setTimeout(()=>{let t=AO();he=t,xe=Date.now(),VO(),e.remove(),this.renderDashboard(t)},10)}}renderDashboard(e){this.renderActionBar(e);let t=e.stats?zO(e.stats):null;if(t&&this.renderOverview(t,e.health),t&&this.renderTopSkills(t),e.health||e.context){let s=this.containerEl.createDiv("as-dash-row");e.health&&this.renderHealth(e.health,s),e.context&&this.renderContext(e.context,s)}e.burn&&this.renderBurn(e.burn),e.health&&this.renderStale(e.health)}renderActionBar(e){let t=this.containerEl.createDiv("as-dash-action-bar");if(xe){let n=Math.round((Date.now()-xe)/1e3),o=n<5?"just now":n<60?`${n}s ago`:`${Math.round(n/60)}m ago`;t.createSpan({cls:"as-dash-updated",text:`Updated ${o}`})}let s=t.createDiv("as-dash-action-buttons"),i=s.createEl("button",{cls:"as-action-btn",text:"Update skills"});i.addEventListener("click",()=>{i.setText("Updating..."),i.disabled=!0,en().then(n=>{if(n.success){let o=n.count>0?`Updated ${n.count} skill(s)`:"All skills up to date";new ue.Notice(o,5e3),he=null,xe=null,this.render()}else new ue.Notice(`Update failed: ${n.output}`,5e3);i.setText("Update skills"),i.disabled=!1})});let r=s.createEl("button",{cls:"as-action-btn",text:"Scan sessions"});if(r.addEventListener("click",()=>{r.setText("Scanning..."),r.disabled=!0,window.setTimeout(()=>{let n=ze("scan");n.success?(new ue.Notice("Scan complete",5e3),he=null,xe=null,this.render()):new ue.Notice(`Scan failed: ${n.output}`,5e3),r.setText("Scan sessions"),r.disabled=!1},10)}),e.health&&e.health.usage.unused_30d>0){let n=s.createEl("button",{cls:"as-action-btn as-action-btn-danger",text:`Prune ${e.health.usage.unused_30d} stale`});n.addEventListener("click",()=>{_e(this.app,"Prune stale skills",`Remove ${e.health.usage.unused_30d} unused skills? This cannot be undone.`,()=>{n.setText("Pruning..."),n.disabled=!0,window.setTimeout(()=>{let o=ze("prune --yes");o.success?(new ue.Notice("Pruned stale skills",5e3),he=null,xe=null,this.render()):new ue.Notice(`Prune failed: ${o.output}`,5e3),n.setText(`Prune ${e.health.usage.unused_30d} stale`),n.disabled=!1},10)})})}}renderNoSkillkit(){let e=this.containerEl.createDiv("as-dash-empty"),t=e.createDiv("as-dash-empty-icon");(0,ue.setIcon)(t,"bar-chart-2"),e.createEl("h3",{text:"Dashboard requires skillkit"}),e.createEl("p",{text:"Install skillkit to unlock usage analytics, burn rate, context tax, and more."}),e.createDiv("as-dash-install-cmd").createEl("code",{text:"npm i -g @crafter/skillkit && skillkit scan"}),e.createEl("a",{cls:"as-skillkit-link",text:"Learn more",href:"https://www.npmjs.com/package/@crafter/skillkit"}).addEventListener("click",r=>{r.preventDefault(),ut("https://www.npmjs.com/package/@crafter/skillkit")})}renderOverview(e,t){let s=this.containerEl.createDiv("as-dash-section");s.createDiv({cls:"as-dash-title",text:"Overview"});let i=s.createDiv("as-dash-stats");if(this.statCard(i,String(e.total_invocations),"invocations","activity"),this.statCard(i,String(e.unique_skills),"active skills","sparkles"),this.statCard(i,String(t?.installed??0),"installed","package"),this.statCard(i,String(t?.usage.unused_30d??0),"stale","alert-triangle"),e.streak&&e.streak.current>0){let r=s.createDiv("as-dash-streak-row");r.createSpan({cls:"as-streak-value",text:`${e.streak.current} day streak`}),e.streak.current>=7&&r.createSpan({cls:"as-streak-fire",text:"on fire"}),r.createSpan({cls:"as-streak-longest",text:`longest: ${e.streak.longest}d`})}if(e.velocity&&e.velocity.this_week>0){let r=s.createDiv("as-dash-velocity-row");r.createSpan({text:`This week: $${e.velocity.this_week.toFixed(0)}`}),r.createSpan({cls:"as-velocity-vs",text:`vs $${e.velocity.last_week.toFixed(0)} last week`});let n=e.velocity.change_pct,o=n>0?"as-velocity-up":n<0?"as-velocity-down":"",l=n>0?"+":"";r.createSpan({cls:`as-velocity-change ${o}`,text:`${l}${n.toFixed(0)}%`})}}statCard(e,t,s,i){let r=e.createDiv("as-stat-card"),n=r.createDiv("as-stat-icon");(0,ue.setIcon)(n,i),r.createDiv({cls:"as-stat-value",text:t}),r.createDiv({cls:"as-stat-label",text:s})}renderTopSkills(e){if(e.top_skills.length===0)return;let t=this.containerEl.createDiv("as-dash-section");t.createDiv({cls:"as-dash-title",text:`Top Skills (${e.period.days}d)`});let s=e.top_skills[0]?.total||1,i=t.createDiv("as-dash-bars");for(let r of e.top_skills.slice(0,10)){let n=i.createDiv("as-bar-row");n.createSpan({cls:"as-bar-name",text:r.name}),n.createDiv("as-bar-wrap").createDiv("as-bar-fill").setCssProps({"--bar-w":`${r.total/s*100}%`}),n.createSpan({cls:"as-bar-count",text:String(r.total)})}}renderHealth(e,t){let s=(t||this.containerEl).createDiv("as-dash-section");s.createDiv({cls:"as-dash-title",text:"Health"});let i=e.usage.used_30d+e.usage.unused_30d,r=i>0?Math.round(e.usage.used_30d/i*100):0,n=s.createDiv("as-dash-health-row"),o=n.createDiv("as-donut");o.setCssProps({"--pct":`${r}`}),o.createDiv({cls:"as-donut-label",text:`${r}%`}),o.createDiv({cls:"as-donut-sub",text:"active"});let l=n.createDiv("as-health-details");l.createDiv({cls:"as-health-line",text:`${e.usage.used_30d} used in 30d`}),l.createDiv({cls:"as-health-line as-health-warn",text:`${e.usage.unused_30d} never triggered`});let c=l.createDiv("as-budget-bar").createDiv("as-budget-fill");c.setCssProps({"--bar-w":`${e.metadata.pct}%`}),e.metadata.pct>80&&c.addClass("as-budget-over"),l.createDiv({cls:"as-health-line",text:`Metadata budget: ${e.metadata.pct}%`})}renderBurn(e){let t=this.containerEl.createDiv("as-dash-section");t.createDiv({cls:"as-dash-title",text:`Burn Rate \u2014 ${e.agent} (${e.period.days}d)`});let s=t.createDiv("as-dash-stats as-dash-stats-sm");if(this.statCard(s,`$${Math.round(e.cost.total).toLocaleString()}`,"total cost","flame"),this.statCard(s,`$${Math.round(e.cost.total/(e.period.days||1)).toLocaleString()}`,"daily avg","trending-up"),this.statCard(s,`${(e.period.sessions||0).toLocaleString()}`,"sessions","terminal"),this.statCard(s,`${((e.period.api_calls||0)/1e3).toFixed(0)}k`,"API calls","zap"),e.by_model&&e.by_model.length>0){let o=t.createDiv("as-model-breakdown");for(let l of e.by_model.slice(0,4)){let O=o.createDiv("as-model-row");O.createSpan({cls:"as-model-name",text:l.model}),O.createSpan({cls:"as-model-calls",text:`${l.apiCalls.toLocaleString()} calls`}),l.costUsd>0&&O.createSpan({cls:"as-model-cost",text:`$${Math.round(l.costUsd).toLocaleString()}`})}}let i=e.by_day.slice(-14);if(i.length===0)return;let r=Math.max(...i.map(o=>o.costUsd),1),n=t.createDiv("as-burn-chart");for(let o of i){let l=n.createDiv("as-burn-col"),O=l.createDiv("as-burn-bar"),c=Math.max(2,o.costUsd/r*100);O.setCssProps({"--bar-h":`${c}%`}),O.title=`${o.date}: $${o.costUsd.toFixed(0)}`,l.createDiv({cls:"as-burn-date",text:o.date.slice(8)})}}renderContext(e,t){let s=(t||this.containerEl).createDiv("as-dash-section");s.createDiv({cls:"as-dash-title",text:"Context Tax"});let i=e.always_loaded.total_tokens,r=[{label:"CLAUDE.md",tokens:e.always_loaded.claude_md_tokens,cls:"as-ctx-claude"},{label:"Skills metadata",tokens:e.always_loaded.skill_metadata_tokens,cls:"as-ctx-skills"},{label:"Memory",tokens:e.always_loaded.memory_tokens,cls:"as-ctx-memory"}],n=s.createDiv("as-ctx-bar");for(let O of r){let c=n.createDiv(`as-ctx-part ${O.cls}`);c.setCssProps({"--bar-w":`${O.tokens/i*100}%`}),c.title=`${O.label}: ${(O.tokens/1e3).toFixed(1)}k tokens`}let o=s.createDiv("as-ctx-legend");for(let O of r){let c=o.createDiv("as-ctx-legend-item");c.createSpan({cls:`as-ctx-dot ${O.cls}`}),c.createSpan({text:`${O.label}: ${(O.tokens/1e3).toFixed(1)}k`})}let l=s.createDiv("as-ctx-costs");l.createDiv({text:`Per session (cached): $${e.session_estimate.with_cache.toFixed(2)}`}),l.createDiv({text:`Without cache: $${e.session_estimate.without_cache.toFixed(2)}`}),l.createDiv({cls:"as-ctx-savings",text:`Cache saves ${e.session_estimate.savings_pct.toFixed(0)}%`})}renderStale(e){if(e.usage.never_used.length===0)return;let t=this.containerEl.createDiv("as-dash-section");t.createDiv({cls:"as-dash-title",text:`Stale skills (${e.usage.unused_30d})`});let s=t.createDiv("as-stale-list");for(let i of e.usage.never_used.slice(0,20))s.createDiv("as-stale-item").createSpan({text:i});e.usage.never_used.length>20&&s.createDiv({cls:"as-stale-more",text:`+${e.usage.never_used.length-20} more`})}};var de=require("obsidian"),Ge=require("fs"),hn=require("path"),mn=require("os");var Oe=require("obsidian"),Ie=require("fs"),pn=require("path"),un=require("os");var C=require("fs"),R=require("path"),Vt=require("os"),nn=require("obsidian"),on=require("crypto");var rn=new Set(["readme.md","license","license.md","changelog.md",".ds_store","thumbs.db"]);function qO(a){return(0,on.createHash)("sha256").update(a).digest("hex").slice(0,12)}function WO(a){let e=a.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!e)return{frontmatter:{},content:a};try{let t=(0,nn.parseYaml)(e[1]);return{frontmatter:typeof t=="object"&&t?t:{},content:e[2]}}catch{return{frontmatter:{},content:a}}}function IO(a,e,t,s="auto",i="skill"){if(i==="command")return typeof a.name=="string"&&a.name?a.name:(0,R.basename)(t,(0,R.extname)(t));if(s==="auto"){if(typeof a.name=="string"&&a.name)return a.name;let n=e.match(/^#\s+(.+)$/m);if(n)return n[1].trim()}let r=(0,R.basename)(t,(0,R.extname)(t));return r==="SKILL"?(0,R.basename)((0,R.join)(t,"..")):r}function ln(a,e,t,s="auto",i=0){if(!(0,C.existsSync)(a)||i>3)return[];let r=[];for(let n of(0,C.readdirSync)(a,{withFileTypes:!0})){let o=(0,R.join)(a,n.name);if(!(n.isDirectory()||n.isSymbolicLink()&&(0,C.statSync)(o,{throwIfNoEntry:!1})?.isDirectory()))continue;let O=(0,R.join)(o,"SKILL.md");if((0,C.existsSync)(O)){let c=ct(O,e,t,"directory-with-skillmd",s);c&&r.push(c)}else r.push(...ln(o,e,t,s,i+1))}return r}function GO(a,e,t,s="auto"){if(!(0,C.existsSync)(a))return[];let i=[];for(let r of(0,C.readdirSync)(a,{withFileTypes:!0})){let n=(0,R.join)(a,r.name);if(r.isDirectory()||r.isSymbolicLink()&&(0,C.statSync)(n,{throwIfNoEntry:!1})?.isDirectory()){let c=(0,R.join)(n,"SKILL.md");if((0,C.existsSync)(c)){let u=ct(c,e,t,"flat-md",s);u&&i.push(u);continue}let d=(0,C.readdirSync)(n).filter(u=>u.endsWith(".md")&&!rn.has(u.toLowerCase())),p=d.find(u=>u.toLowerCase()===`${r.name.toLowerCase()}.md`)||d[0];if(p){let u=ct((0,R.join)(n,p),e,t,"flat-md",s);u&&i.push(u)}continue}let l=r.name.toLowerCase();if(!l.endsWith(".md")||rn.has(l))continue;let O=ct(n,e,t,"flat-md",s);O&&i.push(O)}return i}function UO(a,e,t,s="auto"){if(!(0,C.existsSync)(a))return[];let i=[];for(let r of(0,C.readdirSync)(a,{withFileTypes:!0})){if(!r.name.endsWith(".mdc")&&!r.name.endsWith(".md")||r.isDirectory())continue;let n=ct((0,R.join)(a,r.name),e,t,"mdc",s);n&&i.push(n)}return i}function ct(a,e,t,s="directory-with-skillmd",i="auto"){try{let r=(0,C.readFileSync)(a,"utf-8"),n=(0,C.statSync)(a),{frontmatter:o,content:l}=WO(r),O=IO(o,l,a,i,e),c=typeof o.description=="string"?o.description:"",d;try{d=(0,C.realpathSync)(a)}catch{d=a}return{id:qO(d),name:O,description:c,type:e,tools:[t],filePath:a,realPath:d,dirPath:(0,R.join)(a,".."),content:r,frontmatter:o,lastModified:n.mtimeMs,fileSize:n.size,isFavorite:!1,collections:[]}}catch{return null}}function ns(a,e,t="auto"){switch(a.pattern){case"directory-with-skillmd":return ln(a.baseDir,a.type,e,t);case"flat-md":return GO(a.baseDir,a.type,e,t);case"mdc":return UO(a.baseDir,a.type,e,t)}}function NO(a,e){let t=[],s=[{sub:".claude/skills",type:"skill",pattern:"directory-with-skillmd"},{sub:".claude/commands",type:"command",pattern:"flat-md"},{sub:".claude/agents",type:"agent",pattern:"flat-md"},{sub:".cursor/skills",type:"skill",pattern:"directory-with-skillmd"},{sub:".codex/skills",type:"skill",pattern:"directory-with-skillmd"}];for(let i of s){let r=(0,R.join)(a,i.sub);if(!(0,C.existsSync)(r))continue;let n={baseDir:r,type:i.type,pattern:i.pattern};t.push(...ns(n,e))}return t}function On(a){return a.projectsHomeDir||(0,Vt.homedir)()}function BO(a,e){let t=(0,Vt.homedir)(),s=[];for(let i of[...e.paths,...e.agentPaths]){let r=(0,R.relative)(t,i.baseDir);if(r.startsWith("..")||r.startsWith("/"))continue;let n=(0,R.join)(a,r);if((0,C.existsSync)(n))try{s.push(...ns({...i,baseDir:n},e.id))}catch{}}return s}function FO(a){let e=On(a);if(!(0,C.existsSync)(e))return[];let t=[];try{let s=new Set(["node_modules",".Trash","Library","Applications","Music","Movies","Pictures","Public"]);for(let i of(0,C.readdirSync)(e,{withFileTypes:!0})){if(!i.isDirectory()&&!i.isSymbolicLink()||s.has(i.name))continue;let r=(0,R.join)(e,i.name);for(let n of W){if(!n.isInstalled())continue;let o=a.tools[n.id];if(o&&!o.enabled)continue;let l=BO(r,n);l.length>0&&t.push({items:l,toolId:n.id})}}}catch{}return t}function os(a,e){let t=e||(0,Vt.homedir)();if(!a.startsWith(t+R.sep))return"global";let i=a.slice(t.length+1).split(R.sep);return i.length>1&&!i[0].startsWith(".")?i[0]:"global"}function cn(a){$s();let e=a.namingMode||"auto",t=new Map,s=new Map;function i(r,n){let o=t.get(r.id);if(o){o.tools.includes(n)||o.tools.push(n);return}let l=s.get(r.name);if(l){let O=t.get(l);O&&!O.tools.includes(n)&&O.tools.push(n);return}r.isFavorite=a.favorites.includes(r.id);for(let[O,c]of Object.entries(a.collections))c.includes(r.id)&&r.collections.push(O);t.set(r.id,r),s.set(r.name,r.id)}for(let r of W){if(!r.isInstalled())continue;let n=a.tools[r.id];if(n&&!n.enabled)continue;let o=[...r.paths,...r.agentPaths];for(let l of o)for(let O of ns(l,r.id,e))i(O,r.id)}for(let r of a.customScanPaths)if((0,C.existsSync)(r))for(let n of NO(r,"claude-code"))i(n,"claude-code");if(a.projectScanEnabled)for(let{items:r,toolId:n}of FO(a))for(let o of r)i(o,n);return t}function ls(){return W.filter(a=>a.isInstalled()).map(a=>a.id)}function dn(a){let e=[];for(let t of W)if(t.isInstalled())for(let s of[...t.paths,...t.agentPaths])(0,C.existsSync)(s.baseDir)&&e.push(s.baseDir);if(a?.projectScanEnabled){let t=On(a),s=new Set(["node_modules",".Trash","Library","Applications","Music","Movies","Pictures","Public"]);try{for(let i of(0,C.readdirSync)(t,{withFileTypes:!0})){if(!i.isDirectory()&&!i.isSymbolicLink()||s.has(i.name))continue;let r=(0,R.join)(t,i.name);for(let n of[".claude/skills",".claude/commands",".claude/agents",".cursor/skills",".codex/skills"]){let o=(0,R.join)(r,n);(0,C.existsSync)(o)&&e.push(o)}}}catch{}}return e}var Os={};for(let[a,e]of Object.entries(zt))Os[e]||(Os[e]=a);var cs=(0,pn.join)((0,un.homedir)(),".skillkit","install-prefs.json"),Re=null,qt=!0;function HO(){if(!Re&&(0,Ie.existsSync)(cs))try{let a=JSON.parse((0,Ie.readFileSync)(cs,"utf-8"));Re=new Set(a.agents||[]),qt=a.globalInstall??!0}catch{}}function JO(){try{(0,Ie.writeFileSync)(cs,JSON.stringify({agents:Re?[...Re]:[],globalInstall:qt}),"utf-8")}catch{}}HO();var Wt=class extends Oe.Modal{skill;settings;onInstalled;selectedAgents;isGlobal;constructor(e,t,s,i){if(super(e),this.skill=t,this.settings=s,this.onInstalled=i,Re)this.selectedAgents=new Set(Re);else{this.selectedAgents=new Set;let r=ls();for(let n of r){let o=zt[n];o&&this.selectedAgents.add(o)}}this.isGlobal=qt}onOpen(){let{contentEl:e}=this;e.addClass("as-install-modal"),e.createEl("h3",{text:`Install ${this.skill.name}`}),e.createEl("p",{cls:"as-install-source",text:this.skill.source}),new Oe.Setting(e).setName("Install globally").setDesc("Shared across all projects (~/.agents/skills/)").addToggle(l=>l.setValue(this.isGlobal).onChange(O=>{this.isGlobal=O})),new Oe.Setting(e).setName("Agents").setHeading();let t=e.createDiv("as-install-scroll"),s=ls(),i=new Set(s.map(l=>zt[l]).filter(Boolean));for(let l of Fr){let O=i.has(l.id),c=Os[l.id],p=new Oe.Setting(t).addToggle(f=>f.setValue(this.selectedAgents.has(l.id)).onChange(w=>{w?this.selectedAgents.add(l.id):this.selectedAgents.delete(l.id)})).nameEl,u=c&&I[c]?c:I[l.id]?l.id:I[l.id+"-code"]?l.id+"-code":I[l.id+"-cli"]?l.id+"-cli":null,g=p.createSpan("as-install-agent-icon");u?ne(g,u,14):g.addClass("as-install-agent-placeholder"),p.createSpan({text:l.label}),O&&p.createSpan({cls:"as-install-detected",text:"detected"})}let r=e.createDiv("as-install-footer");r.createEl("button",{text:"Cancel"}).addEventListener("click",()=>this.close()),r.createEl("button",{cls:"mod-cta",text:"Install"}).addEventListener("click",()=>this.doInstall())}doInstall(){let e=[...this.selectedAgents];if(e.length===0){new Oe.Notice("Select at least one agent",5e3);return}Re=new Set(this.selectedAgents),qt=this.isGlobal,JO(),this.close(),new Oe.Notice(`Installing ${this.skill.name}...`,3e3),Jr(this.skill.source,e,{runner:this.settings.packageRunner,globalInstall:this.isGlobal,skillName:this.skill.name}).then(t=>{t.success?(new Oe.Notice(`Installed ${this.skill.name}`,5e3),this.skill.installed=!0,this.onInstalled()):new Oe.Notice(`Failed to install ${this.skill.name}`,5e3)})}onClose(){this.contentEl.empty()}};var ds=(0,hn.join)((0,mn.homedir)(),".skillkit","marketplace-popular.json"),ce=null,It="",Ze=null,KO=new de.Component;function ec(){if(!ce&&(0,Ge.existsSync)(ds))try{let a=JSON.parse((0,Ge.readFileSync)(ds,"utf-8"));ce=At(a)}catch{}}function tc(){if(ce)try{(0,Ge.writeFileSync)(ds,JSON.stringify(ce),"utf-8")}catch{}}ec();var Gt=class{containerEl;inputEl=null;listEl=null;previewEl=null;searchTimer=null;selectedSkill=null;app;settings;onRefresh;constructor(e,t,s,i){this.containerEl=e,this.app=t.app,this.settings=s,this.onRefresh=i}render(){if(!this.inputEl){this.containerEl.empty(),this.containerEl.addClass("as-marketplace");let e=this.containerEl.createDiv("as-mp-search");this.inputEl=e.createEl("input",{type:"text",placeholder:"Search skills on skills.sh...",cls:"as-mp-search-input"}),this.inputEl.addEventListener("input",()=>{this.searchTimer&&window.clearTimeout(this.searchTimer),this.searchTimer=window.setTimeout(()=>{this.doSearch(this.inputEl.value)},300)});let t=this.containerEl.createDiv("as-mp-body");this.listEl=t.createDiv("as-mp-list"),this.previewEl=t.createDiv("as-mp-preview"),this.previewEl.createDiv({cls:"as-mp-hint",text:"Select a skill to preview."})}this.inputEl.value=It,It.length>=2&&Ze?this.showResults(Ze):ce?this.showPopular():this.loadPopular()}async loadPopular(){if(!this.listEl)return;this.listEl.empty(),this.listEl.createDiv({cls:"as-mp-loading",text:"Loading popular skills..."}),ce=await Br(),tc(),this.showPopular()}refreshList(){ce&&At(ce),Ze&&At(Ze),It.length>=2&&Ze?this.showResults(Ze):this.showPopular()}showPopular(){if(this.listEl){if(this.listEl.empty(),!ce||ce.length===0){this.listEl.createDiv({cls:"as-mp-hint",text:"Search for skills to browse and install."});return}this.listEl.createDiv({cls:"as-mp-section-title",text:"Popular"});for(let e of ce)this.renderSkillCard(e)}}showResults(e){if(this.listEl){if(this.listEl.empty(),e.length===0){this.listEl.createDiv({cls:"as-mp-hint",text:"No skills found."});return}for(let t of e)this.renderSkillCard(t)}}async doSearch(e){if(!this.listEl)return;if(It=e,e.length<2){Ze=null,this.showPopular();return}this.listEl.empty(),this.listEl.createDiv({cls:"as-mp-loading",text:"Searching..."});let t=await ts(e);Ze=t,this.showResults(t)}renderSkillCard(e){if(!this.listEl)return;let t=this.listEl.createDiv("as-mp-card");this.selectedSkill?.id===e.id&&t.addClass("is-selected");let s=t.createDiv("as-mp-card-header");s.createSpan({cls:"as-mp-card-name",text:e.name}),e.installed&&s.createSpan({cls:"as-mp-installed-badge",text:"Installed"}),t.createDiv({cls:"as-mp-card-source",text:e.source});let i=t.createDiv("as-mp-card-meta"),r=i.createSpan("as-mp-dl-icon");(0,de.setIcon)(r,"download"),i.createSpan({cls:"as-mp-card-installs",text:is(e.installs)}),t.addEventListener("click",()=>{this.selectedSkill=e,this.listEl&&this.listEl.querySelectorAll(".as-mp-card").forEach(n=>n.removeClass("is-selected")),t.addClass("is-selected"),this.showPreview(e)})}async showPreview(e){if(!this.previewEl)return;this.previewEl.empty();let s=this.previewEl.createDiv("as-mp-preview-header").createDiv("as-mp-preview-top"),i=s.createDiv("as-mp-preview-left");i.createDiv({cls:"as-mp-preview-name",text:e.name});let r=i.createDiv("as-mp-preview-meta");r.createSpan({cls:"as-mp-preview-source",text:e.source});let n=r.createSpan("as-mp-dl-icon");(0,de.setIcon)(n,"download"),r.createSpan({cls:"as-mp-preview-installs",text:is(e.installs)});let o=s.createDiv("as-mp-preview-right");if(!e.installed)this.renderInstallButton(o,e);else{o.createSpan({cls:"as-mp-installed-label",text:"Installed"});let c=o.createEl("button",{cls:"as-mp-uninstall-btn",text:"Uninstall"});c.addEventListener("click",()=>{_e(this.app,"Uninstall skill",`Remove "${e.name}" from all agents?`,()=>{c.setText("Removing..."),c.disabled=!0,new de.Notice(`Removing ${e.name}...`,3e3),Kr(e.name,this.settings.packageRunner).then(d=>{d.success?(new de.Notice(`Removed ${e.name}`,5e3),e.installed=!1,this.refreshList(),this.showPreview(e)):(new de.Notice(`Failed to remove ${e.name}`,5e3),c.setText("Uninstall"),c.disabled=!1)})})})}let l=this.previewEl.createDiv("as-mp-preview-content");l.createDiv({cls:"as-mp-loading",text:"Loading skill content..."});let O=await Nr(e.source,e.name,e.id);if(l.empty(),O){e.content=O;let c=l.createDiv("as-mp-rendered markdown-rendered");de.MarkdownRenderer.render(this.app,O,c,"",KO)}else l.createDiv({cls:"as-mp-hint",text:"Could not load skill content."})}renderInstallButton(e,t){e.createEl("button",{cls:"as-mp-install-btn",text:"Install"}).addEventListener("click",()=>{new Wt(this.app,t,this.settings,()=>{this.refreshList(),this.showPreview(t)}).open()})}};var me=require("obsidian"),fe=require("fs"),Ut=require("path");function ac(){let a=[];for(let e of W){if(!e.isInstalled())continue;let t=[];for(let s of[...e.paths,...e.agentPaths])s.type==="rule"||s.type==="memory"||t.push({sp:s,label:s.type});t.length>0&&a.push({tool:e,paths:t})}return a}var sc={skill:"sparkles",command:"terminal",agent:"bot"},Nt=class extends me.Modal{onCreated;toolOptions;selectedTool=null;selectedPath=null;name="";step="tool";constructor(e,t){super(e),this.onCreated=t,this.toolOptions=ac()}onOpen(){this.modalEl.addClass("as-create-modal"),this.render()}render(){let{contentEl:e}=this;e.empty(),this.step==="tool"?this.renderToolStep(e):this.step==="type"?this.renderTypeStep(e):this.renderNameStep(e)}renderToolStep(e){this.renderHeader(e,"Choose tool",null);let t=e.createDiv("as-create-grid");for(let s of this.toolOptions){let i=t.createDiv("as-create-card");i.style.setProperty("--tool-color",s.tool.color);let r=i.createDiv("as-create-card-icon");I[s.tool.id]&&ne(r,s.tool.id,24),i.createDiv({cls:"as-create-card-name",text:s.tool.name}),i.addEventListener("click",()=>{this.selectedTool=s,s.paths.length===1?(this.selectedPath=s.paths[0],this.step="name"):this.step="type",this.render()})}}renderTypeStep(e){if(!this.selectedTool)return;this.renderHeader(e,`${this.selectedTool.tool.name}`,()=>{this.step="tool",this.render()}),e.createDiv("as-create-subtitle").setText("What do you want to create?");let s=e.createDiv("as-create-type-grid");for(let i of this.selectedTool.paths){let r=s.createDiv("as-create-type-card");r.style.setProperty("--tool-color",this.selectedTool.tool.color);let n=sc[i.label]||"file",o=r.createDiv("as-create-type-icon");(0,me.setIcon)(o,n),r.createDiv({cls:"as-create-type-label",text:i.label}),r.addEventListener("click",()=>{this.selectedPath=i,this.step="name",this.render()})}}renderNameStep(e){if(!this.selectedTool||!this.selectedPath)return;let t=this.selectedTool.paths.length>1?"type":"tool";this.renderHeader(e,`New ${this.selectedPath.label}`,()=>{this.step=t,this.render()});let s=e.createDiv("as-create-badge");s.style.setProperty("--tool-color",this.selectedTool.tool.color);let i=s.createSpan("as-create-badge-icon");I[this.selectedTool.tool.id]&&ne(i,this.selectedTool.tool.id,14),s.createSpan({text:this.selectedTool.tool.name});let n=e.createDiv("as-create-input-wrap").createEl("input",{type:"text",placeholder:`my-${this.selectedPath.label}-name`,cls:"as-create-input"});n.value=this.name,n.addEventListener("input",()=>{this.name=n.value.trim()}),n.addEventListener("keydown",O=>{O.key==="Enter"&&this.name&&this.create()}),window.setTimeout(()=>n.focus(),10);let l=e.createDiv("as-create-actions").createEl("button",{text:`Create ${this.selectedPath.label}`,cls:"as-create-submit"});l.style.setProperty("--tool-color",this.selectedTool.tool.color),l.addEventListener("click",()=>this.create())}renderHeader(e,t,s){let i=e.createDiv("as-create-header");if(s){let r=i.createDiv("as-create-back");(0,me.setIcon)(r,"chevron-left"),r.addEventListener("click",s)}i.createDiv({cls:"as-create-title",text:t})}create(){if(!this.name||!this.selectedPath)return;let e=this.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");if(!e){new me.Notice("Invalid name");return}let t=this.selectedPath.sp,s;if(t.pattern==="directory-with-skillmd"){let i=(0,Ut.join)(t.baseDir,e);if((0,fe.existsSync)(i)){new me.Notice(`Already exists: ${e}`);return}(0,fe.mkdirSync)(i,{recursive:!0}),s=(0,Ut.join)(i,"SKILL.md"),(0,fe.writeFileSync)(s,["---",`name: ${this.name}`,'description: ""',"---","",`# ${this.name}`,"","## Instructions","",""].join(`
22`),"utf-8")}else{if((0,fe.existsSync)(t.baseDir)||(0,fe.mkdirSync)(t.baseDir,{recursive:!0}),s=(0,Ut.join)(t.baseDir,`${e}.md`),(0,fe.existsSync)(s)){new me.Notice(`Already exists: ${e}.md`);return}(0,fe.writeFileSync)(s,["---",'description: ""',"---","",""].join(`
23`),"utf-8")}new me.Notice(`Created ${this.name}`),this.close(),this.onCreated(s)}onClose(){this.contentEl.empty()}};var $n=require("obsidian"),Ue=require("fs"),bn=require("path"),kn=require("os");var ps={customTags:{},favorites:[]},us={tools:{},watchEnabled:!0,watchDebounceMs:500,deepSearchDefault:!1,deepSearchScope:"both",favorites:[],collections:{},customScanPaths:[],namingMode:"auto",projectScanEnabled:!0,projectsHomeDir:"",packageRunner:"auto"};var re=require("fs"),$e=require("path"),fs=require("os"),fn=require("readline"),ic=(0,$e.join)((0,fs.homedir)(),".claude"),hs=(0,$e.join)(ic,"projects"),rc=5*1024*1024,ms=500;function nc(a){let e=(0,fs.homedir)().split($e.sep).filter(Boolean),t=e.join("-"),s=a;if(s.startsWith(t+"-"))s=s.slice(t.length+1);else if(s.startsWith("-")){s=s.slice(1);let r=e.join("-")+"-";s.startsWith(r)&&(s=s.slice(r.length))}let i=s.split("-").filter(Boolean);return i.length<=2?i.join("-")||"root":i.slice(-2).join("-")}function Bt(a){if(typeof a=="string")return a;if(Array.isArray(a)){let e=[];for(let t of a)if(typeof t=="object"&&t!==null){let s=t;s.type==="text"&&typeof s.text=="string"&&e.push(s.text)}return e.join(`
24`)}return""}function gn(a){if(!Array.isArray(a))return[];let e=[];for(let t of a)if(typeof t=="object"&&t!==null){let s=t;s.type==="tool_use"&&typeof s.name=="string"&&e.push(s.name)}return e}function oc(a){let e=[],t="",s="";for(let i of a)try{let r=JSON.parse(i),n=typeof r.timestamp=="string"?r.timestamp:void 0;if(n&&(t||(t=n),s=n),r.type==="user"){let o=r.message;if(!o)continue;let l=Bt(o.content);l&&e.push({role:"human",text:l,timestamp:n||""})}if(r.type==="assistant"){let o=r.message;if(!o)continue;let l=Bt(o.content),O=gn(o.content);l&&e.push({role:"assistant",text:l,timestamp:n||"",toolCalls:O.length>0?O:void 0})}}catch{}return{messages:e,firstTimestamp:t,lastTimestamp:s}}function lc(){let a=[];if(!(0,re.existsSync)(hs))return a;let e;try{e=(0,re.readdirSync)(hs)}catch{return a}for(let t of e){let s=(0,$e.join)(hs,t);try{if(!(0,re.statSync)(s).isDirectory())continue}catch{continue}let i=nc(t),r;try{r=(0,re.readdirSync)(s).filter(n=>n.endsWith(".jsonl"))}catch{continue}for(let n of r){let o=(0,$e.join)(s,n);try{let l=(0,re.statSync)(o);a.push({uuid:(0,$e.basename)(n,".jsonl"),project:i,projectPath:s,filePath:o,fileSize:l.size})}catch{continue}}}return a}function Oc(a){try{let t=(0,re.readFileSync)(a.filePath,"utf-8").split(`

Callers 1

renderMethod · 0.45

Calls 1

utFunction · 0.85

Tested by

no test coverage detected