Repository navigation
feat(agents): support Qoder CN via its .qoder-cn user directory - #695
Conversation
|
f5c1de9 to
8be8016
Compare
|
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.
6e6e504 to
b6d919a
Compare
|
Findings
|
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.
|
… 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.
|
Round 4, findings 1 and 2 — one confirmed and fixed, one partially confirmed and stated honestly. Finding 2 ( The root cause is narrower than I first described it. The write path already resolved ownership from the enabled set — Finding 1 ( 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 Finding 3 is a real gap I am not able to close here. Verified at this head: |
|
Findings
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. |
… (#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.
…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]>
…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.
Closes #667.
Summary
Qoder CN keeps its user directory at
~/.qoder-cninstead of~/.qoder, so a CN install saw none of TeamAI's synced resources — the workaround was to symlink the two directories together. This registersqoder-cnas its own built-in target.Only the user directory differs. Project scope still uses
.qoder/, which is whatscopedToolPathsencodes: top-level fields are the project paths, and auserScopeblock carries the user overrides. The entry follows that contract — top-level stays.qoder/*,userScopeholds.qoder-cn/*,mcpis the user-level MCP file andmcpProjectthe 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
Test Plan
npx tsc --noEmitpassesnpx vitest runpasses — see the baseline note belownpm run build+ real-CLI end-to-end record — belowReal-CLI end-to-end record
Run against the public
teamai-hub/teamai-cli-devdogfood repo from CONTRIBUTING, with a scratchHOMEso the user-scope paths are observable, atb6d919a:Resulting filesystem state:
<HOME>/.qoder-cn/settings.json<HOME>/.qoder/settings.json<project>/.qoder/skills/…<project>/.qoder-cn/The two bold rows are the bug: before the scoping correction the hooks went to
~/.qoder/settings.json— the international install's config — andteamai doctorreportedteamai hooks in qoder-cn settingsas missing.The
⚠ Member registration could not be pushedline 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 passedfiles,71 failed | 3701 passed | 5 skippedtests. 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 thevitest runbox 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.
userScopedid not admitsettings. The schema and its splice covered skills, rules, agents, hooks and claudemd only. Without addingsettings, a user-scopeqoder-cnwould have had its hooks written to~/.qoder/settings.json— the same class of error as the one being fixed, in the other direction.settingsis now part of theuserScopeschema and splice.2. Hooks do not always live at the config's scope.
resolveHookScopemaps a non-self project scope to HOME (#264), but the callers resolved their tool paths fromlocalConfig. Every one of them therefore looked under the project prefix inside HOME (doctor.tseven documents the #264 behaviour right above the line that got it wrong).resolveHookScopeandresolveLegacyProjectHookScopenow report the scope they resolved, andhooks.ts,pull.ts,hooks-cmd.tsanddoctor.tsuse it. This is whyteamai doctorpreviously 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 CNrow to all fiveREADME*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.mdanddocs/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 thetrae-cnpattern, which registers skills only.traeis a bare registry entry with notoolPaths, whereasqoderis a full target — a skills-onlyqoder-cnwould 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-cnis the only other CN variant and has notoolPathsat all, so it establishes the user-prefix pattern but says nothing about project prefixes. The code carries a labelledASSUMPTION: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 listand uninstall discovery resolved paths at the wrong scope. Both used the HOME base directoryresolveHookScopereports while deriving the settings filename from the config's scope, so they looked in~/.qoder/settings.jsonfor hooks living in~/.qoder-cn/settings.json.hooks listreported 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.reconcileHooksToAllToolsiterates per tool and re-renders each built-in with the current tool's dispatch identity, so the laterqoder-cnpass won. Reproduced on the pre-fix tree with the default configuration (no agent whitelist) in self mode with<root>/.qoderpresent:Six built-ins all
--tool qoder-cn, zero--tool qoder, and thetools: [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
qoderbeforeqoder-cn, so the existing target keeps ownership and CN stays a user-scope addition there. A CN-only pass still targets the file asqoder-cn, because nothing else claims it, so this PR's own single-target behaviour is unchanged.hooks listmirrors 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-cnexists; 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 toqoderor omittools:(omitting means it applies toqoder).4. MCP documentation contradicted the implementation.
docs/usage-guide.md:797andusage-guide.zh-CN.md:770said<project>/.qoder-cn/settings.json, whilemcpProjectand the surrounding prose use<project>/.qoder/. Corrected in both languages; a re-grep confirms every remaining.qoder-cnmention is user-scope.Verification after this round
tsc --noEmitexit 0. Full suite30 failed | 240 passedfiles and71 failed | 3705 passed | 5 skippedtests — 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 devagainstteamai-hub/teamai-cli-dev:~/.qoder-cn/settings.json~/.qoder/settings.json--agent qoder-cn--tool qoder-cnonly--agent qoder--tool qoderonly; no--tool qoder-cnOne honest limit on that table: the second row uses an explicit
--agent qoderwhitelist, 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.