Commit Graph
683 Commits
Author SHA1 Message Date
zishuo ce9593e98e feat(install): add Gitea platform support with API fast path
Support Gitea (gitea.com and self-hosted instances) as a git hosting
platform for installing skills. Includes both core platform integration
and a Gitea Contents API fast path for direct file downloads without
full git clone.

Platform support (P0):
- auth.go: add PlatformGitea, detect gitea hosts, resolve GITEA_TOKEN
- config.go / project.go: add gitea_hosts config field with normalization,
  env var merge (SKILLSHARE_GITEA_HOSTS), and EffectiveGiteaHosts()
- source.go: add isGiteaHost() and GiteaHosts to ParseOptions
- install.go: pass GiteaHosts from config to source parsing
- install_git.go: include GITEA_TOKEN in auth error hints

API fast path (P1):
- gitea_download.go: Gitea Contents API recursive directory download
  (GET /api/v1/repos/{owner}/{repo}/contents/{path}), matching the
  GitHub Contents API pattern
- install_apply.go / install_discovery.go: hook Gitea API fallback
  after sparse checkout, before full clone
2026-05-26 19:00:25 +08:00
zishuo 17a9a0879b feat(install): add CNB platform support
Support CNB (Cloud Native Base, cnb.cool) as a git hosting platform for
installing skills. This adds platform detection, token authentication
via CNB_TOKEN, host configuration (cnb_hosts / SKILLSHARE_CNB_HOSTS),
and URL parsing for both direct and web URLs (including /-/tree paths).

Changes:
- auth.go: add PlatformCNB, detect cnb.cool hosts, resolve CNB_TOKEN
- config.go / project.go: add cnb_hosts config field with normalization
  and env var merge, plus EffectiveCNBHosts() accessor
- source.go: add isCNBHost() and CNBHosts to ParseOptions
- install.go: pass CNBHosts from config to source parsing
- install_git.go: include CNB_TOKEN in auth error hints
2026-05-26 19:00:25 +08:00
Willie a2f958d288 feat(ui): background mode, in-place upgrade, and PWA support
Three user-visible additions to the web dashboard, plus the CLI surface
needed to drive them.

* `skillshare ui start` / `skillshare ui stop` — run the dashboard as a
  managed background process. Re-running start reuses the existing
  healthy process; stop uses the remembered host/port. Foreground
  `skillshare ui` keeps working unchanged. Process tracking lives in
  ui_process_{unix,windows,other}.go via a PID + current-state file.
* `--app` — opens the dashboard in a Chromium app-mode window (Chrome,
  Edge, Brave) on macOS, Windows, and Linux for a separate Dock/taskbar
  entry without browser chrome.
* In-place upgrade from the browser — the Update dialog and the Doctor
  page's Version card now expose an Update now button. Backed by two
  new endpoints (POST /api/upgrade, POST /api/restart in
  handler_restart_upgrade.go); the browser polls GET /api/health and
  reloads once the new server is ready. Dev builds short-circuit with
  `devMode: true` and a simulated restart so the flow can be exercised
  without rebuilding the binary.
* Progressive Web App — site.webmanifest, app icons (192/512), and a
  minimal service worker registered from main.tsx. Supporting browsers
  can install the dashboard as a standalone desktop app.
* Doctor Version card redesign — state-coloured icon (blue when an
  update is available, green when up to date), explicit
  `current → latest` delta, Update button only when there is something
  to upgrade.
* i18n — translate "DEV mode" in zh-TW / zh-CN / ko (previously left
  as raw English).

Adds CHANGELOG.md and website changelog entries for v0.19.20 and
refreshes website/docs/reference/commands/ui.md to document the new
modes, --app flag, new REST endpoints, and the in-place upgrade flow.
2026-05-24 01:21:06 +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 4d7011983c feat(sync): warn on skill path overlap with one-line hint
Detect overlapping target paths during sync — either two targets
sharing the same primary path, or cross-runtime discovery via the
also_scans table — and surface a brief one-liner pointing users at
`skillshare doctor` for the full breakdown.

Triggers in both CLI (sync.go, sync_project.go) and Web UI (sync API
warnings array, rendered by existing SyncPage warnings card). Detection
logic lives in internal/config/path_overlap.go and is shared between
both paths.

Quiet by design: no output when no overlap exists. JSON output mode
remains untouched.
2026-05-22 01:00:54 +08:00
Willie 88a1bd50a4 feat(doctor): warn on shared paths and cross-target discovery
Add two new doctor checks to detect duplicate-skill problems
surfaced in issue #135:

Layer 1 — checkSharedTargetPaths:
  Warns when two or more enabled targets resolve to the same
  filesystem path after tilde expansion. Pure metadata check; no
  runtime probing. Catches universal/warp/witsy all sharing
  ~/.agents/skills.

Layer A — checkCrossTargetDiscovery:
  Driven by a new also_scans field in targets.yaml that documents
  paths a target's runtime reads beyond its primary skills
  directory. Sourced from each tool's official docs. Populated
  for amp, antigravity, codex, cursor, firebender, kimi, roo.

  Warns when an enabled target's also_scans path is the primary
  path of another enabled target. Example: enabling codex +
  universal warns that Codex's runtime will see ~/.agents/skills
  content.

  Overlaps are grouped per scanner so a multi-overlap target
  (e.g. firebender reading 5 brand dirs for cross-compat) emits
  a single warning with indented detail lines.

config:
  - New targetAlsoScans struct + AlsoScansGlobal / AlsoScansProject
    accessors.
  - targets.yaml schema is backward-compatible (optional field).

Layer B (sync engine routing) and Layer C (user-declared
authoritative roots) are intentionally deferred — diagnosis comes
first, behaviour changes only if users actually ask.
2026-05-21 23:49:40 +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 8731554456 fix: fail closed on config load error in agents check
Project-mode 'check agents' previously fell back to .skillshare/agents
when LoadProject failed. With custom sources.agents this could scan
the wrong directory and report green while the configured source is
unchecked. Now returns the load error instead.
2026-05-20 18:28:32 +08:00
Willie bb3745b8f5 fix: reject source/target path overlap and fail closed in check
ValidateProjectConfig now resolves each target's skills/agents path
and rejects configs where a source aliases or nests with any target
path. Without this guard, sources.skills: .claude/skills with a
claude target makes sync --force delete the source.

check -p now returns an error on LoadProject failure instead of
falling back to .skillshare/skills.
2026-05-20 18:24:41 +08:00
Willie 4f908a171e fix: fail closed on config load error in enable/disable/new commands
Project-mode disable/enable and new previously fell back to default
.skillshare/{skills,agents} when LoadProject failed. With custom
sources this could write .skillignore/.agentignore or create new
skills in the wrong directory. Now both paths return an error
instead of silently using the default path.
2026-05-20 18:02:58 +08:00
Willie 49abc19eef fix: fail closed on config load error in destructive uninstall commands
Project uninstall previously fell back to default .skillshare/skills
when config was malformed. With custom sources this could trash skills
from the wrong directory. Now both skill and agent uninstall paths
return an error instead of silently using the default path.
2026-05-20 17:09:24 +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 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 9307fc521c chore: release v0.19.12 2026-05-14 23:43:43 +08:00
Willie fb821b7328 fix(project): add backups/ to .skillshare/.gitignore managed dirs
Project mode agent backup (sync --agents, backup -p) creates
.skillshare/backups/ but it was not gitignored — backup artifacts
could be accidentally committed.

Agent backup was added in 95c46ca8 (2026-04-06), after the gitignore
fix in 90c096b8 (2026-03-16) which only covered logs/ and trash/.
2026-05-13 03:49:40 +08:00
Willie 56fafb53e0 fix: preserve update metadata keys for symlinked sources 2026-05-12 21:10:08 +08:00
Willie 56007efa5c chore: fix lint error 2026-05-11 23:46:43 +08:00
Willie 9a7271c1ae fix: address PR #151 review feedback
- Project mode JSON sync now includes context_cost (was nil)
- Server handler respects symlink mode (skips include/exclude filters)
- checkBudget reports all targets exceeding threshold (not just worst)
- Budget warnings include target name in CLI and UI output
- ConfigPage indentation restored to original 2-space style
2026-05-11 21:34:38 +08:00
Willie 402fe38340 refactor: simplify budget warning code after review
- Define budgetTypeAlwaysLoaded/budgetTypeOnDemand constants
- Add showDetails param to printBudgetWarning; analyze reuses it
- Hoist buildAnalyzeEntries call to avoid duplicate computation
- Remove WHAT-comments that restate function names
2026-05-11 21:34:38 +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 76a242c019 feat(analyze): show budget warning when thresholds exceeded
Reuses checkBudget from sync_budget.go. No top-offender list
since analyze already shows the full per-skill breakdown.
2026-05-11 21:34:38 +08:00
Willie 87c355c76d feat(sync): add context_cost to JSON output
Always included in --json mode regardless of --quiet flag.
Contains grouped token counts and budget violation warnings.
2026-05-11 21:34:38 +08:00
Willie cfc7502774 feat(sync): wire up token summary and budget warnings in sync CLI
Add --quiet/-q flag to suppress token summary and budget warnings.
Both global and project sync paths call buildAnalyzeEntries after
SyncSummary to display context cost and budget violations.
2026-05-11 21:34:38 +08:00
Willie 8af9a89774 feat(sync): add printTokenSummary and printBudgetWarning 2026-05-11 21:34:38 +08:00
Willie 1d29686962 feat(sync): add core budget functions with unit tests 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 f60976645b feat: add alias auto-detection to completion scripts
Bash, zsh, and PowerShell completion scripts now auto-detect aliases
pointing to skillshare (e.g. alias ss=skillshare) and register
completions for them. Also adds powershell/nushell to the shell
options in all completion scripts.
2026-05-08 15:58:42 +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 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 204340c2e0 fix: wire azure_hosts through project install and agent update paths
- install_project.go: pass AzureHosts to temporary Config (was only
  passing GitLabHosts, so project-mode direct install ignored azure_hosts)
- update_agents.go: thread ParseOptions through batchUpdateAgents and
  reinstallAgent, replacing bare ParseSource with ParseSourceWithOptions
- handler_update.go: use ParseSourceWithOptions with s.parseOpts() for
  agent update in web UI

Without this fix, azure_hosts in .skillshare/config.yaml was silently
ignored during project install and agent update, causing on-prem Azure
DevOps URLs to be parsed incorrectly.
2026-05-05 18:54:45 +08:00
Willie e48a301623 feat: add azure_hosts config for Azure DevOps Server on-premises
Add azure_hosts config parameter (analogous to gitlab_hosts) that allows
users to register self-hosted Azure DevOps Server hostnames so they
receive proper URL parsing without appending .git to clone URLs.

- Add AzureHosts field to Config and ProjectConfig structs
- Add SKILLSHARE_AZURE_HOSTS env var support with merge semantics
- Generalize hostname validation into shared normalizeHostList/mergeHostsFromEnv
- Add azureOnPremPattern regex and parseAzureOnPrem for /_git/ URL routing
- Add isAzureHost for config-based host detection (no auto-detect)
- Update TrackName to handle on-prem Azure DevOps clone URLs
- Wire AzureHosts through InstallContext, ParseOptions, and Server
- Add JSON Schema, UI fieldDocs, and website documentation
- Add 19 new tests covering config, source parsing, and server

Closes #147
2026-05-05 18:33:07 +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 85abcb8bd6 chore: release v0.19.2 2026-04-14 18:16:11 +08:00
Willie 8a2196acdb feat(ui): show local agent count in targets and fix agent batch uninstall
Add agentLocalCount to target API and CLI JSON output so the UI can
display how many local (non-source) agents exist per target.

- Add LocalCount to AgentSummary, computed via FindLocalAgents
- Surface agentLocalCount in both CLI target list JSON and server API
- Show local agent counts in target detail summaries (CLI + UI)
- Collect button now appears for targets with local agents and routes
  to CollectPage with scope=agent query param
- CollectPage reads scope from URL and auto-scans on mount
- Fix BatchUninstallPage: agents tab was collapsing individual agent
  names into the repo name via buildApiNames(), causing 'agent not
  found' errors; now sends each agent flatName individually
- Invalidate targets + diff queries after successful collect
2026-04-14 18:03:41 +08:00
Willie 8b72af58a1 fix(install): root orchestrator skill copies only SKILL.md (#124)
Root SKILL.md in multi-skill repos has no directory boundary — the entire
repo root is its source, which drags in project infrastructure (src/,
assets/, CI, build scripts). Now when Path="." and descendants exist,
only the SKILL.md file is copied. Children install as independent flat
directories instead of nesting under the root.

Remove orchestrator nesting logic from installSelectedSkills — each skill
now installs at the top level regardless of whether the root is selected.
2026-04-13 23:02:11 +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 d892eca91e feat(install): explicit SKILL.md URLs resolve to single skill + radio TUI follows cursor
Two related improvements for issue #124:

1. Source parsing now tracks ExplicitSkill when a blob URL points
   directly at a SKILL.md file. Discovery constrains results to
   the root skill only, skipping the orchestrator pack/selection
   prompt entirely — the user clearly wants that one skill.

2. Single-select (radio) checklist TUI reworked: selection follows
   the cursor automatically, space keeps exactly one item active,
   enter confirms the focused item. Pre-selected items set the
   initial cursor position. This gives immediate visual feedback
   and eliminates the confusing empty-selection edge case.

Refs: #124
2026-04-11 03:17:22 +08:00
Willie 50b0aba714 fix(install): install orchestrator children as independent skills
An orchestrator repository containing a root SKILL.md together with
child SKILL.md directories (e.g. iOfficeAI/OfficeCLI) previously
installed as a single bundled directory that mirrored the git clone:
copying the root dragged every child skill dir into it, and children
marked selected were silently skipped as "included in parent" while
their computed dest paths were never written to.

Make each discovered skill a first-class install:

- New copyDirExcluding() skips subdirectories by slash-normalized
  relative path, so a skill directory is copied without duplicating
  any nested skill that is itself being installed elsewhere.
- installFromDiscoveryImpl computes the descendant skill paths of the
  skill currently being copied and passes them as excludes. For the
  root of an orchestrator repo this drops every child skill dir; for
  a non-root skill it drops any sub-skill nested inside it.
- installSelectedSkills stops skipping children after the root is
  installed. The existing dest-path logic already places each child
  under <parentName>/<childName>, so the children are written as
  siblings to the root install.

After the fix, a multi-skill repo with N skills produces N independent
installed directories discoverable by sync, updatable individually.

Refs: #124
2026-04-11 00:52:29 +08:00
Willie f3176da208 fix(install): include root skill in individual selection for orchestrator repos
When a repo contains both a root SKILL.md and child skills, picking
"Select individual skills" previously excluded the root entirely, so
the orchestrator skill could never be installed from the multi-select
UI — users had to resort to --name as a workaround.

Include the root skill in the individual selection list (listed first)
so it is visible and selectable alongside its children.

Refs: #124
2026-04-11 00:43:49 +08:00
Willie 788f9bc6e9 feat(agents): JSON output + audit gate for install/update
Extend install/update with agent-aware --json output and apply the same
audit block-threshold gate skills already use.

Install:
- install --json: imply --force; imply --all only when neither
  --skill nor --agent is set (so explicit selectors still work)
- project-mode install now routes through cmdInstallProjectParsed
  so --json suppresses UI and emits a pure-JSON payload
- agent installs propagate SourceDir so metadata lands in the
  agents root, not the install subdir
- validation error lists --agent / --kind / --branch explicitly

Update agents:
- update agents supports --force, --skip-audit, --audit-threshold
- tracked agent repos + metadata-backed single-file agents now run
  the same audit gate as skills; blocks roll back from a temp stage
- JSON output returns the final per-agent status
  (updated/skipped/failed/up_to_date/...) by merging check results
  with batch update outcomes

Audit:
- auditInstalledAgent shares one helper with auditInstalledSkill
  (scan + cleanup callbacks); single-file agent scans now use
  audit.ScanFile / ScanFileForProject instead of staging the file
  into a temp directory
- UpdateAgentFromDiscovery stages to temp, audits, then renames
  atomically (rename already overwrites on POSIX)

Refactors pulled in while reworking these paths:
- extract jsonUISuppressor helper in json_output.go and use it
  from install/update/update_agents; collapses 4 copies of the
  suppress/restore closure dance and the per-error failJSON block
- drop relPath plumbing from installAgentFromDiscoveryInternal
  now that ScanFile doesn't need a staged relative path
- list.go render functions now use theme.ANSI() so NO_COLOR is
  respected in plain-text output

Tests:
- add TestInstallAgentFromDiscovery_HighFindingBlocked (unit)
- add TestUpdate_Agents_HighFindingBlockedByThreshold (integration)
- add TestInstall_Project_JSON_Agent_PureJSON,
  TestUpdate_Agents_JSON_ReportsFinalStatus
- fix TestList_SKILLSHARE_THEME_Light / TestList_NO_COLOR to
  write a config before invoking list
- fix TestTargetList_NoTUI_FallsBackToPlainText assertion to match
  the new structured Mode: merge output
- fix TestDoctor_AllGood_PassesAll by pinning SKILLSHARE_THEME=dark
  so the no-TTY theme fallback warning doesn't fire
- add list_tui_content_test.go covering light/dark glamour base
- list detail pane now picks LightStyleConfig on light terminals

Docs:
- update install.md, update.md, understand/agents.md for the new
  flags, JSON shapes, and agents update workflow
2026-04-10 23:27:26 +08:00
Willie ce7c7d154d fix(list): group TUI entries by tracked repo root and local top dir
The list TUI had two grouping bugs:

1. Local nested skills (e.g. mma/agent-browser, mma/docker-expert) were
   lumped into the "standalone" group because buildGroupedItems keyed on
   RepoName, which is empty for non-tracked skills.

2. Agents deep inside a tracked repo (e.g. _vijay-agents/agents/core/x.md,
   _vijay-agents/agents/specialized/python/y.md) were split into separate
   groups per sub-directory. discoverAndBuildAgentEntries set RepoName to
   filepath.Dir(RelPath), producing keys like '_vijay-agents/agents/core'
   instead of the tracked repo root.

Fix:

- discoverAndBuildAgentEntries now uses d.RepoRelPath (already computed
  by agent discovery) so tracked agents share one visual group regardless
  of nesting depth. This also corrects a pre-existing mis-count where
  local nested agents were counted as tracked in the summary footer.

- Add skillTopGroup() helper in list_tui_filter.go: tracked → RepoName;
  non-tracked nested → first RelPath segment; flat → "" (standalone).

- buildGroupedItems now keys on skillTopGroup() so local nested groups
  (mma/*) render as their own bucket instead of standalone.

- sortSkillEntries default sort now groups by top-level bucket first,
  placing standalone last, so buildGroupedItems sees contiguous blocks.

- Remove 'if opts.SortBy != ""' gating in both global list paths: sort
  must always run to guarantee the TUI grouping invariant.

Tests: 4 new unit tests cover local nested grouping, deep tracked agents,
skillTopGroup cases, and the top-group-aware sort order.
2026-04-10 19:00:33 +08:00
Willie ea2abf0a68 refactor(tui): delete legacy tui_colors.go and add doctor theme check
Finishes the theme system migration:

- Deletes cmd/skillshare/tui_colors.go entirely (~152 lines). The
  tc struct and tcSevStyle/riskLabelStyle/formatRiskBadgeLipgloss
  helpers are all replaced by equivalents in internal/theme.
- Migrates last 6 helper-function callers in audit_tui.go and
  search_tui.go.
- Adds checkTheme() to doctor.go with warning status on fallback,
  wired into runDoctorChecks() after checkSymlinkSupport.
- Adds theme.Get() call early in main() so OSC 11 probe overhead
  happens at startup, not during TUI rendering.

After this commit:
- grep 'lipgloss.Color(' cmd/skillshare/ returns only the hardcoded
  brand yellow #D4D93C (logo color)
- grep 'tc.|ac.|lc.' cmd/skillshare/ returns only loop variables
- Full build and test suite pass

Refs: #125
2026-04-10 16:50:08 +08:00
Willie 8955ce7813 refactor(tui): migrate remaining TUIs to theme package
Replaces all tc.* references in 26 files under cmd/skillshare/
with the new internal/theme API. Also removes the file-local ac
struct from audit_tui.go and the lc struct from log_tui.go.

Files touched: analyze_tui.go, analyze_tui_item.go, audit_render.go,
audit_rules_tui.go, audit_tui.go, checklist_tui.go, diff_tui.go,
extras.go, extras_init_tui.go, extras_list_tui.go,
extras_list_tui_item.go, hub.go, install_prompt_tui.go, log_tui.go,
new_tui.go, restore_tui.go, search_batch.go, search_tui.go,
sync.go, sync_agents.go, sync_parallel.go, target_agents_test.go,
target_list_tui.go, trash_tui.go, tui_helpers.go.

tui_colors.go (the tc struct definition file) is kept for now; it
will be deleted in the final cleanup commit along with the doctor
integration and main.go early init call.

Refs: #125
2026-04-10 15:24:18 +08:00
Willie 47fe1b8318 refactor(tui): migrate list TUIs to theme package
Replaces all tc.* references in list_tui.go, list_tui_item.go, and
list_tui_content.go with the new internal/theme API. Also fixes the
hardcoded lipgloss.Color("15") at list_tui_item.go:296 — the root
cause of issue #125.

NOTE: The codebase does not compile at this commit alone because
other TUIs still reference the tc struct. The full build is
restored in commit 4 of this PR (migration of remaining TUIs and
deletion of legacy palettes). Treat this PR as one atomic change.

Fixes #125
2026-04-10 14:36:22 +08:00
Willie 49dcbd01c8 fix(doctor): exclude disabled agents from drift count
Doctor was passing all discovered agents (including those disabled
via .agentignore) to the agent target drift check, inflating the
expected count. This caused false drift warnings like '33/66 agents
linked' when the 33 missing agents were actually ignored.

Filter with resource.ActiveAgents() before passing to
checkAgentTargetInline, matching the pattern used by sync and
all server handlers.
2026-04-10 03:42:18 +08:00