Commit Graph
365 Commits
Author SHA1 Message Date
Willie bc5f60fab5 style(audit): add vertical spacing between CLI output sections
Header, findings, and summary box were visually cramped with no
blank lines separating them. Add breathing room between:
- header box and first finding (single-skill / path mode)
- last arrow line and summary box
- logical groups inside summary box (policy / counts / severity / aggregate / note)
2026-03-04 12:16:32 +08:00
Willie 53fdf0b59d feat(audit): add semantic coloring to CLI summary box Threats line
Apply per-category ANSI colors to the Threats breakdown in the CLI
summary box, matching the TUI footer palette. Add Purple, BrightRed,
OrangeAlt, BrightBlue color constants to internal/ui. Non-TTY output
remains plain text.
2026-03-03 16:08:11 +08:00
Willie 1b284e92b5 feat(audit): add semantic coloring to TUI summary footer
Labels use dim style while values use bold semantic colors, making
counts visually prominent. Threat category breakdown now colors each
category independently (injection=red, exfiltration=orange, etc.)
instead of uniform yellow, so users can distinguish threat types at
a glance.
2026-03-03 16:08:11 +08:00
Willie 459c322308 feat(audit): add category breakdown to summary across all output channels
Surface per-category finding counts (e.g., injection:3 exfiltration:2)
in CLI summary, TUI footer, markdown report, JSON output, and web API.
Adds Result.CountByCategory(), formatCategoryBreakdown() with compact
mode for TUI, and byCategory field to all audit summary structs.
2026-03-03 16:08:11 +08:00
Willie 0d04399ba9 feat(audit): surface Phase 2 fields (ruleId, analyzer, category) across all output channels
Previously the Phase 2 finding fields (ruleId, analyzer, category,
confidence, fingerprint) were only emitted in JSON and SARIF output.
This propagates them to CLI text, TUI detail panel, Markdown reports,
Server API responses, and the React frontend — each channel showing
the subset most useful for its audience.

- Server API: all 5 fields (omitempty) in auditFindingResponse
- CLI text: dim [ruleID / analyzer] line between severity and snippet
- TUI: cyan ruleID / analyzer / category line + search index
- Markdown: Rule ID and Category table columns
- Frontend: ruleId · analyzer · category dim metadata line
2026-03-03 16:08:11 +08:00
Willie 5f0b294408 fix(audit): improve policy line readability on dark terminals
LEGACY dedupe label used Gray (ANSI 90) which is near-invisible on dark
backgrounds — switch to Yellow for both CLI and TUI. Add Gray color to
separator and label text (dedupe:, analyzers:) so colored values stand
out from structural punctuation.
2026-03-03 16:08:11 +08:00
Willie 6d9545cb04 fix(audit): populate policy fields before TUI launch and update docs
applyPolicyToSummary was called in cmdAudit after auditInstalled/
auditFiltered returned, but both functions call presentAuditResults
(which launches the TUI) internally — so summary.PolicyProfile was
empty when the TUI rendered. Move applyPolicyToSummary before
presentAuditResults in both functions.

Also fix dedupe default label (global is now the default, not legacy)
and update audit/status docs to reflect current output format.
2026-03-03 16:08:11 +08:00
Willie a7231770fd refactor(audit): extract render and policy helpers, name anonymous struct
Split audit.go (1349→997 lines) into focused files:
- audit_render.go: all terminal output (printSkillResult*, buildAuditSummaryLines, presentAuditResults, printAuditHelp)
- audit_policy.go: policy label/colorize helpers shared by CLI and TUI

Additional cleanups:
- Replace anonymous struct{name,path} with named auditSkillRef
- Move modeString to mode.go, pathExists to helpers.go
- Fix recountSummary missing PolicyAnalyzers preservation after dedupe
- Replace 3 hardcoded ANSI escape codes with ui.Green/ui.Gray/ui.Reset
2026-03-03 16:08:11 +08:00
Willie 6aac91776b refactor(audit): simplify registry, dedupe, colorize, and API signatures
- Make DefaultRegistry() a singleton (stateless analyzers, safe to share)
- Consolidate duplicate ANSI regex into ui.StripANSI(); broaden pattern
  to match all CSI sequences ([a-zA-Z] terminator, not just 'm')
- Extract shared policyProfileLabel/policyDedupeLabel/policyAnalyzersLabel
  helpers; unify formatPolicyLine and formatPolicyLineFromPolicy
- Remove redundant applyPolicyToSummary calls inside auditInstalled and
  auditFiltered (cmdAudit already applies it centrally)
- Fix double isMarkdown check in scanSkillImpl walk loop
- Convert variadic ...*Registry to regular *Registry parameter across
  scanSkillImpl, ParallelScan, scanSkillPath, and scanPathTarget
- Pre-compute registry.Has() before walk loop to avoid per-file O(n) scan
2026-03-03 16:08:11 +08:00
Willie c86886eb90 feat(audit): colorize policy values, show audit config in status
- Add ANSI color helpers (colorizeProfile/Dedupe/Analyzers) for text output
  and lipgloss equivalents (tuiColorize*) for TUI — all values now UPPERCASE
- Colorize threshold with severity color in header, summary box, and TUI
- Colorize Max sev in summary box with severity color
- Add Audit section to `skillshare status` (global + project) showing
  resolved policy: Profile, Block rule, Dedupe, Analyzers
- Fix TUI not showing Policy row: move policy field population from
  runAudit() into scan functions via applyPolicyToSummary() so TUI
  receives populated summary before launch

Color mapping:
  Profile:   DEFAULT=cyan  STRICT=yellow  PERMISSIVE=green
  Threshold: severity color (red/orange/yellow/blue/gray)
  Dedupe:    GLOBAL=cyan   LEGACY=gray
  Analyzers: specific=cyan ALL=cyan
2026-03-03 16:08:11 +08:00
Willie 33578fb497 feat(audit): show policy in header/summary/TUI, suppress clean lines in batch
- Add "policy:" line to header box (before scan starts)
- Add "Policy:" line to text summary box
- Add Policy row to TUI detail panel (right side)
- Add Policy label to TUI footer bar
- Batch no-tui mode: only show skills with findings (suppress 60k+
  clean ✓ lines). Single-skill mode still shows full detail.
2026-03-03 16:08:11 +08:00
Willie d1e7f6558a feat(audit): wire --analyzer CLI flag, config field, and update docs
- Add EnabledAnalyzers []string to AuditConfig struct
- Add enabled_analyzers to both JSON schemas (config + project)
- Parse --analyzer repeatable flag in audit command
- Wire config → PolicyInputs → Registry for all scan paths
  (ParallelScan, single skill, single path, filtered)
- Add PolicyAnalyzers to JSON summary output
- Server handler also reads config enabled_analyzers
- Update audit.md: Policy & Profiles section, Finding Schema table,
  --profile/--dedupe/--analyzer in Options table and examples
- Update configuration.md: expanded audit section with all new fields,
  profile table, analyzer IDs, precedence rules
2026-03-03 16:08:11 +08:00
Willie 07f70abf02 fix(audit): let profile presets set threshold when config has no explicit block_threshold
config.Load() normalized empty block_threshold to "CRITICAL", preventing
ResolvePolicy from applying profile-based thresholds (e.g. strict → HIGH).

Change: normalizeAuditBlockThreshold("") now returns "" instead of "CRITICAL".
All downstream callers (install, update, server) already use
audit.NormalizeThreshold() which handles empty → CRITICAL independently.

Also adds 4 integration tests for --profile, --dedupe, and config-based
profile resolution. Includes gofmt formatting fixes.
2026-03-03 16:08:11 +08:00
Willie d185f21a77 feat(audit): wire --profile/--dedupe flags, dedupe pipeline, and policy output
- CLI: add --profile and --dedupe flags to audit command with help text
- Pipeline: apply DeduplicateGlobal when dedupe_mode=global, recount
  summary after dedup via recountSummary helper
- Output: add policyProfile/policyDedupe to JSON summary and Markdown
  header (non-default profiles only)
- Server: add auditPolicy() method, populate policy fields in API
  responses for both all-skills and single-skill audit endpoints
2026-03-03 16:08:11 +08:00
Willie a97cf9e34e refactor(audit): simplify rules code, fix N+1 I/O, and extract shared helpers
- Remove duplicate readOrCreateRulesFile (use loadUserRules)
- Consolidate severity normalization with shorthand aliases (c/h/m/l/i)
- Merge enable/disable into shared cmdAuditRulesToggle
- Cache builtinYAML() with sync.Once to avoid repeated YAML parsing
- Cache rulesPath/patterns/sevCounts on TUI model, use SetItems over list.New
- Extract execMutation helper, remove dead expandAll/collapseAll/buildTitle
- Fix TestScanContent_InsecureHTTP test pollution via resetForTest()
- Add batch ToggleRules/SetSeverityBatch to eliminate N+1 file I/O
- Extract shared severity helpers to ui/src/lib/severity.ts
- Merge 9 filter() calls into single-pass useMemo in AuditRulesPage
- Add 7 tests for batch toggle and severity operations
2026-03-03 16:08:11 +08:00
Willie dbe759ecfe feat(audit): add CLI rules subcommand, severity override, reset, and redesign Web UI
- Add `audit rules` CLI subcommand with list, enable, disable, severity,
  and reset commands for managing audit rules without editing YAML
- Add SetSeverity/SetPatternSeverity/ResetRules mutations in audit package
- Redesign TUI with severity tabs, two-level pattern→rule navigation,
  inline severity picker (1-5 keys), and reset-all support
- Add compiled rules API endpoints (GET /api/audit/compiled, PATCH toggle)
- Redesign AuditRulesPage with severity-colored stripes, stat cards,
  expand/collapse, toggle switches, and dark-mode-aware CSS variables
- Redesign LogPage with status-colored row stripes, reusable PillButton,
  improved stats cards with left border stripes, default 10 entries/page
- Remove system-writes audit pattern (noisy, low value)
- Fix dark mode contrast across both pages by replacing hardcoded
  design.ts colors with var(--color-*) CSS variable references
2026-03-03 16:08:11 +08:00
Willie 0b3fc11fba feat(audit): add two-level TUI for audit rules browsing and toggling
Implement a full bubbletea TUI with two navigation levels:
- Level 1 (patterns): shows pattern categories with rule count, disabled
  count, and max severity; press Enter to drill in, d to toggle pattern
- Level 2 (rules): shows individual rules with severity and status; detail
  panel shows full ID, regex, message, source; d toggles single rule,
  D toggles entire pattern, Esc returns to Level 1

Also adds audit.ResetGlobalCache() to clear cached rules after YAML
mutations, enabling live-reload within the TUI session.
2026-03-03 16:08:11 +08:00
Willie 1676d7d064 fix(audit): suppress pterm cursor codes leaking into structured stdout
pterm's cursor package writes hide/show ANSI codes (\x1b[?25l/h)
directly to os.Stdout, bypassing WithWriter(). The previous fix
(SetProgressWriter to stderr) was insufficient because pterm still
created progress bar objects that triggered cursor.Hide()/Show().

Add SuppressProgressToStderr() which both redirects ProgressWriter
and forces isProgressTTY() to return false, preventing pterm
components from being instantiated at all. Extract assertNoANSI
test helper and cover all three structured formats (JSON, SARIF,
Markdown).

Also update pre-commit E2E runbook with steps 10-11 (framework
integration tests) and add pre-commit-hook recipe to sidebar.
2026-03-03 16:08:11 +08:00
Willie ca5a036e58 perf(audit): rewrite cross-skill analysis from O(N²) to O(N)
Replace nested pair-checking loop with set-based approach:
- Single pass builds capability sets (credReaders, netSenders, etc.)
- Each rule checks non-empty sets → one summary finding per rule
- 100k skills: ~15ms vs ~30s+ (benchmark included)
- Use DiscoverSourceSkillsLite for audit discovery (skip frontmatter)
- Use patternDataflowTaint constant instead of raw string
2026-03-02 23:01:30 +08:00
Willie 28dacd19b8 feat(audit): expand TUI filter to search risk, status, severity, patterns, and files
Previously the audit TUI "/" filter only matched skill names. Now it
also searches risk label, status (blocked/warning/clean), max severity,
finding pattern names, and finding file names — making it easy to narrow
down results like `/critical`, `/exec-command`, or `/blocked`.
2026-03-02 23:01:30 +08:00
Willie 2fe90526f9 fix(audit): omit SARIF region for line-0 findings and add cross-skill to API
P1: SARIF startLine=0 is invalid per spec — GitHub Code Scanning rejects
it. Use *sarifRegion pointer with omitempty so findings without line
numbers (tier, cross-skill, analyzability, content-integrity) produce
valid SARIF output without a region field.

P2: Server audit endpoint (handleAuditAll) now calls CrossSkillAnalysis
after collecting results, matching CLI behavior. Previously the API
returned only per-skill findings without cross-skill interaction checks.

Also guard fmt.Println() in auditFiltered() for structured output
consistency (same fix as auditInstalled in previous commit).
2026-03-02 23:01:30 +08:00
Willie 23206306d8 fix(audit): prevent stdout pollution in structured output formats
Two issues caused red team test failures after --format flag introduction:

1. ss_capture helper merged stderr into stdout (2>&1), so the --json
   deprecation warning poisoned JSON parsing by jq. Fix: capture stderr
   to a temp file separately from stdout.

2. Two unguarded fmt.Println() calls in auditInstalled() printed blank
   lines to stdout even in JSON/SARIF/markdown mode. Fix: wrap in
   if !jsonOutput guard.

Also migrate all 39 --json invocations in red team tests to --format json
since --json is deprecated.
2026-03-02 23:01:30 +08:00
Willie 89c3586da6 feat(audit): add markdown output format and improve terminal layout
- Add --format markdown for self-contained audit reports (GitHub Issues/PRs)
- Simplify pterm box rendering: replace DefaultBox with separator-line style
- Remove unused SkillBox, SummaryBox, SkillDisplay, wrapText helpers
- Color Box titles cyan (consistent with HeaderBox)
- Add breathing room: blank lines around progress bar and after summary
- Show "skillshare audit (project)" header title in project mode
- Append elapsed time to cross-skill synthetic results to fix slice mismatch
2026-03-02 23:01:30 +08:00
Willie 87268d3098 feat(audit): add cross-skill interaction detection
Two individually harmless skills can form an attack chain when installed
together (e.g., one reads credentials, another has network access).

After per-skill scans complete, the audit engine now extracts a capability
profile from each Result and checks for dangerous cross-skill combinations:

- cross-skill-exfiltration (HIGH): credential reader + network sender
- cross-skill-privilege-network (MEDIUM): privilege commands + network
- cross-skill-stealth (HIGH): stealth skill alongside high-risk skill

Rules only fire for complementary pairs (each skill lacks the other's
capability) to avoid duplicating per-skill findings. Results appear as
synthetic "_cross-skill" entry in all output formats (text, JSON, SARIF, TUI).
2026-03-02 23:01:30 +08:00
Willie b6652f11a0 feat(audit): add command safety tiering (T0–T5) for behavioral classification
Classify every shell command in skill files into 6 behavioral tiers
(read-only, mutating, destructive, network, privilege, stealth) as an
orthogonal dimension to pattern-based severity. This lets audit report
"what kind of actions" a skill performs, not just "which known patterns
it matches."

- Add tier engine with 80+ command mappings and stealth regex patterns
- Detect tiers in scripts and Markdown fenced code blocks separately
- Generate combination findings: T2+T3→HIGH, T5→CRITICAL, T3>5→MEDIUM
- Display tier profile in CLI text, TUI detail panel, and JSON/API output
- Exclude .skillshare-meta.json from totalBytes to fix analyzability ratio
- Document tier definitions, profile output, and combination findings
2026-03-02 23:01:30 +08:00
Willie 787c46c7c3 fix(tui): improve gray text contrast on dark terminals
Bump Dim 245→247 and Faint 239→242 for better readability on
dark terminal backgrounds without losing visual hierarchy.
2026-03-02 23:01:30 +08:00
Willie 71bf0969be feat(audit): show analyzability score in TUI detail panel and summary
- Detail panel: show per-skill "Auditable: X%" with green/yellow color
- Summary footer: append "Auditable: X% avg" to the status bar
2026-03-02 23:01:30 +08:00
Willie 8e83495200 feat(audit): add analyzability score and pre-commit hook
Analyzability score measures what percentage of a skill's content is
auditable plaintext vs binary/non-scannable. Surfaces in CLI text
output, JSON, SARIF, and Web UI API responses.

- Add TotalBytes, AuditableBytes, Analyzability fields to audit.Result
- Emit INFO-level low-analyzability finding when score < 70%
- Show "Auditable: X%" in per-skill and summary text output
- Expose analyzability in server API (auditResultResponse + auditSummary)
- Add .pre-commit-hooks.yaml for pre-commit framework integration
- Add pre-commit hook recipe docs and audit.md cross-references
2026-03-02 23:01:30 +08:00
Willie afb8951359 fix(audit): show spinner/progress on stderr for structured output formats
Previously --format json/sarif completely suppressed spinner and progress
bar, making the CLI appear frozen during long scans.

Now spinner/progress output is redirected to stderr via ProgressWriter,
so progress indicators remain visible while structured data stays clean
on stdout. This follows the Unix convention: data → stdout, diagnostics
→ stderr.

Also:
- Extract fileTTY() shared helper (DRY IsTTY + isProgressTTY)
- Add format constants (formatText/JSON/SARIF) and isStructured()
- Capture/restore previous ProgressWriter in defer (defensive)
2026-03-02 23:01:30 +08:00
Willie 11668b8f0a feat(audit): add --format flag with sarif/json/text + deprecate --json
- Add --format <text|json|sarif> flag to audit command
- Deprecate --json in favor of --format json (with stderr warning)
- SARIF output uses ToSARIF() from internal/audit/sarif.go
- Suppress UI (spinners, progress bars) for all structured outputs
- Update auditPath/auditSkillByName to accept format string
- Update help text with new flag and examples
- Add 3 integration tests: FormatSARIF, FormatJSON, JSONDeprecation
2026-03-02 23:01:30 +08:00
Willie 38f8f1c796 fix(symlink): resolve symlinked source/target dirs across all Walk callsites
filepath.Walk/WalkDir silently skip symlinked root directories because
os.Lstat sees the root as a non-directory symlink and never enters it.
This affected update, uninstall, reconcile, and server handlers when
the source directory was a symlink (common with dotfiles managers).

Extract ResolveSymlink() from sync.go into internal/utils/path.go and
apply it at every filepath.Walk/WalkDir callsite on source/target dirs.

Also add containment guards to resolveGroupSkills (uninstall) and
resolveGroupUpdatable (update) to reject group directories that are
symlinks pointing outside the source tree.
2026-03-02 10:05:57 +08:00
Willie 32a29c8e91 fix(upgrade): clear prompt lines to preserve tree layout
Upgrade prompts ("Install built-in skill?" and "Upgrade to vX?")
left their input lines visible after the user responded, breaking
the tree-drawing structure. Add ui.ClearLines() to erase prompt
lines via ANSI cursor-up + clear-line, so StepEnd connects cleanly
to the preceding tree node. No-op on non-TTY.
2026-03-02 10:05:57 +08:00
Willie d1370c0f98 fix(sync): preserve external symlinks in merge/copy mode conversions
When a target directory is an external symlink (e.g., dotfiles manager
pointing ~/.claude/skills/ elsewhere), sync previously deleted it
unconditionally during symlink→merge/copy mode conversion. This also
affected DiscoverSourceSkills which failed to traverse symlinked source
directories because filepath.Walk uses Lstat on root.

Changes:
- Add resolveWalkRoot() helper; use in both Discover functions so
  filepath.Walk enters symlinked source directories
- Add isSymlinkToSource() to distinguish source-pointing symlinks
  (symlink mode residue, safe to remove) from external symlinks
- Pass explicit sourcePath to SyncTargetMergeWithSkills and
  SyncTargetCopyWithSkills for reliable symlink origin detection
- Fix FindLocalSkills to use utils.ResolveLinkTarget (handles relative
  symlinks correctly) and follow external symlinks for scanning
- Fix CheckStatusMerge to follow external symlinks instead of returning
  StatusConflict
- Add 17 unit tests and 6 integration tests covering symlinked source,
  target, both, chained symlinks, idempotency, prune, and pull
2026-03-02 10:05:57 +08:00
Willie d8fb76d33d fix(restore): handle ReadDir error to prevent accidental backup deletion
os.ReadDir failure was silently ignored, causing otherTargets to be 0
and triggering removal of the entire timestamp directory instead of
just the target subdirectory. Now returns an error early.

Also adds diff TUI expand test from previous session.
2026-03-02 02:23:50 +08:00
Willie 8e5efe36f6 docs: add v0.16.6 changelog entry
Covers diff TUI, --patch/--stat flags, glob pattern matching,
trash/restore TUIs, Homebrew-aware version check, and bug fixes.
2026-03-02 02:23:50 +08:00
Willie 7a22b781f2 feat(diff): async expand with spinner and support all diff types
- Add loading spinner while computing file diffs (prevents TUI freeze)
- Compute file diffs in parallel using sync.WaitGroup
- Support expanding "local only" and "remove" items (not just modify/add)
- Populate dstDir on remove/orphan items for file listing
- Relax ensureFiles to work with dstDir-only entries
- Add stale result guard when navigating during async load
2026-03-02 02:23:50 +08:00
Willie 8a377481cb feat(version): Homebrew-aware version check
Homebrew formula updates lag GitHub Releases by hours/days, causing
Homebrew users to see "update available" when `brew upgrade` says
already up-to-date. Now detect install method from executable path
and query `brew info --json=v2` for Homebrew installs instead of
the GitHub Release API.

- Add InstallMethod type with DetectInstallMethod() and
  FetchBrewLatestVersion() in internal/version/homebrew.go
- Check() accepts InstallMethod to branch fetch strategy
- UpdateNotification() accepts upgradeCmd (shows correct command)
- UpgradeCommand() method on InstallMethod centralizes the mapping
- doctor.go reuses versioncheck.Check() (fixes semver string
  comparison bug in old fetchUpdateMessage)
- Remove duplicated isHomebrewInstall() from upgrade.go
- Skip post-command version check for doctor (has its own)
2026-03-02 02:23:50 +08:00
Willie ae16181689 refactor(auth): consolidate duplicated auth infra and fix GH_TOKEN gap
- Remove duplicated RateLimitError, newGitHubRequest, newGitHubClient,
  checkRateLimit from internal/version — now uses internal/github client,
  which also fixes missing `gh auth token` fallback for version checks
- Add GH_TOKEN as fallback in install.resolveToken() for GitHub platform,
  matching github.GetToken() resolution order (GITHUB_TOKEN → GH_TOKEN)
- Add GH_TOKEN to sanitizeTokens() redaction list
- Extract shared IsAuthError() in install/auth.go; push.go and
  wrapGitError() both delegate to it (adds "Access denied" coverage)
- Consolidate shouldFallback*TrackedClone auth checks via isAuthOrAccessError()
- Thread single *http.Client through search.Search() and all callees,
  reducing ~60 redundant TLS handshakes to connection-pooled reuse
- Pass *http.Client to downloadFile() instead of creating per-file clients
- Replace sourceHost() with extractHost() (same package, identical purpose)
- Remove unused isGitRepo() alias; callers use IsGitRepo() directly
2026-03-02 02:23:50 +08:00
Willie d2883e5773 refactor(tui): consolidate duplicated utilities and cache detail rendering
- Extract shared formatDurationShort, truncateStr, renderHorizontalSplit,
  tuiMinSplitWidth into tui_helpers.go; replace 5 truncate and 3 relative
  time duplicates across cmd/skillshare with thin wrappers
- Remove duplicate applyRestoreDetailScroll from restore_tui.go
- Cache detail panel content in restore_tui.go and trash_tui.go to avoid
  filesystem I/O (recursive walks, SKILL.md reads) on every bubbletea
  render frame — recompute only on selection change or mutation
- Remove dead ListBackupVersions call in startDelete whose result was
  discarded
2026-03-02 02:23:50 +08:00
Willie 13744f89a8 refactor: consolidate duplicated utilities and simplify diff API
- Extract shared applyDetailScroll into tui_helpers.go (was duplicated
  across diff_tui.go, log_tui.go, audit_tui.go)
- Create utils.FileHash and utils.FileHashFormatted, replacing private
  copies in install/meta.go and audit/audit.go
- Export install.MetaFileName constant, use from diff_file.go
- Replace double SHA-256 in fileContentsEqual with streaming byte compare
  for early-exit efficiency
- Add 1MB size cap to generateUnifiedDiff to prevent performance issues
- Move noTUI into diffRenderOpts struct, simplifying function signatures
2026-03-02 02:23:50 +08:00
Willie ada539603e refactor(diff): address code review findings
- Remove dead field diffTUIModel.results (never read)
- Replace hand-rolled countOccurrences with strings.Count
- Skip latestMtime() walk for merge mode (symlinks make it misleading)
- Fix ensureFiles() nil cache miss (return non-nil empty slice)
- Cache sorted items + categories in TUI model (avoid per-render recompute)
2026-03-02 02:23:50 +08:00
Willie 20411ed89c fix(diff): hide .skillshare-meta.json from file-level diff and make --stat imply --no-tui 2026-03-02 02:23:50 +08:00
Willie 924487b334 feat(diff): add file list, text diff, and time info to TUI detail panel
- Add expand state (Enter key toggle) for file-level diff display
- Show file list with +/-/~ icons for add/delete/modify files
- Show colored unified diff (green/red/cyan) for modified files
- Add source/target mtime rows in detail header
- Replace "Actions" section with "Next Steps" using prominent styling
- Update list item description with sync/local breakdown
- Add stat counts (err/diff/ok) to TUI title bar
- Fix freeze: defer file walk to Enter toggle instead of every render
- Fix gofmt in trash_tui.go and restore.go
2026-03-02 02:23:50 +08:00
Willie c72ab5fed4 feat(diff): add --patch and --stat flags with file stat, time info, and unified diff 2026-03-02 02:23:50 +08:00
Willie 6fea949988 feat(diff): redesign labels with git-style symbols and add statistics summary 2026-03-02 02:23:50 +08:00
Willie c59498bc6c feat(diff): extend diff entries with file-level data, source paths, and mtime
- Add files, srcDir, dstDir fields to copyDiffEntry for lazy file diff
- Add srcMtime, dstMtime to targetDiffResult for time display
- Add ensureFiles() lazy loader and latestMtime() helper
- Pass sourceMap through collectMergeDiff for source path resolution
- Use named struct literals throughout collect functions
2026-03-02 02:23:50 +08:00
Willie 398e0bf40c feat(diff): add file-level diff engine for skill content comparison
Implement diffSkillFiles to walk source/destination directories and
detect add/modify/delete changes at the file level. Uses SHA-256 for
content comparison and sergi/go-diff for unified text diffs. Includes
binary detection, git-style stat rendering, and 9 unit tests.
2026-03-02 02:23:50 +08:00
Willie 27e5c3ae82 feat(diff): add interactive bubbletea TUI with left-right panel layout
Left panel shows target list with status icons (✓/!/✗), right panel
displays categorized diff details for the selected target. Supports
filter (/), detail scroll (Ctrl+d/u), and narrow terminal fallback.

Add --no-tui flag for plain text output; non-TTY auto-falls back.
2026-03-02 02:23:50 +08:00
Willie f5a816673f fix(backup,restore): handle -g/-p mode flags correctly
Both commands were missing parseModeArgs(), causing -g to be
misinterpreted as a target name. Now -g is accepted silently
(global is default) and -p returns a clear error.
2026-03-02 02:23:50 +08:00
Willie c5be126f0b feat(install,update,uninstall): add glob pattern matching for skill names
Support glob patterns (*, ?, [...]) in skill name arguments across all
three commands. Matching is case-insensitive.

- install: --skill and --exclude flags support glob (e.g. -s "core-*")
- update: positional names support glob (e.g. update "core-*")
- uninstall: positional names support glob (e.g. uninstall "core-*")

Shared helpers isGlobPattern() and matchGlob() extracted to helpers.go
to avoid duplication. Includes 25 new tests and updated docs.
2026-03-02 02:23:50 +08:00