Commit Graph
409 Commits
Author SHA1 Message Date
Willie c02b918057 feat(sync): add project mode support for sync extras and sync --all -p
cmdSyncExtras now parses mode args and auto-detects project mode via
projectConfigExists. Global logic is extracted into cmdSyncExtrasGlobal;
new cmdSyncExtrasProject handles project-scoped extras using
config.LoadProject and config.ExtrasSourceDirProject, with relative
target paths resolved against the project root.

sync --all in project mode now defers a cmdSyncExtras("-p", ...) call
instead of printing a warning, so extras are also synced.
2026-03-12 16:45:02 +08:00
Willie 18d54bd293 feat: implement extras init, list, and remove commands
- extras init: create new extra with --target/--mode flags, global + project mode
- extras list: show all extras with sync status detection, --json support
- extras remove: remove extra from config with --force confirmation
2026-03-12 16:45:02 +08:00
Willie f275435d6f feat(schema): add extras definition to config and project-config JSON schemas 2026-03-12 16:45:02 +08:00
Willie 0fcf6d1ee3 feat(sync): update extras source path to extras/<name>/ with auto-migration 2026-03-12 16:45:02 +08:00
Willie 0890fb3015 fix(config): prevent env var gitlab_hosts from leaking into persisted config
Move SKILLSHARE_GITLAB_HOSTS merge from Load()/LoadProject() to new
EffectiveGitLabHosts() methods so the GitLabHosts field stays config-file-only
and Save() never writes env-only hosts to disk.

Also fix project-mode direct install dropping gitlab_hosts from the
synthetic Config, and server project-mode parseOpts() falling back to
global config when project had no hosts configured.
2026-03-12 16:45:02 +08:00
Willie 8f16a90e5f feat(config): add SKILLSHARE_GITLAB_HOSTS env var and cleanup
Support CI/CD pipelines that need gitlab_hosts without a config file.
The env var is comma-separated and merged (deduplicated) with config
file values in both global and project modes.

Also cleans up from review:
- Extract isValidGitLabHostname to share validation logic
- Remove redundant ToLower before EqualFold in isGitLabHost
- Revert 3 no-opts call sites back to ParseSource()
- Add parseOptsFromProjectConfig helper to reduce inline duplication
- Fix project mode LoadProject missing env var merge
- Add install.md tip about custom GitLab domains
2026-03-12 16:45:02 +08:00
Willie a4d52615f7 feat(config): add gitlab_hosts for custom GitLab domain support
Self-managed GitLab instances on custom domains (e.g., git.company.com)
without "gitlab" in the hostname were parsed with 2-segment owner/repo
split instead of full-path repo. Users can now declare extra GitLab
hostnames in config so the parser treats them like gitlab.com (nested
subgroup support).

- Add `gitlab_hosts` field to both global and project Config structs
- Validate entries at load time (reject scheme, path, port, empty)
- Add `ParseOptions` / `ParseSourceWithOptions` to thread hosts into parser
- Add `isGitLabHost()` helper combining built-in + custom host detection
- Extend `InstallContext` interface with `GitLabHosts()` method
- Update all ParseSource call sites (install, search, update, server)
- Add JSON schemas for both config files
- Add unit tests for config validation and source parsing
- Add E2E runbook for devcontainer verification
- Document in configuration reference and URL formats appendix
2026-03-12 16:45:02 +08:00
Willie ad713bc669 fix(ui): render phase headers inline with progress bar to prevent visual duplication
Phase transitions during batch update (e.g. pull repos → update skills) were
printing separate PhaseHeader lines that created a second visible progress bar.
Now phases use ProgressBar.SetHeader() which overwrites the header line in place
via ANSI cursor-up, keeping a single continuous bar from start to finish.
2026-03-09 12:47:03 +08:00
Willie 404ad0afde fix(tui): replace 256-color gray gradient with SGR dim in skill path rendering
colorSkillPath() and colorSkillPathBold() used Color("241")~Color("249")
gradient for subdirectory segments — fixed palette grays that render
inconsistently across terminal themes. Replace with tc.Dim (SGR faint).
2026-03-09 12:47:03 +08:00
Willie ae80756b9a feat(ui): replace bright-black gray with SGR dim for consistent terminal rendering
\033[90m (bright black) renders too dark on many terminals and themes.
Replace with \x1b[0;2m (SGR dim attribute) which adapts to any foreground.

Changes:
- Add Dim constant and DimText() helper in internal/ui
- Replace all pterm.Gray() calls with DimText() in pterm.go
- Replace all ui.Gray references with ui.Dim across cmd/skillshare/
- Replace fixed 256-color grays (Color("247"/"242")) with lipgloss
  .Faint(true) in TUI styles (tui_colors.go, list_tui.go, log_tui.go)
- Fix progress bar layout: put count after % at fixed position,
  title last (truncated) — prevents count from being pushed off-screen
- Extract duplicate renderBar() from diff.go and search_batch.go
  into shared ui.RenderInlineBar() helper
2026-03-09 12:47:03 +08:00
Willie 7c582cbe21 docs: update v0.16.13 changelog to match project style
Expand bug fix descriptions, add grouped layout ASCII example,
and sync website changelog.
2026-03-06 23:10:48 +08:00
Willie 657b833569 fix: suppress devcontainer redirect for -j flag and show tracked badge in filter mode
- Add -j short flag to wants_machine_output() in devcontainer wrapper,
  preventing stderr banner noise for `skillshare list -j` etc.
- Show tracked repo name badge on skill items so filtered results remain
  distinguishable when group headers are absent. Two tracked skills from
  different repos now render with their repo origin visible.
2026-03-06 23:10:48 +08:00
Willie 0e7bfea8ee feat(tui): add structured filter tags to list TUI
Support key:value tag syntax in the `/` filter input for precise
skill filtering by type, group directory, and repo name:

  t:tracked g:security audit
  → type=tracked AND group contains "security" AND free text "audit"

Tags: t:/type: (tracked/remote/local/github), g:/group: (substring),
r:/repo: (substring). Multiple tags use AND logic. Unknown tags
gracefully degrade to free text. Optional `_` prefix on type values
(e.g. t:_tracked) and short alias t:track are accepted.

Filter input placeholder and help line update to show available tags
when filtering mode is active.
2026-03-06 23:10:48 +08:00
Willie 7015aaf611 refactor(tui): unify duplicated group/render logic between list and audit TUIs
- Extract renderPrefixRow shared helper (was duplicated in renderSkillRow
  and auditDelegate.Render)
- Remove auditGroupItem type, reuse groupItem from list_tui_item.go
- Remove skipAuditGroupItem, reuse skipGroupItem
- Simplify buildGroupedItems multi-group check to match audit's
  map-based approach; delete countRepoGroups
- Fix auditFooterLines hot-path: check len(ByCategory) instead of
  calling formatCategoryBreakdownTUI on every render
- Simplify baseSkillPath redundant branch
2026-03-06 23:10:48 +08:00
Willie c085f10a1f fix(tui): skip group separators when single group and fix row truncation
- Skip group separator lines when all items belong to one group
- Fix row truncation: use ANSI-aware xansi.Truncate instead of
  stripping ANSI codes then counting runes (lost color + wrong width)
- Account for bodyStyle padding when calculating text truncation width
- Add MaxWidth to prevent lipgloss from wrapping long rows
2026-03-06 23:10:48 +08:00
Willie 8ddf886921 feat(tui): add grouped layout and dynamic panel height to audit TUI
- Add repo-grouped layout with separator lines (matching list TUI)
- Use custom auditDelegate with compact single-line rows and truncation
- Sort by repo key (tracked first) then severity within each group
- Widen left panel from 25%/[25,45] to 36%/[30,46] to prevent wrapping
- Dynamically calculate panel height based on actual footer line count
  instead of hardcoded overhead, maximizing list space
- Auto-skip group separator items on navigation
2026-03-06 23:10:48 +08:00
Willie a217e40e2b fix(audit): reduce color noise in CLI and TUI output
The audit summary used 10+ distinct colors on a single screen,
making it hard to focus on actionable information.

Changes:
- Threats line: remove per-category rainbow colors (8 colors → dim/bold)
- Severity c/h/m/l/i: zero values now gray, only non-zero get color
- Policy line: dim metadata (only STRICT/LEGACY get warning yellow)
- Passed count: no longer green (normal state needs no emphasis)
- Remove unused categoryStyle() and categoryColorCLI() functions

Design principle: quiet gray baseline with color only for items
that require user attention (failed count, aggregate risk).
2026-03-06 23:10:48 +08:00
Willie 0a0ac2ee57 feat(tui): redesign list panel with grouped layout and compact paths
- Add group separators: tracked repos and standalone skills are visually
  grouped with dim header lines showing repo name and count
- Compact skill paths: strip tracked repo prefix, show at most last 2
  path segments in list rows (full path in detail panel)
- Auto-skip group headers on navigation (up/down/page)
- Replace split Source/Sync sections with unified Details section,
  removing duplicate info already shown in header
- Narrow left panel ratio (42% → 36%) for more detail space
- Separator "/" without spaces for tighter list rows
- Rename local group to "standalone" to avoid confusion with local badge
- Adjust renderFactRow label width (9 → 12) for longer labels
2026-03-06 23:10:48 +08:00
Willie 5ae4c7ab93 fix(tui): improve detail panel readability
- Bold skill name in header for better distinction from list items
- Add spacing between name and metadata line
- Show full source URL instead of truncating at 50 chars
- Rename "Overview" section to "Description" to match frontmatter field
2026-03-06 23:10:48 +08:00
Willie f115ab5e0e fix(tui): show skill name and group in list detail panel
The detail panel header was rendered on L00 (same row as the list title),
making the skill name invisible. Push content to L01 with a leading newline
and use colorSkillPath for consistent group/name coloring matching the left
panel. Compress status/date/targets into a single metadata line to save
vertical space. Show full source URL and synced targets in Quick Facts.

Also suppress devcontainer stderr redirect message in --json/--format modes
and fix audit summary field name (analyzerCount → activeAnalyzers).
2026-03-06 23:10:48 +08:00
Willie 7223ac52f4 fix(sync): preserve non-json dry-run output stream
Keep sync dry-run diagnostics on stdout by default to avoid non-JSON behavior regressions. Introduce sync.DiagOutput so JSON mode can silence diagnostics via io.Discard at command entry and restore after execution. Update search JSON integration assertion to match fully silent progress behavior.
2026-03-06 02:15:36 +08:00
Willie d707fc619b fix(cli): suppress stderr progress messages in --json mode
JSON mode stdout was already pure JSON, but stderr still emitted
progress lines (e.g. "Discovering skills...", "Found N local skill(s)")
which broke `2>&1 | jq .` pipelines. Remove the else-branch stderr
writes so --json mode is fully silent except for stdout JSON output.
2026-03-06 02:15:36 +08:00
Willie 6ad930f71d perf(cli): parallelize git dirty checks in status --json
Extract buildTrackedRepoJSON() that runs git.IsDirty concurrently via
goroutines + WaitGroup instead of sequential subprocess spawns per repo.
Also deduplicates the tracked-repo JSON loop between global and project
status paths, and optimizes skill counting to a single pass with a map.
2026-03-06 02:15:36 +08:00
Willie 0d59f15db4 refactor(cli): deduplicate JSON output helpers and fix ResolvePolicy semantics
- Extract writeJSONResult() to replace 5 identical write+silent-error trailers
- Replace local isRepoDirty() with existing git.IsDirty() (8 call sites)
- Use defer for suppressUIToDevnull restore instead of manual calls at each
  return site in install.go and update.go (prevents stdout leak on new paths)
- Fix ResolvePolicy always filling EnabledAnalyzers, which broke the
  nil-means-all contract for ForPolicy; add EffectiveAnalyzers() for display
- Simplify collectOutputJSON double map allocation
- Remove unnecessary string conversion in writeJSONError
2026-03-06 02:15:36 +08:00
Willie b366f619cb chore: formatting alignment and changelog jq example fix
- diff.go: align JSON struct field tags
- CHANGELOG: fix jq example (.errors → .details)
- analyzer_metadata: align map literal and test struct formatting
2026-03-06 02:15:36 +08:00
Willie 8ddf685aae fix(cli): wrap collect/sync JSON errors with jsonSilentError
collect --json and sync --json returned the raw error after writing
JSON, causing main() to print a duplicate plain-text error. Wrap with
jsonSilentError so main() exits non-zero silently.

Also fix sync --json skipping backup output that would corrupt stdout.
2026-03-06 02:15:36 +08:00
Willie 4535da1d01 refactor(cli): return updateResult from single-target update handlers
updateTrackedRepo and updateRegularSkill now return (updateResult, error)
instead of just error, so callers (including project mode and JSON output)
can accurately report updated/skipped/securityFailed/pruned counts.

Adapt cmdUpdateProject, cmdUpdateProjectBatch, updateAllProjectSkills,
and list_project.go TUI action to the new signatures.
2026-03-06 02:15:36 +08:00
Willie 4b09d2ee3d fix(cli): redirect JSON-mode UI to /dev/null and add status --project --json
suppressUIToStderr was redirecting UI to stderr, but in environments
where stdout and stderr share the same terminal (e.g. docker exec),
all the spinner/progress/header output was still visible alongside
the JSON. Replace with suppressUIToDevnull which opens os.DevNull
for both os.Stdout and ui.ProgressWriter, producing zero visible
noise in --json mode.

Also add status --json support for project mode, reusing the same
JSON schema as global mode (source, skill_count, tracked_repos,
targets, audit, version).
2026-03-06 02:15:36 +08:00
Willie b5430e094b fix(cli): suppress UI output in --json mode for install, diff, uninstall
install --json: logo, spinners, and step output leaked to stdout,
corrupting machine-parseable JSON. Add suppressUIToStderr() around the
entire install flow, restoring stdout before writing JSON.

diff --project --json: spinner and progress display polluted stdout.
Skip spinner and progress creation in JSON mode, matching the existing
cmdDiffGlobal pattern.

uninstall --json: five error paths (discovery failure, no skills found,
glob detection, validation, preflight) returned plain-text errors instead
of JSON error envelopes. Wrap each with writeJSONError().

Add 8 integration tests (5 new failure cases + 3 confirming existing
behavior) with an assertPureJSON helper that validates stdout contains
only valid JSON with no leading/trailing noise.
2026-03-06 02:15:36 +08:00
Willie 9a12df02b4 fix(cli): restore argument validation for status --project mode
The --json addition accidentally removed the guard that rejects
unexpected positional arguments in project mode. Restore it so
`skillshare status --project foo` correctly returns an error
instead of silently ignoring the extra argument.
2026-03-06 02:15:36 +08:00
Willie 1a4de5ddd1 fix(cli): use errors.As for jsonSilentError check in main
Type assertion would break if the error gets wrapped via fmt.Errorf
with %w. errors.As handles wrapped errors correctly.
2026-03-06 02:15:36 +08:00
Willie 18cd0ecc94 fix(cli): preserve non-zero exit code for --json error paths
writeJSONError now returns a jsonSilentError sentinel that main()
recognises — it exits with code 1 without printing plain-text output
to stdout. This fixes a regression where --json errors (config load
failure, missing source dir, discovery failure) returned exit 0.

All writeJSONError call sites changed from the broken pattern:
  writeJSONError(err); return nil   // exit 0, wrong
to:
  return writeJSONError(err)        // exit 1, correct

Also applied the same fix to update.go error paths which had the
older pattern of writeJSONError(err) followed by return err (which
would print both JSON and plain text).

Added regression tests for sync and install error paths verifying
both non-zero exit code and valid JSON error output on stdout.
2026-03-06 02:15:36 +08:00
Willie 6b4a8782bd fix(cli): ensure --json mode outputs pure JSON to stdout
Address code review feedback from PR #67:

- Move all dry-run diagnostic messages (internal/sync) from stdout to
  stderr so they don't pollute JSON output
- Suppress UI output (spinners, headers, warnings) in uninstall --json
  mode by adding jsonOutput guards across all phases
- Return nil after writeJSONError to prevent dual output (JSON + plain
  text error) in install and sync commands
- Handle json.MarshalIndent error in writeJSONError with stderr fallback
- Merge duplicated discovery logic (JSON vs non-JSON branches) in sync,
  sync_project, diff, and collect using nullable spinner pattern
- Remove checkRepoDirty alias in status.go, call isRepoDirty directly
- Remove extractJSON test workaround — tests now assert stdout is valid
  JSON directly, enforcing the clean-stdout contract
2026-03-06 02:15:36 +08:00
Willie 9982c2ebb9 fix(cli): clean up --json output code after review
- Replace hasFlag loop with slices.Contains (stdlib)
- Deduplicate checkRepoDirty → delegate to isRepoDirty
- Add nil-receiver guard to diffProgress.stop() for consistency
- Return explicit error for status --json in project mode
- Use consistent error message in sync --json source-not-found path
2026-03-06 02:15:36 +08:00
Willie 02aa2b2a45 feat(cli): add --json output to 8 commands (Phase 1+2)
Add structured JSON output support for agent and CI/CD consumption:

Phase 1 (mutating): sync, install, update, uninstall, collect
Phase 2 (read-only): target list, status, diff

Key design decisions:
- Per-command JSON schema (no universal envelope)
- Shared helper: writeJSON() with recursive nil slice→[] conversion
- --json implies --force for mutating commands (skip prompts)
- TUI/spinners suppressed; progress goes to stderr, JSON to stdout
- 10 integration tests covering valid JSON, dry-run, nil slices

Also includes post-review cleanup:
- ensureEmptySlices now recurses into nested structs/slices
- Unified mode resolution via getTargetMode() (removed 4 duplicates)
- sync --json now creates backups (behavioral parity with non-JSON)
- targetList no longer double-parses --json flag
2026-03-06 02:15:36 +08:00
Willie 2af44f1d3f chore(skills): strengthen built-in skill descriptions and content
Improve all 5 active skills with pushy descriptions for better
triggering accuracy, following devcontainer as the gold standard.

- changelog: add trigger scenarios (release notes, version prep)
- cli-e2e-test: add trigger scenarios (runbook, E2E validation)
- codebase-audit: add 3 new audit dimensions (handler split, oplog
  coverage, web API consistency) and trigger scenarios
- implement-feature: add project patterns reference (handler split,
  dual-mode, TUI, web API, oplog) and trigger scenarios
- update-docs: expand scope to all 7 doc categories with code-to-doc
  mapping guide and trigger scenarios

Also remove empty .skillshare/skills/frontend/ directory.
2026-03-05 02:13:21 +08:00
Willie ae5708e48d feat(doctor): add skill integrity verification via file hash comparison
Detect local drift (modified/missing/added files) in installed skills
by comparing current SHA-256 hashes against stored .skillshare-meta.json
records. Skills without metadata are flagged as unverifiable warnings.
2026-03-05 02:13:21 +08:00
Willie 0daafd20ee style(tui): remove detail panel box borders for cleaner layout
Replace bordered boxes around Source/Sync sections with simple
title + indented rows. Reserves brand yellow solely for selected
item indicator, reducing visual noise in the detail panel.
2026-03-05 02:13:21 +08:00
Willie 1b8940a630 fix(extras): copy-mode idempotency and display mode label
- Add contentEqual() byte comparison for copy-mode idempotency check:
  re-running sync extras no longer marks identical copies as conflicts
- Restore mode default in CLI handler so display shows "(merge)"
  instead of "()" for targets with no explicit mode
2026-03-04 12:16:32 +08:00
Willie 55bc5289c6 refactor(extras): simplify after code review
- Fix bug: pass `rest` (not `args`) to cmdSyncExtras in --all path
- Return error from cmdSyncExtras when totalErrors > 0
- Remove empty if-block dead code in syncOneExtraFile
- Remove redundant mode default (SyncExtra already defaults to merge)
- Consolidate capitalize/capitalizeFirst into single Unicode-safe helper
- Remove trivial copyExtraFile wrapper, call copyFile directly
- Warn when --all is used in project mode (extras are global only)
- Cache os.UserHomeDir() at package level for shortenPath
- Use source file set instead of per-file os.Stat in pruneExtraOrphans
2026-03-04 12:16:32 +08:00
Willie 17b207fe07 feat(cli): add 'sync extras' subcommand and --all flag
Route `skillshare sync extras` to new cmdSyncExtras handler that
iterates config.Extras, calls sync.SyncExtra per target, and logs
to oplog. `skillshare sync --all` runs normal skill sync followed
by extras sync in one invocation.
2026-03-04 12:16:32 +08:00
Willie 45eaefffb8 refactor(tui): reuse boolPtr, add oplog, eliminate redundant config loads
- Use existing boolPtr() helper instead of inline *bool construction
- Add oplog instrumentation to cmdTUIToggle for operation history
- Pass pre-loaded cfg to shouldLaunchTUI in diff.go and backup.go
  to avoid redundant config.Load() calls
2026-03-04 12:16:32 +08:00
Willie 81369f12e2 fix(tui): prevent detail panel bottom content from being clipped
The old applyDetailScroll embedded a scroll indicator inside the panel
content, consuming panel height and causing MaxHeight to clip the last
visible lines. Long lines that visually wrapped also broke the scroll
line-count calculation.

Replace with wrapAndScroll (hardWrapContent + applyDetailScrollSplit)
which hard-wraps content for accurate line counts and returns scroll
info separately for display in the help bar. Extract appendScrollInfo
helper to eliminate repeated if-append boilerplate across all TUIs.

Affects: audit, audit-rules, log, diff, restore TUIs (both horizontal
and vertical layouts).
2026-03-04 12:16:32 +08:00
Willie f6c5e1d2c8 feat(tui): add persistent TUI toggle via skillshare tui [on|off]
Allow users to globally disable interactive TUI without adding --no-tui
to every command. The setting is stored in config.yaml as `tui: false`.

Priority: --no-tui flag > config tui field > default (true).

- Add Config.TUI *bool field + IsTUIEnabled() helper
- Add centralized shouldLaunchTUI() replacing 9 scattered TTY checks
- Add `skillshare tui` command (show/on/off)
- Update JSON schema with tui boolean property
- Clean up unused golang.org/x/term imports (4 files)
2026-03-04 12:16:32 +08:00
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