Skip to content

sync: a project in a subfolder of a git repository writes exclude patterns that miss its per-machine files #62

Closed

Description

@tenphi

In short

  • For a project below the git root, such as docs-site/ with its own package.json, sync writes its per-machine paths into the repository's .git/info/exclude as if the project were the root: /.claude/skills/... instead of /docs-site/.claude/skills/....
  • Git then shows the skill links, rules and settings as untracked, and init still says "Links and settings for this machine stay out of git".
  • doctor reports each one with a wrong cause: "It is in .git/info/exclude, but a ! pattern in a .gitignore file brings it back."
  • Seen on 0.9.2.

Reproduction

mkdir repo && cd repo && git init -q
mkdir docs-site && cd docs-site
echo '{"name":"site","private":true}' > package.json
npm i -D @tenphi/harnesspm
npx harnesspm init     # "Links and settings for this machine stay out of git: .git/info/exclude lists them."
cd .. && git status --short
# ?? docs-site/.agents/
# ?? docs-site/.claude/
tail ../.git/info/exclude  # (from repo/) /.agents/skills/harnesspm-export, /.claude/skills/..., anchored at the git root

Cause

gitExcludeFile(projectDir) (src/util.ts) returns the exclude file of the git root, but applyPlan() (src/outputs.ts) writes entries as /${relPosix(projectDir, file)}, relative to the project folder. excludedBySync(), doctor and the cleanup of stale links read them back the same way.

Where we met it

Cookbook's documented setup creates a docs site in docs-site/ inside the user's repository (npm create @tenphi/cookbook docs-site -- --source .), and its agent guide says to run harnesspm init in the site's folder (tenphi/cookbook#210).

Proposal

  • Anchor entries at the git root: prefix them with the project's path relative to the git root when writing, and strip it when reading.
  • Key the BEGIN/END sections by that path, so two harnesspm projects in one repository do not overwrite each other's section.
  • Fix doctor's message for an entry whose pattern does not match.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions