Commit Graph
10 Commits
Author SHA1 Message Date
Willie 81974cf350 fix(resource): never skip a hidden-named agents source root (#515)
AgentKind.Discover and the skill detail file listing skipped every
hidden directory, including the walk root itself. The `!= "."` guard in
agent.go never fires because walkRoot is an absolute resolved path, so a
sources.agents directory such as ~/.agents discovered zero agents.

Exempt the walk root (`path != walkRoot`), matching the other walks in
the repo. Nested hidden directories are still skipped.

Related to #511 (same class as #514).
2026-10-10 22:03:53 +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 881d08e52e fix(sync): skip nested target dotdirs when discovering source skills
Installing a repo whose root is a skill copies the whole repo into the
source, including any .claude/skills/ the author keeps for their own
development. Install discovery already skips target dotdirs, but the
source walk used by sync, check, and the dashboard only skipped .git,
so those dev-only skills surfaced as nested skills and were synced to
every target.

Share the skip set through sourcewalk and apply it in both source
walks. Only dotdirs nested below the source root are skipped: host-style
paths directly under the root (.cursor/skills/*) stay visible because
they drive target inference.
2026-10-04 17:11:53 +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 92d5fc66ba fix(agents): exclude convention files and respect agents/ subdir in tracked repos
Agent discovery was treating non-agent files (CLAUDE.md, AGENTS.md, etc.)
as agent resources when they appeared in tracked repos.

Two fixes:
- Expand ConventionalExcludes with 7 well-known convention filenames
  (CLAUDE.md, AGENTS.md, GEMINI.md, COPILOT.md, CONTRIBUTING.md,
  CODE_OF_CONDUCT.md, SUPPORT.md)
- For tracked repos with an agents/ subdirectory, only discover files
  inside agents/ — skip repo root files and other subdirs (docs/, etc.)

Also includes UI polish:
- Display flat names (__ separator) as path separators in toasts/labels
- Consolidate batch install errors into single toast
- Show .agentignore state in sync diff/preview responses
- Track badge + friendly repo name in resource list/folder tree
2026-04-10 02:14:15 +08:00
Willie 7e30699eaa feat: add tracked agent repo discovery and install support
- DiscoveredResource gains RepoRelPath and Targets fields
- AgentKind.Discover populates RepoRelPath via findTrackedRepoRelPath
- AgentCheckResult gains RepoPath and dirty status for tracked repos
- InferTrackedKind auto-detects pure-agent repos for --track install
- TrackedRepoResult reports AgentCount and Agents list
2026-04-10 02:04:55 +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 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 12f8c52a11 feat: add .agentignore support and agent file validation
Add ReadAgentIgnoreMatcher() in skillignore package to read .agentignore
and .agentignore.local files using the same gitignore-style pattern
format as .skillignore.

Integrate .agentignore filtering into AgentKind.Discover() with both
directory-level CanSkipDir() and file-level Match() checks.

Add agent validation in internal/validate/:
- AgentFile(): extension check, filename restrictions (no spaces/special
  chars), file size warning (>100KB), existence and type checks
- AgentName(): name format validation (alphanumeric + hyphens/underscores)

9 new tests across resource and validate packages.
2026-04-07 18:05:40 +08:00
Willie 5160ed5ffe feat(resource): add ResourceKind interface, SkillKind/AgentKind implementations, and reserved name validation
Create internal/resource/ package with:
- kind.go: ResourceKind interface (Discover, ResolveName, FlatName,
  CreateLink, feature gates) + DiscoveredResource struct
- skill.go: SkillKind — directory-based discovery via SKILL.md,
  frontmatter name resolution, nested separator flatten (a/b → a__b)
- agent.go: AgentKind — single-file .md discovery with conventional
  excludes (README/LICENSE/CHANGELOG/SKILL.md), filename-based naming
  with frontmatter override, directory-strip flatten (dir/f.md → f.md)

Add "agents" to reservedSkillNames in validate.SkillName() to prevent
skill names conflicting with the agents source directory.

16 unit tests covering discovery, nested paths, name resolution,
flat name computation, feature gates, and edge cases.
2026-04-07 18:05:39 +08:00