claudecode-dashboard 1.0.1 → 1.0.3
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/dist/cli.js +15 -15
- package/package.json +16 -7
package/dist/cli.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {homedir}from'os';import {join}from'path';import {readFile,readdir,mkdir,appendFile,writeFile,stat}from'fs/promises';import {existsSync}from'fs';import {useApp,useStdout,useInput,Box,Text}from'ink';import {jsxs,jsx}from'react/jsx-runtime';import
|
|
2
|
+
import {homedir}from'os';import {join}from'path';import {readFile,readdir,mkdir,appendFile,writeFile,stat}from'fs/promises';import {existsSync}from'fs';import {useApp,useStdout,useInput,Box,Text}from'ink';import {jsxs,jsx}from'react/jsx-runtime';import vr from'openai';import Sr from'@anthropic-ai/sdk';import {useState,useCallback,useEffect,useMemo}from'react';import ft from'ink-spinner';import {Command}from'commander';import on from'update-notifier';var Ut=Object.defineProperty;var p=(t,e)=>()=>(t&&(e=t(t=0)),e);var Bt=(t,e)=>{for(var r in e)Ut(t,r,{get:e[r],enumerable:true});};function S(){return join(homedir(),".claude")}function Ht(){return join(homedir(),".claude.json")}var b,E=p(()=>{b={userSettings:()=>join(S(),"settings.json"),userSettingsLocal:()=>join(S(),"settings.local.json"),userMemory:()=>join(S(),"CLAUDE.md"),userSkills:()=>join(S(),"skills"),userAgents:()=>join(S(),"agents"),userCommands:()=>join(S(),"commands"),userHooks:()=>join(S(),"hooks"),userOutputStyles:()=>join(S(),"output-styles"),userPlugins:()=>join(S(),"plugins"),metadata:()=>join(S(),"metadata.json"),history:()=>join(S(),"history.jsonl"),todos:()=>join(S(),"todos"),projects:()=>join(S(),"projects"),claudeJson:()=>Ht()};});function $e(){return De}var ne,oe,ie,De,zt,l,k=p(()=>{ne=class{name="memory";entries=[];listeners=new Set;maxEntries;constructor(e=100){this.maxEntries=e;}write(e){this.entries.push(e),this.entries.length>this.maxEntries&&(this.entries=this.entries.slice(-this.maxEntries)),this.notifyListeners();}getEntries(){return [...this.entries]}getRecent(e){return this.entries.slice(-e)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}clear(){this.entries=[],this.notifyListeners();}notifyListeners(){let e=this.getEntries();this.listeners.forEach(r=>r(e));}},oe=class{name="file";logDir;logFile;buffer=[];flushInterval=null;initialized=false;constructor(e){this.logDir=e||join(homedir(),".claude","claudecode-dashboard","logs");let r=new Date().toISOString().split("T")[0];this.logFile=join(this.logDir,`${r}.jsonl`);}async ensureDir(){this.initialized||(existsSync(this.logDir)||await mkdir(this.logDir,{recursive:true}),this.initialized=true);}async write(e){let r=JSON.stringify({ts:e.timestamp.toISOString(),lvl:e.level,src:e.source,msg:e.message,...e.meta&&{meta:e.meta}});this.buffer.push(r),(e.level==="error"||this.buffer.length>=10)&&await this.flush();}async flush(){if(this.buffer.length===0)return;await this.ensureDir();let e=this.buffer.join(`
|
|
3
3
|
`)+`
|
|
4
|
-
`;this.buffer=[],await appendFile(this.logFile,e);}startAutoFlush(e=5e3){this.flushInterval||(this.flushInterval=setInterval(()=>this.flush(),e));}stopAutoFlush(){this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null);}},ie=class{sinks=[];minLevel="info";levelOrder={debug:0,info:1,warn:2,error:3};addSink(e){this.sinks.push(e);}removeSink(e){this.sinks=this.sinks.filter(r=>r.name!==e);}getSink(e){return this.sinks.find(r=>r.name===e)}setMinLevel(e){this.minLevel=e;}shouldLog(e){return this.levelOrder[e]>=this.levelOrder[this.minLevel]}log(e,r,n,a){if(!this.shouldLog(e))return;let
|
|
5
|
-
`)){let[s
|
|
6
|
-
`)){let[s
|
|
7
|
-
`)){let[s
|
|
8
|
-
`),n=r.slice(0,e);if(n[0]==="---"){let
|
|
9
|
-
`).trim();return
|
|
4
|
+
`;this.buffer=[],await appendFile(this.logFile,e);}startAutoFlush(e=5e3){this.flushInterval||(this.flushInterval=setInterval(()=>this.flush(),e));}stopAutoFlush(){this.flushInterval&&(clearInterval(this.flushInterval),this.flushInterval=null);}},ie=class{sinks=[];minLevel="info";levelOrder={debug:0,info:1,warn:2,error:3};addSink(e){this.sinks.push(e);}removeSink(e){this.sinks=this.sinks.filter(r=>r.name!==e);}getSink(e){return this.sinks.find(r=>r.name===e)}setMinLevel(e){this.minLevel=e;}shouldLog(e){return this.levelOrder[e]>=this.levelOrder[this.minLevel]}log(e,r,n,a){if(!this.shouldLog(e))return;let o={level:e,source:r,message:n,timestamp:new Date,meta:a};for(let s of this.sinks)try{s.write(o);}catch{}}debug(e,r,n){this.log("debug",e,r,n);}info(e,r,n){this.log("info",e,r,n);}warn(e,r,n){this.log("warn",e,r,n);}error(e,r,n){this.log("error",e,r,n);}async flush(){for(let e of this.sinks)e.flush&&await e.flush();}},De=new ne(100),zt=new oe,l=new ie;l.addSink(De);l.addSink(zt);});async function F(){let t=b.userSettings();if(!existsSync(t))return null;try{let e=await readFile(t,"utf-8");return JSON.parse(e)}catch(e){let r=e instanceof Error?e.message:"Unknown error";return l.error("settings",`Failed to parse ${t}: ${r}`),null}}var Oe=p(()=>{E();k();});function Qt(t){let e=t.match(/^---\n([\s\S]*?)\n---/);if(!e)return {};let r=e[1],n={};for(let a of r.split(`
|
|
5
|
+
`)){let[o,...s]=a.split(":"),i=s.join(":").trim();o==="name"&&(n.name=i),o==="description"&&(n.description=i),o==="allowed-tools"&&(n.allowedTools=i.split(",").map(c=>c.trim())),o==="model"&&(n.model=i);}return n}async function N(){let t=b.userSkills();if(!existsSync(t))return [];try{let e=await readdir(t,{withFileTypes:!0}),r=[];for(let n of e){if(!n.isDirectory())continue;let a=join(t,n.name,"SKILL.md");if(existsSync(a))try{let o=await readFile(a,"utf-8"),s=Qt(o);r.push({name:s.name||n.name,description:s.description,allowedTools:s.allowedTools,model:s.model,source:"user",path:a});}catch(o){let s=o instanceof Error?o.message:"Unknown error";l.warn("skills",`Failed to read skill ${n.name}: ${s}`);}}return r}catch(e){let r=e instanceof Error?e.message:"Unknown error";return l.error("skills",`Failed to read skills directory: ${r}`),[]}}var je=p(()=>{E();k();});function nr(t){let e=t.match(/^---\n([\s\S]*?)\n---/);if(!e)return {};let r=e[1],n={};for(let a of r.split(`
|
|
6
|
+
`)){let[o,...s]=a.split(":"),i=s.join(":").trim();o==="name"&&(n.name=i),o==="description"&&(n.description=i),o==="tools"&&(n.tools=i.split(",").map(c=>c.trim())),o==="model"&&(n.model=i),o==="permissionMode"&&(n.permissionMode=i),o==="skills"&&(n.skills=i.split(",").map(c=>c.trim()));}return n}async function U(){let t=b.userAgents();if(!existsSync(t))return [];try{let e=await readdir(t),r=[];for(let n of e){if(!n.endsWith(".md"))continue;let a=join(t,n);try{let o=await readFile(a,"utf-8"),s=nr(o),i=s.name||n.replace(".md","");r.push({name:i,description:s.description,tools:s.tools,model:s.model,permissionMode:s.permissionMode,skills:s.skills,source:"user",path:a});}catch(o){let s=o instanceof Error?o.message:"Unknown error";l.warn("agents",`Failed to read agent ${n}: ${s}`);}}return r}catch(e){let r=e instanceof Error?e.message:"Unknown error";return l.error("agents",`Failed to read agents directory: ${r}`),[]}}var Fe=p(()=>{E();k();});function cr(t){let e=t.match(/^---\n([\s\S]*?)\n---/);if(!e)return {};let r=e[1],n={};for(let a of r.split(`
|
|
7
|
+
`)){let[o,...s]=a.split(":"),i=s.join(":").trim();o==="description"&&(n.description=i),o==="argument-hint"&&(n.argumentHint=i),o==="allowed-tools"&&(n.allowedTools=i.split(",").map(c=>c.trim())),o==="model"&&(n.model=i);}return n}async function B(){let t=b.userCommands();if(!existsSync(t))return [];try{let e=await readdir(t,{recursive:!0}),r=[];for(let n of e){let a=String(n);if(!a.endsWith(".md"))continue;let o=join(t,a);try{let s=await readFile(o,"utf-8"),i=cr(s),c=a.replace(/\.md$/,"").replace(/[\/\\]/g,":");r.push({name:c,description:i.description,argumentHint:i.argumentHint,allowedTools:i.allowedTools,model:i.model,source:"user",path:o});}catch(s){let i=s instanceof Error?s.message:"Unknown error";l.warn("commands",`Failed to read command ${a}: ${i}`);}}return r}catch(e){let r=e instanceof Error?e.message:"Unknown error";return l.error("commands",`Failed to read commands directory: ${r}`),[]}}var Ne=p(()=>{E();k();});async function H(){let t=b.userSettings();if(!existsSync(t))return [];try{let e=await readFile(t,"utf-8"),r=JSON.parse(e);if(!r.hooks)return [];let n=[];for(let[a,o]of Object.entries(r.hooks))for(let s of o)for(let i of s.hooks)n.push({event:a,matcher:s.matcher,type:i.type,command:i.command,prompt:i.prompt,timeout:i.timeout,source:"user"});return n}catch(e){let r=e instanceof Error?e.message:"Unknown error";return l.error("hooks",`Failed to parse hooks from settings: ${r}`),[]}}var Ue=p(()=>{E();k();});function le(t,e){return Object.entries(t).map(([r,n])=>({name:r,type:n.type||(n.command?"stdio":"http"),url:n.url,command:n.command,args:n.args,env:n.env,scope:e}))}async function _(){let t=[],e=join(homedir(),".claude.json");if(existsSync(e))try{let a=await readFile(e,"utf-8"),o=JSON.parse(a);o.mcpServers&&Object.keys(o.mcpServers).length>0&&t.push(...le(o.mcpServers,"user"));}catch(a){let o=a instanceof Error?a.message:"Unknown error";l.error("mcp",`Failed to parse ~/.claude.json: ${o}`);}let r=join(homedir(),".mcp.json");if(existsSync(r))try{let a=await readFile(r,"utf-8"),o=JSON.parse(a);if(o.mcpServers){let s=new Set(t.map(c=>c.name)),i=le(o.mcpServers,"user").filter(c=>!s.has(c.name));t.push(...i);}}catch(a){let o=a instanceof Error?a.message:"Unknown error";l.error("mcp",`Failed to parse ~/.mcp.json: ${o}`);}let n=join(process.cwd(),".mcp.json");if(existsSync(n))try{let a=await readFile(n,"utf-8"),o=JSON.parse(a);o.mcpServers&&t.push(...le(o.mcpServers,"project"));}catch(a){let o=a instanceof Error?a.message:"Unknown error";l.error("mcp",`Failed to parse ./.mcp.json: ${o}`);}return t}var He=p(()=>{k();});async function J(){let t=b.userPlugins();if(!existsSync(t))return [];try{let e=await readdir(t,{withFileTypes:!0}),r=[];for(let n of e){if(!n.isDirectory())continue;let a=join(t,n.name),o=join(a,"plugin.json");if(existsSync(o))try{let s=await readFile(o,"utf-8"),i=JSON.parse(s),c=u=>u?Array.isArray(u)?u:[u]:[];r.push({name:i.name||n.name,version:i.version,description:i.description,enabled:!0,path:a,commands:c(i.commands),agents:c(i.agents),skills:c(i.skills),hooks:i.hooks?[i.hooks]:[],mcpServers:i.mcpServers?[i.mcpServers]:[]});}catch(s){let i=s instanceof Error?s.message:"Unknown error";l.warn("plugins",`Failed to read plugin ${n.name}: ${i}`);}}return r}catch(e){let r=e instanceof Error?e.message:"Unknown error";return l.error("plugins",`Failed to read plugins directory: ${r}`),[]}}var Ke=p(()=>{E();k();});var me=p(()=>{E();Oe();je();Fe();Ne();Ue();He();Ke();});function We({categories:t,selected:e,focused:r}){return jsxs(Box,{flexDirection:"column",children:[jsx(Text,{bold:true,underline:true,children:"CATEGORIES"}),jsx(Box,{marginTop:1,flexDirection:"column",children:t.map((n,a)=>{let o=a===e;return o&&r?jsxs(Text,{bold:true,underline:true,children:["\u25B8 ",n.label," ",jsx(Text,{bold:true,children:n.count})]},n.key):o?jsxs(Text,{bold:true,children:["\u203A ",n.label," ",jsx(Text,{dimColor:true,children:n.count})]},n.key):jsxs(Text,{dimColor:true,children:[" ",n.label," ",jsx(Text,{dimColor:true,children:n.count})]},n.key)})})]})}var Ye=p(()=>{});function qe({items:t,selected:e,focused:r,maxHeight:n=15}){if(t.length===0)return jsxs(Box,{flexDirection:"column",children:[jsx(Text,{bold:true,underline:true,children:"ITEMS"}),jsx(Box,{marginTop:1,children:jsx(Text,{dimColor:true,italic:true,children:"No items"})})]});let a=Math.max(5,n-3),o=Math.max(0,Math.min(e-Math.floor(a/2),t.length-a)),s=t.slice(o,o+a);return jsxs(Box,{flexDirection:"column",children:[jsxs(Text,{bold:true,underline:true,children:["ITEMS (",t.length,")"]}),jsxs(Box,{marginTop:1,flexDirection:"column",children:[o>0&&jsxs(Text,{dimColor:true,children:["\u2191 ",o," more"]}),s.map((i,c)=>{let u=o+c,g=u===e,m=i.name.length>24?i.name.slice(0,21)+"...":i.name;return g&&r?jsxs(Text,{bold:true,underline:true,children:["\u25B8 ",m]},`${i.name}-${u}`):g?jsxs(Text,{bold:true,children:["\u203A ",m]},`${i.name}-${u}`):jsxs(Text,{dimColor:true,children:[" ",m]},`${i.name}-${u}`)}),o+a<t.length&&jsxs(Text,{dimColor:true,children:["\u2193 ",t.length-o-a," more"]})]})]})}var Xe=p(()=>{});async function Ze(){existsSync(ge)||await mkdir(ge,{recursive:true});}async function pe(){if(T)return T;if(await Ze(),!existsSync(de))return T={version:1,entries:{}},T;try{let t=await readFile(de,"utf-8");return T=JSON.parse(t),T}catch(t){let e=t instanceof Error?t.message:"Unknown error";return l.warn("cache",`Failed to load cache, starting fresh: ${e}`),T={version:1,entries:{}},T}}async function fe(){if(T)try{await Ze(),await writeFile(de,JSON.stringify(T,null,2));}catch(t){let e=t instanceof Error?t.message:"Unknown error";l.error("cache",`Failed to save cache: ${e}`);}}async function et(t){try{return (await stat(t)).mtimeMs}catch(e){let r=e instanceof Error?e.message:"Unknown error";return l.warn("cache",`Failed to get mtime for ${t}: ${r}`),0}}async function he(t){let e=await pe(),r=e.entries[t];return r?await et(t)!==r.mtime?(delete e.entries[t],await fe(),null):r.summary:null}async function ye(t,e){let r=await pe(),n=await et(t);r.entries[t]={summary:e,mtime:n,generatedAt:Date.now()},await fe();}async function xe(t){let e=await pe();return e.entries[t]?(delete e.entries[t],await fe(),l.info("cache",`Cache cleared for: ${t}`),true):false}var ge,de,T,we=p(()=>{k();ge=join(homedir(),".claude","claudecode-dashboard"),de=join(ge,"cache.json"),T=null;});function ee(){return process.env.ANTHROPIC_API_KEY?"anthropic":process.env.OPENAI_API_KEY?"openai":"none"}function V(){let t=ee();switch(t){case "anthropic":return {provider:t,description:`Claude AI (${Se})`};case "openai":return {provider:t,description:`OpenAI (${ve})`};case "none":return {provider:t,description:"Set ANTHROPIC_API_KEY or OPENAI_API_KEY for AI summaries"}}}function Cr(){if(Q)return Q;let t=process.env.OPENAI_API_KEY;return t?(Q=new vr({apiKey:t}),Q):null}function Tr(){if(Z)return Z;let t=process.env.ANTHROPIC_API_KEY;return t?(Z=new Sr({apiKey:t}),Z):null}function Lr(t){return t.replace(/\|/g,"\u2502").replace(/─{3,}/g,"\u2500\u2500\u2500")}function Er(t,e=tt){let r=t.split(`
|
|
8
|
+
`),n=r.slice(0,e);if(n[0]==="---"){let s=n.findIndex((i,c)=>c>0&&i==="---");s>0&&n.splice(0,s+1);}let a=r.length<=e,o=n.join(`
|
|
9
|
+
`).trim();return o=Lr(o),a?o+=`
|
|
10
10
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
11
|
-
<EOF>`:
|
|
11
|
+
<EOF>`:o+=`
|
|
12
12
|
\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
13
|
-
... (${r.length-e} more lines)`,{text:
|
|
13
|
+
... (${r.length-e} more lines)`,{text:o,isEOF:a}}async function Pr(t,e){let r=ee(),n=`You are a senior engineer reviewing this Claude Code ${e}.
|
|
14
14
|
|
|
15
15
|
Provide a structured analysis (keep it concise, ~500 words max):
|
|
16
16
|
|
|
@@ -23,10 +23,10 @@ Provide a structured analysis (keep it concise, ~500 words max):
|
|
|
23
23
|
|
|
24
24
|
**Engineering notes:** 1-2 practical tips or gotchas.
|
|
25
25
|
|
|
26
|
-
Be specific and technical. Include actual values from the config. Ensure your response is COMPLETE - do not cut off mid-sentence.`,a=t.slice(0,4e3);if(r==="anthropic"){let
|
|
26
|
+
Be specific and technical. Include actual values from the config. Ensure your response is COMPLETE - do not cut off mid-sentence.`,a=t.slice(0,4e3);if(r==="anthropic"){let o=Tr();if(!o)throw l.error("ai","Anthropic client initialization failed"),new Error("Anthropic client init failed");try{let i=(await o.messages.create({model:Se,max_tokens:1e3,messages:[{role:"user",content:`${n}
|
|
27
27
|
|
|
28
|
-
${a}`}]})).content.find(c=>c.type==="text");if(i?.type==="text")return l.info("ai",`Generated summary using ${
|
|
29
|
-
`),needsTruncation:true,totalVisualLines:m.length}},[t,e,r]);useInput((g,m)=>{n||m.return&&i&&
|
|
30
|
-
`),n=[];for(let a of r){if(a.length===0){n.push("");continue}if(a.length<=e){n.push(a);continue}let
|
|
31
|
-
`),a=n[n.length-1]||"",
|
|
32
|
-
`)}function
|
|
28
|
+
${a}`}]})).content.find(c=>c.type==="text");if(i?.type==="text")return l.info("ai",`Generated summary using ${Se}`),i.text.trim();throw l.error("ai","No text in Anthropic response"),new Error("No text in Anthropic response")}catch(s){let i=s instanceof Error?s.message:"Unknown error";throw l.error("ai",`Anthropic API error: ${i}`),s}}if(r==="openai"){let o=Cr();if(!o)throw l.error("ai","OpenAI client initialization failed"),new Error("OpenAI client init failed");try{let i=(await o.chat.completions.create({model:ve,messages:[{role:"system",content:n},{role:"user",content:a}],max_tokens:1e3,temperature:.3})).choices[0]?.message?.content?.trim();if(i)return l.info("ai",`Generated summary using ${ve}`),i;throw l.error("ai","No text in OpenAI response"),new Error("No text in OpenAI response")}catch(s){let i=s instanceof Error?s.message:"Unknown error";throw l.error("ai",`OpenAI API error: ${i}`),s}}throw l.warn("ai","No AI provider configured"),new Error("No AI provider configured")}async function ke(t,e){if(!existsSync(t))return l.warn("summary",`File not found: ${t}`),{aiSummary:null,preview:"[File not found]"};let r;try{r=await readFile(t,"utf-8");}catch(s){let i=s instanceof Error?s.message:"Unknown error";return l.error("summary",`Failed to read file ${t}: ${i}`),{aiSummary:null,preview:"[Failed to read file]"}}let n=Er(r),a=await he(t);if(a)return l.info("summary",`Using cached summary for ${t}`),{aiSummary:a,preview:n.text};if(ee()!=="none")try{let s=await Pr(r,e);return await ye(t,s),{aiSummary:s,preview:n.text}}catch(s){let i=s instanceof Error?s.message:"Unknown error";return {aiSummary:null,preview:n.text,aiError:i}}return {aiSummary:null,preview:n.text}}var ve,Se,Q,Z,tt,rt=p(()=>{we();k();ve="gpt-4o-mini",Se="claude-haiku-4-5-latest",Q=null,Z=null;tt=30;});var be=p(()=>{rt();we();});function ot(t,e){let[r,n]=useState(null),[a,o]=useState(null),[s,i]=useState(null),[c,u]=useState(false),[g,m]=useState(null),x=V(),v=useCallback(async()=>{if(!t){n(null),o(null),i(null);return}u(true),m(null),o(null);try{let y=await ke(t,e);n(y.aiSummary),o(y.aiError||null),i(y.preview);}catch(y){let I=y instanceof Error?y.message:"Failed to load";l.error("summary-hook",`Failed to load summary: ${I}`),m(I);}finally{u(false);}},[t,e]),j=useCallback(async()=>{t&&(l.info("summary-hook",`Regenerating summary for: ${t}`),await xe(t),await v());},[t,v]);return useEffect(()=>{v();},[v]),{aiSummary:r,aiError:a,preview:s,loading:c,error:g,provider:x.provider,providerDescription:x.description,refresh:v,regenerate:j}}var it=p(()=>{be();k();});function mt({tabs:t,activeTab:e,onTabChange:r,disabled:n}){return useInput((a,o)=>{if(n)return;let s=t.findIndex(i=>i.key===e);if(s!==-1){if(o.tab&&!o.shift){let i=(s+1)%t.length;r(t[i].key);}else if(o.tab&&o.shift){let i=(s-1+t.length)%t.length;r(t[i].key);}}}),jsxs(Box,{children:[t.map(a=>{let o=a.key===e;return jsx(Box,{marginRight:1,children:jsxs(Text,{bold:o,color:o?"cyan":void 0,dimColor:!o,children:["[",o?"\u25CF":" ","] ",a.label]})},a.key)}),jsx(Text,{dimColor:true,children:" (Tab \u2194)"})]})}var ut=p(()=>{});function dt({content:t,maxLines:e=8,width:r,disabled:n}){let[a,o]=useState(false),{truncated:s,needsTruncation:i,totalVisualLines:c}=useMemo(()=>{let g=Math.max(20,r-2),m=Or(t,g);return m.length<=e?{truncated:t,needsTruncation:false,totalVisualLines:m.length}:{truncated:m.slice(0,e).join(`
|
|
29
|
+
`),needsTruncation:true,totalVisualLines:m.length}},[t,e,r]);useInput((g,m)=>{n||m.return&&i&&o(x=>!x);});let u=c-e;return i?jsxs(Box,{flexDirection:"column",children:[jsx(Text,{wrap:"wrap",children:a?t:s}),jsx(Box,{marginTop:1,children:jsx(Text,{color:"cyan",children:a?"[Enter: See less \u2191]":`[Enter: See more... +${u} lines]`})})]}):jsx(Text,{wrap:"wrap",children:t})}function Or(t,e){let r=t.split(`
|
|
30
|
+
`),n=[];for(let a of r){if(a.length===0){n.push("");continue}if(a.length<=e){n.push(a);continue}let o=a.split(" "),s="";for(let i of o){let c=s?`${s} ${i}`:i;if(c.length<=e)s=c;else if(s&&n.push(s),i.length>e){let u=i;for(;u.length>e;)n.push(u.slice(0,e)),u=u.slice(e);s=u;}else s=i;}s&&n.push(s);}return n}var pt=p(()=>{});function ht({item:t,width:e,maxHeight:r=30,category:n}){let[a,o]=useState("preview"),s=t?.path,i=n||"configuration",{aiSummary:c,aiError:u,preview:g,loading:m,provider:x,regenerate:v}=ot(s,i);if(useInput(q=>{(q==="r"||q==="R")&&a==="summary"&&!m&&v();}),!t)return jsxs(Box,{flexDirection:"column",paddingX:1,children:[jsx(Text,{bold:true,underline:true,children:"DETAILS"}),jsx(Text,{dimColor:true,italic:true,children:"Select an item to view details"})]});let j="\u2500".repeat(Math.max(10,e-4)),y=yt(t),re=Math.max(5,r-y-6);return jsxs(Box,{flexDirection:"column",paddingX:1,children:[jsx(Text,{bold:true,underline:true,children:"DETAILS"}),jsxs(Box,{marginTop:1,flexDirection:"column",children:[jsx(Text,{color:"green",bold:true,children:"Properties:"}),xt(t,1,e-4)]}),s&&jsxs(Box,{marginTop:1,flexDirection:"column",children:[jsx(Text,{dimColor:true,children:j}),jsx(Box,{marginTop:1,children:jsx(mt,{tabs:Nr,activeTab:a,onTabChange:q=>o(q)})}),jsx(Box,{marginTop:1,flexDirection:"column",minHeight:re,children:a==="preview"?jsx(Ur,{preview:g,loading:m,maxLines:re,width:e-6}):jsx(Br,{summary:c,error:u,loading:m,provider:x,maxLines:re-2,width:e-6})})]})]})}function Ur({preview:t,loading:e,maxLines:r,width:n}){if(e)return jsxs(Text,{color:"cyan",children:[jsx(ft,{type:"dots"})," Loading preview..."]});if(!t)return jsx(Text,{dimColor:true,italic:true,children:"No content available"});let a=Hr(t,r,n);return jsx(Text,{children:a})}function Br({summary:t,error:e,loading:r,provider:n,maxLines:a,width:o}){return n==="none"?jsxs(Box,{flexDirection:"column",children:[jsx(Text,{dimColor:true,italic:true,children:"AI Summary not configured"}),jsx(Text,{dimColor:true,children:"Export ANTHROPIC_API_KEY or OPENAI_API_KEY to enable"})]}):r?jsxs(Text,{color:"cyan",children:[jsx(ft,{type:"dots"})," Generating summary..."]}):e?jsxs(Text,{color:"red",children:["Error: ",e]}):t?jsxs(Box,{flexDirection:"column",children:[jsx(dt,{content:t,maxLines:a-1,width:o}),jsx(Text,{dimColor:true,children:" (R: regenerate)"})]}):jsx(Text,{dimColor:true,italic:true,children:"No summary available"})}function yt(t){let e=0;for(let[,r]of Object.entries(t))r!=null&&(e++,typeof r=="object"&&!Array.isArray(r)?e+=yt(r):Array.isArray(r)&&r.length>0&&typeof r[0]=="object"&&(e+=Math.min(r.length,3),r.length>3&&e++));return e}function Hr(t,e,r){let n=t.split(`
|
|
31
|
+
`),a=n[n.length-1]||"",o=a.includes("<EOF>"),s=a.includes("... (")&&a.includes("more lines)"),i=n.length>=2&&n[n.length-2]?.startsWith("\u2500\u2500\u2500"),c=o||s?i?2:1:0,u=e-c,g=[],m=c>0?n.slice(0,-c):n;for(let v of m){if(g.length>=u)break;if(v.length<=r)g.push(v);else {let j=v.split(" "),y="";for(let I of j){if(g.length>=u)break;(y+" "+I).trim().length<=r?y=(y+" "+I).trim():(y&&g.push(y),y=I);}y&&g.length<u&&g.push(y);}}return g.length<m.length&&g.length>0&&(g[g.length-1]=g[g.length-1].slice(0,r-15)+"... [truncated]"),c>0&&(i&&c===2&&g.push(n[n.length-2]),g.push(a)),g.join(`
|
|
32
|
+
`)}function xt(t,e,r){let n=[],a=" ".repeat(e);for(let[o,s]of Object.entries(t))if(s!=null)if(typeof s=="object"&&!Array.isArray(s))n.push(jsxs(Text,{children:[a,jsxs(Text,{color:"yellow",children:[o,":"]})]},o)),n.push(...xt(s,e+1,r));else if(Array.isArray(s))if(s.length===0)n.push(jsxs(Text,{children:[a,jsxs(Text,{color:"yellow",children:[o,":"]})," ",jsx(Text,{dimColor:true,children:"[]"})]},o));else if(typeof s[0]=="object"&&s[0]!==null)n.push(jsxs(Text,{children:[a,jsxs(Text,{color:"yellow",children:[o,":"]})," ",jsxs(Text,{dimColor:true,children:["[",s.length," items]"]})]},o)),s.slice(0,3).forEach((i,c)=>{let u=i.name||i.event||i.command||`[${c}]`;n.push(jsxs(Text,{children:[a," ",jsxs(Text,{dimColor:true,children:["\u2022 ",String(u).slice(0,r-e*2-6)]})]},`${o}-${c}`));}),s.length>3&&n.push(jsxs(Text,{children:[a," ",jsxs(Text,{dimColor:true,children:["... +",s.length-3," more"]})]},`${o}-more`));else {let i=s.length>5?`[${s.slice(0,5).join(", ")}... +${s.length-5}]`:`[${s.join(", ")}]`;n.push(jsxs(Text,{children:[a,jsxs(Text,{color:"yellow",children:[o,":"]})," ",i]},o));}else {let i=String(s),c=r-a.length-o.length-3,u=i.length>c?i.slice(0,c-3)+"...":i;n.push(jsxs(Text,{children:[a,jsxs(Text,{color:"yellow",children:[o,":"]})," ",u]},o));}return n}var Nr,wt=p(()=>{it();ut();pt();Nr=[{key:"preview",label:"Preview"},{key:"summary",label:"AI Summary"}];});function kt(){let{provider:t,description:e}=V(),r=t!=="none";return jsxs(Box,{borderStyle:"single",paddingX:1,justifyContent:"space-between",children:[jsx(Text,{dimColor:true,children:"\u2191\u2193 Navigate \u2190\u2192 Switch r Refresh q Quit"}),jsx(Text,{color:r?"green":"yellow",children:r?`\u25CF ${e}`:`\u25CB ${e}`})]})}var bt=p(()=>{be();});function Ct(t=10){let e=$e(),[r,n]=useState(()=>e.getRecent(t));return useEffect(()=>e.subscribe(o=>{n(o.slice(-t));}),[t,e]),r}var Tt=p(()=>{k();});function Wr(t){switch(t){case "error":return "red";case "warn":return "yellow";case "info":return "cyan";case "debug":return "gray"}}function Yr(t){switch(t){case "error":return "\u2717";case "warn":return "\u26A0";case "info":return "\u2022";case "debug":return "\u25CB"}}function qr(t){return t.toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Lt({height:t=5}){let e=Ct(t-1);return jsxs(Box,{flexDirection:"column",height:t,borderStyle:"single",borderColor:"gray",paddingX:1,children:[jsx(Text,{bold:true,dimColor:true,children:"LOG"}),e.length===0?jsx(Text,{dimColor:true,italic:true,children:"No logs yet"}):e.map((r,n)=>jsxs(Text,{wrap:"truncate",children:[jsx(Text,{dimColor:true,children:qr(r.timestamp)})," ",jsx(Text,{color:Wr(r.level),children:Yr(r.level)})," ",jsxs(Text,{dimColor:true,children:["[",r.source,"]"]})," ",jsx(Text,{color:r.level==="error"?"red":void 0,children:r.message})]},n))]})}var Et=p(()=>{Tt();});function At({config:t,nav:e,width:r,height:n}){let s=r-22-30-6,i=6,c=Math.max(10,n-6-i);return jsxs(Box,{flexDirection:"column",width:r,children:[jsxs(Box,{borderStyle:"single",paddingX:1,children:[jsx(Text,{bold:true,color:"cyan",children:"ClaudeCode Dashboard"}),jsx(Box,{flexGrow:1}),jsx(Text,{dimColor:true,children:"Claude Code Config Viewer"})]}),jsxs(Box,{height:c,children:[jsx(Box,{flexDirection:"column",width:22,borderStyle:"single",paddingX:1,children:jsx(We,{categories:e.categories,selected:e.categoryIndex,focused:e.panel==="category"})}),jsx(Box,{flexDirection:"column",width:30,borderStyle:"single",paddingX:1,children:jsx(qe,{items:e.currentItems,selected:e.itemIndex,focused:e.panel==="item",maxHeight:c-4})}),jsx(Box,{flexDirection:"column",width:s,borderStyle:"single",children:jsx(ht,{item:e.selectedItem,width:s,maxHeight:c-2,category:e.categories[e.categoryIndex]?.key})})]}),jsx(Lt,{height:i}),jsx(kt,{})]})}var It=p(()=>{Ye();Xe();wt();bt();Et();});function Mt(){let[t,e]=useState({settings:null,skills:[],agents:[],commands:[],plugins:[],hooks:[],mcpServers:[],outputStyles:[]}),[r,n]=useState(true),[a,o]=useState(null),s=useCallback(async()=>{n(true),l.info("config","Loading configurations...");try{let[i,c,u,g,m,x,v]=await Promise.all([F(),N(),U(),B(),H(),_(),J()]);e({settings:i,skills:c,agents:u,commands:g,plugins:v,hooks:m,mcpServers:x,outputStyles:[]}),o(null),l.info("config",`Loaded: ${c.length} skills, ${u.length} agents, ${g.length} commands`);}catch(i){let c=i instanceof Error?i.message:"Failed to load config";l.error("config",`Load failed: ${c}`),o(c);}finally{n(false);}},[]);return useEffect(()=>{s();},[s]),{data:t,loading:r,error:a,refresh:s}}var Dt=p(()=>{me();k();});function Ot(t,e){let[r,n]=useState("category"),[a,o]=useState(()=>{if(!e)return 0;let m=["skills","agents","commands","hooks","mcp","plugins","settings"].indexOf(e);return m>=0?m:0}),[s,i]=useState(0),c=useMemo(()=>[{key:"skills",label:"Skills",count:t.data.skills.length},{key:"agents",label:"Agents",count:t.data.agents.length},{key:"commands",label:"Commands",count:t.data.commands.length},{key:"hooks",label:"Hooks",count:t.data.hooks.length},{key:"mcp",label:"MCP Servers",count:t.data.mcpServers.length},{key:"plugins",label:"Plugins",count:t.data.plugins.length},{key:"settings",label:"Settings",count:t.data.settings?1:0}],[t.data]),u=useMemo(()=>{let m=c[a];if(!m)return [];switch(m.key){case "skills":return t.data.skills;case "agents":return t.data.agents;case "commands":return t.data.commands;case "hooks":return t.data.hooks.map(x=>({...x,name:`${x.event}${x.matcher?`:${x.matcher}`:""}`}));case "mcp":return t.data.mcpServers;case "plugins":return t.data.plugins;case "settings":return t.data.settings?[{name:"Settings",...t.data.settings}]:[]}},[t.data,a,c]),g=u[s]??null;return {panel:r,categoryIndex:a,itemIndex:s,categories:c,currentItems:u,selectedItem:g,up:()=>{r==="category"?(o(m=>Math.max(0,m-1)),i(0)):i(m=>Math.max(0,m-1));},down:()=>{r==="category"?(o(m=>Math.min(c.length-1,m+1)),i(0)):i(m=>Math.min(u.length-1,m+1));},left:()=>n("category"),right:()=>n("item"),select:()=>{r==="category"&&n("item");},pageUp:()=>{r==="item"&&i(m=>Math.max(0,m-10));},pageDown:()=>{r==="item"&&i(m=>Math.min(u.length-1,m+10));}}}var Rt=p(()=>{});var jt={};Bt(jt,{App:()=>rn});function rn({initialCategory:t}){let{exit:e}=useApp(),{stdout:r}=useStdout(),n=Mt(),a=Ot(n,t);useInput((i,c)=>{i==="q"&&e(),i==="r"&&n.refresh(),(c.upArrow||i==="k")&&a.up(),(c.downArrow||i==="j")&&a.down(),(c.leftArrow||i==="h")&&a.left(),(c.rightArrow||i==="l")&&a.right(),c.return&&a.select(),(c.pageUp||i==="u")&&a.pageUp(),(c.pageDown||i==="d")&&a.pageDown();});let o=r?.columns??120,s=r?.rows??30;return o<80?jsxs(Box,{flexDirection:"column",padding:1,children:[jsxs(Text,{color:"yellow",children:["Terminal too narrow (",o," cols)"]}),jsx(Text,{children:"Minimum 80 columns required."}),jsx(Text,{dimColor:true,children:"Press q to quit."})]}):n.loading?jsxs(Box,{padding:1,children:[jsx(Text,{color:"cyan",children:jsx(ft,{type:"dots"})}),jsx(Text,{children:" Loading configurations..."})]}):n.error?jsxs(Box,{flexDirection:"column",padding:1,children:[jsxs(Text,{color:"red",children:["Error: ",n.error]}),jsx(Text,{dimColor:true,children:"Press r to retry, q to quit."})]}):jsx(At,{config:n.data,nav:a,width:Math.min(o,160),height:s})}var Ft=p(()=>{It();Dt();Rt();});me();async function Ve(t){let e=t?.toLowerCase()??"all";try{let r=await dr(e);console.log(JSON.stringify(r,null,2)),process.exit(0);}catch(r){console.error(JSON.stringify({error:r instanceof Error?r.message:"Unknown error"})),process.exit(1);}}async function dr(t){switch(t){case "skills":return N();case "agents":return U();case "commands":return B();case "hooks":return H();case "mcp":return _();case "plugins":return J();case "settings":return F();default:return pr()}}async function pr(){let[t,e,r,n,a,o,s]=await Promise.all([F(),N(),U(),B(),H(),_(),J()]);return {settings:t,skills:e,agents:r,commands:n,plugins:s,hooks:a,mcpServers:o,outputStyles:[]}}var Nt={name:"claudecode-dashboard",version:"1.0.3"};on({pkg:Nt,updateCheckInterval:1e3*60*60*24}).notify();var sn=new Command().name("claudecode-dashboard").description("View Claude Code configurations").version(Nt.version).argument("[category]","Category to show (skills, agents, commands, hooks, mcp, plugins, settings)").option("-j, --json","Output as JSON instead of TUI").action(async(t,e)=>{e.json?await Ve(t||"all"):await an(t);});async function an(t){let{render:e}=await import('ink'),r=await import('react'),{App:n}=await Promise.resolve().then(()=>(Ft(),jt));e(r.createElement(n,{initialCategory:t}));}sn.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claudecode-dashboard",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "CLI dashboard for viewing Claude Code configurations",
|
|
5
5
|
"author": "camping89",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"type": "module",
|
|
16
16
|
"bin": {
|
|
17
|
-
"claudecode-dashboard": "
|
|
18
|
-
"ccd": "
|
|
17
|
+
"claudecode-dashboard": "dist/cli.js",
|
|
18
|
+
"ccd": "dist/cli.js"
|
|
19
19
|
},
|
|
20
|
-
"files": [
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
21
23
|
"scripts": {
|
|
22
24
|
"dev": "tsx src/cli.tsx",
|
|
23
25
|
"build": "tsup",
|
|
@@ -31,11 +33,12 @@
|
|
|
31
33
|
"ink": "^5.0.0",
|
|
32
34
|
"ink-spinner": "^5.0.0",
|
|
33
35
|
"openai": "^6.15.0",
|
|
34
|
-
"react": "^18.3.0"
|
|
36
|
+
"react": "^18.3.0",
|
|
37
|
+
"update-notifier": "^7.3.1"
|
|
35
38
|
},
|
|
36
39
|
"devDependencies": {
|
|
37
|
-
"@types/react": "^18.3.0",
|
|
38
40
|
"@types/node": "^22.0.0",
|
|
41
|
+
"@types/react": "^18.3.0",
|
|
39
42
|
"tsup": "^8.0.0",
|
|
40
43
|
"tsx": "^4.0.0",
|
|
41
44
|
"typescript": "^5.7.0"
|
|
@@ -43,5 +46,11 @@
|
|
|
43
46
|
"engines": {
|
|
44
47
|
"node": ">=20"
|
|
45
48
|
},
|
|
46
|
-
"keywords": [
|
|
49
|
+
"keywords": [
|
|
50
|
+
"claude",
|
|
51
|
+
"cli",
|
|
52
|
+
"dashboard",
|
|
53
|
+
"tui",
|
|
54
|
+
"config"
|
|
55
|
+
]
|
|
47
56
|
}
|