Skip to content

fix(doctor): probe the Copilot hooks file where inject writes it - #733

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
SaulMoro:fix/732-doctor-copilot-hook-path
Sep 23, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
SaulMoro:fix/732-doctor-copilot-hook-path

Conversation

@SaulMoro

Copy link
Copy Markdown
Collaborator

Closes #732

Summary

doctor and inject resolved the Copilot hooks file to two different paths in a non-self project scope. inject writes it at the config scope; doctor joined the user-scope relative path onto the project base dir.

 buildHookChecks
-  for tool in hookToolPaths                      # every path at hook scope ('user')
+  for tool in toolPaths                          # config scope
     if paths.hooks                               # standalone file (Copilot)
       resolveToolBaseDir(tool, localConfig) + paths.hooks
-        # <projectRoot> + hooks/teamai.json  → never written → ✖
+        # <projectRoot> + .github/hooks/teamai.json  → what inject wrote
     else if settings
-      baseDir + paths.settings
+      baseDir + hookToolPaths[tool].settings     # hook scope, unchanged for claude/codex/cursor/…

hooks list already applied this rule (hooks-cmd.ts, hookScopedPaths[tool]?.settings); doctor now matches it. Note for #728: it adds the same parameter to buildHookChecks as part of toolRoots; the two will need a trivial rebase.

Evidence

  • Before: new test checks project Copilot hooks where inject wrote them when userScope.hooks is set (project scope, toolPaths.copilot with both hooks and userScope.hooks, file present at <projectRoot>/.github/hooks/teamai.json):

    Expected: "✔"
    Received: "  ✖ teamai hooks in copilot settings"
    

    After: passes. npx vitest run → 271 files, 3875 passed, 1 skipped. npx tsc --noEmit clean.

  • Before (real CLI, main at cd3e0e6, project scope, Copilot installed):

    ✖ teamai hooks in copilot settings
      → Run `teamai hooks inject` to inject/update hooks
    

    teamai hooks inject → ✔ Hooks injected into all AI tool settings; doctor still ✖.
    After (npm run build, same config):

    Scope: project (/Users/<me>/Repositorios/teamai-cli)
    ✔ teamai hooks in claude settings
    ✔ teamai hooks in codex settings
    ✔ teamai hooks in cursor settings
    ✔ teamai hooks in copilot settings
    ✔ teamai hooks in codebuddy settings
    ✔ All checks passed!
    

Test Plan

  • npx tsc --noEmit
  • npx vitest run (271 files, 3875 passed)
  • npm run build then teamai doctor in a project-scope install (provider github) with Claude, Codex, Cursor, Copilot and CodeBuddy hooks injected: all five hook checks ✔
  • Same install, teamai hooks list: copilot installed <project>/.github/hooks/teamai.json, consistent with doctor
  • Existing user-scope Copilot test (checks standalone Copilot hooks under COPILOT_HOME) still green: $COPILOT_HOME/hooks/teamai.json unchanged

Merge Danger

Door: two-way

Read-only check; revert restores the previous probe path. No file is written.

Blast Radius: doctor

Only the Copilot row of the hook checks changes its path, and only when userScope.hooks differs from hooks in a non-self project scope. Settings-based tools keep the hook-scope path from #695. Also affects the post-pull check registry, which shares buildChecks.

…cent#732)

In a non-self project scope, resolveDoctorContext forces the hook paths to
the hook scope ('user', per resolveHookScope) so settings-based hooks are
probed where reconcileHooksToAllTools writes them. The standalone Copilot
hooks file is written by reconcileTeamHooksForConfig at the config's own
scope instead, so the doctor ended up joining the userScope relative path
(hooks/teamai.json) onto <projectRoot> and reported Copilot missing right
after a successful `hooks inject`.

buildHookChecks now takes both maps and picks per hook kind: a standalone
`hooks` file from the config-scoped paths, `settings` from the hook-scoped
ones. Same rule `hooks list` already applies.

Hypothesis confirmed: scope mismatch between the two path maps, introduced
when Tencent#695 moved the doctor's hook paths to the hook scope for Qoder CN.
@jeff-r2026
jeff-r2026 merged commit ff47714 into Tencent:main Sep 23, 2026
8 checks passed
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.

[bug] doctor reports Copilot hooks missing in project scope right after a successful hooks inject

2 participants