Skip to content

feat: keep the resources teamai delivers in project scope out of git (#915) - #1000

Merged
jeff-r2026 merged 356 commits into
Tencent:mainfrom
SaulMoro:feat/915-git-exclude
Oct 9, 2026
Merged

jeff-r2026 merged 356 commits into
Tencent:mainfrom
SaulMoro:feat/915-git-exclude

Conversation

@SaulMoro

@SaulMoro SaulMoro commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

project-scope delivery
+ record each file teamai wrote and still owns
+ list those files in the clone's local info/exclude
+ combine live worktrees without hiding member files
+ move mixed content into per-member files where supported
+ report and clean up protection through doctor, dry run, and uninstall

Closes #915. The ownership fixes from #995 are merged and included. The pending live tool checks must be verified before merge.

sharing.gitExclude.enabled defaults on for new teams and off for existing ones. A member can override it with gitExcludeEnabled. Credentials stay protected regardless of that setting. Member lines in info/exclude stay intact. Tracked files remain visible and are never deleted by cleanup.

Claude and CodeBuddy MCP servers move to their tools' local scopes. Copilot instructions use an owned file. Codex dispatches project team hooks through its user hook configuration. OpenCode V2 receives instructions and MCP through the plugin; V1 retains its supported file layout. The docs mirror, built-in resources, HTTP deliveries, and workspace cache records are covered.

Evidence

  • Before: a no-config HTTP workspace exposed .teamai/.gitignore and its MCP records to git status; project uninstall deleted an edited managed MCP server. The new real-CLI cases failed on those behaviors. After: generated cache files are ignored, member files remain addable, and edited servers stay with a warning.

  • Workspace MCP cleanup: teamai uninstall --force in the current workspace reads its .teamai/managed-local-mcp.json, both without config and with user config. Invalid tool JSON preserves the records, names the file, and exits 1. Repairing the JSON and repeating the command removes the server and its plaintext token. The 10 MCP cases and 7 HTTP delivery cases pass with --retry=0.

  • Validation at 7567e274: npm run build, npx tsc --noEmit, and npm run lint pass. The complete npx vitest run passes 8,352 tests, with 19 skipped. A Git discovery ceiling at the dependency directory keeps the real-shell fixture from inheriting its parent checkout; assertions are unchanged.

  • Full real-CLI E2E: npm run test:e2e -- --retry=0 passes 983 tests across 124 files, with 27 tests in 3 files skipped. It exits 0 with no RPC timeout, taking 8 min 43 s locally with 4 workers. CI must confirm the new head.

  • The common-directory probe regression failed before caching and passes after it. Failed probes are still retried. The existing damaged-repository git-exclude regression passes unchanged.

  • After integrating main at 6f85cf85 (fix(hooks): keep one owner for main-checkout team hooks across worktrees #1003), validation at e5d505b8 passes build, typecheck, lint and the full unit suite (8,366 passed, 19 skipped). Six affected real-CLI E2E files pass all 69 tests with --retry=0, including all 30 shared-hook isolation cases plus Codex dispatch, self mode, worktree exclusion, and uninstall. The complete 983-test E2E run above predates this merge; only the affected files were rerun after it.

  • After integrating main at 0ea32767 (docs: split long paragraphs and fix repo naming examples #1013 and four fixes), validation at f6db10aa passes build, typecheck, lint and the full unit suite (8,415 passed, 19 skipped). Real-CLI E2E with --retry=0: the four git-exclude-*-915 files, self-mode-git-exclude-915, git-hook-new-worktree, pull-new-worktree-807, doctor-delivery-cli, self-mode-worktrees-808, push-stale-worktree-812, repo-attribution-worktrees-809, local-agent-teardown-915 and local-agent-model-key-915 pass all 219 tests. At c0489516, the HTTP-source files (local-agent-model-key-915, local-agent-teardown-915, local-agent-delivered-915, local-agent-mcp-local-915), codex-team-hook-dispatcher-915 and update-dry-run passed. 642e6c5a passed codex-team-hook-dispatcher-915. 69942c45 passed git-exclude-delivered-915, instruction-targets and opencode-versions-915. The later commits change only uninstall and HTTP-source removal. Each failure path below was confirmed failing before its fix:

    • Codex: a pull with a read-only ~/.codex/hooks.json removed the team hooks from the project file. An uninstall or uninstall --agent codex that could not update that file exited 0. One version also dropped the project from the dispatcher index, so the retry left the dispatcher in place.
    • HTTP source: source remove-http exited 0 in five cases: a models file that did not parse, a model record that did not parse, a workspace cache it could not delete, a skill it could not uninstall, and a read-only exclude file holding a deleted models file's line. Each time it dropped the record of what was left, which could include teamai's model key. When a skill copy could not be deleted, its cache was already gone, so the retry took the copy for the member's and left it. In a repository git could not read, it also left the cache .gitignore and a rule copy behind and dropped their records. An unreadable git-exclude.json was deleted.
    • Uninstall: uninstall exited 0 and dropped the files' exclude lines and records in three cases: a rule it could not delete, a context file whose block had lost its end marker, and copies it kept in a repository whose .git/index git could not read. In the last case it listed those copies as tracked.
    • Worktrees: a pull in one worktree added a shared exclude line that hid a member's file at the same path in another worktree. That worktree had either been set up by an older teamai or had no teamai record at all.
    • HTTP source: when git-exclude.json could not be read, the retry of source remove-http reported nothing left and removed nothing.
    • HTTP rule: a rule copy source remove-http could not delete lost its cached rule first. The retry then took the copy for the member's, exited 0, and left the copy and its line.
    • Unit tests: a delivered copy in a repository git cannot read was deleted; the OpenCode V2 plugin missed the root project's team context, MCP, and rules past a nested package's own .opencode/rules; and a local-agent workspace with an unreadable flag lost its lines when git could not read the repository.

#995 gaps closed here

  • The first pull after upgrading performs a full ownership sync, including when git exclude is off.
  • The next HTTP sync migrates older project MCP installs into the tool's current scope.
  • HTTP resource ownership is recorded per tool. Cleanup keeps member edits and files added inside delivered skills, and removes resources for the tools that received them.

E2E runner

#915 adds 14 E2E files, about 1000s of test time, so the fork-safe job grew from 14 to 24 minutes. Two test-infra changes, no runtime code:

  • yield-between-tests.ts (setup file): Vitest's worker sends each task update with a 60s RPC timeout and reads the reply only when its event loop turns. Back-to-back synchronous tests (spawnSync of the CLI) never let it turn, so a streak past 60s on a slow runner exits 1 with Timeout calling "onTaskUpdate" although every test passed. An afterEach that awaits setImmediate caps the streak at one test. Repro: three synchronous 25s tests exit 1 without it and 0 with it. On GitHub runners, this branch without it hit the timeout in 8 of 8 E2E jobs; with it, 0 of 8.
  • maxWorkers: 4 in CI (was 2): the ubuntu runner has 4 vCPUs. Two runs each on this branch: 2 workers took 24.1 and 25.6 min, 4 workers 12.5 and 14.5 min, all tests passing; the slowest test went from 22s to 33s, under the 60s timeout.

Runtime probe overhead

Successful gitCommonDir probes are reused during one CLI process. Failed probes are retried, and checkout locations must remain stable for that process. OpenCode is probed for its version only after confirming that the current plugin exists. Git-exclude path routing remains uncached so a repository that stops answering is reported immediately.

Two sequential runs per variant with --maxWorkers=1 on the same machine:

Real-CLI E2E file Before After Mean reduction
claude-mcp-local-915 44.67s, 47.06s 35.84s, 36.00s 22%
git-exclude-worktrees-915 63.59s, 64.16s 50.06s, 56.06s 17%

These are local measurements for two files, not a measured reduction of the whole CI job.

Deviations and known limits

  • Skills are listed per file so files a member adds inside a skill remain visible. Project uninstall rebuilds the HTTP block without that project, preserving other workspaces. The docs search whitelist uses !/docs/**. Local MCP ownership is keyed by tool and local-scope key.
  • In self mode, Claude servers stay in each checkout's .mcp.json, listed while teamai-only. Self-mode worktrees share one Claude key, which cannot hold different servers for each branch.
  • Outside self mode, tclaude detection remains per checkout. Worktrees sharing a Claude key can disagree when tclaude exists in only one checkout.
  • source remove-http leaves project MCP servers and preserves their records. Run teamai uninstall in the affected workspace, or use the backend's uninstall_mcp. Uninstall does not scan every unconfigured workspace.
  • The OpenCode V2 plugin uses the nearest .opencode holding teamai-context.md or teamai-mcp.json. Without one, it reads every .opencode/rules from the session up, outermost first, as OpenCode V1 globs teamai's rules entry. A member's nested rules then load beside the team's.
  • teamai deletes or takes over a project file only when git reports it untracked or no repository holds it. A repository git cannot read keeps the file, with a message naming git's error. This covers delivered copies, a created models file, Codex's project hook file and the legacy .codebuddy/.gitignore.
  • Codex team hooks move to the dispatcher only after its entries are written to ~/.codex/hooks.json. If uninstall cannot update that file or the dispatcher index, the project stays in the index and the data home is kept. The run exits 1, and the retry removes the dispatcher.
  • A worktree with no list of delivered files is one an older teamai set up, or one teamai has no record of at all. While it has no list, a file there at a delivered path holds that path's shared line back, unless its bytes equal teamai's copy, so the line cannot hide a member's file. Pull and doctor name the worktree whose teamai pull releases it. Until then the path stays visible to git in every worktree.
  • source remove-http may fail to uninstall a skill, rule or instruction, to read its model record, to clean a models file, or to delete a workspace cache. The same holds when it cannot write an exclude file holding its lines. It then keeps the records naming them and exits 1. A skill's cache goes only after its copies, so a retry can still tell teamai's files from the member's. While git cannot judge a copy or the cache .gitignore, nothing is removed for it, and its records stay. An unreadable git-exclude.json is kept. While installs remain, the disabled marker keeps the source config, which only the retry reads. The retry removes what is left, and a user-scope teamai uninstall then keeps the local agent's home.
  • A delivered skill, rule, agent, or docs file that uninstall cannot delete keeps its exclude line and the data home. So does an instruction file whose block stays, or a docs search whitelist uninstall cannot remove. The run exits 1, so the retry can find the file.
  • No-config uninstall retains protection for built-in skill files left on disk and names them: Kept <lines> in <file>, so git still ignores <paths>, which this uninstall leaves on disk.
  • Legacy HTTP prompt records remain single-tool until reinstall. Copilot and OpenCode HTTP prompt paths lack dedicated real-CLI coverage. Atomic Codex index writes lack crash-injection coverage.

Live checks pending

Before merge: Cursor must load an excluded nested rule; Copilot must apply the owned instructions without an attached file; Codex must run context and blocking hooks through the dispatcher; OpenCode V2 must load plugin context and a project-only MCP server. Fixtures and steps are prepared, but these live checks are not verified.

Conditional changes remain deferred: claude-internal and tclaude need a /memory or /context check proving rules/teamai-context.md loads; Qoder and Qoder CN need confirmation that settings.local.json supplies MCP configuration.

Merge Danger

Door: two-way. Disabling the option removes delivery blocks on the next pull. Uninstall removes protection after safe cleanup and keeps records for failed removals.

Blast Radius: project delivery. Existing teams opt in; the first pull after upgrade runs a full sync. The pending live tool checks must complete before merge.

…Tencent#993)

The mirror replaced a local directory at a team doc file's path, or a
local file at a team docs directory's path, and deleted the backup with
its staging directory. membersDocs now treats such an entry as the
member's unless the team history proves it teamai's (a file where the
team now has a directory, or a directory whose every file is a team
version), and copyDocs leaves a kept entry in place. A link is still
replaced without touching its target.
…e moves onto it (Tencent#915)

src/git-exclude.ts owns info/exclude files: sync (replace), ensure
(add-only gate with a per-path result), remove (owner or all, with a keep
predicate) and report. Owners are named [a-z0-9/_%-] with per-owner
markers; mcp-exclude keeps Tencent#886's markers, trimmed parsing and its
already-ignored rule, and ensureExcludedFromGit maps ensure's results to
GitExclusion unchanged. Lines route to the repository a path lands in
(submodule, nested clone, symlink target), use the on-disk spelling, NFC
only with core.precomposeunicode, and refuse line breaks and trailing
spaces. Each owner's exclude files live in a caller-supplied record;
stateHomeRecord keeps them in <stateHome>/git-exclude.json. git children
drop the repository variables a hook exports.

The re-including rule's source is now resolved from the toplevel, where
git names it, not from the file's directory: a rule in .claude/.gitignore
was named as .claude/rules/.claude/.gitignore.
…ng it (Tencent#993)

membersDocs skipped links, so the mirror still moved a member's link
aside and deleted it with the staging directory (rest of the Codex P1).
A link at a doc's path, or at an ancestor of one, is now the member's
unless the team has the same link there: it is kept, named and never
followed, and the docs under it are not delivered.
…t#993)

Node 22 on macOS failed on 9309e20 with one unhandled rejection from
src/__tests__/recall-attribution.test.ts (a votes-lock write outliving the
test's temp HOME); every test passed and Tencent#995 does not touch that code.
The fork cannot re-run jobs, so this empty commit re-triggers CI.
…ncent#915)

updateFileLocked read through readFileSafe, which turns every read error
into empty content: an info/exclude that exists but cannot be read was
rewritten with only teamai's block, dropping the member's lines, and the
ensure that gated a resolved MCP value reported success.

A read failure other than ENOENT/ENOTDIR now throws NotReadableError and
writes nothing. ensure returns notReadable {path, error, reason, fix};
sync and remove report write kind notReadable and keep the file in the
owner's record; ensureExcludedFromGit maps it to failed, so the secret is
withheld. A missing exclude file is still created.
…tExclude (Tencent#915)

sharing.gitExclude.enabled (default false; init writes true into a new
git-mode or single-repo teamai.yaml) and the partition override
gitExcludeEnabled resolve as override, team, false.

pull() carries one DeliveryRecorder for the project scope. Writers report
landed paths per writer id and say whether they succeeded or failed; the
skills handler is the first (through the pull's ledger, so the local
agent's ledger-less calls report nothing). After pullSources, still under
the partition sync lock and skipped for a contended scope, pull merges the
reports into the checkout record's gitExcludePaths (fast path add-only;
full sync replaces writer by writer, a failed writer keeps its previous
entries still on disk) and syncs teamai's delivered block in the clone's
info/exclude, or removes only that block when the flag is off. The list is
kept whatever the flag; awaitingFullSync and the complete-branch rebuild
carry it, and a record without it misses the fast path, so the first pull
after upgrading from 0.26.0 is a full sync. The delivered owner's exclude
files are recorded in the partition state (gitExcludeFiles).
…t#915)

Every writer of a project-scope pull now reports what it wrote, or
confirmed as teamai's, to the delivery recorder, and says whether it
delivered all it meant to:

- rules, one file per line (namespace subdirectories, flattened names,
  Copilot instructions), also from the fast path's rewrites;
- agents, plus a copy a tool holds for its model while the record still
  matches it;
- the built-in teamai skill and the teamai-recall rule and agent;
- the owned teamai-context files that hold teamai's blocks;
- the main checkout's .claude/settings.local.json while its hook manifest
  records team hooks there, and Copilot's .github/hooks/teamai.json while
  it holds teamai's entries, read from disk so an unresolved team hook
  set or Copilot's built-ins-installed skip still lists them;
- .claude/settings.local.json while the co-author record says teamai
  wrote the empty trailer and the file still holds it;
- source skills this pull landed, never the manifest's entries. No
  configured source is a successful empty result (the copies stay on
  disk, visible); a source left as it was keeps its previous lines.

A copy pull keeps for the member's edit is never reported, so it leaves
the block. Collisions and failed writes mark their writer failed.

The acceptance fixture (roles, a project, a source, recall, team hooks,
MCP with and without a resolved value, Copilot plus six agents, a Codex
copy in .agents/skills, a tracked SKILL.md with a new team file) checks
git status against an allowlist of paths later tickets move, after init,
pull and a session start, with the member's files visible and addable.
…not rewrite (Tencent#993)

An unrecorded server equal to today's team render was adopted into the
in-memory records, but with no file write the manifest was not saved, so
a later team removal or uninstall found nothing owned and left the server
installed. The reconcile now saves the manifest whenever this run changed it.
…all (Tencent#993)

A dry run now says it would record an unrecorded server that already holds
the team's render, in .mcp.json-style files and in Codex config, and still
writes nothing. The real-CLI cases add the dry run before the adoption and
an adoption followed by teamai uninstall; both failed before b62e503.
Hook adoption needs no change: reconcileHooks saves its records whenever
they differ from the previous ones, whether or not it wrote a file.
…mai owns (Tencent#915)

With sharing.gitExclude on, Copilot's project culture, shared-instructions and
recall blocks go to .github/instructions/teamai-context.instructions.md with
applyTo: "**", which the delivered git exclude block lists. The next pull
strips teamai's blocks from .github/copilot-instructions.md and deletes it only
when teamai created it and git does not track it. Turning the flag off moves
the blocks back on the next pull. Doctor checks the new file through the
existing instruction checks; the usage guide names the Copilot surfaces that
read no .github/instructions file and the chat.includeApplyingInstructions
dependency.
Tencent#993)

When the team deleted a doc file the member had replaced with a directory,
the prune walked into that directory and deleted its files, which match no
team version. A directory at a path where the team history had a doc file,
holding anything that is not a team version, is now kept whole and named.
…eep Codex's shared skills (Tencent#915)

When a delivered copy stops being delivered (role or project switch, a root
skill once roles are set, a team tombstone or removed rule, a source dropping
a skill), the removal pass now keeps a path the checkout's index tracks and
names it once per pull with the git rm -r hint, so a later pass that proves
the copy teamai's still leaves it. The inactive-namespace, stale-skill and
tombstone sweeps also visit Codex's .agents/skills/<name>, deleting a copy
only when judgeRemoval returns remove and naming an edited or member copy.
…ngs (Tencent#915)

In a single-repo team with sharing.gitExclude on, Claude Code's team hooks
go to each checkout's own .claude/settings.local.json, which the delivered
block lists, and the committed .claude/settings.json keeps only the
built-ins, so a fresh clone still has them and a pull leaves git status
clean. The per-checkout hook index records the team hooks of the one file
that holds them. Turned off, the next pull moves them back into the tracked
settings. init . syncs the delivered block after its own writers, since it
ends without a pull. hooks remove and uninstall also clear settings.local.json.
…cent#993)

With a lost manifest, a server an older release installed stayed for good
once the team deleted it: only today's names were judged, and with no team
server and nothing owned the reconcile returned early. Pull and uninstall
now also remove an unrecorded entry, in .mcp.json-style files and Codex
config, that equals a render of that server from the team history. A
member's entry under that name stays. The early return now also requires a
team history with no MCP server.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
  • [P1 blocking] src/opencode-hooks.ts:227 treats any nearest .opencode/rules directory as a TeamAI project marker. In a monorepo initialized at the root, opening a nested package with its own user-created .opencode/rules makes the V2 plugin stop there, so it silently omits the root project’s teamai-context.md and teamai-mcp.json. Continue searching unless a TeamAI-specific marker exists.
  • [P3 nit] src/local-agent.ts:2529 preserves an unreadable workspace’s existing exclusions only when report() successfully places and recognizes each path as listed. If the team config is unreadable and Git also fails to inspect a protected path, report() returns gitFailed without listed; the following sync() can remove that path’s existing exclusion. Preserve the current block or force add-only behavior when this report has placement failures.

The five findings from the earlier pass are resolved in the current diff. The PR description includes sufficient real-CLI testing evidence for this runtime-changing PR.

…de lines

The OpenCode V2 plugin stopped at the nearest .opencode with a rules
directory, so a member's own .opencode/rules in a nested package hid the
teamai project above it. It now prefers a .opencode holding a teamai file
and falls back to the nearest rules directory only when none does.

A local-agent workspace whose flag cannot be read passed only the paths
git could place to the sync, which then dropped the lines of the others.
Those paths now reach the sync, which keeps every line while git fails.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
  • [P1 blocking] src/opencode-hooks.ts:236 still falls back to the nearest arbitrary .opencode/rules directory when no TeamAI-specific marker exists. In a rules-only TeamAI project, opening a nested package with member-owned .opencode/rules selects that directory and omits the root project’s TeamAI rules. The prior OpenCode finding is therefore only partially resolved.
  • [P1 blocking] src/hooks.ts:1031 treats gitTracks() returning unknown as equivalent to untracked. If Git cannot inspect a tracked .codex/hooks.json, placeCodexTeamHooks() may classify it as TeamAI-only and write project hooks into the tracked file instead of using the dispatcher. Unknown tracking status must take the conservative/foreign path.
  • [P1 blocking] src/hooks.ts:1080 commits the dispatcher index and returns true before reconcileCodexDispatchers() installs the corresponding entry in ~/.codex/hooks.json. If that later write fails, the same reconciliation removes the team hooks from the project file, leaving Codex with no delivery path for those hooks. The transition must retain the project-file hooks unless dispatcher installation succeeds.
  • [P1 blocking] src/uninstall.ts:2116 considers only hook and OpenCode cleanup failures when deciding whether delivered exclusion lines and ownership state must remain. If deleting a delivered skill, rule, agent, or docs file fails—for example because its parent directory is not writable—the command removes its exclusion and deletes the state anyway, exposing the leftover file to Git and making the advertised retry unable to identify it.
  • [P2 non-blocking] src/local-agent.ts:3043 deletes the legacy .codebuddy/.gitignore whenever Git returns anything other than tracked. If git ls-files fails, a tracked file containing those two lines is deleted despite the function’s stated rule that committed files stay; preserve it unless Git explicitly reports untracked.

The other five first-pass findings and the local-agent preservation finding are resolved. The PR description contains sufficient real-CLI testing evidence for this runtime-changing PR.

…lete

- OpenCode V2 plugin: with no teamai file above the session, read every
  .opencode/rules up, outermost first, as V1's glob does, so a nested
  package's own rules no longer hide a rules-only team's.
- Codex: a hook file git cannot judge inside a repository counts as not
  teamai's, and the project file keeps the team hooks unless the
  dispatcher entries were written to ~/.codex/hooks.json.
- Uninstall: a delivered skill, rule, agent or docs file that could not be
  deleted keeps its exclude line and the data home, and marks the run
  incomplete so the retry finds it.
- Local agent: the legacy .codebuddy/.gitignore goes only when git says it
  is untracked.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
  • [P1 blocking] src/resources/delivered-copies.ts:555 treats every gitTracks() result except tracked as safe to delete. If git ls-files fails inside a repository, pull/uninstall can delete a tracked skill, rule, or agent copy. Preserve the path on unknown; only confirmed untracked or outside-repository paths may be removed.
  • [P1 blocking] src/local-agent.ts:3250 similarly deletes a TeamAI-created models file when Git returns unknown. If the member committed that file and Git is temporarily unable to inspect the repository, model cleanup deletes a tracked file despite the stated tracked-file guarantee.
  • [P1 blocking] src/uninstall.ts:1960 only warns when an owned instruction file cannot be cleaned. The uninstall then removes its exclusion and ownership state and exits successfully, leaving the TeamAI instruction active and potentially visible to Git with no retry metadata. Add the file to filesLeft when cleanup throws or reports an undelimited block. The same issue exists for a failed docs-search-whitelist removal at src/uninstall.ts:2114.
  • [P2 non-blocking] src/hooks.ts:998 deletes the project from codex-team-hooks.json before updating ~/.codex/hooks.json. If the latter write fails, the stale dispatcher remains, and retries short-circuit at runsFromCodexDispatcher() because the index entry is already gone. Reconcile the user hook file first or restore the index entry on failure.

The previously reported findings are resolved in the current diff. The PR description contains sufficient real-CLI testing evidence for this runtime-changing PR.

…ecords on failed cleanup

- gitUntracked: a file git says it does not track, or one in no
  repository; a repository git cannot answer for is neither. Delivered
  copies, a created models file and Codex's project hook file use it, so
  a git failure no longer lets teamai delete or take over a tracked file.
- Uninstall: an instruction file whose block stays, or a docs search
  whitelist it cannot remove, keeps its exclude line and the data home,
  and the run exits 1.
- Stopping Codex dispatch restores the project's index entry when
  ~/.codex/hooks.json cannot be updated, so the retry removes its entries.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
  • [P1 blocking] src/uninstall.ts:2465 swallows failure from stopCodexTeamHookDispatch() without marking uninstall incomplete. If ~/.codex/hooks.json is read-only—or the dispatcher index lock times out—the command exits successfully even though the project remains in codex-team-hooks.json and its team hooks continue running. Set a nonzero exit status and preserve retry state whenever dispatcher removal fails.

The previously reported findings are resolved in the current diff. The PR description contains sufficient real-CLI testing evidence for this runtime-changing PR.

…lete

Uninstall stops the project's Codex team-hook dispatch before the data
home goes. When ~/.codex/hooks.json or the dispatcher index cannot be
updated, the dispatcher counts as a hook left in place: the records stay
for the retry and the command exits 1. Excluding only Codex from the
project does the same.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
  • [P1 blocking] src/local-agent.ts:3159 swallows model cleanup failures, after which finishAgentHookTeardown() deletes the model manifest. If models.json is temporarily invalid or unwritable, source remove-http exits successfully while leaving TeamAI’s model and token behind; retries no longer know which entries TeamAI owned. Preserve the manifest and mark removal incomplete.
  • [P1 blocking] src/local-agent.ts:4821 similarly swallows workspace-cache deletion failures before teardown deletes the workspace manifest. If .teamai/cache cannot be removed, the command reports success and later retries only retain its exclude lines because no state remains to retry deleting the cache. Preserve retry state and return a nonzero status.

The previously reported findings are resolved in the current diff. The PR description contains sufficient real-CLI testing evidence for this runtime-changing PR.

… not delete

Removing the HTTP source logged a models file it could not clean, or a
workspace cache it could not delete, then deleted the manifests that
name them and reported success. The teardown now keeps those manifests,
reports the removal incomplete with exit 1, and the retry, which finds
them with the source already disabled, removes what is left. A user-scope
`teamai uninstall` keeps the local agent's home when its teardown is
incomplete.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
  • [P1 blocking] src/local-agent.ts:4794 swallows a failed skill/rule/instruction uninstall, but finishAgentHookTeardown() only preserves manifest.json for cache failures (src/local-agent.ts:4871). If a delivered skill cannot be deleted, the command exits successfully and deletes its ownership record; retry cannot remove the leftover resource or its retained exclude line. Treat remaining manifest entries as incomplete and preserve the manifest.
  • [P1 blocking] src/local-agent.ts:3154 treats an unreadable or malformed model manifest as an empty manifest. source remove-http then skips every delivered model and deletes the manifest during teardown, reporting success while model entries and plaintext keys remain with no retry metadata. Manifest read failure must mark teardown incomplete and preserve the file.

The previously reported findings are resolved in the current diff. The PR description contains sufficient real-CLI testing evidence for this runtime-changing PR.

…moval could not handle

- A skill, rule or instruction the teardown could not uninstall keeps its
  manifest entry. The disabled marker keeps the source config while any
  entry is left, so the retry uninstalls it. The run exits 1.
- A model record that cannot be read or parsed is kept, no models file is
  changed, and the run exits 1, instead of being read as empty and
  deleted with teamai's models and keys still in place.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
  • [P1 blocking] src/local-agent.ts:2398 deletes the cached skill source before removing its delivered copies. If deleting a destination copy then fails, the retry has no source hashes; localAgentCopyFiles() classifies every remaining file as member-owned, drops the manifest entry, and permanently leaves the delivered skill and exclusion line behind. Keep the cache until all copies are removed, or persist the precomputed ownership for retries.
  • [P1 blocking] src/local-agent.ts:4898 preserves a nonempty git-exclude.json but does not count it as incomplete. If a deleted models file’s credentials block cannot be updated—for example, .git/info/exclude is read-only—source remove-http exits successfully. disabledSourceLeftovers() checks only the local-agent owner, so the retained credentials record is never retried and the stale pattern can hide a future member-created models file.

The previously reported findings remain resolved. The PR description contains sufficient real-CLI testing evidence for this runtime-changing PR.

… report kept exclude lines

- A skill's cached source goes after its copies, so a copy that cannot
  be deleted fails the entry while the cache still proves which files
  are teamai's, and the retry removes it.
- Removing the HTTP source counts an exclude file whose local-agent or
  credentials lines it could not write as incomplete, and exits 1. A
  retry finds a credentials record left behind and judges its lines
  from the checkouts of the recorded exclude files.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
  • [P1 blocking] src/local-agent.ts:4875 treats gitTracks() returning unknown as a successful cache cleanup. If Git temporarily cannot inspect the generated .teamai/.gitignore, source remove-http deletes the workspace manifest, exits 0, and leaves both the file and its exclusion behind. Later retries can locate the exclusion but no longer know to delete the generated .gitignore, so .teamai/local-agent/ remains silently ignored indefinitely. Return false on unknown so the manifest and retry state are preserved.
  • [P3 nit] src/local-agent.ts:4920 interprets an unreadable or malformed git-exclude.json as empty when deciding what state to retain. The preceding cleanup reports this record as a retained block, but teardown then deletes the record, leaving its exclusion blocks without metadata for the advertised retry. Preserve the record whenever reading it fails.

The previously reported findings are resolved. The PR description contains sufficient real-CLI testing evidence for this runtime-changing PR.

…down would remove

- The cache .gitignore a workspace teardown wrote stays, and fails the
  cache cleanup, while git cannot say whether the repository tracks it.
- A skill or rule uninstall fails before it removes anything while git
  cannot judge a copy on disk, so its cache and records stay to prove the
  copy teamai's on the retry.
- An unreadable or malformed git-exclude.json is kept, as it may name
  blocks still in place.
…e on uninstall

- An HTTP rule copy that cannot be deleted gets its cached rule back, so
  the retry still proves the copy teamai's and removes it. The teardown
  warns with each install's cause instead of logging it at debug level.
- Project uninstall counts a copy it keeps because git cannot say whether
  the repository tracks it as left: the run exits 1 and keeps the exclude
  lines and the data home for the retry, and no longer lists the copy as
  tracked.
- The legacy .codebuddy/.gitignore also goes in a workspace outside any
  repository.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
  • [P1 blocking] src/git-exclude-delivered.ts:187 omits live worktrees whose older state has no gitExcludePaths from foreign-file detection. After upgrading a multi-worktree project, pulling in checkout A can add a shared exclude line while un-migrated checkout B has a member-owned file at that same relative path; Git immediately hides B’s file until B runs its first pull. git-exclude-worktrees-915.test.ts:363 explicitly exercises this unsafe window. Treat a null list conservatively or defer shared lines until that checkout is migrated.

The previously reported findings are resolved in the current diff. The PR description contains sufficient real-CLI testing evidence for this runtime-changing PR.

…ivered list

A checkout an older teamai set up has no list of the files teamai
delivered there until its first full sync. Its files were treated as
never foreign, so a pull in another worktree could add a shared exclude
line that hid the member's own file at the same path. A file there now
holds the line back, and pull and doctor name the checkout whose
`teamai pull` releases it.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
  • [P1 blocking] src/pull.ts:3132 builds the delivered union only from lastPullByWorkspace, omitting live worktrees with no record at all. If a sibling worktree predates TeamAI initialization and contains a member-owned file at a delivered path, pulling another checkout adds the shared exclude line and silently hides that file. Include every checkout returned by Git, treating unrecorded ones conservatively like paths: null.
  • [P1 blocking] src/local-agent.ts:4926 converts failure to read git-exclude.json into an empty file list. After teardown preserves an unreadable record and exits 1, the advertised retry reaches disabledSourceLeftovers(), reports nothing left, and performs no cleanup; stale exclude blocks remain permanently. A record-read failure must count as leftovers requiring retry.

The previously reported findings are otherwise resolved. The PR description contains sufficient real-CLI testing evidence for this runtime-changing PR.

… local-agent record

- The delivered union also takes every worktree git lists that teamai has
  no record of, as a checkout without a list. A file in such a checkout
  holds a shared line back unless it holds the same bytes as teamai's
  copy, so a member's own file is never hidden, and teamai's copies in a
  checkout with no list (self mode's main checkout) still get their line.
- A local agent git exclude record that cannot be read counts as left
  for `source remove-http`, so the retry reports it instead of "nothing
  to remove", and removes the blocks once it is readable.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

No findings.

The previously reported findings are resolved in the current diff. The PR description provides sufficient real-CLI/E2E testing evidence for this runtime-changing PR.

@jeff-r2026
jeff-r2026 merged commit b69f888 into Tencent:main Oct 9, 2026
14 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…encent#915) (Tencent#1000)

* test(agents): record the stale Kiro .md sibling as teamai's in the fixture (#993)

* fix(docs): keep a member's entry whose type conflicts with a team doc (#993)

The mirror replaced a local directory at a team doc file's path, or a
local file at a team docs directory's path, and deleted the backup with
its staging directory. membersDocs now treats such an entry as the
member's unless the team history proves it teamai's (a file where the
team now has a directory, or a directory whose every file is a team
version), and copyDocs leaves a kept entry in place. A link is still
replaced without touching its target.

* test(skills): expect the not-teamai's line for a member's copy of a removed skill (#993)

* refactor(git-exclude): one module owns git exclude blocks, mcp-exclude moves onto it (#915)

src/git-exclude.ts owns info/exclude files: sync (replace), ensure
(add-only gate with a per-path result), remove (owner or all, with a keep
predicate) and report. Owners are named [a-z0-9/_%-] with per-owner
markers; mcp-exclude keeps #886's markers, trimmed parsing and its
already-ignored rule, and ensureExcludedFromGit maps ensure's results to
GitExclusion unchanged. Lines route to the repository a path lands in
(submodule, nested clone, symlink target), use the on-disk spelling, NFC
only with core.precomposeunicode, and refuse line breaks and trailing
spaces. Each owner's exclude files live in a caller-supplied record;
stateHomeRecord keeps them in <stateHome>/git-exclude.json. git children
drop the repository variables a hook exports.

The re-including rule's source is now resolved from the toplevel, where
git names it, not from the file's directory: a rule in .claude/.gitignore
was named as .claude/rules/.claude/.gitignore.

* fix(docs): keep a member's link at a team doc's path, without following it (#993)

membersDocs skipped links, so the mirror still moved a member's link
aside and deleted it with the staging directory (rest of the Codex P1).
A link at a doc's path, or at an ancestor of one, is now the member's
unless the team has the same link there: it is kept, named and never
followed, and the docs under it are not delivered.

* ci: re-run checks after an unrelated recall-attribution flake (#993)

Node 22 on macOS failed on 9309e201 with one unhandled rejection from
src/__tests__/recall-attribution.test.ts (a votes-lock write outliving the
test's temp HOME); every test passed and #995 does not touch that code.
The fork cannot re-run jobs, so this empty commit re-triggers CI.

* fix(git-exclude): never take an unreadable exclude file for empty (#915)

updateFileLocked read through readFileSafe, which turns every read error
into empty content: an info/exclude that exists but cannot be read was
rewritten with only teamai's block, dropping the member's lines, and the
ensure that gated a resolved MCP value reported success.

A read failure other than ENOENT/ENOTDIR now throws NotReadableError and
writes nothing. ensure returns notReadable {path, error, reason, fix};
sync and remove report write kind notReadable and keep the file in the
owner's record; ensureExcludedFromGit maps it to failed, so the secret is
withheld. A missing exclude file is still created.

* feat(git-exclude): keep delivered skills out of git behind sharing.gitExclude (#915)

sharing.gitExclude.enabled (default false; init writes true into a new
git-mode or single-repo teamai.yaml) and the partition override
gitExcludeEnabled resolve as override, team, false.

pull() carries one DeliveryRecorder for the project scope. Writers report
landed paths per writer id and say whether they succeeded or failed; the
skills handler is the first (through the pull's ledger, so the local
agent's ledger-less calls report nothing). After pullSources, still under
the partition sync lock and skipped for a contended scope, pull merges the
reports into the checkout record's gitExcludePaths (fast path add-only;
full sync replaces writer by writer, a failed writer keeps its previous
entries still on disk) and syncs teamai's delivered block in the clone's
info/exclude, or removes only that block when the flag is off. The list is
kept whatever the flag; awaitingFullSync and the complete-branch rebuild
carry it, and a record without it misses the fast path, so the first pull
after upgrading from 0.26.0 is a full sync. The delivered owner's exclude
files are recorded in the partition state (gitExcludeFiles).

* feat(git-exclude): keep everything a pull delivers out of git (#915)

Every writer of a project-scope pull now reports what it wrote, or
confirmed as teamai's, to the delivery recorder, and says whether it
delivered all it meant to:

- rules, one file per line (namespace subdirectories, flattened names,
  Copilot instructions), also from the fast path's rewrites;
- agents, plus a copy a tool holds for its model while the record still
  matches it;
- the built-in teamai skill and the teamai-recall rule and agent;
- the owned teamai-context files that hold teamai's blocks;
- the main checkout's .claude/settings.local.json while its hook manifest
  records team hooks there, and Copilot's .github/hooks/teamai.json while
  it holds teamai's entries, read from disk so an unresolved team hook
  set or Copilot's built-ins-installed skip still lists them;
- .claude/settings.local.json while the co-author record says teamai
  wrote the empty trailer and the file still holds it;
- source skills this pull landed, never the manifest's entries. No
  configured source is a successful empty result (the copies stay on
  disk, visible); a source left as it was keeps its previous lines.

A copy pull keeps for the member's edit is never reported, so it leaves
the block. Collisions and failed writes mark their writer failed.

The acceptance fixture (roles, a project, a source, recall, team hooks,
MCP with and without a resolved value, Copilot plus six agents, a Codex
copy in .agents/skills, a tracked SKILL.md with a new team file) checks
git status against an allowlist of paths later tickets move, after init,
pull and a session start, with the member's files visible and addable.

* ci: re-run the Codex PR review, cancelled at its time limit (#993)

* fix(mcp): save the manifest when an adoption records a server it did not rewrite (#993)

An unrecorded server equal to today's team render was adopted into the
in-memory records, but with no file write the manifest was not saved, so
a later team removal or uninstall found nothing owned and left the server
installed. The reconcile now saves the manifest whenever this run changed it.

* fix(mcp): preview a no-op MCP adoption on --dry-run, and cover uninstall (#993)

A dry run now says it would record an unrecorded server that already holds
the team's render, in .mcp.json-style files and in Codex config, and still
writes nothing. The real-CLI cases add the dry run before the adoption and
an adoption followed by teamai uninstall; both failed before b62e503b.
Hook adoption needs no change: reconcileHooks saves its records whenever
they differ from the previous ones, whether or not it wrote a file.

* feat(git-exclude): give Copilot the team instructions from a file teamai owns (#915)

With sharing.gitExclude on, Copilot's project culture, shared-instructions and
recall blocks go to .github/instructions/teamai-context.instructions.md with
applyTo: "**", which the delivered git exclude block lists. The next pull
strips teamai's blocks from .github/copilot-instructions.md and deletes it only
when teamai created it and git does not track it. Turning the flag off moves
the blocks back on the next pull. Doctor checks the new file through the
existing instruction checks; the usage guide names the Copilot surfaces that
read no .github/instructions file and the chat.includeApplyingInstructions
dependency.

* fix(docs): keep a member's directory where the team removed a doc file (#993)

When the team deleted a doc file the member had replaced with a directory,
the prune walked into that directory and deleted its files, which match no
team version. A directory at a path where the team history had a doc file,
holding anything that is not a team version, is now kept whole and named.

* feat(git-exclude): keep tracked copies a removal would delete, and sweep Codex's shared skills (#915)

When a delivered copy stops being delivered (role or project switch, a root
skill once roles are set, a team tombstone or removed rule, a source dropping
a skill), the removal pass now keeps a path the checkout's index tracks and
names it once per pull with the git rm -r hint, so a later pass that proves
the copy teamai's still leaves it. The inactive-namespace, stale-skill and
tombstone sweeps also visit Codex's .agents/skills/<name>, deleting a copy
only when judgeRemoval returns remove and naming an edited or member copy.

* feat(git-exclude): keep self-mode team hooks out of the tracked settings (#915)

In a single-repo team with sharing.gitExclude on, Claude Code's team hooks
go to each checkout's own .claude/settings.local.json, which the delivered
block lists, and the committed .claude/settings.json keeps only the
built-ins, so a fresh clone still has them and a pull leaves git status
clean. The per-checkout hook index records the team hooks of the one file
that holds them. Turned off, the next pull moves them back into the tracked
settings. init . syncs the delivered block after its own writers, since it
ends without a pull. hooks remove and uninstall also clear settings.local.json.

* fix(mcp): remove an unrecorded copy of a server the team deleted (#993)

With a lost manifest, a server an older release installed stayed for good
once the team deleted it: only today's names were judged, and with no team
server and nothing owned the reconcile returned early. Pull and uninstall
now also remove an unrecorded entry, in .mcp.json-style files and Codex
config, that equals a render of that server from the team history. A
member's entry under that name stays. The early return now also requires a
team history with no MCP server.

* feat(git-exclude): one delivered block for every live checkout, and other repositories' paths where git reads them (#915)

A pull now lists in teamai's delivered git exclude blocks the union of the
lists of the project's live checkouts (liveCheckoutRecords, now exported),
so a pull in one worktree no longer drops another worktree's lines, also in
a --separate-git-dir repo and in a project that is a submodule. A removed or
pruned worktree's lines go on the next pull, fast path included.

A delivered path that holds a file of the member's in another live checkout
(not in that checkout's list) gets no line, since the shared line would hide
that file too; pull names it. A checkout with no list yet has no such files,
and the member's own .claude/settings.local.json in a linked worktree is
never one. A path tracked in one checkout and untracked in another stays
listed.

Paths that land in another repository (a tool folder that is a submodule or
a nested clone, a tool home under version control) go to that repository's
exclude file, in a delivered/<id> block named after the partition, so the
superproject stops showing the submodule modified and projects sharing a
tool home each manage only their own block. Turned off, both blocks go.

* perf(sync): read the team's MCP history once per pull, in one git call (#993)

historicalContents read each historical blob with its own git process
(about 370 ms for 60 versions); it now reads them all with one
git cat-file --batch (about 30 ms). The MCP reconcile reads that history
once per run for every target, and only when a target file holds an
unrecorded entry; with no team server, nothing recorded and no server in
any target file it returns without reading it. A dry run names an
unrecorded copy of a server the team deleted that a pull would remove.

* fix(docs): keep a member's link where the team deleted a doc (#993)

The prune unlinked any link at a removed team doc's path. A link there is
now removed only when it is a version of that doc from the team history
(git stores a link as a blob of its target); a link of the member's stays,
and is never followed. A link at a path the team never had is pruned as
before.

* fix(coauthor): keep the record of a shared settings file that does not parse (#993)

A pull that could not read a recorded shared settings file dropped its
record, so once the member repaired the file no later pull removed the old
attribution value. The record now stays until the file can be read.

* fix(docs): keep any non-file entry of the member's where the team deleted a doc (#993)

A link at a removed team doc's path goes only when it is a version of that
doc from the team history; any other entry that is not a regular file stays
and is named. Adds the real-CLI case for a member's link replacing a doc.

* fix(sync): never adopt or write through a link at a delivered file's path (#993)

isTeamaiCopy and the copy judgement followed links: a link at a rule or
agent path whose target held an older team version was taken as teamai's,
and the next pull wrote through it into the member's file. A link in place
of a delivered file is now the member's (kept, named), a link there is
never removed as teamai's copy, and a skill directory holding a link is not
teamai's copy, since copying over it would write through it.

* fix(docs): keep a member's directory of links where the team deleted a doc file, and do not call it stale (#993)

A directory that replaced a former team doc file and held only links read
as teamai's (links are not listed), so the prune removed it. Such a
directory is now the member's whenever it holds a link. doctor also stops
listing files inside a directory pull keeps whole as stale docs.

* fix(hooks): recognize unrecorded team hooks in every format, on pull and uninstall (#993)

Pull recovered a team hook entry whose record was lost only in Claude and
Codex files. In Cursor, Copilot and ZCode files the old entry stayed as the
member's and the new one was added beside it, so both ran. Each entry is now
compared with the team's hooks rendered the way that format's reconciler
writes them; one equal to exactly one hook is replaced or removed as teamai's.

Uninstall did not judge unrecorded entries at all, so with the records lost
it left custom team hooks installed, and missed a main-checkout Codex file
holding only team hooks. It now judges every hook file against the team's
hook history, gated to the project as pull renders them in a non-self
project scope, and removes the entries equal to exactly one team hook.

* fix(sync): treat any non-regular entry in a skill or docs directory as the member's (#993)

A directory is teamai's copy only when every entry is a regular file that
is a team version; a link or any other non-regular entry anywhere below it
makes it the member's. Adds real-CLI cases for a skill directory holding a
link and a docs directory of links where the team deleted a doc file.

* fix(sync): keep a member's link at any delivered path (#993)

A link at a delivered skill directory, rule or agent file, docs entry or
source skill destination is the member's: teamai never creates links, so
it is never adopted, replaced, written through or deleted, on pull,
remove and uninstall alike. Pull and doctor name it: "Kept <path>: it is a
link of yours, so teamai does not replace it. Remove the link to receive
<name> from the team."

This deliberately changes earlier behavior: source and team skills used to
replace a leaf link in place of a skill directory with a copy, and the
Codex duplicate cleanup deleted a configured leaf link. The source tests
that asserted those now expect the link kept.

* fix(git-exclude): report an unreadable exclude file as such, and ask git a fixed number of times per checkout (#915)

* fix(agents): prove a tombstoned agent copy teamai's in a team-defined tool too (#993)

For a tool teamai renders no agents for, the tombstone cleanup had no
proof to check and removed any file with the removed agent's name. It now
removes it only when it is a team agent's own bytes from the history; a
member's file of that name stays.

* fix(rules): never read through, write through or delete a member's link at a rule path (#993)

The cleanup and rerender paths judged a rule copy by reading the file a
link points at, so a link whose target held a team render was rewritten
through or deleted: the "Already synced" rerender, the legacy rules
directories (pull and uninstall), the reserved teamai-context name, the
unselected-rule sweep, the moved nested copy, the flat OMP and Kiro
copies, the older .md layout, and teamai remove rules. Each now treats a
link as the member's and leaves it. The empty-directory sweep no longer
deletes a directory whose only entries are links.

* fix(agents): keep a member's link where an agent was delivered, on pull and teamai remove (#993)

The inactive-namespace cleanup judged a copy by the file a link points at, and teamai remove agents deleted the author's root copy by its placement record alone. A link at either path is now the member's and stays.

* fix(skills): keep a skill directory that holds a member's link, on pull, remove and uninstall (#993)

A recorded skill whose file the member replaced with a link to the same
bytes read as unchanged, so pull copied over the link and remove,
uninstall and the tombstone and inactive-namespace sweeps deleted the
directory with every link in it. A skill directory holding a link is now
the member's on pull, named by the link, and kept by every sweep.
teamai remove skills also judges a link at a built-in skill's name
before the name.

* fix(sync): keep an unrecorded file teamai cannot read where a removed resource was delivered (#993)

judgeRemoval counted a file it could not read as absent and removed it. Without its bytes nothing proves it teamai's, so it is now kept as the member's.

* fix(docs): never read through or delete inside a member's link in a deactivated docs namespace (#993)

Withdrawing a namespace's docs read each copy through any link on its path and deleted what matched the team file. A namespace directory the member linked to a folder of their own lost its files, and a linked doc was deleted. A path through a link is now left alone.

* fix(source): keep a source skill copy that holds a member's link, on pull and source remove (#993)

A recorded destination was the source's whole, so pull copied over a link the member put inside it and source remove deleted the directory with it. Such a copy is now the member's: pull names the link and source remove keeps the directory on record.

* fix(local-agent): keep a member's link where the local agent installs a skill or rule (#993)

The local agent installs through pullItem with no delivery record, which skipped every ownership check: a rule was written through a link and a skill directory link was replaced. A link at the path, or inside the skill directory, is now kept and named.

* fix(sync): deliver team and source skills without the links in them (#993)

Copying a skill recreated each link in its source as a link in the
member's tool directory, which then read as the member's own, and let a
skill plant a link to any target. Delivery now skips a link in a team or
source skill, without following it, and names each one once:
"Skipped <link> in <skill>: teamai does not deliver links."

* fix(docs): keep a member's link in the docs mirror at a path the team never had (#993)

This deliberately changes the mirror prune: it used to unlink any link at
a path the team repo's history never had, as a local leftover. teamai
never creates a link there, so such a link is the member's: pull now
keeps it and names it, and doctor no longer reports it as a stale doc.
A link matching a team link once at a removed doc's path is still pruned.
The docs and doctor tests that expected the unlink now expect it kept.

* feat(git-exclude): doctor checks the delivered blocks, pull --dry-run previews them, background pulls keep what they could not say (#915)

* docs(designs): state that teamai never follows, replaces or deletes a member's link (#993)

* fix(uninstall): remove only teamai's docs from the docs mirror, and keep the member's (#993)

Uninstall deleted the whole docs directory, so a file pull had kept as
the member's, a directory or a link of theirs went with it. It now
removes a file or link only when it is a version of that doc from the
team repo's history, names everything else, and removes a directory only
once it is empty. While the history cannot be read, the mirror stays
whole. A mirror inside the data home that keeps something survives the
removal of that home with it.

* feat(removals): never delete a file git tracks, in layout migrations and explicit commands (#915)

Layout migrations (a rule's legacy .md and superseded copy, legacy rule
directories, moved nested copies, agent format siblings, the Codex
configured-copy dedupe, leftover files of another skill version) keep a
tracked old copy and say where the resource lives now. teamai remove,
source remove and uninstall remove the rest and name each tracked path;
uninstall's summary lists them under Kept (tracked).

A team repo with no rules left now runs the rules sweep, so the copies of
a last rule the team deleted go, on the same ownership proof.

Test names and comments describe behaviour instead of how the work was
split.

* test(commands-reference): load the command table in a fresh module registry (#915)

The test now imports the CLI entry after vi.resetModules() and restores
the env stub after it, so it reads the table under its own guard whatever
another file in the same worker loaded or stubbed.

* fix(mcp): write a linked MCP config through its link, and keep its target out of git (#993)

A member's MCP config can be a symlink into a dotfiles repository. The
atomic writes replaced the link with a regular file. They now write at the
file the link points to, rollbacks included, and a linked CodeBuddy
~/.codebuddy/mcp.json is kept rather than deleted.

A resolved value then lands in the link's target, so the git checks judge
that file in its own repository: a target that repository tracks gets no
value, and an untracked one is listed in that repository's info/exclude,
which pull and uninstall now find to take the line out again.

* fix(docs): name a kept link at a removed doc's path as before, and only a never-team path's link as such (#993)

Goes with keeping a member's link at a path the team never had: a link at a removed doc's path keeps the line that says the team removed it.

* test(skills): expect pull to name the member's link inside a skill directory (#993)

* feat(git-exclude): doctor notes the copies pull keeps because the repository tracks them; document the checks, the preview and background pulls (#915)

* fix(opencode): keep a member's linked opencode.json and openclaw.json as links (#993)

The OpenCode instructions writer and the OpenClaw hook entry writer
replaced a symlinked config with a regular file, and uninstall deleted a
linked .opencode/opencode.json left holding only its $schema. Both now
write at the link's target, and a link is never deleted.

* fix(rules): never delete a linked CLAUDE.md or AGENTS.md when its teamai section goes (#993)

Removing teamai's section from an instruction file teamai created deleted
the file once nothing else was left, a member's link to it included. A
link stays; its target is emptied instead.

* fix(skills): push no links to the team repo, and name why remove and uninstall keep a skill directory (#993)

A push copied a link inside the member's skill into the team repo, so every
member then received a skill teamai will not deliver; push now skips each
link and names it. remove and uninstall now say a kept skill directory is a
link of the member's, or holds one, instead of claiming it has no delivery
record.

* fix(git-exclude): report a delivered path a rule re-includes as a failed sync (#915)

* fix(source): keep reading a record into a removed OpenClaw workspace, and never another repository's history (#993)

A source record of a copy in an OpenClaw workspace outside ~/.openclaw was
rejected once that workspace was gone, so every pull and source remove of
that source failed. The configured workspace now counts as a tool home even
when its directory is missing. A source cache without its own .git no
longer lets git read an enclosing repository's history (a dotfiles HOME):
only today's source proves a copy then.

* feat(git-exclude): a checkout on the un-migrated layout does not decide the setting with its own gitExcludeEnabled (#915)

* feat(removals): keep tracked files in the built-in skill prune, and cover every tracked-copy guard through the real CLI (#915)

* fix(source): leave a copy in a tool home that moved, instead of rejecting the record (#993)

Configuring OpenClaw to another workspace made the record of a copy in the
old one invalid, so every pull and source remove of that source failed.
The record now notes the tool home of each absolute destination; one whose
home moved is dropped from the record and its copy left as it is, while an
absolute path the record cannot account for is still rejected.

* fix(docs): keep the member's hidden files on uninstall, and match a link only to a team link (#993)

uninstall did not count hidden entries in the docs mirror as kept, so with
nothing else kept it deleted the data home around them. They are now named
and keep the mirror. A link in the mirror is now teamai's only when the
team history had a link with that target there, not a file holding the
same text (the history now carries each version's git mode).

* feat(uninstall): remove every teamai git exclude block after the files it hid; --agent drops only that tool's lines (#915)

Uninstall reads the exclude files the project's delivered owners recorded,
plus the project's own and the MCP ones, before it deletes anything, and
under the partition's sync lock removes every teamai block there once the
files are gone and before the partition state goes. Another project's
delivered block in a shared repository stays. An MCP line stays while a
config in any checkout of the repository may hold a resolved value, the
main checkout of a --separate-git-dir repo included; a credentials line
stays while its file is there. A read-only exclude file is named with the
lines to delete by hand; a repository that is gone is skipped.

uninstall --agent drops the tool's paths from every checkout's list,
keeping a path another tool in use reads, and syncs the blocks again.
uninstall --dry-run lists the blocks by owner and file.

HTTP mode: a skill the local agent installed under its SKILL.md name
(dir_name in its manifest) is now removed too.

* fix(git-exclude): keep a recorded block when a path cannot be placed (#915)

When git cannot say which repository a path lands in (sync reports it in
gitFailed), its line may sit in any exclude file the owner recorded. A
replace in that run emptied such a block and dropped the file from the
owner's record, removing protection while reporting the failure.

While any path fails placement, sync now only adds: every block keeps its
lines, every recorded file stays recorded, and the paths that placed are
still listed. The next sync in which every path places replaces as before.

* fix(git-exclude): treat an unverified exclusion as a failure (#915)

After writing a path's line, ensure counted every answer of
`git check-ignore` except "would commit" as excluded. A check that timed
out or failed in any other way therefore let the MCP reconcile write a
resolved value into a file git was never shown to ignore.

Only a verified "ignored" now counts as excluded; any other answer is
gitFailed, naming git's error and the check to repair. The exclude file
stays recorded, as its line was written. ensureExcludedFromGit maps this
to its failed result, so the value is withheld.

Two MCP exclude tests asserted the old reading and now expect the
failure: git failing check-ignore while ls-files answers, and a path
beyond a dangling directory symlink, which git refuses to check.

* fix(skills): keep a delivered skill directory that holds a file the member added (#993)

A skill directory with any file on record was taken as teamai's whole, so
remove, uninstall and the tombstone cleanup deleted a file the member had
added beside teamai's. A recorded directory now goes only when every file in
it is on record or a team version; otherwise it is kept whole and named.
Source skill removal applies the same rule against the source's files and
history.

* docs(mcp): a resolved value waits for git to confirm the exclusion (#915)

* fix(skills): remove and uninstall take only teamai's files from a skill directory (#993)

When a delivered skill directory holds a file the member added, remove and
uninstall now delete only the files on record or matching a team version,
name each file they keep, and leave the directory while anything is left in
it. uninstall plans the exact files, so its dry run shows them.

* fix(source): keep a member's file at the path of a link the source skill has (#993)

Delivery never copies a link from a source skill, but removal counted any
history at that path as the source's, the link included, so a regular file
the member put there was deleted with the skill. Only a regular file the
source has, or had, is the source's now.

* fix(mcp): find teamai's CodeBuddy servers in every user MCP file, and treat a linked lookup path as its target (#993)

A server an earlier teamai left in a CodeBuddy user MCP file that CodeBuddy no longer reads stayed there once its record was lost: pull and uninstall looked only at the file CodeBuddy reads, and returned early when that file was empty. They now also look at the other lookup files that exist and remove an unrecorded entry equal to a current or historical team render; a member's entry stays.

Lookup files are compared by real path. With ~/.codebuddy/.mcp.json a symlink to ~/.codebuddy/mcp.json, a pull recorded the server at the link and then removed it from its target, the same file. With ~/.codebuddy.json a symlink to ~/.codebuddy/mcp.json, the upgrade move emptied and deleted the file the link points to.

* fix(git-exclude): name the check to run when git cannot confirm an exclusion (#915)

When git cannot confirm that it ignores a file after teamai lists it,
the value stays withheld. The message now quotes git's error and names
the next step: check that `git check-ignore -v <path>` works in that
repository, then run the command again.

The two MCP exclude tests changed in the previous fix asserted that an
unconfirmed exclusion still let the resolved value be written, which is
the behaviour fixed there; one of them now asserts the full warning.

* fix(git-exclude): keep both delivered blocks when a path's repository cannot be located (#915)

Pull splits delivered paths between the project's `delivered` block and
`delivered/<id>` by the repository git names for each. A path whose
repository git could not locate (a tool folder whose `.git` points to a
deleted git directory) went to `delivered/<id>` only, so the `delivered`
sync replaced its block and dropped the path's line, although git still
reads that line from the project's own exclude file.

Such a path now goes to both syncs. Each reports it as not placed and
keeps every line its block holds; pull warns once per path.

* fix(rules): keep a tracked teamai-context rule copy where nothing rewrites that path (#915)

An earlier release's copy of a team rule named teamai-context is reclaimed at the tool's instruction file, which the instruction sync rewrites right after (Claude, Cursor, CodeBuddy, WorkBuddy). For OpenCode's .opencode/rules and Kiro's steering directory nothing rewrites it, so a copy the business repository tracks is now kept and named, as every other removal keeps one.

* fix(uninstall): name a built-in skill file kept only because it is tracked once, without the member-files warning (#915)

When removeOwnedFiles keeps a packaged file only because the repository tracks it, keepsTrackedCopy already names it. Uninstall no longer adds "holds files TeamAI did not put there. The packaged files were removed" for that directory, as pruneLegacyBuiltinSkills and retireOtherCodexCopy already do.

* feat(mcp): MCP cleanup and the pull-time release reach every checkout of the project (#915)

projectWorktreeConfigs and the pull-time MCP git exclude release now enumerate checkouts with projectCheckouts (live recorded checkouts plus a complete git worktree list, every recorded root when git cannot list them all), moved next to liveCheckoutRecords. From a linked worktree of a --separate-git-dir repo or a submodule, uninstall now removes teamai's servers and their resolved values from the main checkout's MCP config too, and drops the line once it is clean. A pull there no longer releases the shared .mcp.json line while the main checkout's config still holds a resolved value; that checkout's own pull cleans it and releases the line.

Also covers uninstall --agent codebuddy and --agent workbuddy keeping the .codebuddy/rules lines the other tool still reads.

* fix(sync): prove a CONTRIBUTORS file like any other, and a file only by a file the team had (#993)

A skill's CONTRIBUTORS file counted as teamai's by its name alone, so remove
and uninstall deleted the member's own one, and it never made a directory
the member's. It now needs the same proof as any file. A link in the team
history no longer proves a regular file holding the same bytes, and a
version that changed only its mode is kept as its own version.

* fix(skills): keep a delivered skill when the team or the source adds a file where the member has one (#993)

A file the member added to a recorded team or source skill was overwritten
once the team, or the source, delivered a file at that path. Pull now keeps
such a copy whole and names it, as an edited one, unless the file is a
version from the history. A source removal keeps a copy holding a file of
the member's only when the source's own files prove the copy came from it:
a copy from a replaced repository, or one an in-repo alias placed, is left
to the record, as before.

* fix(docs): keep a file of the member's at a path the team never had (#993)

The docs mirror pruned any local file at a path the team history never
had, so a member's own notes there were deleted on the next pull. Having
no team version is no proof that teamai put a file there: the prune now
removes only teamai's copies of docs the team removed, and leaves the
member's own files without a word. doctor stops calling them stale, and
the usage guide no longer says local drafts are removed. Earlier tests that
expected such files pruned now use team docs the team removed.

* docs(designs): the docs mirror prunes only teamai's copies of removed docs (#993)

* fix(git-exclude): keep the blocks when the team setting cannot be read (#915)

With the team's teamai.yaml missing or invalid and no member override,
sharing.gitExclude fell back to off, so pull removed the delivered blocks
and git add -A staged every delivered resource. In git mode that case is
now unknown: pull and its preview leave the blocks as they are and report
a failed sync (kept by a background pull), and doctor fails with the same
message and names the source "team config unreadable". A member override
still decides, and HTTP mode, which has no team setting, is unchanged.

* feat(local-agent): keep its project skills and rules out of git, and never overwrite a member's file (#915)

The skills and rules the HTTP local agent installs in a project now go in a local-agent block of the exclude file of the repository each copy lands in, while that project's git exclude flag is on (the project's config.yaml, else ~/.teamai/config.yaml). The agent syncs the block after each batch of project installs and uninstalls, lists only workspaces that are live checkouts, and records the exclude files it wrote in ~/.teamai/local-agent/git-exclude.json. Manifest entries record the tools they were written to; an entry from an older CLI counts as recorded where its copy equals the installed version or sits under its dir_name, and gains the field on its next install.

A skill or rule destination the manifest does not record is the member's: the install is not done there and fails with "Kept <path>: it is not teamai's (not in the local agent's records). Rename or delete it; the local agent installs <slug> on its next sync." A copy equal to the download is taken over.

source remove-http drops the block after uninstalling each resource, also when one fails, and teamai uninstall removes it from every exclude file the agent recorded, another repository's included. The instruction targets read the same per-workspace flag.

The HTTP test backend gains rule downloads, the get-config, plugins/config and projects/mine routes, and scope/workspace_path on every command.

* fix(rules): remove a rule copy that holds what pull writes today (#993)

`remove rules` deleted a tool's copy only on the checkout's record or the
team history. A checkout without history and without a record, such as a
resource cache, left teamai's own copy behind. The copy that holds today's
render of the team rule, or the rule verbatim, is now teamai's too, read
before the team file goes, as `remove skills` already does.

* fix(source): keep a source skill copy holding the member's file, on record (#993)

A copy pull kept whole because the source added a file where the member
had one was left off `installedSkills`, so `source remove` forgot it and
dropped the manifest. It stays on record now. Removal then tells the
source's files from the member's by their bytes, not their path, and a
file at a path the skill never had keeps the directory even when no file
of the source is left in it.

* test(local-agent): uninstall_rule removes the installed copy and keeps the member's (#993)

* feat(local-agent): keep model API keys in .codebuddy/models.json out of git, whatever the flag (#915)

Before the local agent writes a model API key into a project's
.codebuddy/models.json, it lists the file in the `credentials` block of
the repository's .git/info/exclude and writes the key only once git
confirms it ignores the file. A tracked file, one a .gitignore rule
re-includes, an exclude file it cannot write, a workspace outside a git
repository or an exclusion git cannot confirm leaves the file as it was;
the task fails with the reason and the fix. The block's exclude files
are recorded in ~/.teamai/local-agent/git-exclude.json.

teamai no longer creates .codebuddy/.gitignore, and deletes the one it
created while it holds only its two lines. An apply_model_config with no
models, and `source remove-http`, delete a models file left with nothing
(never a tracked one or a link), then its line. `teamai uninstall` keeps
a credentials line, with a warning, while the models file still holds a
key in any checkout of the repository.

* fix(local-agent): write the model key outside a repository, and delete only models files teamai created (#915)

A workspace outside any git repository has nothing that could commit
.codebuddy/models.json, so the key is written there as before, with no
git exclude line and no record of one.

An empty model config, or removing the HTTP source, deletes the project
models file only when teamai created it, recorded in the model manifest
in the local agent's state home from now on. A file teamai did not
create stays, and so does its line.

* feat(local-agent): follow each project's git exclude option at every session start (#915)

The local agent's `local-agent` block was only rebuilt after a batch that
installed or removed a project skill or rule, so turning the option on or
off in HTTP mode took effect only when the backend happened to send one.

- Rebuild the block from the manifest and each workspace's option at every
  session start, and after project installs and uninstalls. The agent's
  other runs (prompt, tool call, stop) rebuild it only when the manifest or
  a config.yaml the option is read from changed since the last rebuild,
  judged by a hash kept in the local agent's state home, so they cost no
  git call (about 8 ms per prompt in a one-project measurement, against
  about 30 ms for an unconditional rebuild).
- Keep a failed rebuild in the local agent's state home, under its own
  owner key, so a pull's success never clears it and the reverse. The next
  interactive pull prints it once, and doctor fails a check until a rebuild
  succeeds. Paths no line can name are kept as notices.
- A workspace following a git-mode config whose team teamai.yaml cannot be
  read (and no gitExcludeEnabled) keeps the lines it has, and the agent
  records why; it installs and removes nothing there meanwhile.

* fix(mcp): tell another tool's server by the file's real path (#993)

An entry another tool's record claims in the same file is left to that
tool. The file was compared by name, so a tool whose MCP path links to
another's file adopted that tool's server once its own record was lost,
and a later removal for it would take the server from the shared file.
It is compared by real path now, as the rest of MCP reconciliation does.

* fix(source): keep a source skill copy whose every file the member edited (#993)

Removal kept a copy holding an edited file only when another file still
matched the source. A copy whose every file the member edited, such as a
single SKILL.md, was deleted by `source remove` or by a pull after the
source withdrew the skill. When the source history has the skill, a file
that matches no source version keeps the copy.

* fix(local-agent): say what a refused install or uninstall left undone, and how to fix it (#915)

While a project's flag cannot be resolved, the refusal now names the
resource, the project and the unreadable file, says nothing was written,
and gives both ways out: fix or restore the team's teamai.yaml, or set
gitExcludeEnabled in the project's config.yaml.

* fix(ownership): keep a member's entry of the other type at a delivered path (#993)

A file where a team skill directory goes, or a directory where a rule or
agent file goes, was not judged the member's. Delivery over it failed, yet
the pull could record the team revision as synced, so once the member
removed the entry a plain pull delivered nothing until the team changed or
the member ran `pull --force`. Such an entry is now kept and named, and the
next pull after it is gone delivers the team version.

* feat(pull): keep shared config files that hold only teamai's entries out of git (#915)

A project MCP config without a per-member place (.cursor/mcp.json,
.github/mcp.json, .codex/config.toml, Kiro, OMP, Pi, .workbuddy/mcp.json,
OpenCode's root opencode.json), .codex/hooks.json and OpenCode's
.opencode/opencode.json are listed in the delivered block while git does
not track them and they hold nothing but teamai's entries: no other
top-level key ($schema included), and every server, team hook or
instructions entry one teamai's records own (equal to what teamai writes,
for the OpenCode instructions). They are judged after the MCP and hook
reconciles, so a file written before the upgrade or after its records were
lost qualifies by content.

They are judged on every pull, fast path included, and replace their
previous list (DeliveryRecorder.judgedAll). The first pull that finds an
entry teamai does not own in a listed file takes its line out and says
"<path> now holds entries teamai does not own, so git can see it."; a
background pull keeps it as a git exclude notice for the next interactive
pull.

The usage guide documents the files and the limit when a teammate commits
the same path.

* fix(skills): keep a member's file when removing a skill with a built-in's name (#993)

`teamai remove skills <name>` deleted the whole directory when the name is
one the CLI once shipped (such as team-wiki-codebase), so a file the member
added beside it was lost. It now removes the files the team history proves
teamai's and the files a release packaged there, as uninstall does, and keeps
and names a directory left holding anything else.

* fix(skills): keep a delivered skill when the team adds a file where the member has a directory (#993)

When the team added a file to a delivered skill at a path where the member
had a directory, or a directory where the member had a file, the copy failed
inside pull and the pull still advanced to the team revision, leaving the
skill stale. Such an entry is the member's now: the skill is kept whole and
named, as when the team adds a file where the member has one.

* feat(docs): keep the delivered docs mirror out of git, still searchable (#915)

* fix(pull): say nothing when a shared MCP config with a resolved value takes in a member's server (#915)

Such a file stays in the mcp-exclude block whatever it holds, so leaving
the delivered block does not make it visible, and "git can see it" was
wrong. Also cover a .codex/hooks.json written before the upgrade (no hook
records) and a single-repo team's .codex/hooks.json, which keeps the
built-in hooks and stays visible.

* fix(local-agent): tell CodeBuddy's user MCP file by its real path (#993)

With `~/.codebuddy/.mcp.json` linked to `mcp.json`, a record an older agent
wrote without a file resolved to `mcp.json`, while the install target was
`.mcp.json`. The record was dropped as another file's, so reinstalling the
same server failed as "not managed by teamai". Records are matched to the
target by real path now, as MCP reconciliation does.

* fix(skills): deliver a skill around a member's entry of the other type, and retry failed copies (#993)

A member's directory where the team adds a file to a delivered skill, or a
file where it adds a directory, is the member's: it is kept and named, the
files it covers stay undelivered, and the rest of the skill is delivered.
The pull is not counted as synced, so the next one is a full sync that
delivers those files once the entry is gone.

A skill, rule or agent copy that fails with an error no longer counts as
synced either: the revision stays, and the next pull retries it.

* fix(source): keep a source skill copy when the source adds a directory where the member has a file (#993)

A file of the member's where the source now has a directory was missed by
the collision check, so the copy failed on the conflict instead of keeping
the member's copy. An entry of the other type at a source path, or at one of
its parents, is the member's now, also when the source cache has no history.

* fix(uninstall): keep OpenCode's user plugin on a project uninstall (#993)

The plugin in the user's OpenCode config now also carries the team rules and
instructions for V2, for every project and the user scope. A project-scope
uninstall removed it, which ended delivery for every other project. It keeps
it now and names it, as it does for the other global adapters; a user-scope
uninstall still removes it, and so does `teamai hooks remove`.

* fix(pull): keep a shared config's line while git cannot say it tracks the file (#915)

A teamai-only file git could not answer for was judged `unknown`, and its
entry was replaced with nothing, so its line left the block silently. Only a
confirmed answer replaces the entry now; until then the line stays, the pull
fails naming the file and git's error (a background pull keeps the failure),
and doctor reports the checkout git cannot answer for.

* fix(skills): keep a skill directory holding a git repository of the member's (#993)

The ownership check reads a skill directory's files the way delivery lists
them, which skips `.git`. A recorded skill whose files matched was then
deleted whole by `teamai remove`, `uninstall` or a source removal, taking a
repository the member made in it, with its local commits. A directory holding
a `.git` is never deleted whole now; only teamai's files in it go.

* fix(local-agent): keep a CodeBuddy server copy the member edited when moving it (#993)

When CodeBuddy's preferred user MCP file changed, reinstalling a server
moved it there and deleted the copy in the old file without checking it.
A copy the member edited since teamai installed it is kept now, and named.

* feat(mcp): give Claude the team's project MCP servers in its local scope (#915)

With sharing.gitExclude on, Claude's project servers go to Claude Code's
local scope, ~/.claude.json under projects[<key>].mcpServers, instead of
.mcp.json. The key is the one Claude Code files the checkout under: the
main checkout's real path for it and every linked worktree; in a
--separate-git-dir repository a linked worktree's key is the git
directory, and in a linked worktree of a submodule its directory under
.git/modules. Resolved tokens leave the working tree, and Claude loads the
servers without the approval prompt.

Ownership is shared by every checkout using the key (managed-local-mcp.json
in the project's data home), and uninstall removes exactly teamai's
entries. The next pull moves teamai's servers out of .mcp.json, recorded or
equal to a render in the team's history; keeps the member's own servers,
a teamai server the member changed (named), and the names CodeBuddy still
claims there; and deletes the file when nothing else is left and git does
not track it. Its MCP exclude line goes once no checkout holds a resolved
value. Turning the option off moves the servers back. While tclaude, which
reads .mcp.json, is installed and enabled, Claude keeps the file.

* feat(opencode): deliver team MCP servers through the plugin on OpenCode V2 (#915)

With sharing.gitExclude on, OpenCode V2 and teamai's plugin current, a pull
writes the project's team MCP servers to .opencode/teamai-mcp.json, which the
plugin reads at setup and adds through ctx.mcp.transform for that project
only. The file is teamai's whole, listed in the delivered block, and written
only after the mcp-exclude block holds it when it carries a resolved value.

The pull then takes teamai's V1 entries (recorded or adopted) out of the root
opencode.json and .opencode/opencode.json when git does not track them and
they hold nothing else, and deletes a file left empty. A tracked or mixed
file is left; doctor names it. The plugin is reconciled before the decision,
so a plugin from an older build is replaced and the V1 entries go in the same
pull. Without a current plugin, on V1, or with the option off, the V1 entries
stay or come back and the V2 file goes.

The OpenCode major version is asked once per run. The plugin's project
walk-up also stops at a .opencode/ holding only teamai-mcp.json.

* fix(local-agent): keep a CodeBuddy server's record until its move is written (#993)

Moving a server to the user MCP file CodeBuddy now reads recorded it in the
new file before writing it there. When that write failed, the record pointed
at the new file while the server stayed in the old one, so uninstall left it
installed. The old file's record is existing ownership now: it stays until the
new file is written, as for a server already recorded in the target file.

* fix(uninstall): record a project's OpenCode exclusion when its plugins are kept (#993)

A project-scope `uninstall --agent opencode` keeps the user plugin
directory, so with only a server-pushed agent-hook plugin there the plan was
empty: it said "Nothing to uninstall" and never excluded OpenCode, whose
global hooks stayed active for the project. OpenCode now takes the
exclusion-only path, like the other tools with global channels, and the kept
agent-hook plugins are named with the other retained adapters.

* fix(skills): list a skill delivered around a member's entry file by file (#915)

A skill delivered around a member's entry of the other type was listed in
the delivered exclude block as its whole directory, which hid the member's
entry from git status. Such a skill is now listed one file per line, in
pull and in the --dry-run preview.

* fix(pull): list a delivered skill's files, never its directory (#915)

A skill was listed as its directory (`/<dir>/`), so a file the member added
inside a delivered skill was hidden from `git status` and `git add -A`. Every
writer that delivers skills (team, role, project, source and built-in skills,
Codex's `.agents/skills`, `.github/skills`, the local agent's installs) now
reports the files it wrote, and the git exclude module refuses a directory.

In a skill, a tracked file gets no line and is reported while the skill's
other delivered files keep theirs; a member's negation that re-includes one
of them fails the sync naming the rule. Doctor and `pull --dry-run` report
per file. An older directory line goes on the next full sync, which rewrites
the block.

* feat(hooks): run Codex team hooks from a dispatcher when the project's hooks.json is not teamai's alone (#915)

While sharing.gitExclude is on and a project's .codex/hooks.json is tracked,
holds a member's entry or another top-level key (always in single-repo mode,
whose committed file holds the built-ins), teamai stops writing the team's
Codex hooks into it. The pull that sees this takes teamai's entries, recorded
or adopted, out of the file through its hook manifest and records the
project's hooks in ~/.teamai/codex-team-hooks.json; ~/.codex/hooks.json gets
one `teamai hook-dispatch <Event> --tool codex --team-hooks` entry per event,
timed out at the largest team-hook timeout, before the built-ins. Once the file
is gone or teamai's alone again, the next pull writes the hooks back; turning
the setting off does too.

The new --team-hooks option of the hidden hook-dispatch command resolves the
project from the hook's cwd, evaluates matchers, applies each hook's timeout
(stopping its process group), and passes on stdout and a blocking exit 2. It
exits at once when no project dispatches. The entries name no project, so
their Codex trust holds as worktrees come and go; teamai trusts them like the
built-ins, in single-repo mode too. Uninstall drops the project and the
entries no other project needs.

* fix(uninstall): keep the local agent's lines for the workspaces it still serves (#915)

A project `teamai uninstall` removed every `local-agent` block the agent
recorded, so another project's installs, and a linked worktree's in the
shared exclude file, showed in `git status` until a later session start.
The agent stays after a project uninstall, so its blocks are now rebuilt
from its records without that project's workspace: only this project's
lines go. A user-scope uninstall, which removes the agent, still removes
every block.

* fix(docs): keep a member's doc that has the bytes of a team doc that is a link (#993)

A regular file of the member's at the path of a team doc that is a link was
taken for teamai's copy when its bytes matched the link's target, and the
mirror replaced it with the link. Equal bytes now prove a copy only of a team
file; such a doc is the member's unless the team history has that file.

* fix(mcp): keep a resolved value's own line when only teamai's blocks ignore the file (#915)

A project MCP config that git already ignored got no `mcp-exclude` line. Since
the `delivered` block lists teamai-only configs, that ignore could be
teamai's own: once the member added a server, turned the option off or ran
`uninstall --agent`, the `delivered` line went, and the file holding the
resolved value became visible to `git add -A`.

An ignore from teamai's own blocks no longer counts as already ignored: the
line is skipped only when the rule `git check-ignore -v` names is outside
every `# [teamai:` block. The `credentials` owner already lists every path,
ignored or not; a test now covers that too.

* fix(mcp): judge each CodeBuddy lookup file with the tools that write it (#993)

Cleaning CodeBuddy's other user MCP files reused the ownership check built for
the file it reads, which knew of no other tool writing there. With
`~/.codebuddy/mcp.json` linked to Claude's `~/.claude.json`, Claude's copy of a
team server matched CodeBuddy's render and was deleted through the link. Each
file is now judged with the records of every tool whose MCP file it is.

* fix(docs): judge a deactivated namespace's doc by its type as well as its bytes (#993)

When a docs namespace stops being active here, its copies that are teamai's
are removed. A member's regular file whose bytes equal the target of a team
doc that is a link was taken for teamai's, through the link and through a
history check that also matched link versions, and deleted. A file is
teamai's only as a team file now, today's or one from the history, as on
every other docs path that deletes or replaces (prune, copy, uninstall).

* test(hooks): check a Codex dispatcher entry outlasts its slowest team hook (#915)

Codex stops the dispatcher entry at its own timeout, so it has to cover
every team hook it runs, counting Codex's 600 s default for a hook that
names none.

* fix(mcp): count another tool's servers in a shared file even when it is not detected (#993)

Whose entries a config file holds was judged only with the tools detected on
this run. With `~/.codebuddy/mcp.json` linked to Claude's `~/.claude.json` and
Claude no longer installed, a CodeBuddy pull took Claude's identically rendered
server for its own and deleted it through the link, leaving Claude's record
stale. Every tool that maps a file counts now, detected or not: detection
decides where teamai writes, never what it may delete. Doctor judges the same way.

* fix(mcp): restore a file two tools write through linked paths once, to its first state (#993)

Configs written during an MCP sync are restored when ownership cannot be
saved. Snapshots were keyed by path, so a file two tools reach through
linked paths got one per path and the later one, taken after the first
tool's write, was restored last: the server stayed without its record. One
snapshot per real file now, taken before its first write.

* fix(coauthor): leave a settings file that does not parse as it is (#993)

Project scope writes the co-author setting to `.claude/settings.local.json`,
the member's own file. One that did not parse was read as empty, so a pull
replaced the whole file with teamai's `attribution` block and the member's
settings were lost. A Claude or Cursor file that is not a JSON object is now
left untouched and reported as skipped, and the setting is written on the
first pull after the member repairs it.

* fix(hooks): leave a hook settings file that does not parse as it is (#993)

Every hook writer read its settings file as empty when it did not parse, so
a pull or a session-start pass while the member was mid-edit of, say, their
HOME `~/.claude/settings.json` replaced the whole file with teamai's hooks.
The Claude, Cursor, Copilot, Codex and ZCode writers, and the agent-hook
install and removal, now leave such a file byte-identical and say which file
and why; nothing is recorded, and the first pull after the repair writes it.

* fix(docs): never walk a docs mirror that is a link of the member's (#993)

When `sharing.docs.localDir` itself was a link to a personal directory,
uninstall walked it and deleted the files behind it that matched a team doc
from the history, outside the mirror. A mirror root that is a link is now the
member's on every path: pull copies, prunes and withdraws nothing through it
and names it, doctor reports it, and uninstall leaves it and what it points at.

* fix(uninstall): keep the record of hooks a settings file that does not parse still holds (#993)

Uninstall left out a hook settings file that did not parse, then deleted the
data directory holding the record of its hooks; once the member repaired the
file, teamai's hooks ran there with no record left to remove them by. Such a
file is now tried, named and left as it is, and the data directory stays, so
uninstall run again after the repair removes them. `source remove-http` and
uninstall keep the record of an HTTP agent hook they could not remove, and the
local agent's directory with it, instead of clearing the whole manifest.

Pull also names a docs mirror that is a link before counting or previewing
its files, so it never walks it, on a dry run either.

* fix(uninstall): report an uninstall that left hooks in place as incomplete (#993)

When a hook settings file could not be cleaned, uninstall kept the data
directory but still said "teamai uninstalled" and exited 0, and a targeted
uninstall of the last tool did not record the tool as excluded, so the hook
left in place could sync its resources back. Hooks left in place now make the
uninstall incomplete, as an OpenCode entry it could not remove does: exit code
1, the files named, and the tool excluded. The message for a settings file that
does not parse no longer points at `teamai pull`.

* fix(uninstall): stop hooks an incomplete uninstall left in place from syncing back (#993)

A full uninstall that could not remove a tool's hooks kept the data directory
with every tool still enabled, so the hook left in place ran a session-start
pull that restored what had just been removed. Each tool whose hooks remain is
now excluded, and the session-start pull of an excluded tool's hook does
nothing, as its instruction and HTTP handlers already did, until the uninstall
is run again after the repair.

* fix(local-agent): keep removed HTTP sources disabled (#993)

* fix(local-agent): serialize HTTP sync and source removal (#993)

* docs(http): describe skipped concurrent hook syncs (#993)

* fix(mcp): take teamai's Claude local-scope servers out of every recorded key on uninstall and flag off (#915)

Uninstall and a pull with sharing.gitExclude off took teamai's servers out
of the current checkout's key only. A key no checkout has any more, as a
removed linked worktree of a --separate-git-dir repository leaves, kept
them, with their resolved values, for good. Both now clean every key
recorded in managed-local-mcp.json; a server the member changed stays and
is named, except on uninstall.

* feat(mcp): give CodeBuddy the team's project MCP servers in its local scope (#915)

With sharing.gitExclude on, CodeBuddy's project servers go to
${CODEBUDDY_CONFIG_DIR:-~}/.codebuddy.json under
projects[<realpath of the worktree root>].mcpServers, the key CodeBuddy
uses for the directory it runs in, instead of the project's .mcp.json.

- Each checkout writes its own key, on pull and on the pull git runs when
  it creates a worktree; records live with Claude's local-scope records,
  keyed by tool and key.
- The next pull takes teamai's servers out of the key of a worktree that is
  no longer a checkout of the repository, keeping the member's own and a
  copy they changed (named).
- Migration and flag-off follow Claude's: teamai's servers leave .mcp.json
  (recorded or proven by the team's history), the file goes when only
  they made it, and turning the option off moves them back.
- Uninstall removes exactly teamai's servers from every checkout's key.

* fix(opencode): on V2, take teamai's V1 entries out of a file that also holds the member's (#915)

On OpenCode V2 with teamai's plugin, a pull left the root opencode.json and
.opencode/opencode.json as they were once they held anything of the
member's, so V2 loaded teamai's servers twice. It now takes teamai's own
servers (recorded, or adopted by the per-name judgement) and its
instructions entries (equal to the ones it writes) out of a file git does
not track, and keeps the member's. A file git tracks is still never
modified, and doctor still names it.

* fix(uninstall): remove the HTTP source under its lock before teardown (#993)

A full user-scope uninstall removed agent hooks, plugins and ~/.teamai
without the local-agent lock, so a hook sync paused after loading its
config could reinstall resources once uninstall reported success.
Uninstall now runs the remove-http shutdown first: it waits up to 30
seconds for the lock, disables the source before teardown, and exits 1
without removing anything when the lock cannot be taken.

* fix(local-agent): let a server-pushed uninstall hold its sync's lock (#993)

A sync holds the HTTP source lock while it runs an uninstall_teamai
command, so the uninstall it spawns waited for that lock until the hook's
15-second budget killed the sync, unacknowledged and with teamai still
installed. The sync now passes its pid to the command; a child whose
parent holds the lock runs under it without acquiring or releasing it.

* test: stop hooks-wrapper from writing src/index.js, which shadowed the CLI entry (#915)

hooks-wrapper.test.ts wrote a stub src/index.js for the length of each
test so resolveTeamaiEntryScript() would find an entry. While it existed,
any test file running in parallel that imported '../index.js' resolved to
the stub instead of src/index.ts and got an empty module, so `program`
was undefined: a different command-table test failed on each loaded run.

The test now reports src/index.js as present through an existsSync spy
and writes nothing into the source tree. Tests that read the command
table load it through helpers/command-table.ts, which fails with the
reason when the entry yields no table instead of a TypeError.

* refactor(mcp): judge local-scope claims on the reconcile's claim targets (#915)

Leaving a tool's other MCP location re-resolved every tool's ta…
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] keep the resources pull delivers in project scope out of git

2 participants