Commit Graph
764 Commits
Author SHA1 Message Date
Willie 9b5429a3fd feat(targets): add Warp, Purecode AI, Witsy targets
Add 3 new AI agent targets discovered from vercel-labs/skills PRs:
- warp: universal path (~/.agents/skills)
- purecode (alias: purecode-ai): ~/.purecode/skills (global), .agents/skills (project)
- witsy: universal path (~/.agents/skills)

Update website docs: badge grid, path table, alias table, universal
info box, and target counts (50+ → 55+).
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.
v0.16.12
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 bcf31d851a fix(audit): show actual active analyzers in status --json output
When no explicit analyzer filter was configured, status --json reported
an empty analyzers array. Now ResolvePolicy backfills the full list of
built-in analyzer IDs so the JSON output reflects what actually runs.

Add Registry.IDs() helper with deduplication (markdownLinkAnalyzer and
staticAnalyzer share the "static" ID).
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 71f560331b docs: add v0.16.12 changelog
Structured JSON output for 8 commands (sync, install, update,
uninstall, collect, target list, status, diff), bringing total
--json coverage to all 12 major CLI commands.
2026-03-06 02:15:36 +08:00
Willie 5c31332efb feat(skill): add --json assertion guidance to cli-e2e-test skill
Runbooks can now leverage structured JSON output for verification
instead of brittle text matching. Adds --json quick reference table
(12 commands), jq assertion patterns, and updated checklist/templates.
2026-03-06 02:15:36 +08:00
Willie 18bfe5ff96 feat(skill): improve built-in skill for v0.16.12
- Expand description from 160 to 708 chars with broader trigger keywords
  (targets, backup/restore, trash, hub, symlink/copy, include/exclude filters)
- Add Skill Hubs recipe section (hub add/list/remove/default/index)
- Add Scripting & CI/CD recipe section (12 --json commands)
- Add --json column to Quick Lookup table
- Fix backup row: correctly show ✗ for project mode (global-only)
- Split tui/ui rows: tui/upgrade are ✗, ui supports -p
- Add hub to command list
- Update AI Caller Rules: hardcoded secret detection, --no-tui commands,
  12 --json commands
- Add --json flag docs to reference files (install, update, uninstall,
  status, diff, sync, collect)

Eval results: 100% pass rate across 5 test cases (up from 80% in iteration 1).
Key fix: Quick Lookup backup ✗ resolved false project-mode claims.
2026-03-06 02:15:36 +08:00
Willie f03ba456c0 chore: update docs 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 6730760215 feat(audit): add hardcoded secret detection (10 rules)
Detect inline API keys, tokens, and passwords in skill files via 10 new
hardcoded-secret-* rules (HIGH severity): Google API keys, AWS access
keys, GitHub PATs (classic + fine-grained), Slack tokens, OpenAI keys,
Anthropic keys, Stripe keys, PEM private key blocks, and generic
api_key/password assignments.

Closes a gap where GitHub Secret Scanning caught a Google API key in a
skill file but our audit engine missed it entirely.
v0.16.11
2026-03-05 02:34:24 +08:00
Willie 7e072c33c9 feat(ui): replace "Show more" pagination with virtualized scrolling
AuditPage: use Virtuoso with useWindowScroll for skill audit cards.
SyncPage: use Virtuoso with fixed-height container for diff items
(100+ threshold), flat render for small lists.
2026-03-05 02:13:21 +08:00
Willie 344b067806 feat(ui): add SSE streaming for update, check, and diff pages
Replace sequential POST loops and blocking useQuery calls with
Server-Sent Events for real-time progress feedback on Update, Check,
and Diff operations. Extract shared helpers to reduce duplication:

- initSSE() in middleware.go consolidates SSE preamble across 4 handlers
- createSSEStream() in client.ts unifies EventSource lifecycle management
- StreamProgressBar component replaces 3 near-identical progress bars
- handleDiff now delegates to computeTargetDiff (eliminates ~150 lines)
- Paginate audit results (20 cards + 10 findings per card) to prevent
  DOM overload with large skill counts
2026-03-05 02:13:21 +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 ebf2aaf822 feat(audit): add metadata analyzer for supply-chain trust verification
Add metadataAnalyzer (skill scope) that cross-references SKILL.md
metadata against the actual git source from .skillshare-meta.json:

- publisher-mismatch (HIGH): description claims an org but repo owner
  differs (e.g. "from Acme Corp" but sourced from evil-fork)
- authority-language (MEDIUM): uses "official"/"verified" language but
  source is not a well-known organization

Both rules are disable-able via audit-rules.yaml. The analyzer reads
meta from disk (zero API signature changes) and avoids import cycles
by defining its own minimal metaJSON struct.
2026-03-05 02:13:21 +08:00
Willie 272735c607 feat(install): detect SSL certificate errors and show actionable guidance
When git operations fail due to SSL certificate issues (self-signed certs,
internal CAs), the error message now suggests GIT_SSL_CAINFO, GIT_SSL_NO_VERIFY,
and SSH as alternatives instead of showing raw git stderr.

Env vars like GIT_SSL_CAINFO are already inherited via os.Environ() in
gitCommand() — the actual gap was error detection and user guidance.
2026-03-05 02:13:21 +08:00
Willie 76c1904afb feat(ui): add SSE-based audit streaming and real-time progress
Add server-sent events endpoint for audit scans so the web UI can
display per-skill progress instead of waiting for the full batch.

Backend:
- Extract discoverAuditSkills and processAuditResults from handler
- Add handler_audit_stream.go with SSE streaming endpoint
- Register GET /api/audit/stream route with read-lock middleware
- Add CORS headers for SSE connections in middleware

Frontend:
- Add AuditStreamPanel and AuditResultCard components
- Wire streaming audit into AuditPage with start/stop controls
- Add useAuditStream hook and streamAudit API client method
- Add per-skill audit action on SkillDetailPage
- Add check-based update detection on UpdatePage
- Configure Vite proxy for SSE endpoint
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 1aa8b5623c chore: update readme 2026-03-04 13:40:42 +08:00
Willie 5bfca0e12d docs: add v0.16.10 changelog, tui command page, and release notes
Add CHANGELOG and website changelog entries for v0.16.10 covering
sync extras and tui toggle features. Create dedicated tui command
reference page and register it in sidebar and commands index.
Bump built-in skill version to v0.16.10.
v0.16.10
2026-03-04 12:16:32 +08:00
Willie 9b849172ff docs: add sync extras documentation across website, skill, and README
Document the new `sync extras` subcommand and `--all` flag:
- sync.md: add Sync Extras section with config, modes, flowchart, example
- configuration.md: add `extras` field reference with schema table
- file-structure.md: show extras source directories alongside skills
- quick-reference.md: add sync extras and sync --all entries
- SKILL.md + references/sync.md: add extras recipes for AI callers
- README.md: add v0.16.10 to Recent Updates
2026-03-04 12:16:32 +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 65c7d75c41 style: fix gofmt alignment in extras_test.go and ui.go 2026-03-04 12:16:32 +08:00
Willie 671e3c5215 test(integration): add sync extras E2E tests
Cover sync extras merge mode, copy mode, no-extras-configured,
orphan pruning, --all flag, and missing source directory scenarios.
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 fbccdb9628 feat(sync): add extras sync engine — walk, symlink/copy, prune 2026-03-04 12:16:32 +08:00
Willie 035c9fe3f7 feat(config): add ExtraConfig struct for extras sync
Add ExtraTargetConfig and ExtraConfig structs to support a new
`extras:` section in config.yaml for syncing non-skill resources
(rules, commands, etc.) to target directories.

- ExtraConfig: name + list of ExtraTargetConfig (path + mode)
- Extras field added to Config struct (after Targets, before Ignore)
- Load() expands ~ in extras paths, matching existing target behavior
- Tests cover parsing, tilde expansion, mode field, and empty extras
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 6caf73faf0 docs(audit): split monolith audit.md into focused pages
The 1294-line audit.md mixed command reference, conceptual teaching,
rule management, and CI/CD recipes. Split into:

- understand/audit-engine.md — threat model, detection rules, risk
  scoring, command tiering, cross-skill analysis
- reference/commands/audit-rules.md — rule management, custom rules,
  built-in rule IDs table (adds 4 cross-skill finding IDs)
- how-to/recipes/ci-cd-skill-validation.md — absorb output format
  docs (SARIF, Markdown, JSON+jq, exit codes)
- reference/commands/audit.md — slim to ~370 lines, link to new pages

Also fixes:
- Replace ghost rule `system-writes-0` with `insecure-http-0` in all
  docs (the old ID no longer exists in rules.yaml)
- Update 3 cross-page links in security.md
- Update 1 rule ID in configuration.md
- Add sidebar entries for both new pages
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 ef26da2280 chore: update docs v0.16.9 2026-03-03 16:08:11 +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 714d5f929d perf(audit): reduce regex scans with conservative prefilters
Add compile-time literal prefilters for audit rules using regexp AST analysis and apply prefilter gating before MatchString in hot scanning loops.

Changes:
- extend compiled rule with prefilter metadata (literal + case-fold flag)
- derive conservative must-match literals via regexp/syntax (fallback to LiteralPrefix)
- apply prefilter checks in unified scanners, legacy ScanContent paths, and markdown link rule checks
- add unit tests for prefilter extraction and case-fold matching

Verification:
- docker compose -f .devcontainer/docker-compose.yml exec -T --user "501:20" skillshare-devcontainer bash -lc 'cd /workspace && GOCACHE=/tmp/go-build go test ./internal/audit -count=1'
- docker compose -f .devcontainer/docker-compose.yml exec -T --user "501:20" skillshare-devcontainer bash -lc 'cd /workspace && GOCACHE=/tmp/go-build go build -o /tmp/skillshare ./cmd/skillshare && SKILLSHARE_TEST_BINARY=/tmp/skillshare GOCACHE=/tmp/go-build go test ./tests/integration -run TestAudit_ -count=1'
2026-03-03 16:08:11 +08:00