From fb044d68a6ff8d3a2ccc57c24e61ccd12d1a4635 Mon Sep 17 00:00:00 2001 From: Willie Date: Fri, 27 Mar 2026 00:33:36 +0800 Subject: [PATCH] feat(analyze): add filtered token summary bar to Web UI Shows always-loaded, on-demand, and total token sums for the current search/filter result set using mini stat chips with icon + label + value. Appears only when a filter is active. Search matches on path (relPath) to support group filtering. Lint filter badge shows readable rule name. --- ui/src/pages/AnalyzePage.tsx | 57 +++++++++++++++++++++- website/docs/reference/commands/analyze.md | 40 +++++++++++++++ 2 files changed, 95 insertions(+), 2 deletions(-) diff --git a/ui/src/pages/AnalyzePage.tsx b/ui/src/pages/AnalyzePage.tsx index 41a4e03c0..80ea0e07c 100644 --- a/ui/src/pages/AnalyzePage.tsx +++ b/ui/src/pages/AnalyzePage.tsx @@ -12,6 +12,7 @@ import { FileText, HelpCircle, ExternalLink, + Filter, } from 'lucide-react'; import { Link } from 'react-router-dom'; import { api } from '../api/client'; @@ -478,6 +479,52 @@ function LintSummary({ skills, onRuleClick }: LintSummaryProps) { ); } +/* ────────────────────────────────────────────────────────────────────── + * Filtered Summary Bar + * ────────────────────────────────────────────────────────────────────── */ + +function FilteredSummaryBar({ filtered, total }: { filtered: AnalyzeSkill[]; total: number }) { + const summary = useMemo(() => { + let descTokens = 0; + let bodyTokens = 0; + for (const s of filtered) { + descTokens += s.description_tokens; + bodyTokens += s.body_tokens; + } + return { descTokens, bodyTokens, totalTokens: descTokens + bodyTokens }; + }, [filtered]); + + if (filtered.length === total) return null; + + const stats = [ + { label: 'Always', value: formatTokens(summary.descTokens), icon: , colorClass: 'text-info', bgClass: 'bg-info-light border-info' }, + { label: 'On-demand', value: formatTokens(summary.bodyTokens), icon: , colorClass: 'text-pencil', bgClass: 'bg-paper border-muted-dark' }, + { label: 'Total', value: formatTokens(summary.totalTokens), icon: , colorClass: 'text-success', bgClass: 'bg-success-light border-success' }, + ]; + + return ( +
+
+ + + {filtered.length}/{total} + +
+ {stats.map((s) => ( +
+ {s.icon} + {s.label} + {s.value} +
+ ))} +
+ ); +} + /* ────────────────────────────────────────────────────────────────────── * Full Skill Table * ────────────────────────────────────────────────────────────────────── */ @@ -511,7 +558,10 @@ function SkillTable({ // Search filter if (search) { const q = search.toLowerCase(); - result = result.filter((s) => s.name.toLowerCase().includes(q)); + result = result.filter((s) => { + const searchField = s.path || s.name; + return searchField.toLowerCase().includes(q); + }); } // Lint rule filter @@ -580,7 +630,7 @@ function SkillTable({ onClick={() => onLintFilterChange(null)} > - {lintFilter} + {readableRule(lintFilter)} @@ -596,6 +646,9 @@ function SkillTable({ + {/* Filtered summary */} + + {/* Table */}
diff --git a/website/docs/reference/commands/analyze.md b/website/docs/reference/commands/analyze.md index 53af7a8e7..666ed0d5e 100644 --- a/website/docs/reference/commands/analyze.md +++ b/website/docs/reference/commands/analyze.md @@ -139,6 +139,16 @@ Passing a target name automatically enables verbose output: skillshare analyze claude ``` +### Filter by Group + +```bash +# See total token cost of all frontend skills +skillshare analyze claude --json --filter frontend + +# Pre-populate the search box in TUI +skillshare analyze --filter marketing +``` + ## Options | Flag | Description | @@ -148,6 +158,7 @@ skillshare analyze claude | `--no-tui` | Disable interactive TUI, print plain text | | `--project`, `-p` | Analyze project-level skills (`.skillshare/`) | | `--global`, `-g` | Analyze global skills (`~/.config/skillshare`) | +| `--filter ` | Filter skills by name/path substring | | `--json` | Output as JSON (for scripting/CI) | | `--help`, `-h` | Show help | @@ -208,6 +219,35 @@ skillshare analyze -p claude # Single target details skillshare analyze -p --json # JSON output ``` +## Filtering + +Use `--filter` to narrow results to a subset of skills. The filter performs a case-insensitive +substring match on the skill's relative path (which includes the group directory). + +For example, if you installed skills with `--into frontend`: +- `--filter frontend` matches all skills in the `frontend/` group +- `--filter react` matches any skill with "react" in its path + +In TUI mode, `--filter` pre-populates the filter input. You can also use the `/` key to start filtering interactively. + +In JSON mode, the output includes a `filtered_summary` with aggregated token counts: + +```json +{ + "filter": "frontend", + "matched_count": 5, + "total_count": 50, + "filtered_summary": { + "always_loaded": { "chars": 2400, "tokens": 600 }, + "on_demand": { "chars": 8000, "tokens": 2000 }, + "total": { "chars": 10400, "tokens": 2600 } + }, + "skills": [...] +} +``` + +The Web UI also shows a dynamic token summary bar when search or filter is active. + ## See Also - [list](/docs/reference/commands/list) — View installed skills