Commit Graph
241 Commits
Author SHA1 Message Date
Willie a726e363fc refactor: redesign status output — unified layout with agents in targets
Restructure status command output for both -g and -p modes:

- Remove "(project)" suffix from all section headers (logo already shows it)
- Merge agents source info into Source section alongside skills
- Show agents as sub-items under each target instead of a separate section
- Remove standalone printAgentStatus/printProjectAgentStatus (dead code)
- Simplify cmdStatus: remove kind parameter since status always shows all
- JSON output unchanged (backward compatible)
2026-04-08 21:55:32 +08:00
Willie 525ae0b9f4 refactor: status always shows both skills and agents
Remove kind filter (agents/--all) from status command — it now defaults
to showing everything, matching diff behavior. Status is a read-only
overview command; users expect the full picture without extra flags.

- Remove parseKindArgWithAll from cmdStatus, hardcode kindAll
- Update help text and usage examples
- Simplify tests: merge agents/all variants into default tests
- Update runbook steps 9-11 → 9-10
2026-04-08 21:40:03 +08:00
Willie eadfcf3d6f refactor: replace positional "all" keyword with --all flag for kind filter
Migrate from "ss list all" syntax to "ss list --all" across all commands
that support kind filtering (list, sync, status, check, audit, backup,
restore, trash).

- Remove "all" as a recognized positional keyword in parseKindArg
- Add extractAllFlag and parseKindArgWithAll helpers
- Update help text, usage examples, and runbook
- Update all integration tests to use --all flag
2026-04-08 21:31:41 +08:00
Willie 43c5154a78 Flatten nested agent sync names
Align agent target naming with the skills-style __ flattening so nested agents do not collide by basename in flat agent directories. Add unit and project-mode integration coverage to verify repeated syncs stay stable and no longer report false updates.
2026-04-08 20:52:29 +08:00
Willie 27f352e5d2 fix: resolve relative paths in project mode extras and agent targets
Extract resolveProjectPath() helper to centralize ~ expansion and
relative-to-project-root resolution. Fixes extras sync and agent
target path resolution in project mode when paths are relative.

Add integration tests for sync --all agents/extras overlap detection
in both global and project modes.
2026-04-08 18:35:36 +08:00
Willie f95a113fce test: migrate all test metadata to centralized store format
Replace .skillshare-meta.json sidecar writes with centralized
.metadata.json store writes across all test files. Use
install.MetadataFileName constant instead of hardcoded strings.

Updated: audit_test, doctor_test, gitignore_project_test,
install_online_test, list_project_test, sync_symlinked_dir_test,
uninstall_project_test, uninstall_test, uninstall_trash_test,
audit_output_online_test, audit_scan_skill_test, analyzer_metadata_test
2026-04-08 17:43:46 +08:00
Willie ff032b3745 test: update integration tests for full-path metadata keys
Grouped install tests now assert full-path keys (e.g. 'frontend/pdf-skill')
instead of basename keys, and verify that legacy basename keys are removed
after migration.
2026-04-08 16:35:40 +08:00
Willie 2acfec82ec refactor: simplify metadata — extract helpers, remove dual-write, add kind constants
Code quality fixes from review:
- Extract RemoveByNames() to eliminate copy-paste in uninstall Phase 7
- Add MetadataKindSkill/MetadataKindAgent constants
- Remove dual-write shim (findSkillsRoot + writeMetaToCentralized)
- install_apply.go uses WriteMetaToStore with SourceDir (no sidecar)
- Move LoadMetadata out of walk loops (P0 efficiency fix)
- isGroupDir accepts store parameter to avoid redundant loads
- Add SourceDir to InstallOptions for --into group support
2026-04-08 15:00:22 +08:00
Willie 424a9df7a4 chore: remove debug test files and local metadata 2026-04-08 14:30:29 +08:00
Willie e91890d2b0 test: fix all integration tests for centralized .metadata.json format
- Dual-write in WriteMeta: also writes to .metadata.json for backward compat
- Migration looks in parent dir for registry.yaml
- Group uninstall matches entries by Group field + full path
- Sync test uses MetadataStore instead of registry.yaml
- All integration tests pass (0 FAIL)
2026-04-08 14:28:57 +08:00
Willie ebcfaf6bc4 feat(agents): add --group support, fix nested discovery, and improve TUI dispatch
- CheckAgents uses recursive discovery via resource.AgentKind{}.Discover()
  so nested agents (e.g. demo/code-reviewer.md) are found correctly
- Add --group/-G flag to update, check, and uninstall agents commands
  with shared validateAgentGroups/matchesAnyGroup helpers
- Fix TUI project-mode dispatch: call cmdUpdateAgentsProject and
  cmdUninstallAgents directly instead of passing 'agents' keyword to
  handlers that don't understand it
- TUI confirmation overlay shows correct command with 'agents' keyword
  and confirmKind field tracks skill vs agent
- TUI toggleDisabled (E key) writes to .agentignore for agents instead
  of .skillignore
- Agent Discover now marks .agentignore matches as Disabled=true instead
  of skipping them, so disabled agents appear in list with [disabled] tag
- Sync filters out disabled agents via resource.ActiveAgents()
- auditSkillByName uses scanPathTarget to support single-file agent audit
- Uninstall agents display uses RelPath (e.g. demo/tutor) instead of
  frontmatter name (e.g. Python Tutor Expert)
2026-04-08 02:37:42 +08:00
Willie 49d33938a2 feat(sync): skip extras 'agents' targets that overlap with agents sync
When extras has an entry named 'agents' whose target paths overlap with
the resolved agent target paths from targets.yaml, the extras targets
are skipped with a warning — the agents sync system takes priority.

Detection uses dual conditions: extras name == 'agents' AND resolved
path overlap. Non-'agents' extras targeting agent paths are unaffected.
Agents source must exist with actual files; empty/missing source means
no overlap (extras sync normally).

Also fixes:
- CheckAgents now recurses into subdirectories via resource.AgentKind
- update agents resolves nested agent names via filepath.Base
- filterAgentCheckResults matches both full path and basename
2026-04-07 22:35:59 +08:00
Willie 3241159b56 style(sync): unify summary format and headers across skills, agents, extras
- Replace ui.Info() agent summary with ui.AgentSyncSummary() using
  OperationSummary pattern (colored metrics, consistent spacing)
- Add ui.ExtrasSyncSummary() call to extras sync (was missing summary)
- Unify section headers: 'Syncing X' / 'Syncing X (project)' pattern
- Remove extra fmt.Println() before extras to fix double blank lines
- Rename agentSyncStats.skipped to .local to match UI semantics
2026-04-07 22:05:34 +08:00
Willie de49f31a39 test: add E2E test for mixed-repo install then sync to correct targets
Validates the full agent workflow: install mixed repo (skills + agents)
then sync all — verifying skills go to skills targets, agents go to
agent-capable targets, agents are excluded from targets without agents
path, and the skip warning mentions the target name.

Uses 'sync all' since plain 'sync' only syncs skills by design.
2026-04-07 20:27:31 +08:00
Willie 73d4d32dfe feat(sync): warn when targets are skipped for agents (no agents path)
Both syncAgentsGlobal and syncAgentsProject now collect target names
where agentPath is empty and print a summary warning after the sync
summary line. This makes it visible to users which targets were
silently skipped, helping them configure agents paths if desired.
2026-04-07 20:22:30 +08:00
Willie e2a3d7024c fix: install agents from mixed repos after skills
Mixed repos containing both skills/ and agents/ directories previously
only installed skills, silently ignoring agents. Now after every skill
install exit point, discovered agents are also installed to the agents
source directory.

- Add installDiscoveredAgents helper that installs agents post-skills
- Update 'Found' message to show agent count in mixed repos
- Call helper at all 4 skill install exit points in handleGitInstall
- Add integration test for mixed-repo install scenario
2026-04-07 20:20:21 +08:00
Willie 031306af62 test(tui): add integration tests for agent TUI features
- TestList_Agents_KindFilter_NoTUI: verifies list agents/all/default
  kind filtering works correctly in --no-tui mode
- TestTrash_MergedList_IncludesAgents: verifies uninstalled agents
  appear in trash agents list --no-tui output
2026-04-07 19:07:21 +08:00
Willie 30f8fb0131 feat(agents): add project-mode backup and restore for agents
Add -p/--project support to 'backup agents' and 'restore agents' commands.
Project-mode backups are stored under .skillshare/backups/ (parallel to
.skillshare/trash/).

Backup engine changes:
- Add ProjectBackupDir(), CreateInDir(), ListInDir() to internal/backup
- Add RestoreLatestInDir(), FindBackupsForTargetInDir(),
  GetBackupByTimestampInDir() to restore.go
- Existing global functions become thin wrappers (zero caller churn)

Command layer changes:
- Allow project mode through for kind=agents in cmdBackup/cmdRestore
- Auto-detect project mode when .skillshare/config.yaml exists
- Refactor backup_agents.go with resolveAgentBackupContext() to
  resolve backup dir + agent targets per mode

Skills backup in project mode remains unsupported (error unchanged).
2026-04-07 18:27:08 +08:00
Willie 075c0191b7 feat(agents): implement project-mode agent support for all commands
Remove all "not yet supported in project mode" errors. Every command
that supports agents in global mode now also supports project mode:

- status -p agents: shows project agent source + per-target status
- status -p all: shows both skills and agents
- check -p agents: checks agent status from .skillshare/agents/
- diff -p agents: computes agent diffs (missing/orphan per target)
- diff agents (global): also now fully implemented via diffGlobalAgents
- collect -p agents: collects local agents from project targets
- audit -p agents: scans .skillshare/agents/ for security patterns

New file: diff_agents.go — shared agent diff logic for both modes
(computeAgentDiff, diffProjectAgents, diffGlobalAgents).

11 new integration tests covering all 5 commands in project mode.
Total agent tests: 56.
2026-04-07 18:05:40 +08:00
Willie eceb9cc6e4 test(agents): fill coverage gaps — project mode uninstall, trash empty/delete, multi-target, JSON kind
7 new integration tests covering:
- trash agents empty / delete
- uninstall agents in project mode (fix: wire kind into project dispatch)
- check all (combined skill + agent)
- sync agents skips targets without agent path
- list all --json verifies kind field on every entry
- status agents --json with target details

Total agent tests: 45 (38 + 7).
2026-04-07 18:05:40 +08:00
Willie 95c46ca822 feat(agents): wire backup/restore and update CLI help text (Phase 4)
backup/restore:
- "backup agents" backs up agent target paths (entry name: <target>-agents)
- "restore agents <target>" restores from agent backup
- Default backup unchanged (skills only)

help text:
- Updated 9 commands with agents positional in Usage and Examples:
  list, sync, update, uninstall, collect, trash, backup, restore,
  status, diff

5 new integration tests (backup/restore round-trip, dry-run, default
unchanged, project mode rejected), all passing.
2026-04-07 18:05:40 +08:00
Willie c2b9a1537d feat(agents): wire kind filter into status, diff, doctor (Phase 3)
status:
- "status agents" shows agent source + per-target agent status (path, linked, drift)
- "status all" shows both skills and agents
- JSON output includes "agents" section with source/count/targets
- Default "status" unchanged (skills only)

diff:
- Kind field populated in JSON output ("skill" or "agent")
- parseKindArg wired into cmdDiff dispatch
- diffItemToJSON helper centralizes Kind defaulting

doctor:
- New checkAgentTargets: validates agent target paths, detects broken
  symlinks and drift (expected vs linked count)
- Checks run after existing agent source check

8 new integration tests, all passing.
2026-04-07 18:05:40 +08:00
Willie cb55ffe55c feat(agents): add positional kind filter and wire agents into list, sync, update, uninstall, collect, trash
Phase 1 — Foundation:
- parseKindArg() defaults to kindSkills, adds "all" keyword
- list: discover agents via resource.AgentKind, populate Kind field in JSON/TUI
- sync agents / sync all: new sync_agents.go handles agent sync to targets
- uninstall: migrate from --kind flag to positional ("uninstall agents <name>")

Phase 2 — Core CRUD:
- update agents: check status, enrich with remote, reinstall from source
- uninstall agents: move .md + sidecar to agent trash with confirmation
- collect agents: CollectAgents from agent-capable targets to source
- trash agents: list/restore/delete/empty for agent trash directory
- trash.RestoreAgent(): file-level restore (vs directory-level for skills)

Behavior: all commands default to skills-only (no breaking change).
"cmd agents" = agents only, "cmd all" = skills + agents.

Fix: TestLog_SyncPartialStatus uses dangling symlink instead of chmod
(root ignores permissions in devcontainer).

25 new integration tests, all passing.
2026-04-07 18:05:40 +08:00
Willie f8c958d305 test: add agent integration tests for install, check, enable, and uninstall
7 integration tests covering:
- install --kind flag parsing and validation
- install -a flag parsing
- check agents with empty dir, local agent, and JSON output
- enable/disable --kind agent routing to .agentignore
- uninstall --kind agent flag parsing
2026-04-07 18:05:40 +08:00
Willie e51fe60254 fix(sync): upgrade existing absolute symlinks to relative in project mode
sync previously skipped symlinks that pointed to the correct source,
even if their format (absolute vs relative) didn't match the expected
mode. This meant existing absolute symlinks in project mode were never
converted to relative on subsequent syncs.

Add linkNeedsReformat(dest, wantRelative) helper that checks whether
the raw readlink result has the wrong format. All four 'already
correct' skip points now check format and recreate when mismatched:

- SyncTargetMergeWithSkills (skills merge mode)
- SyncTarget (skills symlink mode)
- syncExtraSymlinkMode (extras directory symlink)
- syncOneExtraFile (extras per-file merge)

Global mode is unaffected: shouldUseRelative returns false, so
linkNeedsReformat never triggers on absolute links.

Also fix macOS /var → /private/var path mismatch in
TestSyncProject_RelativeSymlinks by EvalSymlinks on expected path.
2026-04-07 17:26:37 +08:00
Willie 39eea955b1 test: verify relative symlinks in project mode, absolute in global mode
Ref: #120
2026-04-07 17:26:37 +08:00
Willie e82d18cfa4 fix: sync must not prune registry entries for installed skills
Sync's registry prune logic removed entries for installed skills whose
files were missing from disk. This was wrong: the registry is the
authoritative record of installations managed by install/uninstall.

Remove PruneStaleSkills calls from sync (CLI global, CLI project, and
web UI handler). Reconcile (called during install) still uses prune
with full metadata context, which is correct.

Fixes: running 'sync' after 'install' would clear registry.yaml when
the installed skill's source files were not yet on disk.
2026-04-06 17:28:10 +08:00
Willie 24b7b4d5b2 fix(reconcile): write tracked repo branch to registry.yaml
Tracked repos have no .skillshare-meta.json, so reconcile could not
read branch from metadata. Now falls back to git rev-parse --abbrev-ref
HEAD for tracked repos, ensuring branch is written to registry.yaml
for cross-device rebuild.

Added gitCurrentBranch() helper in config package (cannot import
internal/git due to circular dependency).

Added registry assertion to TestInstallBranch_TrackedRepo.
2026-04-01 00:32:49 +08:00
Willie 284b3cb2fd fix(test): update sync warning assertion to match summary format
TestSync_TargetNamingStandard_InvalidSkillWarnsAndSkips now checks
for summarized output 'skill(s) skipped (naming validation)' instead
of per-skill warning line.
2026-04-01 00:32:49 +08:00
Willie 428eb11120 feat(install): persist branch to metadata and registry, read in update
- NewMetaFromSource: set meta.Branch from source.Branch
- installFromDiscoveryImpl: forward discovery.Source.Branch when building
  per-skill Source struct for metadata
- installFromGitSubdir: pass source.Branch to sparseCloneSubdir (was
  hardcoded empty string, causing subdir installs to ignore --branch)
- ReconcileGlobalSkills: sync meta.Branch to registry on both new and
  existing entries
- toSkillEntryDTOs: include Branch field in DTO conversion
- updateRegularSkill / updateSkillFromMeta: restore source.Branch from
  meta before reinstalling, so updates pull from the originally-specified
  branch

Tests: TestInstallBranch_MetadataPersistence, TestInstallBranch_UpdatePreservesBranch
2026-04-01 00:32:49 +08:00
Willie 55ce0fb89e feat(install): pass --branch to discovery clone for regular installs
Source.Branch threads the branch parameter through discovery.
cloneRepo() passes --branch to git clone when set.
source.Branch is set from parsed.opts.Branch in cmdInstall.

Ref: #90
2026-04-01 00:32:49 +08:00
Willie 09a40a4bdf feat(install): pass --branch to git clone for tracked repos
cloneTrackedRepo(), cloneRepoFull(), and sparseCloneSubdir() now accept
a branch parameter. When non-empty, --branch <name> is passed to
git clone. Fallback chain (partial → full) preserved.

Ref: #90
2026-04-01 00:32:49 +08:00
Willie 1c4aeff4e5 feat(install): parse --branch / -b flag
Add --branch / -b flag to install command:
- Flag parsing with value-required and non-empty validation
- Mutual exclusion: --branch rejected for non-git (local path) sources
- Help text added to printInstallHelp()
- Integration tests covering all three error paths
2026-04-01 00:32:49 +08:00
Willie ccdafd3293 feat(sync): add target_naming config option (flat/standard)
Add per-target target_naming setting that controls how skill directories
are named in sync targets. 'flat' (default) preserves the existing
flattened __ separator behavior. 'standard' uses the SKILL.md name field
directly, following the Agent Skills specification.

Standard mode:
- Validates SKILL.md names match directory basenames
- Detects and skips name collisions with warnings
- Auto-migrates managed entries when switching from flat to standard
- Preserves legacy entries when bare name is already occupied

Also includes:
- Per-target toggle via CLI (--target-naming), TUI (N key), and Web UI
- Collision output redesigned as deduplicated compact summary
- Config inheritance: global target_naming → per-target override
- JSON schema + UI validation for the new field

Closes #110
2026-04-01 00:32:49 +08:00
Willie 621b5c7ac6 test: integration tests for enable/disable and collect mode inheritance 2026-03-29 04:59:23 +08:00
Willie ffdded311f feat(analyze): add --filter flag with filtered_summary in JSON output
Support case-insensitive substring filter on skill relPath.
When --filter is set, JSON output includes filtered_summary with
always_loaded, on_demand, and total token counts for matched skills.

Ref: Discussion #99
2026-03-26 23:47:28 +08:00
Willie 9a433723bd fix(test): update registry.yaml path in integration tests
Tests now look for registry.yaml in source dir instead of config dir,
matching the new registry location.
2026-03-26 22:50:03 +08:00
Willie b3bbfc0469 test: add registry migration and source dir integration tests
Verify MigrateRegistryToSource behaviour end-to-end:
- old-only: registry.yaml is moved from config dir to source dir
- both-exist: old file is kept, new file unchanged, warning printed
- global mode fresh sandbox: registry.yaml never written to config dir
2026-03-26 22:44:44 +08:00
Willie d404eda70e test(analyze): add integration test for JSON lint output 2026-03-26 19:20:52 +08:00
Willie 78ba5c7282 refactor(analyze): polish TUI rendering and add docs
- Fix nil pointer panic when WindowSizeMsg arrives before data loaded
- Fix TestAnalyze_Verbose: create 12 skills to match analyzeTopN=10
- Unify left panel with shared renderPrefixRow (▌ prefix bar style)
- Right-align token counts in skill list rows
- Pre-compute colored dots to avoid per-render lipgloss allocations
- Add category tab bar at top for future analysis categories
- Improve target bar separator (│ → ·) and footer spacing
- Extract renderFooter to eliminate viewSplit/viewVertical duplication
- Add analyze command reference page and sidebar/index entries
2026-03-26 19:20:52 +08:00
Willie a636fc6f85 feat(analyze): add --no-tui flag and TUI dispatch 2026-03-26 19:20:52 +08:00
Willie 620141af2b feat(analyze): add context analysis command
Analyze context window usage per target, showing always-loaded
(description) vs on-demand (body) token costs.

- Single-pass discovery with frontmatter-aware char/token counting
- Per-target filtering (include/exclude/symlink mode)
- Unified output when all targets have identical skills
- Verbose mode shows top 10 largest descriptions
- Project mode (-p) support
- JSON output (--json)
- Integration tests
2026-03-26 19:20:52 +08:00
Willie 3bcbd7b170 fix(test): update upgrade tests for metadata.version format
Test SKILL.md content changed from top-level version: to
metadata.version to match the new format.
2026-03-25 21:14:16 +08:00
Willie 31db9fa36f test(extras): integration tests for flatten sync
Covers: flatten merge (files land flat), collision detection (warn and
skip), and config YAML round-trip.

Ref: #97
2026-03-25 21:14:16 +08:00
Willie 5a0a8753d0 fix(test): update extras source-not-exist test for auto-create behavior
Sync now auto-creates missing extras source directories instead of
failing with "does not exist". Update the assertion to match.
2026-03-20 02:36:50 +08:00
Willie 34819c664b fix(ui): fix TypeScript build errors for tsc -b strict mode
- Add explicit undefined initial value to all useRef<setTimeout>
  calls (5 hooks) — tsc -b requires initial argument
- Remove unused ValidationError import in test file
2026-03-20 02:36:50 +08:00
Willie 14823027b5 test: comprehensive extras source config coverage
Unit tests:
- ResolveExtrasSourceDir 3-level priority + empty fallbacks
- ResolveExtrasSourceType per-extra/extras_source/default
- Config Load() tilde expansion for ExtrasSource and per-extra Source

Server tests:
- GET /api/extras includes source_type
- POST /api/extras with/without source field
- Project mode returns default source_type
- Create backfills extras_source

Integration tests:
- extras_source config, per-extra --source flag
- source_type in JSON, priority chain
- sync/collect/doctor/status with custom source
- sync auto-creates missing source dirs
- init backfills extras_source

E2E runbook (24 steps, mdproof verified):
- All three sync modes with content verification
- Tilde expansion, backward compatibility
2026-03-20 02:36:50 +08:00
Willie dc82b93d05 fix: address code review findings for auto-create target dirs
- Remove early return in dry-run so linked/copied counts are populated
  correctly (P1: UI preview no longer hides Sync Now button)
- Use local quietDryRun flag instead of mutating global DiagOutput
  to suppress per-skill messages (P2: safe under parallel sync)
- Use "Will create" for dry-run, "Created" for actual sync (P3)
- Include dir_created in allUpToDate check so empty source + missing
  dir still shows Sync Now in the preview modal
2026-03-19 04:16:36 +08:00
Willie 643e3c5c07 fix: auto-create missing target directories with notification (#87)
v0.17.5 blocked sync when target directories didn't exist, which
prevented first-time users on fresh CLI installs from syncing.

Sync now auto-creates missing directories and reports what it did
in CLI output, dry-run preview, and the Web UI. Init also creates
target directories when it detects an installed CLI tool.

Web UI: Sync Preview modal stays open after sync with a success
banner instead of immediately closing, so users can review results.

Closes #87
2026-03-19 03:57:08 +08:00
Willie ae1906297f test: add integration tests for metadata.targets sync
Verify that the new metadata.targets format works end-to-end
through the full sync pipeline: filtering, mixed format
coexistence, and metadata-over-toplevel priority.
2026-03-18 22:35:02 +08:00