Skip to content

fix(sync): copy files that a negation re-includes under an ignored folder - #986

Merged
runkids merged 1 commit into
mainfrom
runkids/copy-ignore-negation
Nov 23, 2026
Merged

runkids merged 1 commit into
mainfrom
runkids/copy-ignore-negation

Conversation

@runkids

@runkids runkids commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)
  • Approved feature or large change (the linked issue has the approved label)

Linked Issue

No issue. Found while reviewing #980.

What was wrong

The ignore: list in the config decides which files copy-mode targets receive. Its rules use .skillignore matching, where a later ! rule re-includes a path even inside an ignored folder. The copy, mtime and checksum walks skipped every ignored folder, so the negation never ran:

ignore:
  - docs/
  - "!docs/keep.md"

sync never copied docs/keep.md, and diff still reported the target in sync.

Fix

  • The three walks skip a folder only when CanSkipDir says no negation can reach inside it. Files are still matched one by one.
  • The copy walk creates an ignored folder it entered only when a kept file or folder needs it, with the source folder's mode. Folders that hold nothing kept are not created in the target.
  • Below a symlinked folder, the copy walk now matches rules against the path from the skill root, as the checksum walk already did. Before, it restarted at the link target, so the two walks could pick different files. Then a copied file could change without diff or sync noticing.

The docs gain one paragraph on ! rules, and the default list now matches the code (.DS_Store, .git/, __pycache__/). Translations are updated.

Upgrade effect:

  • A negation that is not anchored, such as !*.md, now re-includes matching files inside every ignored folder, node_modules/ included, and sync walks those folders.
  • Below a symlinked folder, rules now match from the skill root even without any ! rule. A link named docs under the rule docs/ used to be copied in full and now is not. An anchored rule such as /build/ no longer matches a build/ folder inside the link target.
  • A target synced by an older version may keep its old files until the source changes or sync --force runs. The manifest's fast paths do not know the ignore rules, so if no file the walk compares changed, nothing looks changed. Changing ignore: already behaves this way today.

Tests

All fail on main and pass with the fix, except the guard noted below:

  • internal/sync/file_ignore_test.go:
    • a file re-included under an ignored folder is copied;
    • a later change to it is synced;
    • a re-included folder (docs/ plus !docs/api/) is copied;
    • an entered ignored folder without kept files is not created. This guard passes on main, which never entered the folder. It fails if the copy walk creates folders as it enters them.
  • internal/sync/checksum_test.go: the checksum and mtime walks include the re-included file and still leave out ignored ones.
  • internal/sync/symlinked_dir_test.go: through a symlinked folder, a file changes the checksum exactly when it was copied. There are two cases. The link named docs fails on main. The link above docs/ passes on main, where both walks skipped the folder, and fails with only the CanSkipDir change.

Checks

  • make check passes in the devcontainer.
  • End to end with the built binary in global mode, using a copy-mode target and a symlinked folder:
    • sync copies only the kept file and diff reports in sync.
    • Editing the kept file makes diff report it, and the next sync copies it.
    • Editing an ignored file leaves diff in sync.

Not in this PR

  • In project mode, the dashboard does not read the project's ignore: list. Its sync and diff use only the defaults.
  • Manifest.OwnsCopy hashes the target with the default patterns only. A user rule that re-includes a default pattern makes an unchanged copy look locally modified when switching to merge mode.
  • diff --files does not apply ignore: at all.

Checklist

  • I've read CONTRIBUTING.md, including its AI-assisted contributions section
  • I've reviewed every line of the diff and can explain it
  • Tests included and passing (make check) — for code changes
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

…lder

The config `ignore:` list uses .skillignore matching, where a later "!"
rule re-includes a path inside an ignored folder. The copy, mtime and
checksum walks skipped every ignored folder, so a rule such as
`!docs/keep.md` after `docs/` never took effect and diff still reported
the target in sync.

The walks now skip a folder only when CanSkipDir says no negation can
reach inside it. The copy walk creates an entered ignored folder only
when something kept needs it, so targets gain no empty folders. Below a
symlinked folder the copy walk matches rules from the skill root, as the
checksum walk does, so the two walks pick the same files.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T02:59:18.153495Z 73c259f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@runkids
runkids merged commit 0538c5c into main Nov 23, 2026
10 checks passed
@runkids
runkids deleted the runkids/copy-ignore-negation branch November 23, 2026 03:04
runkids added a commit that referenced this pull request Nov 23, 2026
…#994)

Three gaps left after the ignore: fixes in #986-#993:

- `disable` kept the line it wrote when a "!" rule kept the skill
  enabled, so the ignore file gained a rule that did nothing. The line is
  now removed again when it disables none of the skills it names.
- `skillshare disable inner` writes the folder name, but the list TUI and
  the dashboard removed only the skill's path line on enable, so the
  skill stayed disabled with no way to turn it back on there. They now
  also remove the folder-name line, unless it disables a skill or agent
  that is not being enabled.
- `diff` counted files that ignore: keeps out of the copy in the "source
  changed" time of a copy-mode target. It now counts only what sync
  copies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant