32 Commits
Author SHA1 Message Date
3217d44881 fix(reconcile): keep tracked repo declarations this machine has not cloned (#880)
* test(install): reproduce loss of pulled tracked records

Exercise the two-machine push and pull sequence and reconciliation states so
missing tracked clones cannot silently erase shared install intent.

* fix(reconcile): preserve tracked records missing local clones

Pull transfers tracked repository metadata but not ignored clones. Keep the
missing records during global reconciliation so another install and push cannot
erase shared intent or accepted audit findings on every machine.

* test(reconcile): isolate tracked record fixtures

Use the shared sandbox fixture for both reconciliation tests so their home
and configuration paths remain isolated from the invoking environment.

* fix(reconcile): retain all sourced tracked declarations

Legacy tracked members and unfollowed source links can hide declarations
from the local walk. Preserve sourced tracked records regardless of their
path so unrelated installs cannot erase them or their audit acceptances.

Document restoring a missing checkout before uninstalling it and cover
migration, link collisions, aliases, and explicit removal.

* test(reconcile): drop fixtures existing tests already pin

The tracked-record unit test also seeded a missing plain record and a
live plain record. TestReconcileGlobalSkills_PrunesStaleEntries already
pins both outcomes: a sourced plain record whose folder is gone is
pruned, and one on disk survives. The tracked record with no source
still catches a fix that keeps everything or skips the prune.

The two-machine test passed HOME and SKILLSHARE_CONFIG to RunCLIEnv,
which already sets both from the sandbox for each child process.
Separate homes, XDG paths, client overrides and git config remain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(reconcile): retain tracked entry for unavailable link

Expect sourced tracked declarations to survive reconciliation with either
source-link policy, so the test matches the cross-machine retention contract.

* fix(config): prune legacy tracked members

Retain only sourced tracked repository declarations during reconciliation.
Migrated member records are not restorable as repositories and retaining them
would leave permanent misleading install requests and audit acceptances.

* fix(reconcile): preserve tracked intent across followed links

A source link can exist before a tracked repository declaration is pulled. Preserve that declaration when the linked folder is not a checkout so later reconciliation does not discard its record and audit acceptances.

* test(reconcile): cover grouped followed declarations

A followed group can contain the path of a pulled legacy repository declaration, which must retain its tracked intent while its key migrates.

* fix(test): scope collision fixture runner correctly

Keep the isolated CLI runner in the collision subtest that uses it so the integration test package can compile.

* docs(manifest): clarify tracked checkout recovery

A retained declaration cannot restore a checkout while another folder or source link occupies its destination, and restoration requires a reachable source. State those prerequisites in each manifest translation.

* fix(config): prune members under recorded repositories

A migrated underscore-named member can otherwise survive a missing checkout as a repository declaration. Check recorded ancestor paths while preserving ambiguous grouped declarations and unrelated aliases.

* docs(manifest): restore fresh-clone project guidance

Explain that project declarations without local install records remain available so teammates can install them after cloning.

* refactor(reconcile): drop the tracked-intent walker policy

Restore baseline normalization for present paths while retaining absent
repository declarations through the shared metadata predicate. Isolate the
reconcile fixtures without building a CLI and share native-client overrides
without changing the original two-machine record and audit regression.

Validation: gofmt, git diff --check and context-router check only.
Runtime, builds and tests were not executed under the source-only gate.

* fix: forget linked checkout records and declarations without checkouts

Extend the metadata and uninstall owners to remove a declaration without
reading or moving its occupant, contacting its source, or changing trash
and gitignore. A failed metadata save makes every metadata-only result fail.

Clean up global unlink records in CLI and API, preserve existing-path name
precedence, report record-only results truthfully, and list declarations in
the dashboard API with noCheckout. Keep project removal behavior unchanged.
Remove the obsolete grouped-link walker-policy assertion while preserving
grouped absent declarations and the original record/audit A/B regression.

Validation: source-only five-pass review, gofmt, git diff --check and the
context-router check. No runtime, builds, tests or frontend tooling ran.
Stop at commit 15 for the mandatory Luna checkpoint before UI and docs work.

* fix(server): reload metadata before removing declarations

Preserve CLI records and audit acceptances written while the dashboard is open. Resolve new declarations from disk and refuse stale-cache saves after a reload failure, retaining unlink success when its link already moved.

* feat(dashboard): remove a tracked repository record without a checkout

Show declaration-only rows without checkout actions or status promises. Reuse Uninstall with record-specific confirmation and feedback, keep real-checkout force handling, and refresh the missing-entry list after repository removal or unlink.

* docs: explain kept declarations and how to remove them

Document direct global declaration removal and optional restore in English and all four translations, including occupied paths and normalization after reconcile. Keep built-in guidance accurate and use the existing API removal result for dashboard success feedback after concurrent CLI changes.

* fix(dashboard): confirm restored checkouts after forceable refusals

A tracked declaration can be restored through the CLI while its dashboard
row still says there is no checkout. Treat a forceable uninstall refusal
as evidence of the current checkout and promote the existing confirmation
to its dirty or unreadable-status warning before allowing explicit force.

Author stale-row regressions for both forceable codes before the source
repair, and retain nonforceable failure and actual-result success feedback.
Validation: five serial source review passes, git diff --check, and the
context-router check. Tests, builds, runtime and frontend tooling were not
run under the source-only gate.

* test(server): persist overview declarations before routed request

The overview fixture added declarations only to the in-memory skills store,
which the real request's config reload replaced with on-disk metadata. The
hosted unit, offline, and Nix jobs consequently returned no tracked rows.

Save the complete fixture through MetadataStore before serving the request
and fail setup on a save error. Keep the middleware, assertions, and
production behavior unchanged.

* fix(server): prefer exact declarations before checkout shorthand

Removing a missing _team declaration from the dashboard could resolve the
different org/_team checkout by basename and trash it instead.

Reload metadata before declaration lookup, give exact declarations priority,
and preserve checkout resolution before non-exact declaration fallback.
Add routed absent/occupied regressions and checkout precedence guards, and
persist existing checkout fixtures so the metadata reload keeps their state.

Validation: gofmt, git diff --check, and context-router check passed.
Tests were authored but not run under the source-only fleet restriction.

* fix: preserve removal intent and report partial failures

Bind dashboard record-only removal to its canonical declaration and refuse
restored checkouts before checkout resolution or force. Refresh the row and
require another confirmation before moving a restored checkout to trash.

Keep unresolved uninstall inputs and their reasons in JSON failed results,
including all-invalid requests, partial successes and dry runs. Report unlink
metadata cleanup failures as partial results, refresh completed unlinks and
show localized warnings. Keep CLI and dashboard guidance aligned.

Regression tests were authored before source changes and remain unrun under
the source-only task restriction. Static formatting, diff and router checks
passed; no build, product runtime, frontend tooling or test suite was run.

* fix(unlink): log partial metadata cleanup failures

Write the unlink result after global metadata cleanup so load and save
failures retain their diagnostic and report partial success. Preserve the
successful link removal, warning, target and exit policy, and the existing
link, project unlink and native removal failure behavior.

Add the corrupt-metadata regression before the fix; leave it unrun under
the source-only authorization. Formatting, diff and context-router checks
pass; runtime verification remains with the coordinator.

* fix(unlink): forget records below the removed link name

Reconcile can normalize a followed link's record to untracked, and linked
collections can retain nested repository declarations. Clean the removed
namespace through the existing metadata path owner in both unlink callers,
including audit acceptances, while keeping declaration uninstall strict.

Author CLI and route regressions before the source fix for normalized and
nested records, sibling preservation, and subsequent bare install. Tests
remain unrun under the source-only task restriction; static checks only.

* fix(uninstall): refuse a restored checkout at execution

A declaration selected while absent can become a checkout before removal
runs. Recheck the resolved source-relative name in the shared metadata-only
execution owner and refuse before touching metadata, regardless of force.

Reuse the existing dashboard conflict response and refresh/reselection flow
for this refusal, preserving the earlier record-only intent guard. CLI
results already carry shared execution failures through text and JSON.

Author restoration, force, absent/occupied control and client boundary
regressions before production edits. Correct the unlink fixture name and
response-key assertion found in serial static review. All tests remain
unrun under the source-only restriction; formatting/diff/router checks pass.

* refactor(server): consolidate repository uninstall result handling

Resolve a declaration or checkout to one item and canonical name before
using the existing uninstall, conflict, log and success response tail.
Keep metadata-only removal unforced, preserve its error and cache recovery
behavior, and report movedToTrash from the selected item.

Preserve exact declaration precedence, record-only checkout refusals,
ordinary checkout errors and project behavior without changing tests.
Five serial source review passes, gofmt, diff checks and the context-router
check completed. Tests and builds remain unrun under the source-only brief.

* fix(unlink): preserve independent records and trash undo metadata

Limit unlink's legacy group matching to members so a retained declaration
such as team/_repo survives unlinking _team. Share snapshot and removal
matching while keeping generic uninstall's legacy contract unchanged.

Save the exact removed records, audit acceptances and target overrides
through uninstall's existing trash sidecar owner before pruning metadata.
Keep metadata on sidecar failure and preserve completed-unlink warnings,
fresh reloads, cache refresh and project-mode behavior.

Author owner, CLI and API regressions for namespace collisions, undo,
partial failures and project/empty controls. Source-only verification:
gofmt, diff check and context-router check passed; runtime tests, builds,
frontend checks and final make check remain unrun for root-owned gates.

* fix(install): preserve independent tracked declarations

Limit declaration-only cleanup to the precise namespace and legacy members already used by unlink. Keep independently installed prefixed repositories, their audit acceptances, and overrides when forgetting a missing checkout.

* fix(cli): explain missing tracked repository recovery by mode

Offer global record removal when restoring an unreachable source is unwanted. Keep project recovery scoped to install -p, share the hint with doctor, and align update documentation in every existing locale.

* refactor(uninstall): share declaration and unlink operations

Keep declaration resolution and unlink metadata ordering in shared owners so CLI and API preserve the same scope and recovery behavior. Consolidate domain regressions while retaining caller translation coverage.

Distinguish record-only removals in API and CLI operation logs and CLI JSON, including mixed batches and dry runs. Document outcome fields, warning semantics, and current API error codes across existing locales.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Willie <egg358358@gmail.com>
2026-11-14 13:11:27 +08:00
Willie 769087b882 fix(project): keep config.yaml true after reinstall, uninstall and fresh-clone installs (#860)
In project mode the committed config.yaml is what teammates install from, but
it could disagree with what a machine actually has (#858):

- `uninstall -p` and the dashboard's single-skill and tracked-repo removal
  left the skill's entry in config.yaml, so a later `install -p` brought it
  back. They now drop the entry and the lock pin through one shared
  config.ForgetProjectSkills, as the uninstall docs already promised.
- Installing a skill again from another source or branch (after an uninstall,
  or over the copy with --force) updated only the gitignored .metadata.json.
  config.yaml kept the old source and skills.lock.json ended with the old
  source and the new commit. Installs from a named source (CLI install,
  search, dashboard) now compare the records from before and after the
  command and let the config entry follow the skills it actually reinstalled.
  Install from config never rewrites an entry from local records, so a
  teammate's edit survives on a machine that has not updated yet.
- Reconcile removed every config entry that had no folder and no record. On a
  fresh clone nothing is installed yet, so `install <source> -p` deleted all
  the other declared skills. An entry now goes only when the skill was
  installed here and its folder is gone, when it was moved, or when a command
  removed it; `move` passes the old paths and `update --prune` cleans the
  config itself.
2026-11-11 22:42:03 +08:00
Willie f9ed43611d fix: keep git folders inside a tracked repo out of repo uninstall
Batch uninstall treated any name whose last segment starts with "_" and
is a git checkout as a tracked repo. A submodule such as
_team/vendor/_lib inside a tracked repo matched, so the dashboard could
move it out of the repo's checkout, leaving the repo dirty for update.
The fallback for "_"-prefixed names had the same hole before --into
support. --into folders cannot start with "_" (validate.IntoPath), so a
repo name may have "_" only in its last segment; both checks now use
that rule.

Also, the list TUI gave the root skill of an --into repo (RelPath equal
to RepoName, e.g. org/_team) the group "org"; it now has no group, like
a top-level repo's root skill.
2026-10-07 21:41:43 +08:00
Willie c9b649143d refactor: return slash repo paths and simplify --into repo lookup
GetTrackedRepos returned OS-native paths, so every caller that compared
them with slash paths (RepoRelPath, dashboard repoPath, metadata keys)
had to convert first. Two callers in install_queries already did, and
this branch added four more. It now returns slash paths on every OS,
matching GetMissingTrackedRepos; filepath.Join and filepath.Base accept
them on Windows, and `update org/_repo` now also matches by full path
there. The per-call-site conversions are gone.

Smaller cleanups in the same code:
- repoOf takes the slash relPath and looks up prefixes by substring, so
  the walk no longer splits and joins per directory;
- repo .skillignore matchers are keyed by the same slash rel path, so
  isSkillIgnored no longer needs walkRoot;
- batch uninstall uses utils.IsTrackedRepoDir instead of a literal "_";
- the dashboard uses repoOf where it spelled out isInRepo && folderOf;
- the new tests reuse postBatchUninstall and share one --into sandbox.
2026-10-07 21:35:05 +08:00
Willie 4dd62d4ce5 fix: treat tracked repos installed with --into as repos
`install --track --into org` clones to org/_repo, but skill discovery
only marked a skill as in-repo when the first path segment started with
"_". Everything downstream also assumed the repo name was that first
segment. Skills of such a repo were therefore treated as loose skills:
no source in the dashboard, not grouped under the repo, a skill count of
0 in `status`, and an install hint that pointed at the wrong name.

Discovery now records each skill's tracked repo root (RepoRelPath). A
first-segment "_" folder still counts as before; a deeper one counts
only when the walk saw it as a git clone, so a plain org/_drafts folder
stays a folder. The repo's .skillignore is looked up by the same root.

Consumers move from "first segment" to that root:
- the API exposes it as repoPath, and the dashboard groups, updates and
  uninstalls repos by it;
- `list` and `status` use it for repo names and counts;
- batch uninstall accepts a nested repo name, so the dashboard can still
  remove an --into repo now that its skills are in-repo;
- repo names sent to the dashboard by check and update-all use slash
  paths, so they match repoPath on Windows too;
- the install hint suggests `skillshare update org/_repo`.

Fixes #470
2026-10-07 21:23:26 +08:00
Willie 2e9f14da49 feat(ui): let the dashboard force a refused tracked-repo uninstall
DELETE /api/repos/{name} now refuses a repo with uncommitted changes or
unreadable git status, and the Dashboard page never sent force, so those
repos could not be removed from it at all.

The two refusals force overrides now carry their own error code. The
page still sends the first request without force; on either code the
confirmation says why and retries with force only when the user
confirms. Other refusals, such as a linked folder that is itself a
skill, keep the plain error because force does not change them.

Refs #442
2026-10-07 00:35:03 +08:00
Willie 764ca7f9c0 fix(uninstall): keep a grouped skill's legacy metadata key on review
Review of the shared uninstall operation found that RemoveByNames still
matched a bare key: removing top-level "foo" pruned the legacy entry
"foo" with Group "frontend", which belongs to the installed
frontend/foo. Entries are now matched by their full path only.

Also from review: a dry run no longer runs git status for tracked
repos (it reports no git state), the unused Outcome.Removed is gone,
the two single-item handlers share one status mapping, and the CLI
reports a single target in one place instead of three flag checks.

Refs #442
2026-10-07 00:20:20 +08:00
Willie 4c6d152abf refactor(uninstall): run the CLI and dashboard through one operation
The uninstall sequence (move-out check, dirty check, move to trash,
.gitignore cleanup, metadata prune) lived in the CLI and in three
dashboard handlers, and the copies had drifted: three different prune
rule sets, no dirty check on DELETE /api/repos, and no metadata prune
at all on DELETE /api/resources, which left the removed skill's entry
and target overrides in .metadata.json.

internal/uninstall now owns the sequence for resolved items. Callers
keep name resolution, prompts, output, HTTP status and oplog.
MetadataStore.RemoveByNames is the single prune rule set: an entry goes
when it is a removed path or lies below one, by key or by Group, plus
the tracked legacy group of a top-level repo.

Behaviour changes, all intended:
- DELETE /api/repos/{name} refuses a dirty tracked repo, or one whose
  git status cannot be read, with 409 unless ?force=true.
- DELETE /api/repos/{name} refuses a followed link whose folder is
  itself a skill, like every other uninstall path.
- DELETE /api/resources/{name} prunes the skill's metadata.
- Removing top-level "foo" no longer prunes "frontend/foo" (CLI), and
  removing repo "_team" no longer prunes the untracked group "team"
  (dashboard batch); both dropped metadata of skills still installed.

Refs #442
2026-10-07 00:13:47 +08:00
Willie cd6e0165dd fix(uninstall): refuse skills at followed link roots
A root skill discovered through a followed source link occupies the link entry itself. Moving that entry to trash silently unlinks every nested skill instead of removing one skill.

Share the root-skill guard across single and batch API handlers and CLI uninstall, report the unlink action clearly, and preserve explicit unlink and nested skill removal.
2026-10-05 20:02:58 +08:00
Willie 3ad3af713f fix(server): resolve uninstall names without basename collisions
Prefer exact skill flat names and reject ambiguous basename fallbacks in both uninstall handlers. Route explicit managed repositories before basename lookup so a followed checkout cannot hijack removal of a root skill or repository.
2026-10-05 18:27:12 +08:00
Willie db45b0db06 fix(server): uninstall individual skills from followed links
Resolve followed skills with the discovery policy before applying tracked-repo restrictions or prefix-based batch routing. This lets dashboard uninstall move only the selected skill from a followed checkout while retaining managed-repo protection and logical trash restore paths.

Add single and batch handler regressions for global and project modes, skipped links, and tracked-repo members; document the API behavior.
2026-10-05 18:27:12 +08:00
Willie a502e9316b feat(sourcefs): write through followed first-level source links
With follow_source_links on, discovery reports <source>/_dev-skills/foo,
but every write to it was refused: sourcefs rejects a link in the path, and
its source-root os.Root refuses descendants outside the source. Dashboard
edits, nested uninstall, regular skill replacement, and tracked installs
under such a link all failed, although writing through a link the user
placed is the agreed behavior (#410).

sourcefs.Open, Create, MkdirAllIn, and CheckMoveOut take the operation's
optional sourcewalk.Follow. A clean name <link>/<rest> whose first
component the policy follows is handled by a second os.Root opened at the
link's canonical target, with the same per-component link check on <rest>,
so a nested link or ".." still cannot escape the target. Names with ".."
keep the source root, which refuses them through the link. Without a
policy nothing changes.

The link entry itself stays a link: RemoveAll, Rename, and writes on it are
refused, install --track --force still refuses to replace it, and
CheckMoveOut still lets trash rename the link without following it.
MkdirAll on a followed link is a no-op, since it already is that directory;
install --into needs that. A rename across the link boundary is refused.

The install, update, uninstall, and server callers pass the same policy
their discovery uses, through InstallOptions.SourceFollow and the update
context. No raw-write allowance was needed.

Refs #274
2026-10-05 14:42:09 +08:00
Willie 89fc4fbdf1 feat(sourcewalk): follow first-level source links when enabled
Users link a checkout directly under the skills source (e.g.
skills/_dev-skills -> ~/code/dev-skills) and expect it to behave like any
other first-level entry. sourcewalk resolved only the root, so these links
were invisible to discovery, sync, update, and the dashboard.

follow_source_links (global and project config, default false) enables a
per-operation sourcewalk.Follow policy. Walk, WalkDir, and ReadDir report a
followed link under its own name as a directory and descend into its
target, so names, RelPath, FlatName, SourcePath, tracked-repo detection, and
metadata keys stay logical. Only entries directly under the source root are
followed. The policy is built from config and passed explicitly to every
discovery caller in the CLI, server, and reconcile, so counts agree; the
server keeps a per-instance snapshot refreshed on config load and save
instead of a process-global flag.

A link is skipped, with one warning per operation, when its target is
missing or unreadable, is the source or a parent of it, or overlaps an
active skills target. A missing or unreadable target marks the operation
incomplete: sync then skips pruning and copy-orphan deletion, and reconcile
keeps metadata, so an unmounted drive or a re-clone in progress cannot
erase target entries or install records. A link to an existing file is not
a directory link and stays an ordinary entry; treating it as incomplete
would disable pruning for anyone sharing a file such as .skillignore.

doctor keeps raw link identity: with the key off it still says the link is
not followed and names follow_source_links: true; with it on it reports
followed links and skipped links with the reason.

The raw-walk allowlist gains entries for the policy path in Walk and
WalkDir: the source root walk with a policy, and the walk of a validated
link target whose paths are remapped to the logical link path. Both live
in sourcewalk itself, the package that owns source traversal.

Refs #274
2026-10-05 14:26:09 +08:00
Willie c61f48865e fix(server): reject skill names that escape the skills source (#408)
GET /api/audit/{name} joined the client-supplied name to the source
without checking it, so a name such as ../../x scanned a directory
outside the skills source and returned a clean result for it. The
single-skill update, the update stream, and the batch uninstall built
paths the same way; the tracked-repo uninstall route already refused
such names inline.

One helper, validSourceName, now holds that rule: non-empty, relative,
not starting with "..", and no Windows separators or volume prefixes on
any host, as sourcewalk does for declared names. The audit and update
routes answer 400, the update stream reports the name as an error
result, the batch uninstall fails that item, and the repo uninstall
route uses the same helper. Nested names such as group/skill still
resolve.

Closes #402
2026-10-05 11:03:39 +08:00
Willie 8c60f51b9f feat(source): add the sourcewalk walker and sourcefs write boundary for proposal 274 (#385)
Implements rollout steps 1 and 2 of proposals/274-skillfollow.md. Nothing follows a link or parses .skillfollow yet.

Step 1: doctor reports first-level symlinks and junctions in the skills source as info, in text and JSON, without following them.

Step 2a: internal/sourcewalk owns traversal of the skills source. Thirteen raw walks move onto it with identical behavior, and a go/parser ratchet fails the tests on any new unclassified walk.

Step 2b: internal/sourcefs wraps an os.Root opened at the skills source and refuses any write whose path has a link component. The six write sites the proposal found in review move onto it, including the cross-device copy fallback, and a second ratchet covers raw os write calls. The only behavior change is that an explicit path crossing a link inside the source is refused instead of written through.

Refs #274

Release-As: 0.24.3
2026-10-04 15:15:43 +08:00
Willie 36a314442b refactor(server): decode JSON request bodies through one size-limited helper
About 57 handlers decoded request bodies with no size limit, and the few
that had one each picked their own. They now go through decodeJSON with a
1 MiB default; handlers that need more keep their larger limit. An
oversized body gets 413 instead of whatever the handler returned for bad
JSON (MCP and plugin requests used to answer 400). Every other decode
error keeps the handler's existing status and message.
2026-09-30 02:25:42 +08:00
Willie 6a325037f2 refactor(server): share the skills config reconcile step
Install, batch install, tracked-repo install, uninstall and rehydrate
each repeated the same nine-line block to reconcile the project or
global skills config. reconcileSkillsConfig now holds that block, so a
change to reconcile behavior or logging is made once instead of five
times. Each caller still passes its own source directory, so behavior
is unchanged.
2026-09-30 01:35:10 +08:00
Willie 20ae89a838 fix(server): stop dropping git and metadata errors in check, uninstall and batch targets
The dashboard check reimplemented the CLI's per-repo check but fetched
without the HTTPS token and ignored git status errors. Private tracked
repos could fail in the dashboard while `skillshare check` worked, and a
repo whose status could not be read showed as up to date. Both check
endpoints now call check.ParallelCheckRepos, the same code the CLI uses.
The JSON and SSE response shape does not change.

Batch uninstall treated a failed dirty check as clean and moved the
repo to trash. Without force, that item now fails with the git error
instead. This is stricter than the CLI, which only warns and continues.

Batch target updates ignored metadata save failures and still reported
success, so an override could silently disappear on the next reload.
They now return 500.
2026-09-30 01:34:58 +08:00
Willie bc01ff1b3e feat(server): let tracked-repo skills take dashboard targets
Setting targets on a skill inside a tracked repo used to be refused,
because writing its SKILL.md leaves the clone dirty and `update` then
skips the repo (or `--force` throws the setting away).

Store those targets in the source's .metadata.json instead, keyed by
the skill's path, and apply them at discovery over the frontmatter.
The clone stays clean, `update` keeps working, and the setting survives
it. Uninstalling a repo or skill drops its entries.

Overrides are saved in the same lock section that writes them: every
API request reloads the store from disk, so saving after unlocking
could lose them, and saving outside the lock raced with other writers.

Refs #295
2026-09-26 21:02:28 +08:00
Willie acb150dfe3 fix(server): allow uninstalling disabled skills via Web UI
The skill list endpoint discovers skills with DiscoverSourceSkillsAll
(which includes disabled skills), but the uninstall handler used
DiscoverSourceSkills, which excludes anything listed in .skillignore.
A disabled skill therefore stayed visible in the dashboard yet failed
to uninstall with "skill not found".

Switch handleBatchUninstallSkills to DiscoverSourceSkillsAll so the two
endpoints agree on which skills exist. The CLI was unaffected.

Fixes #190
2026-06-02 23:48:09 +08:00
Willie 996d00e342 feat(config): migrate consumers to Effective*Source helpers (Phase 3+5)
Make the v0.19.16 sources map actually do something: route all path
reads through Config.EffectiveSkillsSource() / EffectiveAgentsSource() /
EffectiveExtrasSource() so users who set sources.skills / sources.agents /
sources.extras get the configured paths everywhere.

Mechanical changes (~50 files):
- cmd/skillshare/**: replace cfg.Source / cfg.ExtrasSource reads with
  cfg.EffectiveSkillsSource() / cfg.EffectiveExtrasSource()
- internal/server/**: replace s.cfg.Source / s.cfg.ExtrasSource reads
  with the same helpers; server.skillsSource() / gitignoreDir() use the
  global-mode helper
- internal/config/config_validate.go: validate using EffectiveSkillsSource
  while still rejecting configs that set neither field explicitly
- internal/config/reconcile.go, registry.go: read via helpers

Behavioral fixes (paired with the migration):
- extras init / extras source / POST /api/extras no longer silently
  backfill the legacy extras_source field — the runtime fallback inside
  EffectiveExtrasSource() handles it. This stops surprise diffs in users'
  config.yaml after running extras commands.
- extras source command writes back to whichever field the user already
  configured (sources.extras if set, otherwise legacy extras_source) so
  the update is not shadowed.
- source_type in /api/extras and extras list correctly reports "default"
  vs "extras_source" by inspecting the raw (unresolved) configured value;
  sources.extras counts as configured for this purpose.

UI:
- ui/src/lib/fieldDocs.ts: neutralize sources / sources.* descriptions
  so they describe both project and global modes (Phase 5).

Preserved (intentional):
- Direct writes to cfg.Source / cfg.AgentsSource / cfg.ExtrasSource in
  init, migrate.go, cloneForSave, and server.reloadConfig — these are
  raw-field writes, not path reads.
- Updated test expectations for the removed backfills.
2026-05-21 14:49:11 +08:00
Willie 5b7ca8ba3d fix: trash before gitignore cleanup and skip gitignore for external sources
Reorder handleUninstallRepo to move repo to trash before removing the
.gitignore entry, preventing accidental exposure of tracked content
when trashing fails.

ProjectGitignoreTarget now returns empty strings for source paths
outside projectRoot, since parent-relative patterns (../) are invalid
in .gitignore. All six callers guard on empty gitignoreDir and skip
gitignore management for external sources.
2026-05-20 16:34:02 +08:00
Willie 0c010c55f4 fix: wire custom sources into server reload and gitignore paths
reloadConfig now updates s.cfg.Source and s.cfg.AgentsSource from the
refreshed ProjectConfig so project UI handlers see the latest source
directories after a config edit.

Add ProjectGitignoreTarget helper that computes the correct .gitignore
directory and entry prefix based on whether the source path is inside
.skillshare/ or a custom location. All gitignore write and remove
operations (reconcile, install, uninstall, server handlers) now use
this helper instead of hardcoded 'skills/' prefix.

Fix nil projectCfg panics in three server tests that simulate project
mode by setting projectRoot without projectCfg.
2026-05-20 16:12:02 +08:00
Willie 2475acd35e feat(ui): add agent support to batch uninstall and trash pages
- Add agent-mode batch uninstall handler with kind-based routing
  in handler_uninstall.go (skill/agent dispatch)
- Add Skills/Agents tab navigation to BatchUninstallPage and TrashPage
  with per-tab filtering and scoped empty states
- Extract SourceBadge component to replace duplicated getTypeLabel /
  skillTypeLabel helpers across ResourcesPage, ResourceDetailPage,
  BatchUninstallPage, and AnalyzePage
- Add kind field to BatchUninstallRequest API type
- Capitalize badge labels for consistency (tracked → Tracked, etc.)
2026-04-09 13:48:30 +08:00
Willie 1f1790b6be refactor: replace Registry with MetadataStore in reconcile, server, install context
Phase 1 of caller migration:
- projectRuntime: registry → skillsStore + agentsStore
- globalInstallContext: reg → store
- ReconcileGlobalSkills/ProjectSkills/ProjectAgents: take *MetadataStore
- Server struct: registry → skillsStore + agentsStore
- handler_install, handler_skills, handler_uninstall: use MetadataStore
- install.go, search.go: post-install reconciliation via MetadataStore
2026-04-08 10:59:13 +08:00
Willie 9a053a35b6 feat(ui): add agent stat card, kind filter tabs, and kind fields to API handlers
DashboardPage: add Agents stat card with Bot icon and accent color,
linking to /skills?kind=agent.

SkillsPage: add Skills/Agents filter tabs alongside existing filters.
KindBadge displayed on each skill card. matchFilter supports kind-based
filtering with accurate filter counts.

handler_collect: add kind field to localSkillItem response.
handler_uninstall: add kind field to batch request and result structs.
2026-04-07 18:05:40 +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 a570670a92 fix: registry cleanup after uninstall and sync, UI polish
- Fix UI batch uninstall not removing nested skill registry entries:
  handler used flat names (__) but registry stores path names (/),
  now tracks exact RelPath from discovered skills for matching

- Add stale entry pruning to ReconcileGlobalSkills and
  ReconcileProjectSkills using a live set built during disk walk,
  so skills deleted from source are removed from registry

- Trigger registry reconcile after sync in both UI handler (via defer
  for early-return safety) and CLI (global + project mode), writing
  warnings to stderr to avoid corrupting --json output

- UI: fix BatchUninstallPage search treating plain text as exact-match
  glob (now substring search when no * or ? present), display nested
  skill paths with / instead of __ in confirm and result dialogs

- UI: hide redundant 'X repo(s) and Y skill(s) already up to date'
  line on UpdatePage when everything is already current

- Fix test isolation: set XDG_CONFIG_HOME in server test helpers to
  prevent host agents dir leaking into test results, skip chmod-based
  oplog test when running as root

- Add README badge for Awesome Codex CLI
2026-04-01 22:30:39 +08:00
Willie eabb556cc6 refactor(config): cache SourceRoot in Config.RegistryDir
Eliminates redundant .git/ directory walks on every LoadRegistry call.
SourceRoot() is now computed once in config.Load() and cached in
cfg.RegistryDir. All 11 call sites use the cached value.
2026-03-26 23:32:15 +08:00
Willie a7de6a3a69 feat(registry): move registry.yaml to source dir for git sync (#103)
- Add SourceRoot() helper to find git repo root from cfg.Source
- Add MigrateRegistryToSource() for one-time migration
- Update all 11 global-mode LoadRegistry/Save call sites
- registry.yaml now lives in skills/ dir and is tracked by git
2026-03-26 22:42:00 +08:00
Willie 0b5eba205d feat(ui): add batch uninstall route, nav entry, and link from SkillsPage
- Add lazy import and route for BatchUninstallPage in App.tsx
  (placed before skills/:name to avoid capturing as dynamic param)
- Add "Batch Uninstall" nav entry with Trash2 icon in Layout.tsx MANAGE group
- Add "Batch Uninstall" secondary button next to "New Skill" in SkillsPage header
2026-03-19 16:33:24 +08:00
Willie bb04987f75 feat(server): add POST /api/uninstall/batch endpoint
Batch uninstall with skip-and-continue semantics, registry cleanup,
config reconciliation, and gitignore batch removal. Supports both
global and project mode.
2026-03-19 16:33:24 +08:00