Commit Graph
19 Commits
Author SHA1 Message Date
Willie 0793ebe3c6 fix(update): fail tracked repos whose git status cannot be read
update discarded the error from the uncommitted-changes check, so a repo
whose git status could not be read was treated as clean and pulled over
whatever local edits it had. It now fails that repo with "failed to check
git status: <err>" unless --force, matching uninstall and the Web API.
Batch update counts these as failed instead of skipped and exits non-zero.
2026-09-30 02:22:48 +08:00
Willie f52ae74c5f feat(audit): remember findings accepted via --force across updates
Overriding the audit gate with --force was per-invocation, so skills that
legitimately quote attack strings (security scanners, red-team docs) had to
be forced on every `update --all`. The only alternative, disabling the rule,
was global and turned it off for every skill.

Record the accepted findings (rule + file + matched text, no line number) in
.metadata.json under `audit_accepted`, keyed by skill relPath so it survives
entry rewrites and works for tracked repos. Later updates mark matching
findings as acknowledged and exclude them from the block decision; any new
finding, or the same rule matching different text, still blocks.

Staged installs audit a temp directory, so InstallOptions gains an
AuditAcceptRoot/AuditAcceptPath override pointing at the final destination.

Refs #279
2026-09-17 10:24:18 +08:00
Willie efcc3e6f61 fix(update): honour installed branch in batch update and web UI check/update
Skills installed from a non-default branch record that branch in metadata,
but the grouped update path (update --all) cloned the remote default branch,
so the skills were either downgraded or reported as removed upstream and
pruned. The web UI update and check handlers had the same gap, comparing
against the remote HEAD instead of the installed branch.

Group batch updates and web UI checks by URL+branch, pass the branch through
to the clone, and resolve remote tree hashes for that branch as well.

Refs #268
2026-09-02 13:08:40 +08:00
Willie 0a3e669b09 fix(audit): decouple audit override from Force so --force reaches the gate
InstallOptions.Force carried two meanings: "overwrite what is already
there" and "proceed despite audit findings". Update paths set Force
unconditionally to overwrite a staged temp dir, so they had to leave it
off to keep the audit gate alive -- which swallowed the caller's --force
and made the gate impossible to override from either the CLI or the web
UI.

Split the audit intent into InstallOptions.AuditOverride and route every
gate through it alone. Entry points translate --force explicitly, so a
missed one degrades to "force has no effect" rather than "audit is
bypassed". Scan failures stay fail-closed regardless: accepting known
findings is not the same as being unable to learn any.

This also closes two paths that bypassed the gate outright, since both
inherited Force for overwrite reasons alone: install --json and grouped
batch updates.

In the web UI, Force Retry now appears only on failures force can
actually resolve -- a permission-denied unlink previously offered a
button that could never succeed -- and CLI-only flag hints are stripped
from messages rendered there.

Behaviour change: a --force at install time no longer exempts later
updates from the audit gate; it is a one-off decision per command.
2026-08-27 17:10:29 +08:00
Willie 54dd7d12a3 fix(update): surface missing tracked repos in update --all across CLI, API, and UI
When tracked repo metadata is committed but the gitignored clone dirs are
absent on a fresh machine, `update --all` silently reported zero work: the
batch path skipped missing repos with no message, and the web UI's
update-all paths only listed repos present on disk.

Missing tracked repos are now detected and surfaced everywhere:
- CLI: a warning block (human output) plus an aggregated
  `missing_tracked_repos` summary (names + one-shot rehydrate hint) in JSON;
  the per-item error is concise. Fixed for both global and project modes,
  and batch and single-target paths.
- Server: GET /api/update/missing-tracked-repos and the update-all/stream
  summaries report them; POST /api/update/rehydrate re-clones them from
  metadata (mirrors bare `skillshare install`).
- UI: the Update page shows a warning banner listing missing repos with a
  Rehydrate button; strings added to all 11 locales.

Closes #212
2026-06-11 15:32:28 +08:00
Willie 56fafb53e0 fix: preserve update metadata keys for symlinked sources 2026-05-12 21:10:08 +08:00
Willie e91890d2b0 test: fix all integration tests for centralized .metadata.json format
- Dual-write in WriteMeta: also writes to .metadata.json for backward compat
- Migration looks in parent dir for registry.yaml
- Group uninstall matches entries by Group field + full path
- Sync test uses MetadataStore instead of registry.yaml
- All integration tests pass (0 FAIL)
2026-04-08 14:28:57 +08:00
Willie 34ecba48ee test: stabilize make test under updated audit rules 2026-03-03 16:08:11 +08:00
Willie f8205a27a8 refactor(install): prefer sparse checkout over GitHub API for subdir install
Swap fast path order: sparse checkout is now fast path 1 (works for all
hosts including file://), GitHub Contents API is fast path 2 (fallback
when sparse is unavailable or fails). Also reset subdirPath on sparse
failure to ensure proper fallback chain.

Fix red team helpers to inject -g flag after subcommand, preventing
.skillshare/ auto-detection from hijacking global-mode tests.

Add blocked section assertions to TestUpdate_BatchAll_FailsOnMalicious.
2026-02-25 07:02:54 +08:00
Willie 70502ecd44 refactor(ui): compact audit findings display with grouping and risk score
- Rewrite renderInstallWarnings with summary-first layout: counts + threshold status on top
- Group duplicate findings by (severity, message), show "× N" with locations
- Strip redundant "audit " prefix under Audit Findings section
- Show compact top-5 groups by default, full list with --audit-verbose
- Add renderAuditRiskOnly for batch mode (just risk score)
- Wire update single-item/batch paths (global + project) to shared renderers
- Remove renderUpdateAuditResult (all callers migrated)
- Update test assertions for new output format
2026-02-24 01:47:38 +08:00
Willie cd5902c590 feat: unify update audit threshold gate and docs 2026-02-23 04:18:01 +08:00
Willie 3ad814d3ba fix: add audit gate to install --track and tracked repo updates
InstallTrackedRepo and updateTrackedRepo had no security audit,
allowing --track to bypass all supply-chain checks. This adds
auditTrackedRepo (removes repo on block for fresh installs) and
auditTrackedRepoUpdate (git reset rollback for updates), plus
input validation, testable removeAll, and hardened error handling
across audit/install/uninstall paths.
2026-02-23 04:18:01 +08:00
Willie 2171dc4db0 feat: add --diff and audit visibility for regular skill updates
Regular skills (non-git, metadata-based) now support --diff flag using
hash-based file comparison, display audit results after update, and
properly enforce the audit gate by not passing Force to inner Install.
2026-02-23 04:18:01 +08:00
Willie a0bfe9958a fix: batch update error propagation, skip-audit passthrough, and security hardening (#39)
- P1: Batch/all update now returns non-zero when repos are blocked by
  security audit (fail-closed for CI pipelines)
- P2: Pass --skip-audit to regular skill update via InstallOptions
- P2: Add path containment check in content integrity to prevent
  directory traversal via crafted file_hashes keys
- P3: Switch git diff parsing to NUL-delimited (-z) for safe handling
  of special filenames
2026-02-23 04:18:01 +08:00
Willie a5f84c2485 feat: auto-audit gate after update with rollback and --diff summary (#39)
Supply-chain hardening Phase 2:
- Add post-pull audit gate: HIGH/CRITICAL findings auto-rollback in
  non-interactive mode (fail-closed), prompt in TTY mode
- Use full 40-char commit hashes for reliable rollback (avoids short-hash ambiguity)
- Add --skip-audit flag to bypass the gate when risk is accepted
- Add --diff flag to show file-level change summary after tracked repo update
- Add GetChangedFiles() and ResetHard() git helpers
- Add audit gate in install --update git-pull path to prevent bypass
2026-02-23 04:18:01 +08:00
Willie 15e2b6db58 fix: add HTTPS token auth to update pull paths 2026-02-21 06:07:35 +08:00
Willie a202557192 feat(update): support multiple names and --group/-G flag
Allow `update` to accept multiple positional names and a repeatable
`--group/-G` flag, matching the UX already available in `uninstall`.

- Add `updateOptions` struct and `parseUpdateArgs` (mirrors `parseUninstallArgs`)
- Add `resolveGroupUpdatable` to walk a group dir for updatable items only
  (tracked repos or skills with metadata; local skills silently skipped)
- Add `isGroupDir` to auto-detect positional args that are group directories
  (checked before basename resolution so "feature-radar" expands the group
  rather than matching the nested "feature-radar/feature-radar" by basename)
- Refactor `cmdUpdate` (global) and `cmdUpdateProject` (project) to use the
  shared parser and support batch updates
- `--all` is mutually exclusive with names/groups
- Project mode preserves default `--all` when no args given
- 10 new integration tests (8 global + 2 project)
- Update docs with multi-name, --group examples and options table
2026-02-20 13:10:46 +08:00
Willie Hung 4af34fe695 feat: rename update to upgrade with CLI self-update support
- Rename `update` command to `upgrade`
- Add CLI binary self-update from GitHub releases
- Add `--cli` and `--skill` flags to upgrade specific components
- Detect Homebrew installation and use `brew install` instead
- Refactor SKILL.md with progressive disclosure pattern
- Split references into separate files (status, sync, install, etc.)
- Move run.sh to skills/skillshare/scripts/
- Fix --update flag to auto-reinstall when git pull not possible

BREAKING CHANGE: `skillshare update` is now `skillshare upgrade`
2026-01-16 22:12:03 +08:00
Willie Hung 4337bf7890 feat: add update command for built-in skill
- Add `skillshare update` to download latest skill from GitHub
- Download skill during init with fallback if offline
- Remove embedded template approach
- Add integration tests for update command
- Update README with update command docs
2026-01-16 00:52:31 +08:00