299 Commits
Author SHA1 Message Date
Willie 8ffb8698de fix: allow default global skills source
Validate global configs against the effective skills source so sync --global honors the default source when source and sources.skills are omitted.

Add unit and integration coverage for issue #238.
2026-06-29 17:51:13 +08:00
Willie 3743a1ef3f fix(sync): honor file ignore patterns in copy mode
Apply config ignore patterns to copy-mode file traversal, checksum, mtime, CLI diff, and server sync/diff paths.

Add default ignores for .DS_Store, .git, and __pycache__ in global and project init configs.

Tests: go test ./... -count=1
2026-06-29 10:30:11 +08:00
Willie 2d06b004d5 fix(init): collapse shared skills discovery
Avoid presenting targets that share ~/.agents/skills as individually detected CLIs during init discovery. Show the universal shared-directory guidance instead and cover the re-init regression.
2026-06-17 20:55:27 +08:00
Willie ebe8cc277e fix(install): prevent project root self-install
Reject project-mode installs that target the current project root and add a copy-layer guard that skips destination subtrees during recursive copies. This prevents install ./ -p from recursively copying .skillshare/skills into itself on Windows.
2026-06-15 22:21:46 +08:00
Willie a897c2cd6c test(backup): select newest backup dir to fix flaky symlink test
TestBackup_AfterSync_ResolvesSymlinks failed ~7-10% of runs. The cause
is in the test, not production: `sync` takes a pre-sync backup of the
target before creating the agent-browser symlink, and the explicit
`backup` takes a second one. When the two land in different clock-seconds
there are two timestamp dirs, and `entries[0]` (lexicographically oldest)
points at the pre-sync backup that predates the symlink, so the
symlinked-skill assertion fails.

Select the newest backup dir (last entry, ascending sort) so the
assertion targets the post-sync backup that actually contains the
resolved symlink. Verified 0/80 failures under -race.

ref #226
2026-06-14 20:57:31 +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 59754ca3e6 fix(sync): resolve agent target aliases 2026-06-11 01:32:34 +08:00
Willie 2b08bdf400 fix: use relative project symlinks for agents 2026-06-10 23:39:45 +08:00
Willie 10d94a3542 fix: suggest install for missing tracked repos 2026-06-10 15:54:23 +08:00
Willie ef57f030dc fix: report missing tracked repositories 2026-06-10 15:37:16 +08:00
Willie 87809a264b test(audit): strengthen tracked hub repo coverage 2026-06-03 12:46:31 +08:00
Jason Blackburn b4be5a16e2 fix(audit): respect .skillignore for tracked hub repos in audit scan (#191) 2026-06-03 11:02:30 +08:00
Willie 86b91efe95 feat(extras): refine per-target management UI and path resolution
UI (Extras page):
- Label per-target flatten/extension/mode controls with column headers
- Render flatten as a dropdown so it matches the adjacent selects
- Collapse the add-target form behind a button and widen the path input
- Confirm before removing a target
- Polish layout: tinted icon, inset source chip, hover rows, aligned columns

Components:
- Select: bound the dropdown width so long option descriptions wrap instead
  of stretching the popup across the page
- Toast: render messages multi-line, widen the container, and give
  error/warning toasts more time to read

Sync feedback:
- Restructure extras sync-failure toasts into readable lines and fix the
  contradictory "N more errors" count (new nMoreErrors translation)

CLI/server:
- Match extra target paths by resolved absolute path (handles ~ vs /home)
  when adding, removing, or updating targets
2026-06-02 18:40:00 +08:00
Willie 0a1724a74f test(extras): migrate mode tests to shorthand after subcommand removal 2026-06-02 17:27:28 +08:00
Willie 4be846cb28 test(extras): integration tests for per-target add/remove 2026-06-02 17:13:33 +08:00
Willie f255c4a28b fix: scope agent installation to the requested filter (#183)
Installing a specific skill from a mixed repo dragged in every agent.
The -a/--agent handler implicitly set Kind=agent, but -s/--skill never
set Kind=skill, so installDiscoveredAgents could not tell that the user
had narrowed the install — and it looped over every discovered agent
without applying the -a name filter.

Fix the install path so agents track the user's intent:

- -s/--skill (without -a) installs only the named skills, no agents.
- -s/--skill with -a installs only the named agents, via selectAgents,
  matching the pure-agent path.
- --all/--yes still installs everything.
- An unknown -a name fails the whole command before any skill is
  installed (validated up front against the discovered agents, including
  repos with no agents at all), so automation never sees a half-success.

Add integration tests covering each case.

Fixes #183
2026-06-01 14:42:24 +08:00
Letiancheng Lee 50e6cb885f feat: add target removal hints to doctor suggestions 2026-05-31 22:49:02 +08:00
Willie 2f6f6bd052 fix(git): enforce root-scope safety on commit/push instead of warning
Root-scope git operations detected hazards but proceeded anyway, letting
preventable mistakes reach the remote:

- Nested git repos were only warned about, then committed/pushed as empty
  submodules (silent data loss). Now commit/push abort (CLI non-zero exit,
  server 400) until the nested repos are disabled, and the web UI disables
  the commit/push buttons while any are present.
- The pre-stage safety sweep ran before the dry-run check, so `--dry-run`
  wrote .gitignore and ran `git rm --cached config.yaml`. The sweep/guard is
  now strictly read-only on dry-run and only reports what would change.
- Server git endpoints used EffectiveGitRoot() without validating git_root,
  so a hand-edited invalid scope silently fell back to skills. They now share
  a gitSource() guard that rejects invalid scopes with 400, mirroring the
  CLI's resolveGitRoot.
2026-05-30 19:23:12 +08:00
Willie 5807a4c743 feat(init): set remote during headless git_root scope switch
Combining --git-root <scope> with --remote <url> on an already-initialized
setup now switches the scope and wires the remote onto the new scope's repo
in one command, instead of warning and ignoring --git-root. Reuses the
existing scope-switch and remote-configuration paths back to back.
2026-05-30 19:23:12 +08:00
Willie 9ca77bd12e feat(init): friendlier error for global-only git flags in project mode
Project init rejected --git-root (and other git flags) with a bare 'unknown
option', which is confusing when the user just forgot that git integration is
global-only — easy to hit when the current directory has a .skillshare/ and
init auto-detects project mode. Match git-related flags (--git-root, --git,
--no-git, --remote) explicitly and explain they are global-only, pointing at
'skillshare init -g <flag>'. Add TestInitProject_GitRootFlag_RejectedAsGlobalOnly.
2026-05-30 19:23:12 +08:00
Willie 314e2b2df4 feat(init): switch git_root scope headlessly on an existing setup
Previously 'skillshare init --git-root <scope>' on an already-initialized
setup either errored with 'already initialized' (no --remote) or warned and
ignored the flag (with --remote), so there was no non-interactive way to
change the scope after init — only the web UI or a manual config edit.

handleExistingInit now treats 'init --git-root <scope>' (without --remote) as
a headless scope switch via switchGitRootScope: it inits a repo at the new
scope directory (reusing one already there, sharing doGitInitIfAbsent with the
fresh-init and server paths) and persists git_root. It does not relocate an
existing repo — switching scope means 'version a different directory', not
'move history'. Combined with --remote the flag still falls through to the
remote path, now pointing users at the standalone form instead of a bare
'ignored' warning.

Update the mismatch guidance to offer 'skillshare init --git-root <scope>' as
the first fix, and revise the git_root docs (configuration + init) to document
the headless switch, superseding the earlier 'must re-run init / not supported'
wording. Add TestGitRoot_SwitchScopeAfterInit.
2026-05-30 19:23:12 +08:00
Willie 7f91625ec8 test(git-root): skip git_root tests when the container git env cannot commit
Stripped one-shot containers (read-only HOME, unwritable identity, or owner
mismatch) can make git init/commit fail during test setup, surfacing as a
misleading assertion failure deep inside a test. Add a requireWorkingGit probe
that init/config/add/commits in a throwaway temp dir up front and t.Skips with
the underlying git error when the environment cannot create commits. The probe
touches nothing outside its temp dir and does not change git_root behavior.
2026-05-30 19:23:12 +08:00
Willie fa87ef745f test(integration): end-to-end extras extension transform 2026-05-30 19:23:12 +08:00
Willie e51134af24 feat(git-root): surface scope mismatch in UI and document git_root field
Add Config.GitRootMismatch() as the single source of truth for detecting
when the git repo lives at a different scope than git_root configures, and
reuse it across the CLI guidance, the server status response (scopeMismatch
/mismatchScope/mismatchDir), and a new warning banner on the Git Sync page.

Document git_root in the config structure-view field docs (fieldDocs) and the
GitStatus client type, and add the gitSync.scope.* / gitSync.mismatch.* i18n
keys across all locales to keep dictionary parity.

Cover the behavior with config, server handler, and CLI integration tests:
push/pull honor the root scope (agents files reach the remote, config.yaml
stays untracked), POST /git/root inits+persists the scope and rejects invalid
scopes and project mode, and git status reports scope mismatches.
2026-05-30 19:23:12 +08:00
Willie 9e371f2dde refactor(git-root): enforce config.yaml exclusion, dedupe scope mapping, warn on scope change
- writeInitGitignore now appends config.yaml to a pre-existing root .gitignore
  if missing (enforces the safety guarantee instead of best-effort)
- single source of truth config.ScopeDir; EffectiveGitRoot/scopeDir/gitRootScopes delegate
- warn when --git-root is passed with --remote on an already-initialized repo
- use 0o644 and check WriteFile errors; add tests for the append + agents scope
2026-05-30 19:23:12 +08:00
Willie e79bde558b test(git-root): cover init --git-root root setup 2026-05-30 19:23:12 +08:00
Willie d6c21e9638 test(git-root): cover root-scope commit and scope mismatch guidance 2026-05-30 19:23:12 +08:00
Willie 0becff010e feat: add local commit command 2026-05-27 15:10:00 +08:00
Willie c60bfd3c08 chore: release v0.19.19 2026-05-23 01:18:38 +08:00
WillieandClaude a61a0e3bea fix(install): include root SKILL.md in tracked repo discovery
After Phase A (210605ea) fixed metadata + status display for tracked
repos with a root-level SKILL.md, three output gaps remained:

- 'Found 0 skill(s)' on install (should be 1 — root SKILL.md counts)
- 'tracked_repos[].skill_count' was 0 (same root-case)
- 'Run sync' suggestion appeared even when no skill was discovered

Root cause: install/update used discoverSkills(destPath, false) which
walks the tracked repo's own root, treating the root SKILL.md at
relPath='.' as ignored. But 'skillshare sync' walks the source
directory; the same SKILL.md inside _<name>/ has relPath='_<name>'
(not '.') and is discovered as a normal skill. The two walkers used
the same helper with different includeRoot settings and produced
inconsistent counts.

Changes:

- installTrackedRepoImpl and updateTrackedRepo: switch to
  discoverSkills(repoPath, true) so SkillCount matches sync's view.

- buildTrackedRepoJSON: when counting skills per repo, accept both
  RelPath='<repo>/...' (nested) and RelPath='<repo>' (root-only).

- handleTrackedRepoInstall: suppress the 'Run sync' next-step when
  the repo had no skills/agents discovered.

Closes #163

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-22 11:29:01 +08:00
WillieandClaude 210605ea4e fix(install): persist metadata for tracked repos with root-level SKILL.md
When --track installed a repo whose SKILL.md sits at the repository root
(non-spec layout), the install reported success but:

- .metadata.json gained no entry (cross-machine recovery via metadata broken)
- status --json tracked_repos did not list the repo

Two coupled bugs caused this:

1. cmdInstall gated ReconcileGlobalSkills on len(InstalledSkills) > 0.
   Tracked repos with no discoverable nested skills produced an empty
   InstalledSkills slice, so reconcile never ran and never detected the
   _<name>/.git directory to write a tracked entry.

2. extractTrackedRepos derived repo names from discovered skills, so
   repos with zero discoverable skills were silently dropped from status
   and list output.

Fix both by:

- Making the post-install reconcile unconditional on success. Reconcile is
  idempotent and cheap; gating it on InstalledSkills > 0 created a path
  where successful installs left metadata stale.

- Switching extractTrackedRepos to install.GetTrackedRepos (a directory
  walk for _-prefixed git repos), the same source-of-truth used by check
  and update. Shared across status, status_project, list, and list_project.

Closes #163

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-22 10:57:55 +08:00
Willie 8e0117a29d feat(init): emit sources map for new global configs (Phase 4)
Fresh `skillshare init` (global) now writes the v0.19.16 `sources:` map
instead of the legacy top-level fields:

  sources:
    skills: ~/.config/skillshare/skills
    agents: ~/.config/skillshare/agents

What changed:
- cmd/skillshare/init.go: construct Config with Sources{Skills, Agents}
  rather than Source/ExtrasSource. The --subdir update path writes to
  cfg.Sources.Skills accordingly. The --remote re-init path uses
  cfg.EffectiveSkillsSource() for git operations so it works whichever
  shape the existing config uses.
- internal/config/config.go: add `,omitempty` to Source field so configs
  that only set sources.skills don't get a noisy `source: ""` line.
- tests/integration/extras_test.go: rename TestInit_SetsExtrasSource to
  TestInit_WritesSourcesMap and assert the new shape (sources map
  present, legacy source/extras_source/agents_source absent).

Existing configs are untouched — legacy fields keep working through
Config.Effective*Source helpers. No auto-migration on Save.
2026-05-21 14:54:24 +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 906ede81e0 test: add integration coverage for fail-closed and source/target overlap
- 3 malformed-config tests verify uninstall/new/check abort instead of
  silently using the default .skillshare path
- 1 overlap test verifies sync rejects sources.skills aliasing a
  target path
- Fix pre-existing TestUninstall_AllProject fixture which used
  malformed targets: {} (map, not list) — now caught by fail-closed
  load
2026-05-20 18:34:45 +08:00
Willie 68d5eadc0b feat: support custom project source directories via sources map
Add ProjectSources struct to ProjectConfig with optional skills, agents,
and extras fields. When set, project-mode commands resolve source paths
from these values instead of hardcoded .skillshare/{skills,agents,extras}/.

Config example:
  sources:
    skills: ./docs/skills
    agents: ./docs/agents

Three EffectiveXxxSource(projectRoot) methods provide the central
resolution logic with fallback to defaults. The projectRuntime gateway
and server layer route through these methods, so most commands get
custom source support automatically.

Closes #153
2026-05-20 15:42:53 +08:00
Willie 1c22cc7e7b fix(test): align agent install test with new name resolution priority
The tracked repo name resolution was changed to prefer source.Name
over TrackName() in a656e30b, but this integration test still used
TrackName() to compute the expected directory path.
2026-05-17 22:25:58 +08:00
Willie 9307fc521c chore: release v0.19.12 2026-05-14 23:43:43 +08:00
Willie 56fafb53e0 fix: preserve update metadata keys for symlinked sources 2026-05-12 21:10:08 +08:00
Willie f173b1d456 test(sync): add integration tests for token summary and budget warnings
DiscoverSourceSkillsWithStats did not set collectContext=true, so
DescChars/BodyChars were always 0 when sync called buildAnalyzeEntries.
Add DiscoverSourceSkillsWithStatsAndContext that enables both ignore
stats and context collection in a single walk, and use it in sync.go
and sync_project.go.
2026-05-11 21:34:38 +08:00
Willie d8007dd750 refactor: simplify completion with struct map, fix nushell gaps
- Replace three switch statements with a single shells map[string]shellDef
- Add missing --add-agent-{include,exclude} and --remove-agent-{include,exclude}
  flags to nushell target completion
- Fix nushell audit using 'target?' instead of 'subcommand?'
- Replace raw fmt.Println with ui.Info in post-install hints
- Use testutil assertion helpers in integration tests
- Verify --install actually writes the file to disk
2026-05-08 16:06:14 +08:00
Willie 79cb6c2410 feat: add powershell/nushell completion + fix bash fallback (#148)
- Add PowerShell and Nushell completion scripts
- Fix bash completion when bash-completion package is not installed
  (fallback from _init_completion to manual COMP_WORDS parsing)
2026-05-08 15:54:16 +08:00
Willie 829851f420 feat: add shell completion command for bash/zsh/fish (#148)
Add 'skillshare completion <shell>' command that generates shell
completion scripts. Supports --install flag to auto-write the script
to the correct platform path.

Covers all commands, subcommands, and per-command flags for bash,
zsh, and fish shells.
2026-05-08 15:49:33 +08:00
Willie d2946cb4d1 fix(tests): align integration tests with cursor project path change
The cursor target's project path was updated from .cursor/skills to
.agents/skills in 57b0649d but three integration tests still asserted
the old path:

- TestInitProject_Fresh_CreatesStructure
- TestInitProject_Discover_WithMode_AddsTargetMode
- TestSyncProject_MultipleTargets

Fix testutil knownPaths map and test assertions to match the new path.
Discover test now uses windsurf (unique path) instead of cursor
(grouped at .agents/skills with 10+ other targets).
2026-05-05 12:11:06 +08:00
hhh2210 851f06dc0a fix(sync): infer targets from host skill paths 2026-04-29 18:47:05 +08:00
Willie 07c091529b refactor(search): harden preview error handling, cache, and a11y
- Add ErrSkillNotFound sentinel error in search/preview.go so callers
  can distinguish 404 from other errors with errors.Is instead of
  brittle string matching
- Cap previewCache at 200 entries with TTL purge + full reset on
  overflow to prevent unbounded memory growth
- Make Card and SearchResultsTable rows keyboard-accessible
  (role=button, tabIndex=0, Enter/Space handlers)
- Refactor SkillPreviewModal to accept a single SearchResult prop
  instead of 6 individual fields — reduces prop drilling and keeps
  the modal in sync with the result shape
- Fix search_online_test: add --list flag so output is not gated
  behind interactive TUI
2026-04-23 16:46:53 +08:00
Willie cb69b78513 fix(test): resolve macOS symlink path mismatch in target list project JSON test
On macOS, temp dirs are under /var/folders which is a symlink to
/private/var/folders. EvalSymlinks normalises the path before comparing,
matching what the CLI outputs after os.Stat resolution.
2026-04-14 20:51:43 +08:00
Willie 1a5b4f809f feat(target): add targetNaming, sync, and agentSync fields to target list JSON output
Refactors targetListJSON (global and project modes) to use the shared
buildTargetTUIItems + newTargetListJSONItem path, eliminating duplicated
item-building logic and ensuring both modes expose consistent metadata:
- targetNaming: effective naming strategy (flat/nested)
- sync: skill sync summary string
- agentSync: agent sync summary string

Adds assertions in target_agents_test.go and a new integration test
(TestTarget_List_Project_JSON_IncludesSyncMetadata) to cover the new fields.
2026-04-14 20:41:56 +08:00
Willie e0f946ac93 test: replace online antigravity tests with offline mock repo
The antigravity repo (47MB, 995 skills) took ~110s per test on CI due
to audit scanning all skills.  Replace with a local file:// bare repo
containing 4 mock skills (2 clean + 2 malicious) that produces the
same batch audit output (Blocked/Failed, CRITICAL, findings, etc.)
in under 1 second.

This moves the tests from online to offline (build tag !online),
eliminating the network dependency entirely.
2026-04-13 18:23:10 +08:00
Willie e32f2164c9 fix: suppress update notice in all structured-output modes
UpdateNotification() wrote to stdout via fmt.Printf, corrupting JSON
output when --json was passed to commands like search.  Machine
consumers got invalid JSON with trailing human-readable text.

Three-layer fix:
1. Move UpdateNotification output to os.Stderr (safety net for any
   caller that bypasses the main.go guard).
2. Add isStructuredOutput() that detects all machine-readable modes:
   --json, -j, and --format json/sarif/markdown.
3. Skip the update check and trailing newline entirely in main()
   when structured output is requested, honouring the contract that
   stdout = pure structured data and stderr = empty.

Tests:
- Unit: isStructuredOutput table test (9 cases)
- Unit: UpdateNotification writes only to stderr
- Integration: versioned binary (1.0.0) with seeded cache (9.9.9)
  exercises the real update path for search --json, list -j, and
  audit --format json — asserts valid JSON stdout + empty stderr.

Closes #129
2026-04-13 16:00:18 +08:00
Willie 5476ec84c3 fix(tests): remove unused os import in install_online_test
The os package was imported but not referenced, causing the online
integration test build to fail in CI (docker-sandbox-online job).
2026-04-11 03:53:38 +08:00