Skip to content

feat(agents): support Qoder CN via its .qoder-cn user directory - #695

Merged
jeff-r2026 merged 4 commits into
Tencent:mainfrom
PerryLink:feat/qoder-cn-support
Sep 22, 2026
Merged

jeff-r2026 merged 4 commits into
Tencent:mainfrom
PerryLink:feat/qoder-cn-support

Conversation

@PerryLink

@PerryLink PerryLink commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #667.

Summary

Qoder CN keeps its user directory at ~/.qoder-cn instead of ~/.qoder, so a CN install saw none of TeamAI's synced resources — the workaround was to symlink the two directories together. This registers qoder-cn as its own built-in target.

Only the user directory differs. Project scope still uses .qoder/, which is what scopedToolPaths encodes: top-level fields are the project paths, and a userScope block carries the user overrides. The entry follows that contract — top-level stays .qoder/*, userScope holds .qoder-cn/*, mcp is the user-level MCP file and mcpProject the project-level one. An earlier revision of this PR put .qoder-cn/* at the top level, which would have written project-scope resources into a directory Qoder CN does not read.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature causing existing behavior to change)
  • Documentation only
  • Refactor / internal cleanup

Test Plan

  • npx tsc --noEmit passes
  • npx vitest run passes — see the baseline note below
  • Added/updated tests for the change
  • npm run build + real-CLI end-to-end record — below

Real-CLI end-to-end record

Run against the public teamai-hub/teamai-cli-dev dogfood repo from CONTRIBUTING, with a scratch HOME so the user-scope paths are observable, at b6d919a:

$ npm run build
ESM dist\index.js  1.75 MB   Build success

$ teamai init https://github.com/teamai-hub/teamai-cli-dev \
      --scope project --role dev --agent qoder-cn
✔ Authenticated as PerryLink
✔ Team repo cloned
✔ Registered as team member: PerryLink
⚠ Member registration could not be pushed (no write access?). You are still set up locally.
✔ teamai initialized successfully!

$ teamai pull
✔ Updated teamai hooks in <HOME>\.qoder-cn\settings.json

$ teamai doctor
✔ qoder-cn is installed
   ✔ teamai hooks in qoder-cn settings
✔ teamai hooks in qoder-cn settings

Resulting filesystem state:

Path Result
<HOME>/.qoder-cn/settings.json written
<HOME>/.qoder/settings.json not written
<project>/.qoder/skills/… written (19 files)
<project>/.qoder-cn/ not created

The two bold rows are the bug: before the scoping correction the hooks went to ~/.qoder/settings.json — the international install's config — and teamai doctor reported teamai hooks in qoder-cn settings as missing.

The ⚠ Member registration could not be pushed line is expected for a contributor without write access, exactly as CONTRIBUTING describes.

Unit tests

npx tsc --noEmit → exit 0.

Full suite at b6d919a: 30 failed | 240 passed files, 71 failed | 3701 passed | 5 skipped tests. The 30 failing files are the pre-existing Windows failures (path separators, and hook assertions that need a shell), unchanged from the baseline; the failing-test count moved from 75 to 71 across this rebase because upstream's eight new commits changed those files. I have not ticked the vitest run box because it is not literally green here, and I would rather say so than tick it.

Related Issues

Fixes #667

Notes for Reviewers

Three things worth your attention.

1. userScope did not admit settings. The schema and its splice covered skills, rules, agents, hooks and claudemd only. Without adding settings, a user-scope qoder-cn would have had its hooks written to ~/.qoder/settings.json — the same class of error as the one being fixed, in the other direction. settings is now part of the userScope schema and splice.

2. Hooks do not always live at the config's scope. resolveHookScope maps a non-self project scope to HOME (#264), but the callers resolved their tool paths from localConfig. Every one of them therefore looked under the project prefix inside HOME (doctor.ts even documents the #264 behaviour right above the line that got it wrong). resolveHookScope and resolveLegacyProjectHookScope now report the scope they resolved, and hooks.ts, pull.ts, hooks-cmd.ts and doctor.ts use it. This is why teamai doctor previously reported the qoder-cn hooks missing. It is a slightly wider blast radius than "add one table row", so it is called out here rather than buried — but without it the feature is incorrect at user scope, and the two constants cannot be reconciled by editing one line.

3. The support matrix has moved. This PR originally added a Qoder CN row to all five README* files. Upstream's #722 ("slim README to a landing page and move product details out") removed that table from the READMEs in the meantime, so the rebase drops those edits and puts the row where the matrix now lives: docs/product-overview.md and docs/product-overview.zh-CN.md.

One judgement call I made and would still like your view on: I mirrored qoder's first-class shape (skills, rules, hooks, MCP, subagents) rather than the trae-cn pattern, which registers skills only. trae is a bare registry entry with no toolPaths, whereas qoder is a full target — a skills-only qoder-cn would still leave users symlinking for everything else, which is what the issue is about.

Assumption I could not verify. That Qoder CN's project-scope layout is shared with Qoder (.qoder/) rests on the premise that only the user directory differs, which the issue itself states. I could not corroborate it from this repository — trae-cn is the only other CN variant and has no toolPaths at all, so it establishes the user-prefix pattern but says nothing about project prefixes. The code carries a labelled ASSUMPTION: comment naming exactly what to change if that is wrong.


Update: review round 3 (four P1 findings)

1. Real-CLI E2E record — added above; the round-3 bot ran against the previous description, before that section existed.

2. hooks list and uninstall discovery resolved paths at the wrong scope. Both used the HOME base directory resolveHookScope reports while deriving the settings filename from the config's scope, so they looked in ~/.qoder/settings.json for hooks living in ~/.qoder-cn/settings.json. hooks list reported a healthy CN install as missing and uninstall left the CN hooks behind. Both now use the hook scope. Uninstall's skills/rules/agents/claudemd discovery deliberately stays at the config scope — those are real project resources, and pointing them at user paths would strand the project copies.

3. Qoder and Qoder CN claim the same project-scope hook file — fixed, and this was introduced by this PR. Moving qoder-cn's top-level paths to .qoder/* (so project scope matches Qoder, as the contract requires) made two targets resolve to <root>/.qoder/settings.json. reconcileHooksToAllTools iterates per tool and re-renders each built-in with the current tool's dispatch identity, so the later qoder-cn pass won. Reproduced on the pre-fix tree with the default configuration (no agent whitelist) in self mode with <root>/.qoder present:

{"exists":true,"toolQoderBuiltin":0,"toolQoderCn":6,"qoderOnlyPayload":false,"toolQoderDispatch":0}

Six built-ins all --tool qoder-cn, zero --tool qoder, and the tools: [qoder] team hook deleted — a plain international-Qoder user's file rewritten as CN.

Each settings file is now reconciled once, for the first target that reaches it; the shipped table lists qoder before qoder-cn, so the existing target keeps ownership and CN stays a user-scope addition there. A CN-only pass still targets the file as qoder-cn, because nothing else claims it, so this PR's own single-target behaviour is unchanged. hooks list mirrors the rule so the shared file is listed once.

I picked "first target owns it" over merging per tool because two built-ins for the same event and matcher would double-fire — the failure mode #370 exists to prevent — and a correct union needs alias-aware definition plumbing in the shared engine. A maintainer may prefer the union semantics or want CN to own the file when ~/.qoder-cn exists; that is a judgement call and I would rather flag it than have it read as settled. Note it is not decidable from paths in self mode: both roots are project-relative.

Known limitation, documented rather than fixed: in project scope a team hook scoped tools: [qoder-cn] no longer lands in the shared file. One physical file carries one dispatch identity, so it is not representable there; teams can scope to qoder or omit tools: (omitting means it applies to qoder).

4. MCP documentation contradicted the implementation. docs/usage-guide.md:797 and usage-guide.zh-CN.md:770 said <project>/.qoder-cn/settings.json, while mcpProject and the surrounding prose use <project>/.qoder/. Corrected in both languages; a re-grep confirms every remaining .qoder-cn mention is user-scope.

Verification after this round

tsc --noEmit exit 0. Full suite 30 failed | 240 passed files and 71 failed | 3705 passed | 5 skipped tests — the 71-test failure set is identical to the baseline, with the only delta being this round's four new tests. Four deliberate breaks (list scope, list de-duplication, the ownership claim, uninstall) each turned exactly their own new test red.

Real CLI, with a scratch HOME, --scope project --role dev against teamai-hub/teamai-cli-dev:

Invocation ~/.qoder-cn/settings.json ~/.qoder/settings.json dispatch identity
--agent qoder-cn written not written --tool qoder-cn only
--agent qoder not written written --tool qoder only; no --tool qoder-cn

One honest limit on that table: the second row uses an explicit --agent qoder whitelist, so it demonstrates that the international target is not contaminated, not the both-targets/no-whitelist collision itself. That case is covered by unit test, which fails if the ownership rule is removed.

@jeff-r2026 jeff-r2026 self-assigned this Sep 21, 2026
@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Missing required real-CLI end-to-end verification. The PR description reports TypeScript checks and targeted Vitest tests, but no npm run build followed by an actual teamai CLI flow against Qoder CN. The repository rules explicitly require a successful build and real-CLI E2E record before merge; inability to run the suggested dogfood environment does not replace that requirement.

  • [P1 blocking] Public support documentation is incomplete. Adding qoder-cn as a full built-in target at src/types.ts:364 affects the README support matrix, but all five README* variants still list only Qoder. The Windows hooks guides also enumerate only .qoder/settings.json. The repository rules require every affected bilingual document to remain synchronized; update all README language variants and both Windows hooks guides, or narrow/document the feature so those sections are not misleading.

@PerryLink
PerryLink force-pushed the feat/qoder-cn-support branch from f5c1de9 to 8be8016 Compare September 21, 2026 15:08
@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Use separate user/project paths for Qoder CN — src/types.ts:364 makes .qoder-cn/* the default for both scopes. However, Qoder CN uses ~/.qoder-cn/... for user resources and <project>/.qoder/... for project resources. Project-scope pulls will therefore write skills, rules, agents, hooks, and MCP configuration where Qoder does not read them. Keep .qoder/* as the base paths and add .qoder-cn/* through userScope; update the test at src/__tests__/qoder-cn.test.ts:20, which currently codifies the incorrect mapping. citeturn6search0turn7search2turn9search0
  • [P1 blocking] Add the required real-CLI E2E record — The PR description reports TypeScript and unit-test results but explicitly omits dogfood/E2E verification and does not record npm run build. The trusted review rules require a build followed by real-CLI end-to-end validation and mandate blocking PRs without an E2E record.
  • [P2 non-blocking] Update both Windows hook runbooks — docs/windows-hooks.md:106 and docs/windows-hooks.zh-CN.md:100 claim to enumerate every hook-capable agent but omit the newly supported qoder-cn settings path and verification steps. The repository rules require all affected bilingual documentation to remain synchronized.

Qoder CN keeps its user directory at ~/.qoder-cn instead of ~/.qoder, so a CN install saw none of TeamAI's synced resources and users worked around it with symlinks. Register qoder-cn as its own built-in target mirroring qoder: skills discovery, toolPaths defaults, the Claude-compatible agent/MCP formats, and the subagent render/reverse switches. Docs list the new paths.
The first cut registered `qoder-cn` with `.qoder-cn/*` as every path, which
wrote project-scope resources into a directory Qoder CN does not read. Only the
*user* directory differs (`~/.qoder-cn`); project scope still uses `.qoder/`.
`scopedToolPaths` documents the contract -- top-level fields are the project
paths, `userScope` carries the user overrides -- so the entry now follows it:
top-level stays `.qoder/*`, `userScope` holds `.qoder-cn/*`, `mcp` is the
user-level MCP file and `mcpProject` the project-level one.

`userScope` did not admit `settings` at all, so a user-scope `qoder-cn` would
have had its hooks written to `~/.qoder/settings.json` -- the international
install's config. `settings` is now part of the userScope schema and its splice.

Hooks do not necessarily live at the config's scope: `resolveHookScope` maps a
non-self project scope to HOME (#264). Every caller that resolved paths from
`localConfig` while using that HOME base directory therefore looked under the
project prefix inside HOME. `resolveHookScope` and
`resolveLegacyProjectHookScope` now report the scope they resolved, and the
inject, remove and check paths use it -- `hooks.ts`, `pull.ts`, `hooks-cmd.ts`
and `doctor.ts`, the last of which is why `teamai doctor` reported "teamai hooks
in qoder-cn settings" as missing.

Verified with a real CLI end-to-end run, not only unit tests. Against
`teamai-hub/teamai-cli-dev` with a scratch HOME, `--scope project --agent
qoder-cn`:

- `~/.qoder-cn/settings.json` is written; `~/.qoder/settings.json` is not
- project scope delivers to `<project>/.qoder/skills`; `.qoder-cn/` is not created
- `teamai doctor` reports `qoder-cn is installed` and `teamai hooks in qoder-cn
  settings` both green (the latter failed before this change)

`npx tsc --noEmit` clean; full suite unchanged at 30 failed / 240 passed files
and 75 failed / 3655 passed tests, the pre-existing Windows failures.
@PerryLink
PerryLink force-pushed the feat/qoder-cn-support branch from 6e6e504 to b6d919a Compare September 22, 2026 11:08
@github-actions

Copy link
Copy Markdown

Findings

  • [P1 blocking] The PR description lacks the required real-CLI end-to-end record. It documents only type-check/unit-test results and explicitly skips dogfooding; add npm run build plus actual CLI verification covering this behavior before merge.
  • [P1 blocking] The new user-scoped settings override is not used by hooks list or uninstall discovery. For a non-self project config, hooks are injected into ~/.qoder-cn/settings.json, but those paths are still resolved with project scope, so listing checks ~/.qoder/settings.json and uninstall can leave the CN hooks active. Update both consumers and add coverage. src/types.ts:392
  • [P1 blocking] Qoder and Qoder CN have identical project paths, so when both targets are enabled—or an older config has no whitelist—project synchronization treats the same .qoder installation as both tools. In self mode, hook reconciliation edits the same settings file twice, and the later qoder-cn pass replaces the managed qoder hooks, breaking tool-specific hooks and dispatch identity. The project target needs deduplication or an unambiguous ownership model. src/types.ts:383
  • [P1 blocking] The MCP documentation contradicts the implementation and the new Qoder CN paragraph: the table says <project>/.qoder-cn/settings.json, while mcpProject and the prose use <project>/.qoder/settings.json. Correct this in both language versions. docs/usage-guide.md:797

Registering `qoder-cn` with the project paths `.qoder/*` made two targets
resolve to the same project-scope hook file. `reconcileHooksToAllTools` iterates
per tool and `reconcileClaudeFormat` re-renders every built-in entry with the
current tool's dispatch identity, so the later `qoder-cn` pass rewrote a plain
international-Qoder install's file as `--tool qoder-cn` and dropped team hooks
scoped to `tools: [qoder]`. Reproduced with the default configuration (no agent
whitelist) in self mode with `<root>/.qoder` present: 6 built-ins all
`--tool qoder-cn`, 0 `--tool qoder`, and the `tools: [qoder]` hook gone.

Each settings file is now reconciled once, for the first target that reaches it.
The shipped table lists `qoder` before `qoder-cn`, so the existing target keeps
ownership of `<root>/.qoder/settings.json` and CN remains a user-scope addition
there; a CN-only pass still targets the file as `qoder-cn` because nothing else
claims it. `hooksList` mirrors the same rule, so the shared file is listed once
instead of reporting the CN row as missing.

Two user-scope consumers resolved their paths at the config's scope while using
the HOME base directory `resolveHookScope` reports, so they looked in
`~/.qoder/settings.json` for hooks that live in `~/.qoder-cn/settings.json`:
`hooksList` reported a healthy CN install as missing, and `uninstall` discovery
never found the CN hooks and left them behind. Both now use the hook scope.
Skills, rules, agents and claudemd stay at the config scope in uninstall — they
are real project resources, and resolving those to user paths would strand the
project copies.

Corrected the MCP table in both `docs/usage-guide.md` and
`docs/usage-guide.zh-CN.md`, which still said `<project>/.qoder-cn/settings.json`
while `mcpProject` and the surrounding prose use `<project>/.qoder/`.

Known limitation, documented rather than fixed: in project scope a team hook
scoped `tools: [qoder-cn]` no longer lands in the shared file. One physical file
can carry only one dispatch identity, so it is not representable there; teams can
scope to `qoder` or omit `tools:`. Union semantics would need engine support for
alias-aware definitions and is out of scope here.

`tsc --noEmit` clean; full suite 30 failed / 240 passed files unchanged, the
71-test failure set byte-identical, +4 tests from this change.
@github-actions

Copy link
Copy Markdown
  • [P1 blocking] src/hooks.ts:1442 — Deduplicating the shared project settings file by always giving qoder ownership breaks qoder-cn semantics in self/project scope when no agent whitelist is configured. Built-ins are written with --tool qoder, and team hooks restricted to tools: [qoder-cn] are silently omitted, so Qoder CN is not actually treated as a separate target.
  • [P1 blocking] src/hooks-cmd.ts:104 — hooksList does not apply enabledAgents/disabledAgents before claiming duplicate settings paths. For a self-mode configuration enabling only qoder-cn, the earlier qoder entry claims .qoder/settings.json; the command checks it using Qoder’s expected commands, reports it missing, and never lists the enabled Qoder CN target.
  • [P1 blocking] PR description — The description includes a real-CLI E2E record, but it does not satisfy the repository’s required pre-PR test matrix: npx vitest run is explicitly failing, and no real-CLI verification is recorded for Claude, Codex, CodeBuddy, OpenCode or the required git/gitlab provider coverage.

… path

`hooksList` iterated the whole tool table without applying the enabled set, so
for a self-scope config that enabled Qoder CN alone, `qoder` — disabled, but
earlier in the shipped table — claimed `<root>/.qoder/settings.json`, was probed
for Qoder's dispatch identity, and was reported `missing` while the enabled
`qoder-cn` target never appeared in the table at all.

The write path already got this right: `reconcileHooksToAllTools` skips any tool
outside `filterAgents`, which `reconcileTeamHooksForConfig` derives from
`enabledAgents` and `disabledAgents`. Only the read path was missing the same
rule, so the fix reuses the filter `doctor` already applies to this path table.

Ownership of the shared file therefore follows the enabled set rather than the
table order, and the two paths now agree.
@PerryLink

Copy link
Copy Markdown
Contributor Author

Round 4, findings 1 and 2 — one confirmed and fixed, one partially confirmed and stated honestly.

Finding 2 (hooks-cmd.ts) was accurate, and it was narrow. hooksList iterated the whole tool table without applying the enabled set, so a self-scope config that enabled Qoder CN alone had qoder — disabled, but earlier in the table — claim <root>/.qoder/settings.json, probe it for Qoder's dispatch identity and report missing, while the enabled target never appeared in the table. A probe printed the real call list before and after: 8: qoder <- <project>/.qoder/settings.json with no qoder-cn row, against 0: qoder-cn <- … after.

The root cause is narrower than I first described it. The write path already resolved ownership from the enabled set — reconcileHooksToAllTools skips tools outside filterAgents, which is derived from enabledAgents/disabledAgents. Only the read path was missing that rule. So the fix is one behavioural line reusing the filter doctor already applies to the same path table, not a new ownership algorithm — which is what I had originally proposed, and which would have been a no-op here, since in the both-enabled case qoder is enabled too.

Finding 1 (hooks.ts) is real but only half-fixable, and I want to be explicit rather than have the fix read as complete. The dedup gives the shared project file one dispatch identity, so with no agent whitelist — where both targets are enabled — built-ins are written as --tool qoder and a team hook scoped tools: [qoder-cn] is silently omitted. That is not fixable while two tools share one physical settings file and each editor loads it: writing both identities would double-dispatch every built-in. What the change does fix is the form that is representable — when Qoder CN is the only enabled target it now owns the file, gets --tool qoder-cn built-ins, and keeps its tool-scoped team hooks. The write path already behaved correctly there; the correction was to its comment, not its code.

If you want Qoder CN to be fully independent in project scope, the only route is giving it a distinct project directory, which is a design decision rather than a patch — and it depends on the ASSUMPTION already flagged in the description (that Qoder CN reads <root>/.qoder/ at project scope), which I cannot verify from this repository.

Finding 3 is a real gap I am not able to close here. npx vitest run is not green on Windows — 30 files fail on this machine from pre-existing path-separator and shell-dependent assertions, identical before and after my changes — and I have no way to run the Claude / Codex / CodeBuddy / OpenCode × git / gitlab / github matrix the pre-PR checklist asks for. I would rather say that plainly than present a partial record as the full one.

Verified at this head: tsc --noEmit exit 0; full suite 30 failed | 240 passed files and 71 failed | 3707 passed | 5 skipped tests, with the failing set identical to the baseline and the +2 being exactly this round's new tests. Mutating the new line to if (false && …) turns exactly those two red and nothing else.

@github-actions

Copy link
Copy Markdown

Findings

  • [P1 blocking] Qoder CN-only hooks are silently dropped when both targets are enabled — src/hooks.ts:1520. In self/project scope, both targets resolve to .qoder/settings.json; the first-wins dedup lets qoder claim the file, while reconcileHooks() filters out definitions scoped to tools: [qoder-cn]. Shared files need alias-aware union/ownership rather than silently omitting configured hooks.
  • [P1 blocking] doctor reports a valid shared Qoder configuration as broken — src/doctor.ts:378. buildHookChecks() does not deduplicate shared settings paths, so it checks the same file once as qoder and again as qoder-cn; whichever identity did not own the file is reported missing. This also produces false post-pull failures.
  • [P1 blocking] Targeted uninstall deletes resources belonging to the sibling Qoder edition — src/types.ts:383. In project scope, both entries expose identical skills/rules/settings/agents paths. Consequently, uninstall --agent qoder-cn collects and removes .qoder/*, including hooks owned by qoder, even when qoder remains enabled. Shared paths require ownership-aware uninstall handling.

The PR description contains a concrete build and real-CLI end-to-end record, so no testing-description finding. Per request, I only read the diff and did not run the PR.

@jeff-r2026
jeff-r2026 merged commit 1e2c029 into Tencent:main Sep 22, 2026
10 checks passed
jeff-r2026 pushed a commit that referenced this pull request Sep 23, 2026
… (#733)

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 #695 moved the doctor's hook paths to the hook scope for Qoder CN.
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…ent#695)

* feat(agents): support Qoder CN via its .qoder-cn user directory

Qoder CN keeps its user directory at ~/.qoder-cn instead of ~/.qoder, so a CN install saw none of TeamAI's synced resources and users worked around it with symlinks. Register qoder-cn as its own built-in target mirroring qoder: skills discovery, toolPaths defaults, the Claude-compatible agent/MCP formats, and the subagent render/reverse switches. Docs list the new paths.

* fix(agents): resolve Qoder CN paths by scope, not by one flat table

The first cut registered `qoder-cn` with `.qoder-cn/*` as every path, which
wrote project-scope resources into a directory Qoder CN does not read. Only the
*user* directory differs (`~/.qoder-cn`); project scope still uses `.qoder/`.
`scopedToolPaths` documents the contract -- top-level fields are the project
paths, `userScope` carries the user overrides -- so the entry now follows it:
top-level stays `.qoder/*`, `userScope` holds `.qoder-cn/*`, `mcp` is the
user-level MCP file and `mcpProject` the project-level one.

`userScope` did not admit `settings` at all, so a user-scope `qoder-cn` would
have had its hooks written to `~/.qoder/settings.json` -- the international
install's config. `settings` is now part of the userScope schema and its splice.

Hooks do not necessarily live at the config's scope: `resolveHookScope` maps a
non-self project scope to HOME (Tencent#264). Every caller that resolved paths from
`localConfig` while using that HOME base directory therefore looked under the
project prefix inside HOME. `resolveHookScope` and
`resolveLegacyProjectHookScope` now report the scope they resolved, and the
inject, remove and check paths use it -- `hooks.ts`, `pull.ts`, `hooks-cmd.ts`
and `doctor.ts`, the last of which is why `teamai doctor` reported "teamai hooks
in qoder-cn settings" as missing.

Verified with a real CLI end-to-end run, not only unit tests. Against
`teamai-hub/teamai-cli-dev` with a scratch HOME, `--scope project --agent
qoder-cn`:

- `~/.qoder-cn/settings.json` is written; `~/.qoder/settings.json` is not
- project scope delivers to `<project>/.qoder/skills`; `.qoder-cn/` is not created
- `teamai doctor` reports `qoder-cn is installed` and `teamai hooks in qoder-cn
  settings` both green (the latter failed before this change)

`npx tsc --noEmit` clean; full suite unchanged at 30 failed / 240 passed files
and 75 failed / 3655 passed tests, the pre-existing Windows failures.

* fix(agents): keep Qoder CN off the paths Qoder already owns

Registering `qoder-cn` with the project paths `.qoder/*` made two targets
resolve to the same project-scope hook file. `reconcileHooksToAllTools` iterates
per tool and `reconcileClaudeFormat` re-renders every built-in entry with the
current tool's dispatch identity, so the later `qoder-cn` pass rewrote a plain
international-Qoder install's file as `--tool qoder-cn` and dropped team hooks
scoped to `tools: [qoder]`. Reproduced with the default configuration (no agent
whitelist) in self mode with `<root>/.qoder` present: 6 built-ins all
`--tool qoder-cn`, 0 `--tool qoder`, and the `tools: [qoder]` hook gone.

Each settings file is now reconciled once, for the first target that reaches it.
The shipped table lists `qoder` before `qoder-cn`, so the existing target keeps
ownership of `<root>/.qoder/settings.json` and CN remains a user-scope addition
there; a CN-only pass still targets the file as `qoder-cn` because nothing else
claims it. `hooksList` mirrors the same rule, so the shared file is listed once
instead of reporting the CN row as missing.

Two user-scope consumers resolved their paths at the config's scope while using
the HOME base directory `resolveHookScope` reports, so they looked in
`~/.qoder/settings.json` for hooks that live in `~/.qoder-cn/settings.json`:
`hooksList` reported a healthy CN install as missing, and `uninstall` discovery
never found the CN hooks and left them behind. Both now use the hook scope.
Skills, rules, agents and claudemd stay at the config scope in uninstall — they
are real project resources, and resolving those to user paths would strand the
project copies.

Corrected the MCP table in both `docs/usage-guide.md` and
`docs/usage-guide.zh-CN.md`, which still said `<project>/.qoder-cn/settings.json`
while `mcpProject` and the surrounding prose use `<project>/.qoder/`.

Known limitation, documented rather than fixed: in project scope a team hook
scoped `tools: [qoder-cn]` no longer lands in the shared file. One physical file
can carry only one dispatch identity, so it is not representable there; teams can
scope to `qoder` or omit `tools:`. Union semantics would need engine support for
alias-aware definitions and is out of scope here.

`tsc --noEmit` clean; full suite 30 failed / 240 passed files unchanged, the
71-test failure set byte-identical, +4 tests from this change.

* fix(cli): resolve the shared hook file by the enabled set on the read path

`hooksList` iterated the whole tool table without applying the enabled set, so
for a self-scope config that enabled Qoder CN alone, `qoder` — disabled, but
earlier in the shipped table — claimed `<root>/.qoder/settings.json`, was probed
for Qoder's dispatch identity, and was reported `missing` while the enabled
`qoder-cn` target never appeared in the table at all.

The write path already got this right: `reconcileHooksToAllTools` skips any tool
outside `filterAgents`, which `reconcileTeamHooksForConfig` derives from
`enabledAgents` and `disabledAgents`. Only the read path was missing the same
rule, so the fix reuses the filter `doctor` already applies to this path table.

Ownership of the shared file therefore follows the enabled set rather than the
table order, and the two paths now agree.

---------

Co-authored-by: PerryLink <[email protected]>
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…cent#732) (Tencent#733)

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.
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.

[feat] 适配 Qoder CN

2 participants