13 Commits
Author SHA1 Message Date
Willie 310478c28d fix(ui): fetch each repository once when the dashboard updates skills (#931)
* fix(ui): fetch each repository once when the dashboard updates skills

Updating many skills from the Updates tab cloned the repository once per
skill and reinstalled every one, so 31 skills from 8 repositories took over
a minute where `skillshare update --all` takes 16 seconds, and unchanged
skills were reported as updated.

The update stream and the update-all endpoint now group the request's
skills by repository and branch and go through install.UpdateSkillsFromRepo,
as the CLI does. A skill that already matches upstream is left alone and
reported as up to date; the Updates tab shows and counts it that way.
Results still arrive in request order, which the dashboard relies on.

Updating a single skill and switching its branch still reinstall. Those
paths now also pass the configured parse options to the installer.

* fix(ui): keep checkouts and recorded sources when updates share a fetch

Grouping a dashboard update by repository sent every skill through the
discovery installer. A root skill kept as a Git checkout was replaced by
a plain copy, losing its repository, and an updated skill had its source
recorded in the repository's canonical spelling, which a project
declaration written with another spelling no longer matches.

A checkout now updates on its own by pulling, as before, and an updated
skill keeps the source its record had, as updating one skill does.
2026-11-17 02:43:57 +08:00
Willie 7a7cceefab feat(update): flag and protect skills edited since install (#622)
* feat(update): flag and protect skills edited since install

A skill installed from a repository and then edited by hand looked
exactly like an untouched one: check said up to date, and update either
reported it current or silently reinstalled it over the edit (#621).

Install already records each file's hash, so check now compares a
remote skill's files with those hashes and reports "modified", and
update skips such a skill until --force (CLI single, --all/--group,
dashboard). --force, the dashboard's Force Retry on the skipped row, or
the confirmation on the skill page discards the edit and reinstalls.

Two hash paths had to be made reliable for this to be trusted: the
dashboard's folder-wide target edit refreshed hashes by basename, so a
nested skill looked edited after skillshare's own change, and a skill
whose files cannot be hashed now counts as modified instead of being
overwritten.

* fix(server): keep earlier local edits when a target change rewrites SKILL.md

Changing a skill's targets in the dashboard rewrites its SKILL.md, and
both the folder-wide and the single-skill handler then re-hashed the
whole directory as the new baseline. An edit the user had already made
to any file in the skill was absorbed into that baseline, so the skill
stopped counting as modified and the next update overwrote the edit
without --force.

Both handlers now move only SKILL.md's recorded hash, and only when the
file still matched it before the rewrite. skillshare's own target edit
no longer reads as a local change, and an earlier edit still does. The
whole-directory refresh helpers lost their last callers and are removed.
2026-10-24 16:33:37 +08:00
Willie e3af6274fc feat(install): install config entries from the dashboard and name repos by owner
Bare `skillshare install` already restores everything .metadata.json records
but the disk lacks, yet the dashboard could only re-clone missing tracked
repos through a separate rehydrate path. Expose the CLI's install-from-config
flow instead (GET /api/install/missing, POST /api/install/from-config) so both
surfaces share one detection and one installer, and drop the old
missingTrackedRepos plumbing from update responses.

The install summary now counts tracked repos and their skills apart from
standalone skills, since "Installed 1 skill" hid a whole repo. New tracked
repos are named `_<owner>-<repo>` so two `skills` repos no longer collide;
existing installs keep their names. `check` passes the stale status through
so the dashboard can offer to prune skills deleted upstream.
2026-10-08 12:01:42 +08:00
Willie 2edf7649fd refactor(update): update tracked repos through one shared operation
Updating a tracked repo is a fail-closed sequence: check for uncommitted
changes, pull, audit what was pulled, reset to the pre-pull commit when the
audit blocks. The CLI had two copies of the pull flow, the dashboard a third,
and the audit gate existed four times (CLI, dashboard, and two in install).
The copies had drifted: the dashboard ignored a failed git status and never
refreshed root-skill metadata, and each copy worded a failed rollback on its
own.

update.TrackedRepo now owns the sequence and returns a structured result;
install.AuditGate is the only gate. internal/update is a new package because
internal/git already imports internal/install. The CLI keeps its spinner,
rows and the "Apply anyway?" prompt, passed in as one Confirm callback; the
dashboard turns the result into its JSON item.

Behaviour changes, all towards the stricter copy:
- the dashboard reports a failed git status as an error instead of pulling;
- the dashboard refreshes root-skill metadata after an update, like the CLI;
- a prompt that fails rolls the update back instead of leaving it applied;
- the rollback-failed and rollback-unavailable texts come from one place.

Accepted findings stay as they were (CLI honours and records them, the
dashboard does neither), now as the explicit AcceptedFindings input. The
"blocked and rolled back" texts are unchanged per caller because the
dashboard matches on them.

Refs #443
2026-10-07 00:10:54 +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 0e091a5e63 fix: refresh metadata after nested skill updates 2026-05-26 13:37:47 +08:00
Willie 5975c1109a test: add regression tests for azure_hosts wiring in project install and agent update
- TestParseOptsFromConfig_IncludesAzureHosts: verify global config
  helper passes AzureHosts to ParseOptions
- TestParseOptsFromProjectConfig_IncludesAzureHosts: verify project
  config helper passes AzureHosts
- TestParseOptsFromProjectConfig_AzureHostsParseOnPrem: end-to-end
  verify project config azure_hosts produces correct on-prem CloneURL
- TestUpdateAgent_AzureOnPrem_UsesParseOpts: verify server agent
  update handler parses on-prem Azure source via ParseSourceWithOptions
2026-05-05 19:26:11 +08:00
Willie 115edf3f24 fix(server): correct project-mode gitignore path + prevent registry prune basename collision
P2-1: handleUninstallRepo and handleBatchUninstall used s.cfg.Source for
gitignore removal, but project-mode installs write to .skillshare/.gitignore
with a "skills/" prefix. Add gitignoreDir() helper that returns the correct
base directory per mode, and prefix entries in project mode.

P2-2: Registry prune used filepath.Base(repoName) to derive the legacy group,
causing sibling nested repos (e.g., org/_team-skills vs dept/_team-skills) to
collide on the same basename. Now uses exact Group match for nested repos and
restricts legacy basename matching to top-level repos only.

Tests added (15 new):
- resolveTrackedRepo: auto _ prefix, nested, already-prefixed, not-found,
  basename fallback
- Registry prune: full-path Group, nested members by prefix, sibling isolation
- Project-mode gitignore: single + batch uninstall
- updateSingle: basename fallback, not-found, regular skill priority
- cleanEmptyParents: multi-level, stops at non-empty, stops at boundary
2026-04-04 17:05:22 +08:00
Willie a4984cd322 fix(server): resolve nested repos in update + prune registry on uninstall
P1: updateSingle now uses resolveTrackedRepo (shared with uninstall)
to find nested tracked repos like org/_team-skills instead of only
probing root-level _name/name.

P2: handleUninstallRepo now prunes registry entries belonging to the
uninstalled repo and runs ReconcileGlobalSkills/ReconcileProjectSkills,
matching the cleanup that handleUninstallBatch already does.

Extracted resolveTrackedRepo as a Server method to deduplicate the
nested path resolution logic between uninstall and update handlers.
2026-04-04 17:05:22 +08:00
Willie cd5902c590 feat: unify update audit threshold gate and docs 2026-02-23 04:18:01 +08:00
Willie bd76ec9aa5 feat: surface audit risk score in update API and UI
Return auditRiskScore and auditRiskLabel in update results so the
dashboard can show security posture after both tracked-repo and
regular-skill updates. auditGateTrackedRepo now returns the audit
result alongside the blocked indicator.
2026-02-23 04:18:01 +08:00
Willie a03e5a8e20 test: add isSecurityError unit test and server audit gate rollback failure tests
- cmd/skillshare/update_test.go: table-driven test covering all
  isSecurityError keywords (security audit, post-update audit,
  rolled back, rollback failed) and negative cases
- internal/server/handler_update_test.go: three tests for
  auditGateTrackedRepo: rollback failure warning on HIGH findings,
  rollback failure warning on scan error, and clean repo returns nil
2026-02-23 04:18:01 +08:00