Ten tests assumed POSIX behaviour:
- Five asserted os.ModeSymlink, but Windows links with a junction;
check utils.IsLinkMode instead.
- Two used `/abs/...` as an absolute path, which has no volume on
Windows; give the fixtures one.
- Windows has no permission bits to preserve, so the 0600 check is
skipped there.
- Reading a file as a directory reports not-exist on Windows, which
prune ignores, so that prune-error test is skipped there.
- A single-file extension relies on the shebang and the executable bit,
so ListExtensions finds only directory extensions on Windows, as the
extras docs describe.
Add ./internal/sync and ./internal/trash to the windows-test package
list so they stay green.
Refs #344
Copy and extension modes pruned every unexpected .md (or output-extension)
file in the agents target, so agent files a user kept there were deleted
on the next sync, unlike skills copy mode, which prunes only manifest
entries.
Copy and transform outputs are now tracked with the same checksum
manifest the merge fallback already uses, and prune removes only tracked
copies the user has not edited. Existing copies are adopted while their
agent is still synced, and an untracked pre-transform .md that still
matches its agent is treated as a stale copy, so switching to an
extension keeps cleaning it up. Copies already orphaned before upgrading
are kept and must be removed by hand.
copyTracker.pruneOrphans now continues past a failed removal and joins
the errors, so one locked file no longer leaves the other orphans behind.
prunableLink treated any stat failure as a broken link, so a live link
whose referent was temporarily unreadable (for example permission denied)
was deleted as if it pointed nowhere. Only a missing referent now counts
as broken.
PruneOrphanAgentLinks and PruneOrphanAgentCopies ignored os.Remove errors
and still listed the entry as removed, so sync reported a prune that did
not happen. Failed removals are now returned as errors, which the agent
runner already surfaces as warnings.
Merge-mode pruning for agents and extras removed any link whose name was
not expected, so links a user made to agent or extra files outside the
source were deleted on the next sync or `extras --remove-target --prune`.
Agents and extras do not record their links in a manifest, so the #315
provenance check cannot be reused. Prune now removes a link only when it
is broken or resolves inside the source. Relative links are resolved from
the real parent directory, matching how createLink writes them, so
orphans under a symlinked target directory are still found.
Tools disagree on agent frontmatter and some need another format entirely,
so an agent written for Claude is misread elsewhere. An `extension` on a
target's agents block reuses the extras transform mechanism to convert each
agent during sync.
Converted targets hold transformed output, so collect never pulls them back
into the source. Leftover symlinks from merge or symlink mode are removed
rather than written through, and a failed conversion drops the old output
so an unconverted agent never stays active.
The bundled opencode-agents extension keeps only fields OpenCode documents
and refuses agents that restrict their tools, since dropping those fields
would widen the agent's access.
Refs #267
Refs #241
Project-mode agent sync re-reported every agent as updated on the second
sync when the project lived under a symlinked ancestor (e.g. macOS temp
dirs under /var -> /private/var), failing idempotency on macOS CI.
Two interacting causes:
- shouldUseRelative was unstable: on the first sync the target directory
does not exist yet, so evalOrClean fell back to a non-resolved path and
the under-project-root check failed, producing an absolute link; on the
second sync the directory existed and resolved, so it wanted a relative
link and reformatted the existing one. evalOrClean now resolves the
deepest existing ancestor and re-appends the missing tail, so the answer
is the same whether or not the leaf exists.
- The existing-symlink comparison only did a direct string compare, so a
stable relative link whose resolved target carried the unresolved alias
prefix looked like it pointed elsewhere. It now canonicalizes both sides
via EvalSymlinks on the slow path, mirroring isSymlinkToSource.
Adds a regression test that reproduces the symlinked-ancestor case on any
platform.
TestSyncAgents_MergeMode_NestedSameBasename_IsStable compared raw
symlink targets against t.TempDir() paths without EvalSymlinks, causing
false failures on macOS where /var is a symlink to /private/var.
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.
Add SyncAgents() dispatcher supporting all three sync modes:
- merge: per-file symlinks with local file preservation
- symlink: whole directory symlink to agent source
- copy: file copy with content-diff detection
Add CheckAgentCollisions() to detect agents that flatten to the same
filename from different subdirectories.
Add PruneOrphanAgentLinks() for merge mode and PruneOrphanAgentCopies()
for copy mode to clean up stale agent files in targets.
Add CollectAgents() to copy non-symlinked .md files from target back
to agent source directory.
18 tests covering all modes, collision detection, pruning, and collect.