Skip to content

[pull] main from Tencent:main - #82

Merged
pull[bot] merged 5 commits into
Walternater:mainfrom
Tencent:main
Sep 29, 2026
Merged

pull[bot] merged 5 commits into
Walternater:mainfrom
Tencent:main

Conversation

@pull

@pull pull Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

SaulMoro and others added 5 commits September 29, 2026 21:00
…igrations (#893) (#901)

* fix(dry-run): load mcp inject and mcp list without persisting a migration (#893)

mcp inject loaded its scope bare, so --dry-run still saved a pending role
migration, partition rename or self-mode bootstrap. It now forwards dryRun;
mcp list is read-only and loads with dryRun: true unconditionally, as status
and list do since #866.

* fix(dry-run): forward dryRun to the loader in roles init/add/remove/update (#893)

roles list is read-only and loads with dryRun: true unconditionally.

* fix(dry-run): forward dryRun to the loader in projects add/update/remove (#893)

projects list and projects members are read-only and load with dryRun: true.

* fix(dry-run): forward dryRun to the loader in tags add/remove (#893)

tags list is read-only and loads with dryRun: true.

* fix(dry-run): forward dryRun to the loader in source add/remove/add-http (#893)

source list and source browse are read-only and load with dryRun: true.
source list also reached a second bare load through loadLocalAgentConfig,
whose HTTP backfill reads only repo.kind and repo.url; it now loads with
dryRun: true, and the migration persists on the next command that writes.

* fix(dry-run): forward dryRun to the loader in remove and uninstall (#893)

* fix(dry-run): forward dryRun to the loader in packages install (#893)

* fix(dry-run): forward dryRun to the loader in import --from-iwiki/mr/claude/repo (#893)

--from-repo-list and --from-org reach the same load through importFromRepo.

* fix(dry-run): forward dryRun to the codebase loader; --lint and --status load read-only (#893)

* fix(dry-run): forward dryRun to the loader in models switch; models list loads read-only (#893)

* fix(dry-run): load read-only commands without persisting a migration (#893)

hooks list, members, exclude list, recall status and doctor load with
dryRun: true unconditionally, as status and list do since #866.

* docs(designs): name which commands take the dry-run detection path (#893)

* test(dry-run): pin that every loader on a dry-run or read-only path migrates nothing (#893)

LOAD_ONLY_COMMANDS gains the read-only commands and the previews that stay
clean on the legacy-role fixture. PREVIEWS covers the commands that fail past
the loader on that fixture: it asserts only config.yaml, with the same call
without --dry-run as the positive control that the load is on the path.

* fix(dry-run): forward dryRun through resolveMemberToolRoots for import --from-claude (#893)

scanCandidates resolves Claude's tool root before the loader import.ts already
fixed, through a bare load in resolveMemberToolRoots, so the dry run still
saved the migration. resolveConfigForDir and findUnreadableProjectConfig take
the same optional LoadOptions for the read-only callers below; hook and usage
callers pass nothing and behave as before.

* fix(dry-run): pass dryRun into loadLocalAgentConfig instead of forcing it (#893)

Forcing dryRun there made real hook runs print the [dry-run] migration
preview and stop persisting it. source list now passes it through
describeLocalAgent; every other caller is unchanged. source add-http forwards
{ dryRun: options.dryRun } like the rest of the file.

* fix(dry-run): load skill list/show, webhook list, stats and digest read-only (#893)

detectTeam takes optional LoadOptions; the Stop-hook share gate passes none.

* docs(designs): name read-only commands by example, not as every list subcommand (#893)

* test(dry-run): prove each row reached the load, and cover the remaining changed sites (#893)

Every dry-run row now asserts the loader logged its migration preview, so an
early return cannot pass. Adds source browse, codebase --lint, skill list/show,
webhook list, digest, projects update/remove, import --from-claude, and a
config-only table for members, projects members and stats.

* fix(dry-run): keep the pre-command migration from adopting a partition on a dry run (#893)

The preAction hook passes dryRun to maybeMigrate, but planMigration and
queueKeptInCheckout resolved the partition bare, so pull/push --dry-run
still renamed a pre-#546 partition. Both now take the option.

* fix(dry-run): load skill get/path read-only through the share gate (#893)

blockReason fell back to shareGate(), a bare load, when no team was passed;
only skill get, skill path and the catalog reach that fallback. The Stop
hook still asks shareGate directly and is unchanged.

* refactor(dry-run): give loadWebhookConfig the option instead of copying its branch (#893)

Also note in loadLocalAgentConfig that dryRun covers only its config.yaml load.

* revert(dry-run): leave stats out of this change (#893)

stats also loads bare per session through the dashboard scope helpers on the
pull/report path; a partial fix would claim more than it does. Tracked in the
follow-up issue with the other dry-run gaps.

* test(dry-run): cover the pre-command migration and skill get/path share (#893)

* refactor(dry-run): give shareGate the option instead of repeating it in blockReason (#893)

Also correct the test comment on when the pre-command migration runs.

* fix(dry-run): keep loadLocalAgentConfig from writing config.json under dryRun (#893)

The option reached only the config.yaml load. The legacy group-binding
cleanup, the binding-key canonicalization and the HTTP backfill still saved
config.json, so `teamai source list` could rewrite or create it. Under
dryRun they now stay in memory, and the cleanup prints a `[dry-run] Would
remove` preview instead of `Removed`.

* fix(dry-run): keep models list from saving a re-bound beta key (#893)

models list loaded the scope read-only but read the team keys through
loadTeamValues without the option, so a key a 0.26.0 beta stored under the
profile id alone was bound to its gateway and the values file rewritten.
It now binds the key in memory only; the next write command saves it.
… not just self-mode (#867) (#873)

* fix(init): seed a custom agent's configured root dir on regular init, not just self-mode

Problem: in a multi-repo setup, `teamai init --agent AA` with `AA` a
custom agent whose skills/rules root is configured only through
`teamai.yaml`'s `toolPaths` (e.g. `AA: { skills: 'a/skills' }`) silently
delivers nothing, forever. `pull`'s `isToolInstalled` treats a missing
root directory as "not installed" and skips the tool — correct for a
real third-party tool the user has to install themselves, but wrong for
a purely teamai-managed directory convention that nothing else will ever
create. `--agent AA` is the only "installation" such an agent has (#867).

First approach, reverted: generalizing `isToolInstalledForConfig`'s
existing Copilot-only `enabledAgents` short-circuit to any tool broke
`doctor`'s own "`<tool> is installed`" diagnostic (#598), which reuses
the exact same function (via `skillsDirForTool`) to deliberately flag a
tool the user *claimed* via `enabledAgents` but never actually
installed — precisely the scenario that check exists to catch, not
paper over. Confirmed by running the full suite with each version: the
broad fix broke 3 `doctor.test.ts` cases ("buildChecks — a tool enabled
but not installed") that assert exactly this.

Actual fix: single-repo mode already solves the identical "the tool's
root doesn't exist yet, but the user explicitly asked for it" problem
via `seedSelfModeToolDirs`, called before hook injection specifically
because "a teammate's fresh clone has no `<repo>/.claude` yet, so
nothing would ever inject." That function is not actually self-mode
specific (it only uses `resolveBaseDir` + `enabledAgents`, neither of
which is self-mode-only) — it was just never called anywhere else.
Added the same call, in the same position (before hook injection), to
both the regular git-mode `init` and `initHttp`, and updated its
docstring to describe the now-dual motivation. `doctor`'s diagnostic is
untouched and still correctly flags a genuinely-uninstalled built-in
tool.

Test plan: new unit test in self-mode-agents.test.ts proving
`seedSelfModeToolDirs` seeds a custom agent's root outside self mode
(user scope, `toolPaths`-only entry). Real e2e verification via a
scratch script against the actual built CLI: confirmed `pull` silently
skips delivery and `doctor` correctly reports "AA is installed: false"
before the fix; after seeding, `pull` delivers both a skill and a rule
into the custom root for real, and `doctor` reports the check passing.
Full regression suite unchanged from the pre-existing baseline (48
failed files / 166 failed tests / 5072 passed) plus the one new test
passing (5073 passed) — no new failures.

Fixes #867.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(init): address automated review findings on custom-agent seeding

The codex-review bot on PR #873 found three real gaps in the previous
fix (seedSelfModeToolDirs reused wholesale for regular/HTTP init):

1. It seeded *every* enabledAgents entry, including built-in tools. On
   a machine without Claude installed, `teamai init --agent claude`
   would silently create ~/.claude/skills, defeating doctor's "is
   installed" diagnostic (#598) — the whole point of which is to catch
   a claimed-but-absent tool instead of manufacturing a fake root for
   it. Fixed: outside self mode, only agents not in KNOWN_AGENTS (true
   custom agents) get seeded; built-in tools must already exist on
   disk, same as before.

2. It read teamConfig.toolPaths directly instead of resolving through
   scopedToolPaths, so a custom agent with a userScope path override
   would have its default path seeded while pull/doctor resolved the
   user-scope path — permanently mismatched. Fixed: use
   scopedToolPaths(teamConfig, localConfig), the same resolver every
   other call site (doctor, hooks, local-agent) already uses.

3. It only ever probed the `skills` path, so a custom agent configured
   with only e.g. `rules` (no `skills`) was never seeded and stayed
   "not installed" forever. Fixed: probe skills ?? rules ?? agents ??
   settings ?? hooks, the same order doctor.ts's buildEnabledToolChecks
   already uses for its own probe.

Also updates the --agent help text (src/index.ts,
skill-data/core/references/commands.md) and the FAQ in
docs/usage-guide.md (+ zh-CN) to describe the custom-agent seeding
exception, per the bot's P2 finding.

Test plan: added 3 tests to self-mode-agents.test.ts covering each
fixed scenario (built-in tool not seeded outside self mode, userScope
override honored, rules-only custom agent seeded) — 25/25 passing.
Full regression suite: 48 failed files / 166 failed tests / 5076
passed / 8 skipped (5250 total), exactly matching the pre-existing
baseline (166 failed, all pre-verified unrelated) plus these 3 new
passing tests. Real-CLI e2e whitelist test (#510) still passes
unchanged, confirming a built-in tool named in enabledAgents is still
gated on actually being installed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(init): seed the tool root, not the resource path, for file-valued fields

Second round of codex-review findings on PR #873:

1. settings/hooks/claudemd are FILE paths in ToolPathsSchema (e.g.
   "a/settings.json", "a/AGENTS.md"), unlike skills/rules/agents which
   are directories. The previous fix called ensureDir on whichever
   probe path matched first, so a custom agent configured with only
   `settings: "a/settings.json"` got a directory literally named
   settings.json created — hook reconciliation then can't write the
   real file there, so init reports success while installing nothing.

2. claudemd was missing from the probe order entirely (copied verbatim
   from doctor.ts's own probe, which has the same gap), so a custom
   agent configured with only `claudemd` was never seeded and stayed
   "not installed" forever.

Fixed: skills/rules/agents (directories) still seed the full resource
path as before; settings/hooks/claudemd (files) now seed only their
parent tool root via toolInstallRoot(), added claudemd to the probe.

Test plan: 2 new tests (settings-only and claudemd-only custom agents)
— 27/27 passing in self-mode-agents.test.ts. Typecheck clean, real-CLI
e2e whitelist test (#510) still passes. Full regression suite: 48
failed files / 166 failed tests / 5078 passed / 8 skipped (5252
total), exactly matching the pre-existing baseline (166 failed, all
pre-verified unrelated) plus these 2 new passing tests.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(init): seed every configured root, including the HOME hook-scope root

Third round of codex-review findings on PR #873:

1. seedToolRoots (formerly inline) picked only one directory path via
   nullish coalescing (skills ?? rules ?? agents), so a custom agent
   configured with both e.g. skills and rules at different roots only
   got its skills root created — rules stayed "not installed" forever.
   Fixed: collect every distinct configured root into a Set and
   ensureDir each one.

2. A bare root-level file path (no "/", e.g. claudemd: "AGENTS.md")
   made toolInstallRoot return the path unchanged, so the previous fix
   would ensureDir a bogus directory literally named "AGENTS.md".
   Fixed: skip a file path whose toolInstallRoot equals itself — there
   is no parent directory to create for it.

3. Non-self project scope injects hooks into HOME, not the project
   root (resolveHookScope, #264 — `~/.claude` always exists for a
   built-in tool, so that gate passes without help). Seeding only
   under the project root left a custom agent's HOME root missing, so
   `init --scope project --agent <custom>` created its resource dirs
   correctly but silently skipped its session-start auto-pull hook.
   Fixed: seedSelfModeToolDirs now also seeds the hook-scope root when
   it differs from the config's own base dir.

Test plan: 3 new tests (multi-root seeding, bare-file-path no bogus
dir, HOME hook-scope root in project scope) — 30/30 passing. Typecheck
clean, real-CLI e2e whitelist test (#510) still passes, targeted
hooks-cmd/hook-dispatch-scope/init/doctor tests match their
pre-existing baselines exactly (verified via git stash comparison).
Full regression suite: 48 failed files / 166 failed tests / 5081
passed / 8 skipped (5255 total), exactly matching the pre-existing
baseline (166 failed, all pre-verified unrelated) plus these 3 new
passing tests.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(init): seed bare settings/hooks files, restrict HOME pass to hook paths

Fourth round of codex-review findings on PR #873:

1. Skipping a bare root-level settings/hooks path (no parent directory
   to create) left hook installation permanently broken instead of
   fixed: reconcileHooksToAllTools's gate is
   `pathExists(join(baseDir, toolInstallRoot(paths.settings)))`, and
   toolInstallRoot degenerates to the path unchanged when there is no
   "/" — so the gate checks whether the settings FILE itself exists,
   which seeding never created. reconcileHooks already treats a
   missing settings/hooks file as `{}` (readJson(...) ?? {}), so this
   now seeds an empty JSON object at the bare path instead of skipping
   — satisfies the gate and gives it something valid to merge into.
   claudemd is deliberately NOT included: its own bare-root "installed"
   check in local-agent.ts keys off a `.${tool}` directory convention
   unrelated to the claudemd path itself, so a bare claudemd path is
   still left alone (extending seeding there would guess at a
   convention no custom agent is guaranteed to follow).

2. The HOME hook-scope second pass (added last round for #264) was
   seeding every resource root — skills/rules/agents/claudemd — under
   HOME, not just what hook installation reads. A custom agent with
   only `skills` configured (no settings-based hook surface at all)
   got a meaningless `~/.aa` created for nothing. Extracted the
   settings/hooks-only logic into seedHookInstallRoot and restricted
   the HOME pass to just that, leaving the full seedToolRoots pass for
   the config's own base dir only.

Test plan: 2 new tests (bare settings path seeds `{}`, not a
directory; HOME pass skips skills-only custom agents) — 32/32 passing.
Typecheck clean, real-CLI e2e whitelist test (#510) still passes. Full
regression suite: 48 failed files / 166 failed tests / 5083 passed / 8
skipped (5257 total), exactly matching the pre-existing baseline (166
failed, all pre-verified unrelated) plus these 2 new passing tests.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* docs(init): scope the custom-agent --agent seeding claim to git-backed init

Fifth round of codex-review findings on PR #873 (P2 non-blocking):
seedSelfModeToolDirs cannot seed a custom agent in HTTP init. initHttp
writes a local teamai.yaml stub with no toolPaths at all (Step 2,
'sharing: {}' only) — HTTP mode deliberately never clones a real
teamai.yaml; delivery works entirely through its own report/sync/ack
mechanism instead (refreshTeamRepo's http branch: "no repo tree to
pull here"). So `--agent AA` in HTTP mode records AA in enabledAgents
but seedSelfModeToolDirs finds no configured paths for it and creates
nothing.

Fetching a custom agent's remote paths at HTTP init time would need a
new API call HTTP mode doesn't have today — real work disproportionate
to a P2, and orthogonal to #867 (a git/self-mode custom-agent-root
bug). Took the bot's own suggested alternative instead: narrowed the
"(any mode)" claim in the --agent help text (src/index.ts,
skill-data/core/references/commands.md) and the FAQ
(docs/usage-guide.md + zh-CN) to say plainly that custom-agent seeding
is git-backed-init only, and HTTP init only ever seeds built-in tools
that are already installed.

Docs/help-text only — no logic changed. Typecheck clean, build clean,
self-mode-agents.test.ts still 32/32 (unaffected).

Co-Authored-By: Claude Sonnet 5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
…names (#894) (#895)

* fix(models): key team values by repo identity, migrating legacy slug names (#894)

* fix(models): address review on the repo-identity values scheme (#894)

- never migrate the legacy values file in a dry run: `pull --dry-run` and
  `models switch --dry-run` thread { dryRun } into migrateTeamValuesPath
- match the legacy digest the old implementation actually keyed on — the
  repo: claim in teamai.yaml overrode the identity there, so an SSH remote
  beside an HTTPS repo: no longer orphans keys and switches
- when several legacy files share a digest, migrate the newest one, so
  keys re-entered after a team rename win over stale copies
- sync docs/designs/model-profiles.zh-CN.md with the hash-only file name

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* fix(models): preview migration in dry runs, stop alias collisions, race-safe link

- dry run returns the newest legacy file's path so it reads exactly the
  keys the real run would migrate and read, instead of reporting a key
  missing from a not-yet-existing hash-only file
- a bare remote alias (`fork`) no longer names the values file: two
  checkouts sharing the alias hashed to one file and could read each
  other's keys, so hashing falls back to the URL, then the local path
- migration links the legacy file to the target instead of renaming:
  a concurrent migration that links first makes ours fail with EEXIST,
  so stale keys can never overwrite fresh ones on POSIX

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* fix(models): narrow the path digest to path-only configs, copy when links fail

- the legacy local-path digest is a candidate only when the old
  implementation would have keyed on the path itself (no repo: claim,
  no configured remote, no URL): a default-path checkout re-initialized
  for another team with a URL no longer adopts the previous team keys
- when a filesystem rejects hard links (EPERM, ENOTSUP, ...), migration
  falls back to an exclusive, never-overwriting copy (open wx mode,
  partial writes removed) instead of skipping every candidate and
  returning a path with no file behind it

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* fix(models): publish the copy fallback atomically via a temp file

The copy fallback wrote the target in place after an exclusive open, so
a concurrent reader could observe the empty or partially written values
file and fail to parse it. The content is now written to a unique temp
file and linked into place: until the publish link succeeds the target
does not exist, so a concurrent reader sees either the complete previous
file or none, and two migrations still cannot overwrite each other (the
loser publish link fails and its temp file is removed).

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* refactor(models): read legacy values in place instead of migrating files

Rename-and-migrate had to be atomic, no-clobber, link-optional, and
partial-write-free all at once, and each fix round surfaced another way
the migration could strand or clobber a secrets file. Drop the machine:
while the hash-only file does not exist, findTeamValuesPath returns the
newest legacy file and it is read where it lies; the next save writes
the hash-only name, which then shadows the legacy file. Reads no longer
mutate anything — a dry run needs no special casing — and no link,
rename, or copy stands between the keys and their reader.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* fix(models): identify alias-digest legacy files by slug as well

Two checkouts that shared a bare non-origin alias (`fork`) hashed the
same legacy digest, so findTeamValuesPath could read one team's values
for the other. A repository-bound digest (URL, repo: claim, local path)
still matches by digest alone, since the slug drifts on team renames;
a file keyed by an alias digest is adopted only when its slug is this
checkout's too, the discriminator the old scheme kept those files
apart by.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* fix(models): align switch-record matching with file matching, mirror old precedence

- sameTeamIdentity applied the alias slug check only when reading a
  values file, not when matching a switch record: two teams sharing
  remote fork could treat each other managed switches as their own.
  The slug requirement now covers every non-repository-bound digest.
- legacyTeamValueHashes mirrored the old precedence too loosely: with a
  repo claim present, the old implementation hashed only the claim,
  so the remote, URL, and path candidates never applied. A replaced
  checkout at the same path can no longer adopt a path-digest record
  the old code would never have produced for it.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* fix(models): prefer the repo: claim over the local path for the values file name

A config with remote origin and no repo.url hashed the checkout path,
so reusing that path for another team shared the first team's hash-only
values file and its identity: team B read team A's API keys and claimed
its managed switches. The claim is the remaining repository identity
before the path, so it now wins whenever the remote and the URL name
no repository.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* fix(models): qualify provider-relative identities with the provider

A path-shaped identity like owner/repo names a different repository on
each provider, so two teams with the same repo value on GitHub and
GitCode hashed to one values file and one identity: opening team B read
team A keys and accepted its managed-switch identity. The provider now
qualifies path-shaped identities; host-bearing ones (URLs) already
carry the host and stay as they are.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* fix(models): use the effective provider and slug-check legacy claim digests

- the values file identity qualified a path-shaped source with the local
  provider override, normally absent, so two teams declaring the same
  repo: value on GitHub and GitCode still hashed to one file; the
  teamai.yaml provider now wins for its own claim, and the local
  override applies only when the claim carries none
- legacy candidates marked a path-shaped claim digest repository-bound,
  so sameTeamIdentity adopted another team's switches and
  findTeamValuesPath read its file under the matching digest; a
  URL-shaped claim stays repository-bound while a path-shaped one is
  matched under this team's slug, like an alias
- also fixes the candidate guard inverted while landing the above:
  with a claim present the remote, URL, and path candidates were
  dropped, and without one they were duplicated

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* fix(models): read legacy claim files by digest and slug-guard path-only records

Path-shaped repo claims now adopt their legacy values files by digest
alone, so a team rename no longer orphans its keys; the slug check
moves to switch-record matching, where a claim digest names no single
repository. Path-only configs mix the team slug into the hash-only
identity, so a checkout path reused by a differently named team can no
longer read the previous teams keys.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* docs(models): describe the path-only slug-fallback hash in both languages

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>

* fix(models): slug-guard provider-ambiguous legacy files, repair renames by gateway origin

A legacy file's digest hashes the bare path-shaped claim name with no
provider, so GitHub team Alpha and GitCode team Beta can produce the same
old digest. The previous fix read such files by digest across renames,
letting the second provider adopt the first's file and API key; slug-guarding
records instead orphaned a renamed team's own switches. Gate both on the
one evidence that survives both a rename and a provider change: the
gateway origin each stored key is bound to under `<team:<id>@<origin>`.

Path-shaped claim digests now require this team's slug for files and
switch records, and are re-admitted under a different slug only when the
legacy file provably stores keys bound to this team's gateways — which a
rename keeps and another provider cannot claim. Keys still in a
beta-era `team:<id>` form (no origin) are not evidence, so their files
are left unread rather than guessed at. Callers thread the resolved team
profiles through `findTeamValuesPath`, `sameTeamIdentity`,
`switchedGatewayOrigins`, `activeAgentsFor`, and the pull re-apply.

* fix(models): prove rename-repaired legacy files from this machine's own switch history

Gateway-origin key binding is not a team identity: two teams sharing a
profile id and gateway URL behind the same path-shaped claim would pass
the provenance check, letting the second read the first's file and claim
its switches. But refusing differ-slug files entirely orphans a renamed
team, whose legacy `<slug>-<hash>.json` carries its own old slug.

The trustworthy, machine-local evidence is managed.json: this checkout
records the exact identity each past `team:` switch used. A differ-slug
provider-ambiguous file or switch record is re-admitted only when that
identity appears in this checkout's own switch history — a renamed team's
file, recognized without trusting a gateway a foreign team could share, a
key binding another team's file may also carry, or a slug a rename just
moved. Foreign teams hold only their own slug in managed.json and are
refused; beta-era unbound keys need no binding to be recognized this way.

Provider-relative remotes (`owner/repo`) also get the provider
qualification already given to path-shaped claims, so two providers using
the same checkout path and slug no longer share one values file.
Design docs synced in both languages.

* fix(models): never auto-adopt provider-ambiguous legacy values — adopt explicitly

Two review rounds proved no silent rule can attribute a legacy file or
switch record whose digest never encoded the provider:

- a same-slug provider-ambiguous file is read across providers (a GitHub and
  a GitCode 'Alpha' on the claim 'acme/widgets' hash the same file; the slug
  is not provenance), and
- machine switch history (managed.json) is global and self-validating: one
  file is shared by every checkout on the machine, so the record being
  proved sits in the same store a foreign team's checkout reads, letting a
  differently named team claim a same-digest record or file.

Provider-ambiguous legacy values files (path-shaped claim, provider-relative
remote, bare alias, path-only) are now never read by a silent rule, same slug
or not. The CLI lists them once (unadoptedLegacyFiles) and the user
explicitly adopts the exact `<slug>-<digest>` identity for this checkout;
the read then happens where the file lies and the next save migrates the
keys to the provider-qualified hash-only name, which shadows the legacy file
forever (no re-ask, no ambiguity left). Non-interactive and --dry-run runs
never adopt: they report the file and leave it unread. Differ-slug
provider-ambiguous switch records are refused — no machine-global proof is
ever consulted again. URL-bound legacy identities still match by digest
alone: the host is in the identity.

Design docs synced in both languages. Tests: same-slug cross-provider never
auto-reads, foreign file/record refusal, explicit-adoption read + unbound-key
migration, alias digest under this team's adoption.

* fix(models): do not offer a legacy file for adoption once its target exists

A past adoption and migration is the permanent record: the
provider-qualified hash-only target shadows every legacy name forever, so
unadoptedLegacyFiles returns no candidates when getTeamValuesPath exists.
Without this, the in-memory adoption set (which resets per invocation)
combined with the intentionally-kept legacy file re-prompted on every later
interactive command and misled non-interactive/--dry-run runs with a stale
warning. Test: after migration the file is shadowed and never offered again.

* fix(models): scope legacy adoption to the provider-qualified team and config

Two review findings on the adoption layer:

1. adoptedLegacyValues was global, keyed only by the legacy basename. In a
   pull with inheritUserScope, user scope runs first; a same-slug, same-claim
   team on a DIFFERENT provider resolves to the same adoption key, so
   confirming the user-scope file also silently authorized the project scope
   to read and migrate that key in its own provider space. Adoption is now
   keyed `${target}::<slug>-<digest>` — the adopting scope's own
   provider-qualified file path — so a confirmation scopes to exactly that
   team identity, and any other scope/provider must opt in separately.

2. adoptMigrated was a process-global boolean ("any adoption happened"). After
   adopting a user-scope file, declining a project-scope candidate still set
   it true, so the project loaded {} from its nonexistent target and wrote an
   empty hash-only file, permanently shadowing its legacy keys and killing
   future prompts. The write is now decided per config: only when readFrom
   differs from the target (a real legacy read) is the migration saved; a
   declined candidate is read nothing, written nothing, and re-offered next
   run.

Tests: cross-provider scope regression (GitHub adoption under its target never
admits the file for the GitCode scope; same-scope adoption of the same
basename does), namespaced adoption keys everywhere, migration-shadow check.

* fix(models): refuse shadowing writes while adoption pending; never claim ambiguous records by slug

Two review findings:

1. A non-interactive `models configure team:<id> --from-env X` reads {} past an
   unadopted legacy file, then writes ONLY the configured key to the
   hash-only target — permanently shadowing the legacy file (the target's
   existence silences every future adoption prompt) and orphaning its other
   API keys without a warning anyone can act on. configure and switch now
   refuse the write while unadopted legacy files remain, naming the
   interactive adoption path. A pull is unaffected: its read-time save is the
   migration itself and already requires a real legacy read.

2. A same-slug provider-ambiguous switch record matched Team B's checkout. The
   old name never encoded the provider, so a GitHub and a GitCode team both
   named `Alpha` on the bare claim `acme/widgets` share the identical
   `alpha-<digest>` form: with Team B holding its own hash-only key, pulling
   B claimed an agent switched to Team A and overwrote it. A legacy record
   under a provider-ambiguous digest never matches now — slug equality is not
   ownership across providers, consistent with the differ-slug refusal.
   Repository-bound records still match by digest (the host is in the
   identity). Adoption of the values file re-establishes the team; its
   switched agents are re-recorded by the next `models switch`.

Docs synced (en + zh-CN). Tests: path-only/alias/claim records all refused
even under the exact slug, cross-provider same-slug record regression, and
the 4 prior adoption-scoping expectations.

* fix(models): a provider-relative remote is the top identity; never a Windows drive as a URL

Two review findings on identity derivation:

1. A provider-relative remote never got its documented precedence.
   isRepoReference('owner/repo') is false, so the selector picked the URL or
   teamai.yaml claim instead; two checkouts with DIFFERENT remotes
   (acme/team-a vs acme/team-b) but the same claim/provider therefore shared
   one hash-only secrets file and could consume each other's keys. A
   configured non-origin remote now names the repository with the highest
   precedence whether URL-shaped or provider-relative (which names one repo
   together with its provider); only a bare alias (no slash, no scheme) falls
   through. Different remotes -> different files, always.

2. new URL('C:\\teams\\repo') accepts c: as a scheme, so Windows drive paths
   were hashed as phantom URLs and a path-only config skipped the
   provider-and-team-slug fallback; replacing that checkout with a
   differently named team reused the file. URL parsing now rejects
   single-letter schemes, keeping drive paths in the path form whose slug
   separates teams at one checkout.

Tests: two different provider-relative remotes with a shared claim collide no
more; same remote+provider names one repo across paths; bare aliases and
drive paths never hash as URLs. Full suite 5285 passed.

* fix(models): use the teamai.yaml provider for provider-relative remotes; bare aliases never key the file

Two more identity findings:

1. A provider-relative remote ignored the provider declared in teamai.yaml
   when no local override existed, so GitHub and GitCode teams sharing
   `remote: owner/repo` both hashed `tgit:owner/repo`. The effective provider
   now consults the teamai.yaml `provider:` (via the claim or, when the claim
   is absent, directly) before the local override and the tgit default — the
   same qualification the path-shaped claim already applied. Provider survives
   a team rename, so the file stays bound to the repository.

2. A bare remote alias (`remote: fork`, no URL, no claim) was still hashed
   directly as `tgit:fork`, so two checkouts sharing the alias shared one
   hash-only secrets file. A bare alias names no repository, so it now falls
   through to the provider/slug/path identity, whose slug keeps teams sharing
   a checkout path apart. Legacy `<slug>-<digest>` files for alias-keyed
   checkouts remain migration candidates.

Tests: each checkout declares its own teamai.yaml provider and stays distinct;
a bare alias no longer changes the file over the path-only form and two teams
sharing it stay separated by the slug. Full suite 5285 passed.

* fix(models): partial adoption never orphans a declined legacy file; adoption merges all adopted keys

Two defects in the read-time migration:

1. Declining one of several matching provider-ambiguous legacy files then
   saving the hash-only target stranded the declined file forever: the very
   existence of the target silences every future adoption candidate, so keys
   unique to the declined file became unreachable with no further prompt
   possible. The migration save now happens only when NO candidate remains
   for this team (adopted or gone); a declined file stays a candidate, keeps
   its keys reachable, and is re-offered on the next run.

2. A single-file read kept only the newest adopted identity's keys. When
   several files shared this checkout's digest, adopting all of them still
   dropped every non-newest identity's unique keys before the target
   shadowed them. Adoption now merges the keys of every adopted identity into
   the migrated target (new mergeModelInputs; the later map wins).

Tests: with two matching files, adopting one still surfaces the other to the
migration guard; adopting both leaves no candidates and the merge keeps both
identities' keys. Full suite 5286 passed.

* fix(models): member provider overrides the team's; declines are durable and no longer block migration

Two review findings, one shared root: the migration's consent model could not
distinguish "not yet decided" from "deliberately declined".

1. The effective provider put teamai.yaml's provider before the member's own,
   so a team declaring GitHub with the same bare claim made a member
   initialized with --provider gitlab share the GitHub team's hash-only file.
   The member's own provider now wins (localConfig.provider ?? team provider ??
   tgit), as everywhere else in the CLI.

2. Requiring every same-digest file to be adopted blocked migration behind a
   foreign team's file: declining GitHub Alpha to adopt GitCode Beta left an
   unadopted candidate forever, so no target could ever be created. Declining
   now records a durable, target-scoped ${target}::<slug>-<digest> refusal in
   the models manifest. A declined identity is neither re-offered on every run
   (no re-prompt loop) nor silently shadowed when migration proceeds (the
   choice is explicit, visible state, reversible by removing the key or the
   file) and does not count toward the migration guard — adopting only your
   own team's file no longer forces you to merge a foreign team's keys.

unadoptedLegacyFiles and findTeamValuesPath now take { adopted, declined };
findTeamValuesPath reads an adopted identity and skips a declined one.

Tests: found the regression itself (adopt one of two, decline the other leaves
no candidate and reads the adopted file only), the provider-override case, and
a refuseLegacyValue/refusedLegacyValueKeys manifest round-trip with a
fail-closed schema check. Full suite 5288 passed.

* fix(models): serialize the migration target against a concurrent writer by merging before save

The migration write into the new hash-only target is the one place a values
file is created from a different file, so it must not clobber a target a
concurrent process wrote between the legacy read and the save: writeJsonAtomic
prevents torn files, not lost updates. A pull reading the legacy file while a
configure creates the target could otherwise overwrite the newly configured
key with its stale snapshot. The migration now re-reads the target and merges
before saving (the concurrent content wins collisions).

The merge runs only in the migration branch (readFrom !== target). When the
run merely re-saves the file it already read, the target holds the same
content this bind just consumed — merging would re-inject the raw legacy
entries the bind renamed, so there is nothing to guard against there.

Full suite 5288 passed.

* fix(models): hold the team values lock across the whole read-modify-write

Re-reading the migration target and saving it were still two separate
operations, so the race the review flagged only shrank: a pull could re-read
the target, a concurrent configure could save a new key, and the pull could
then overwrite it with its stale merged snapshot. Team values writers now
share an advisory lock on the target file, and each of them runs its entire
read-modify-write cycle inside it:

- the migration's was already read-merge-save; it now runs that whole cycle
  under the lock instead of only the merge step;
- models configure and the models switch first-use prompt re-read the target
  inside the lock, so their write cannot clobber a migration or a sibling
  configure that landed in the same window.

withTeamValuesLock reuses the existing owner-verified acquireLock/releaseLock
primitive (dead-owner stale locks are reclaimed), so a crashed holder does not
block pulls or configures. Local values writes are untouched; no legacy
migration can race them.

Full suite 5288 passed.

* fix(models): resolve the profile from the key saved by the first interactive switch

The lock round-trip saved the first-use key into the freshly re-read snapshot
(current), but the rest of the command resolved the profile against the
original in-memory values, which had no key yet — so the switch stored the key
and then failed with "no API key", demanding a rerun. Apply the same key to
the in-memory copy after the locked write, and add a regression test for the
first interactive team switch (ask, save, and resolve in one run) so the
behaviour cannot silently split again.

Full suite 5289 passed.

* fix(models): save the awaited key with the first interactive local switch

Moving the getStoredApiKey update after the branch left the local path saving
values.json without the key the prompt returned: the switch succeeded from the
later in-memory copy, but the next invocation found values.json missing the
key and reported it not configured. Put the key in the in-memory copy before
the branch, so the local save already carries it; regression tests now cover
the first interactive switch for both the personal and the team profile.

Full suite 5290 passed.

---------

Co-authored-by: Codebuff <[email protected]>
…te (#900) (#903)

* fix(dry-run): let --dry-run reach recall maintenance and recall promote (#900)

The root program declares --dry-run, and Commander gives it to the root
wherever it is written, so these two actions, which read only their own
options, never saw it: --prune --dry-run pruned and published,
--update-quality --dry-run wrote AI drafts, and promote --dry-run promoted and
published. Both actions now merge program.opts() as the other actions do, and
load with { dryRun }. --confidence-writeback, which ignored the flag, now
reports what it would write and publishes nothing.

* fix(dry-run): create the promotion target directory only when promoting (#900)

executePromotion created <repo>/<category>/ before its dry-run return, so
recall promote --dry-run left an empty directory in the team repo.

* refactor(promote): drop the ensureDir that writeFile already does (#900)
) (#851)

* fix(env,hooks,mcp,status): name the entries that are not delivered (#822)

env list, mcp list, hooks list, status and list <env|hooks|mcp> resolve the
entry types to show what reaches this directory, but dropped the resolution
notices: an entry an unknown key (a mistyped role:) or a removed key (roles:
on env, projects:) takes out of the delivered set was silently missing from
the list, and status counted around it. pull and doctor report these; now the
list commands do too, via reportEntryResolution.

env add on a variable carrying a removed per-entry key kept reporting plain
'Updated' — #833 taught it to warn for keys the schema does not know, but a
removed key is in the shape on purpose (so it can be detected), so it stayed
silent. Warn the same way for those.

* test(e2e): match the delivered DEVOPS_ONLY form, not its name in the notice

env list now reports the withheld per-entry `roles:` variable by name
(#822), so the whole-output not.toContain('DEVOPS_ONLY') assertion tripped
on the delivery notice itself. The variable stays out of the delivered
list; match the listed form `DEVOPS_ONLY=` instead.

* fix(env): point env add at the namespace file, not a key drop

The review of #851 found the update-path warning told users to remove a
per-entry `roles:`/`projects:` key in place, which delivers a root-scoped
secret to the whole team. The remediation now reuses `moveTo`, the same
remedy pull's notice names, so it points at the namespace file to move the
entry into (with the manifest declaration to add when nothing declares it).

`moveTo` and `TargetFiles` move from module-private to exported for this.

The review also found skill-data/setup/references/manage-admin.md still
said only pull and doctor report undelivered entries, while this branch
made the list commands and status report them too. It now names them, as
docs/usage-guide.md does.

* fix(entries): report notices alongside resolution failures

* fix(entries): scope list warnings and document env updates

* docs(entries): align changelog with list and env warnings

---------

Co-authored-by: ydflow <[email protected]>
Co-authored-by: ydflow <[email protected]>
@pull pull Bot locked and limited conversation to collaborators Sep 29, 2026
@pull pull Bot added the ⤵️ pull label Sep 29, 2026
@pull
pull Bot merged commit 3a9a24a into Walternater:main Sep 29, 2026
7 checks passed
Walternater pushed a commit that referenced this pull request Nov 2, 2026
…t#98)

* fix(recall): resolve remaining bugs from issues #82, #84, Tencent#94

- buildConfidence: cumulative sum capped at 1.0 (#82 bug1, Tencent#94 issue3)
- stale detection: Math.abs(fromMs - toMs) for drift (#82 bug2)
- loadWikiPages: recursive traversal (#84 bug1)
- tokenizer.ts: preserve camelCase/PascalCase split, fix OOM (#84 bug2)
- extractCodebase: load-merge-save graph (#84 bug3)
- unified tokenizer: both paths use tokenizer.ts (#84 bug4)
- loadGraphIndex: schema guard (#84 bug5)
- BM25 dl/tf: countOccurrences truncates to MAX_TOKENIZE_CHARS (Tencent#94 issue1)
- shrink-guard: restore 20% soft threshold (Tencent#94 issue2)
- tokenizer.ts: MAX_TOKENIZE_CHARS 50k + iterative segmenter (Tencent#94 issue4)
- i18n: CLI output strings in English (review/import/drift/extract)
- 15 regression tests

Closes #82, closes #84, closes Tencent#94

* feat(import): push knowledge updates via MR instead of direct push

Replace autoPushTeamRepo (direct push to main) with autoPushViaMR
(create branch + create MR/PR) for import flows:

- Add autoPushViaMR() in src/utils/git.ts: creates branch, commits,
  pushes, creates MR via provider, returns to default branch
- Replace direct push in import-repo.ts main flow and deep-enrich
  background callback
- Replace direct push in import-repo-list.ts batch flow
- Reuses existing pushRepoBranch + createPrWithFallback infrastructure

AI-generated knowledge content now requires review before merging
into the team knowledge repository.

---------

Co-authored-by: jaelgeng <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants