Skip to content

✨ feat(copilot): stow whole config dir with runtime-state gitignore - #159

Merged
dandyrow merged 2 commits into
mainfrom
feat/copilot-whole-dir-stow
Sep 1, 2026
Merged

dandyrow merged 2 commits into
mainfrom
feat/copilot-whole-dir-stow

Conversation

@dandyrow

@dandyrow dandyrow commented Sep 1, 2026 •

Copy link
Copy Markdown
Owner

What

Copilot CLI config switches from per-file stowing to the standard whole-dir stow:

  • dotfiles-linking.nix: added "copilot" to configLinks, removed the two per-file home.file entries. ~/.config/copilot is now a single symlink into the repo's copilot/.config/copilot/.
  • Git symlink: copilot/.config/copilot/copilot-instructions.md → ../../../agents/.config/agents/nix-native-deps.md — keeps one source of truth for the machine-wide Nix-native dependency guidance.
  • .gitignore: whitelist ignores all copilot runtime state inside the repo's copilot dir, keeping only the stowed config files tracked (mcp-config.json, settings.json, copilot-instructions.md).
  • settings.json: now tracked in the repo. skillDirectories points at the two skills roots (wd-product-ai/skills and ~/.local/share/agents/skills) instead of enumerating individual skills, so new skills under either tree auto-load. Verified: parent dirs recursively discover all 54 skills across both trees (5 name collisions deduped first-win) via copilot skill list against a scratch COPILOT_HOME.

Why per-file → whole-dir

The previous per-file handling existed because the two copilot config files came from different sources (mcp-config.json from the copilot dir, copilot-instructions.md from the agents dir). With a git symlink inside the repo's copilot dir, the whole dir can be stowed normally while the instructions content still resolves to the canonical agents/nix-native-deps.md.

Research: can global instructions / runtime state live outside $COPILOT_HOME?

No — investigated before implementing:

  1. COPILOT_CUSTOM_INSTRUCTIONS_DIRS cannot reproduce global behaviour. *.instructions.md files are path-specific — only applied when applyTo matches the file being worked on — and AGENTS.md files in the custom dirs are unreliable/not auto-loaded (copilot-cli#713, copilot-cli#1433). Not viable for machine-wide workflow guidance.
  2. The global instructions filename is fixed. Copilot CLI only reads $COPILOT_HOME/copilot-instructions.md; there is no config to point that file at an arbitrary path.
  3. Runtime state can't be redirected to XDG_STATE_HOME. COPILOT_HOME relocates config+state as one bundle with no way to split them (copilot-cli#1954). Only the cache dir is XDG-compliant (COPILOT_CACHE_HOME → ~/.cache/copilot).

Because the whole-dir symlink means runtime state (session-store.db, session-state/, logs/, permissions-config.json, mcp-oauth-config/, etc.) will be written into the repo's copilot dir, the .gitignore whitelist keeps that churn out of git status while keeping the stowed config files tracked.

Verification

  • All three hosts (DansSpectre, New-H0Ryzen, WSL --impure) evaluate via nix eval.
  • git check-ignore confirms runtime names are ignored; tracked config files are not.
  • The git symlink resolves to agents/.config/agents/nix-native-deps.md via readlink -f.
  • copilot skill list (scratch COPILOT_HOME, COPILOT_SKILLS_DIRS unset) confirms the parent-dir skillDirectories discover all 54 skills from both trees.

Post-merge switch notes

nixos-rebuild switch will replace the current real ~/.config/copilot dir (203 MB of runtime state) with the symlink into the repo. Existing sessions/logs/permissions in the old dir are left behind; copilot will recreate its runtime files fresh in the repo dir on next launch (auth in config.json may need re-login if not stored in the system keyring). Worth a one-time migration of mcp-oauth-config/ and permissions-config.json if you want to keep them. The pre-existing ~/.config/copilot/settings.json should be replaced by the repo version after switch (delete or move aside so the symlink's file takes effect).

dandyrow and others added 2 commits September 1, 2026 17:57
Copilot was previously stowed per-file: the two config files were
individual home.file entries. Switch to the standard whole-dir stow by
adding "copilot" to configLinks, so ~/.config/copilot is a single symlink
into the repo. Global instructions now work via a git symlink inside the
copilot dir pointing at agents/.config/agents/nix-native-deps.md, keeping
one source of truth.

Research findings recorded for the commit:
- COPILOT_CUSTOM_INSTRUCTIONS_DIRS cannot reproduce global behaviour:
  *.instructions.md files are path-specific (only applied when applyTo
  matches the file being worked on) and AGENTS.md files in custom dirs
  are not auto-loaded (github/copilot-cli#713, #1433). Not viable for
  machine-wide workflow guidance.
- The global instructions filename ($COPILOT_HOME/copilot-instructions.md)
  is fixed; COPILOT_HOME relocates config+state together but cannot split
  them (github/copilot-cli#1954), so runtime state cannot be redirected to
  XDG_STATE_HOME. Only the cache dir is XDG-compliant via COPILOT_CACHE_HOME.
- Hence runtime state (session-store.db, session-state/, logs/,
  permissions-config.json, mcp-oauth-config/, etc.) lands inside the
  repo's copilot dir through the whole-dir symlink; the gitignore
  whitelist keeps the two stowed config files tracked and ignores the rest.

Verified: all three hosts evaluate via nix eval.

Co-authored-by: Copilot <[email protected]>
Point skillDirectories at the two skills roots instead of enumerating
individual skill directories, so new skills under either tree load
automatically. Verified: parent dirs recursively discover all 54 skills
across both trees (5 name collisions deduped first-win), confirmed with
`copilot skill list` against a scratch COPILOT_HOME before applying.

settings.json is now a stowed config file, so whitelist it in the
copilot gitignore alongside mcp-config.json and copilot-instructions.md.

Co-authored-by: Copilot <[email protected]>
@dandyrow
dandyrow merged commit 034db9e into main Sep 1, 2026
1 check passed
@dandyrow
dandyrow deleted the feat/copilot-whole-dir-stow branch September 1, 2026 17:29
dandyrow added a commit that referenced this pull request Sep 1, 2026
…159)

* ✨ feat(copilot): stow whole config dir with runtime-state gitignore

Copilot was previously stowed per-file: the two config files were
individual home.file entries. Switch to the standard whole-dir stow by
adding "copilot" to configLinks, so ~/.config/copilot is a single symlink
into the repo. Global instructions now work via a git symlink inside the
copilot dir pointing at agents/.config/agents/nix-native-deps.md, keeping
one source of truth.

Research findings recorded for the commit:
- COPILOT_CUSTOM_INSTRUCTIONS_DIRS cannot reproduce global behaviour:
  *.instructions.md files are path-specific (only applied when applyTo
  matches the file being worked on) and AGENTS.md files in custom dirs
  are not auto-loaded (github/copilot-cli#713, #1433). Not viable for
  machine-wide workflow guidance.
- The global instructions filename ($COPILOT_HOME/copilot-instructions.md)
  is fixed; COPILOT_HOME relocates config+state together but cannot split
  them (github/copilot-cli#1954), so runtime state cannot be redirected to
  XDG_STATE_HOME. Only the cache dir is XDG-compliant via COPILOT_CACHE_HOME.
- Hence runtime state (session-store.db, session-state/, logs/,
  permissions-config.json, mcp-oauth-config/, etc.) lands inside the
  repo's copilot dir through the whole-dir symlink; the gitignore
  whitelist keeps the two stowed config files tracked and ignores the rest.

Verified: all three hosts evaluate via nix eval.

Co-authored-by: Copilot <[email protected]>

* 🗂️ feat(copilot): discover skills from parent dirs in settings.json

Point skillDirectories at the two skills roots instead of enumerating
individual skill directories, so new skills under either tree load
automatically. Verified: parent dirs recursively discover all 54 skills
across both trees (5 name collisions deduped first-win), confirmed with
`copilot skill list` against a scratch COPILOT_HOME before applying.

settings.json is now a stowed config file, so whitelist it in the
copilot gitignore alongside mcp-config.json and copilot-instructions.md.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
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