Repository navigation
fix: sync team resources before AI sessions start - #964
Merged
Merged
Conversation
SessionStart keeps seeding its one tool through seedProjectAgentRoot. The new createProjectToolRoots takes a set of tools, defaulting to enabledAgents and, when that is empty, to the tool roots the main checkout already has.
…oots Project-scope init with --agent creates those tools' roots after saving enabledAgents, then init runs the scope's pull so the first session has the team's skills, rules and MCP servers. Without --agent no root is created. Docs and setup skill stop telling members to pull after init.
…sh the rest after The post-checkout pass now runs pull in an internal inline mode: it skips the team repo fetch when the clone was fetched within the source TTL (24 h, new last-fetch.json stamp beside the clone), reads subscribed sources from their cached clones, waits for another pull's partition lock instead of skipping, and leaves learnings, reports, usage reporting and post-pull scripts to a detached full pull started after it.
The post-merge git hook now runs an inline pull. With a separate team repo it fetches the team repo whatever its fetch stamp says, aborting the fetch after 5 s (internal fetchTimeoutMs pull option, AbortSignal into simple-git), and delivers when the revision moved; a detached full pull then refreshes the team repo past the cap, sources, learnings and reports. In single-repo mode it delivers the working tree git pull updated, with no network and no detached pull.
A failure inside the silent git hook (team fetch failed or hit the cap, partition lock held past the inline wait, handler error) is written to debug.log and recorded in the project partition. doctor names it with its fix and reports whether the hook is installed; the next interactive pull mentions it once; a successful hook pull, detached retry included, clears it. The post-merge inline lock wait is capped at its fetch cap.
…er core.hooksPath
… init Project-scope init in a terminal without --agent reuses the single-repo tool picker (Auto = tools installed under HOME). The choice is added to enabledAgents before the tool roots are created, so only the chosen tools' roots appear and the closing pull fills them. --agent and non-interactive runs skip the picker; the latter still create no root.
- Leave an unreadable or non-executable .git/hooks script alone instead of replacing or enabling it; doctor explains the fallback. - Install the git hook after the agent hooks and propagate its failure with the fix; init reports it and still pulls, hooks inject exits non-zero. - Record why a git hook synced nothing when the project config is unreadable. - Cap the self-mode post-merge lock wait at the same 5 s as the fetch. - Keep a partial delivery failure recorded until a complete sync. - Join detached hook pulls before the e2e sandbox is removed.
Resolve refreshTeamRepo's options: keep inline/fetchTimeoutMs and add main's dryRun guard for the self-mode .gitignore self-heal (Tencent#944).
Detection run inside <main>/.teamai/knowledge-wt resolves that worktree as its own project root, so the config-based guard missed it: a self-mode push fired post-checkout there, delivered into the disposable worktree and left a detached pull running. Exclude the main checkout's .teamai/ for both git events.
|
# Conflicts: # src/__tests__/hook-handlers.test.ts # src/pull.ts # src/uninstall.ts
- init --scope user pulls the user scope even inside a project checkout - leave symlinked git hook scripts and their targets untouched - clear a recorded git hook failure only after a pull completes
|
No findings. All earlier findings are resolved in the current diff:
The PR description includes sufficient real-CLI/E2E testing evidence for its runtime changes. |
jeff-r2026
approved these changes
Oct 3, 2026
This was referenced Oct 3, 2026
SaulMoro
added a commit
to SaulMoro/teamai-cli
that referenced
this pull request
Oct 7, 2026
…ded install (Tencent#993) A linked worktree whose old git-mode install another checkout superseded by switching to single-repo mode keeps the team knowledge in .teamai/ and moves only SUPERSEDED_ENTRIES to .teamai.bak. Tencent#964 added last-fetch.json beside the clone, which that list did not name, so it stayed in .teamai/ as an untracked file. The 808 fixture now writes the stamp a Tencent#964 release leaves, so the case fails without the fix whatever teamai the developer has installed.
2 tasks done
jeff-r2026
pushed a commit
that referenced
this pull request
Oct 9, 2026
* fix(opencode): add team rules and instructions to V2 sessions through the plugin OpenCode V2 parses `instructions` and ignores it, so a V2 session got none of the team rules or the culture, claudemd and recall blocks. The teamai plugin's V2 setup now registers the session context and compaction hooks and adds the user instruction file and rules, then the nearest project's .opencode/teamai-context.md and .opencode/rules/**/*.md, sorted by path. V1 delivery through `instructions` is unchanged. (#993) * fix(opencode): write the user instruction file beside the Claude fallback for V2 OpenCode V1 reads ~/.claude/CLAUDE.md while ~/.config/opencode/AGENTS.md does not exist, so teamai wrote no OpenCode user file there. V2 reads neither that fallback nor `instructions`. Pull and HTTP prompts now write ~/.config/opencode/teamai-context.md for teamai's plugin in that case too, and still list it nowhere, so V1 gets no duplicate. (#993) * fix(init): set up only the --agent tools in single-repo init (#993) init . wrote .teamai/teamai.yaml (mode: self) before it read the existing project config. With the marker on disk and no config yet, that read ran the clone-time self-heal, which enabled every tool found in HOME, injected their hooks into the repo and saved them; init then merged --agent into that. Read the config once, before the marker is written, and use that snapshot for inheriting user scope, the enabledAgents union, the tool-roots carry-over and the mode-switch settlement. * fix(coauthor): keep the project-scope co-author setting out of shared settings (#993) In project scope only claude writes attribution, to the member-local .claude/settings.local.json; the rest of the Claude settings family is user-scope only, like Codex and Cursor. The next pull removes an attribution an earlier release wrote to a shared project settings file when it is exactly teamai's value and the co-author record lists the file, deleting only that member's text. * docs(coauthor): note a pre-fix shared value stays while no co-author choice exists (#993) * fix(doctor): check OpenCode V2 delivery from the teamai plugin doctor reported the team rules and instructions active on OpenCode V2 because `instructions` listed them, but V2 ignores that key. doctor now reads the major version from `opencode --version` (missing or unparsable counts as V1) and, on V2, checks that teamai's plugin in HOME is the one this build writes, since its context hook is what delivers them. V1 checks are unchanged. The usage guide describes V2 delivery. (#993) * fix(pull): probe live checkouts from recorded roots, not the worktree list (#993) A pull in a linked worktree of a --separate-git-dir repo or a submodule dropped the main checkout's delivery record and workspaces/<id>/, because git worktree list names the git directory there instead of the main checkout. Its next pull then overwrote edited rules without a word. Records and workspace directories now store their checkout root; a full pull keeps one while that root still has a .git, names the same git common dir, and (records) gives the same checkoutKey, so a re-created worktree still starts fresh (#807). Entries without a root (older CLI) are kept. listWorktrees reads --porcelain -z, skipping bare, prunable and common-dir entries, and returns [] when -z is unsupported instead of splitting lines. * fix(init): skip the clone-time self-heal for init in a single-repo clone (#993) A fresh clone whose committed .teamai/teamai.yaml says mode: self ran the self-heal in the preAction queue check and again in initSelfRepo's config read. Either one enabled every tool found in HOME before --agent could choose. init now loads with selfHeal: false in both places; every other command still self-heals. * fix(sync): adopt config entries that equal a team render, keep the member's (#993) An MCP server or a team hook entry teamai has no record of is teamai's only when it equals teamai's render of a team server or hook, today or at any revision in the team repo's history (one hook only). It is then adopted and handled as recorded. Any other one is the member's: kept and named by pull and doctor; a member's same-name MCP server means the team server is not written to that file. `pull --force` no longer overwrites a member's server (`teamai mcp inject --force` still does). This removes the second copy of each team hook a lost hook manifest caused in .claude/settings.local.json and .codex/hooks.json. * docs(sync): describe ownership of unrecorded MCP servers and hook entries (#993) * test(init): cover init . in a single-repo clone with no --agent and no terminal (#993) With the clone self-heal skipped for init, a fresh clone has no config when init runs. Pin that it takes the non-interactive default (the tools found in HOME) instead of prompting or stopping at "already initialized". * test(hooks): cover hook ownership beside the co-author setting in settings.local.json (#993) * fix(pull): prune a workspace directory without a root only when the worktree list names every checkout (#993) contribute, recall, viz, the MCP writers and the local agent create a checkout's workspaces/<id>/ before its first full pull writes root, so a removed worktree that never ran a full pull kept its directory forever (self-mode-worktrees-808). Such a directory now goes when git worktree list -z names every checkout (no non-bare entry is the common dir) and none has its id, as git prints it or realpath'd. It is kept with --separate-git-dir, in a submodule, on git < 2.36, and when it holds local-agent/. * fix(mcp): create a missing .git/info/ before excluding a resolved MCP config (#993) A repository created with an empty template has no .git/info/. The writability check ran `access(W_OK)` on that directory, got ENOENT, and reported it as "not writable", so every team MCP server holding a resolved value was withheld. Check the exclude file when it exists, otherwise its closest existing directory, and let the write create info/. Report "not writable" only for EACCES, EPERM and EROFS, and name the exclude file in the reason and the fix. Applies to pull, doctor, `mcp list` and local-agent installs, which share ensureExcludedFromGit. * fix(mcp): write CodeBuddy's user MCP servers to the file CodeBuddy reads (#993) CodeBuddy reads only the first user MCP file that exists of ~/.codebuddy/.mcp.json, ~/.codebuddy/mcp.json and ~/.codebuddy.json, and teamai always wrote the second, so team servers and the member's own hid each other. In user scope teamai now writes to that first existing file and creates ~/.codebuddy/.mcp.json only when none exists. Each CodeBuddy record in managed-mcp.json names its file; a pull moves teamai's own entries out of a file CodeBuddy no longer reads, uninstall and `teamai mcp remove` follow the record, and doctor and `teamai mcp list` name a shadowed file. * fix(local-agent): install CodeBuddy's user MCP servers in the file CodeBuddy reads (#993) An HTTP-backed team's install_mcp now writes CodeBuddy's user servers to the first existing file of CodeBuddy's lookup order, as a pull does, and records that file. A reinstall moves a server an earlier install left in a file CodeBuddy no longer reads; uninstall_mcp removes it from the recorded file. * fix(migrate): move the team clone's last-fetch stamp out of a superseded install (#993) A linked worktree whose old git-mode install another checkout superseded by switching to single-repo mode keeps the team knowledge in .teamai/ and moves only SUPERSEDED_ENTRIES to .teamai.bak. #964 added last-fetch.json beside the clone, which that list did not name, so it stayed in .teamai/ as an untracked file. The 808 fixture now writes the stamp a #964 release leaves, so the case fails without the fix whatever teamai the developer has installed. * fix(hooks): keep the managed-hooks index and the package lock out of the working tree (#993) getManagedHooksPath built <root>/.teamai/managed-hooks.json in project scope, so the Copilot hook index showed up untracked in every git project and self mode committed it with git add -A. It now resolves per checkout to <dataHome>/workspaces/<id>/managed-hooks.json, beside managed-mcp.json. legacyManagedHooksPath names the old file for the pre-#370 Codex import, the legacy hook sweep and uninstall. migrateLegacyManagedHooks moves its Copilot records (all records in self mode) before hooks are reconciled, removed or uninstalled, and deletes it once empty and untracked; doctor names a tracked one with the git rm --cached command. teamai.lock moves to the data home too (packageLockDir): an older .teamai/teamai.lock is moved on the next install or session-start read, doctor reads it where it is, and a .teamai/.gitignore holding only teamai.lock is removed outside self mode. Self mode's .teamai/.gitignore lists managed-hooks.json, also through its migration. * fix(pull): keep a rule or agent file teamai cannot prove its own (#993) A rule or agent destination that exists with no delivery record is teamai's only when its bytes equal teamai's render of that resource at some revision of the team repo's history (git blob ids, through ticket 04's matchesHistory). Otherwise it is the member's: pull neither writes nor deletes it, names it, and doctor lists it. This covers a checkout whose record key changed (a restore or copy gives .git a new inode), a role switch after that, and a member's own file with a team name. - DeliveryTarget.origin carries the proof; judgeCopy gains a 'member' verdict; isTeamaiCopy and describeMembersFile are the shared seam. - The rules stale sweep and the tombstone cleanup prove an unrecorded copy before deleting it. - A kept copy is worded as an edit when another checkout record lists its path (a record lost to a new key); no record is carried over. - A pull that keeps a member's file does not count as synced, so a plain pull delivers the team version once the file is gone. * fix(mcp): leave an older teamai's ~/.codebuddy/mcp.json that hides ~/.codebuddy.json (#993) Earlier releases always created ~/.codebuddy/mcp.json, so a member's servers in ~/.codebuddy.json stayed hidden. When that file holds only teamai's servers (recorded, or equal to a team render) and a later file of CodeBuddy's lookup order exists, a pull moves the servers there, deletes the file and says so once. A file that also holds a member's server or any other key stays chosen. * fix(remove): judge rule copies by record and team history in teamai remove (#993) teamai remove's rules refresh ran without the checkout's ledger, so it wrote over a member's own file at a team rule's path, and its explicit sweep deleted a member's own file named after the removed rule. It now opens the ledger, passes it to the refresh and names what it kept, and deletes a copy of the removed rule only when it is on record or its bytes are a version from the team history (the author's root copy keeps its placement record as proof). Docs say a personal rule the team never had is kept, and that a pull keeping a member's file syncs in full until it is gone. * fix(pull): keep a skill or doc teamai cannot prove its own (#993) A skill directory with no delivery record is teamai's only when every file in it is today's team file or a version of it from the team repo's history (SKILL.md also as pull repairs its frontmatter); one file of the member's makes the whole directory theirs. A file in the docs mirror at a team doc's path is teamai's only when it is a version of that doc. Anything else is kept and named, not written over or removed by the tombstone cleanup, and doctor lists it. isTeamaiSkillCopy is the ledger-free decision ticket 05 reuses. * docs(skill): keep the ownership sentence clear of the command check (#993) * fix(rules): delete a legacy .md in .cursor/rules only when it is teamai's (#993) Pull's stale sweep and pullItem deleted every .md in a .mdc tool's rules directory, and uninstall every one with a team rule's name, as a copy of the layout before .mdc. A member's own notes.md there went with them, though the usage guide promised it stays. Each now deletes one only when the checkout record lists it, it is a team version from the history verbatim, or it has a built-in rule's name (isLegacyLayoutCopy); any other is kept silently, since Cursor never reads it. teamai remove already applies the proof since 02b. * fix(coauthor): move a pre-fix attribution to settings.local.json when no choice exists (#993) With no co-author choice (the team dropped sharing.coAuthor and the member has none), the reconcile returned before settling shared project files, so an attribution an earlier teamai wrote to a tracked .claude/settings.json stayed there for git add -A to commit. The next pull now moves it to .claude/settings.local.json under the same guards (teamai's exact value, the record lists the file with "strip", only that key is edited), so the member's trailer is unchanged and the tracked file is clean. A value the member already set in settings.local.json is kept. Other Claude-family tools' shared files have no member-local counterpart and wait for a choice. A failed settle now keeps its record so the next pull retries. * fix(git): list sibling worktrees on git before 2.36 (#993) listWorktrees read only `git worktree list --porcelain -z`, so on git without -z it returned [] to every caller. A pull or uninstall then judged the shared .git/info/exclude line from the current checkout alone and dropped /.mcp.json while a sibling worktree's .mcp.json still held a resolved value (#882/#886). Fall back to the newline-split list when -z fails. Liveness is unchanged: completeWorktreeList stays -z only and returns null there. * fix(mcp): report an exclude directory teamai cannot create as not writable, not as a held lock (#993) acquireLock returns false when it cannot create the lock's directory, so updateFileLocked waited out 25 attempts and reported "another teamai command held <file> past the wait". With .git/info a regular file, MCP exclusion blamed a lock nobody held. updateFileLocked now creates the file's directory before taking the lock. EEXIST and ENOTDIR (a path on the way is not a directory) and EACCES, EPERM and EROFS throw a NotWritableError naming the file and the closest existing path above it, without waiting. ensureExcludedFromGit reports it as "<exclude> is not writable, as <path> is not a directory" and withholds the server as before. acquireLock's boolean contract is unchanged for its other callers. The e2e fixtures now use fresh paths per call, so a retried case rebuilds them instead of failing on the first try's. * docs(mcp): say an unrecorded entry under a name the team dropped is not adopted (#993) MCP ownership adopts an unrecorded entry only under a server name the team defines today, so a copy of a since-deleted team server stays as it is. Say so in the usage guide's ownership paragraph, in both languages. * fix(agents): prove an agent copy an older CLI rendered teamai's (#993) The agent ownership proof accepted a team version verbatim or rendered as pull renders it today, with today's aliases. Every member upgrading from 0.26.0 or earlier has no delivery record, and 0.26.0 rendered agents differently: the spec's model as written (no aliases), and before #830 Qoder, Qoder CN, ZCode and OMP took Claude's tool_extras and tclaude and tcodex only their base tool's. Such a copy read as the member's: never updated, named on every pull, and every pull a full sync. agentOrigin now also accepts the unresolved render and the pre-#830 extras render. * fix(pull): keep a member's file when the team deletes the doc at its path (#993) The docs mirror prune deleted every local file the team repo no longer has. At a path the team once had a doc, it now deletes the file only when it is a version of that doc from the team history; any other is kept and named, and doctor no longer lists it as stale. A local-only file at a path the team never had is pruned as before. * test(e2e): isolate HOME and the teamai binary for fixture git The git hooks teamai installs run `PATH="$HOME/.teamai/bin:$PATH" teamai hook-dispatch ...`. E2E fixtures ran git with the real HOME and PATH, so a fixture merge or checkout ran the developer's installed teamai against the real ~/.teamai (it rewrote ~/.teamai/bin/teamai and left fixture projects in ~/.teamai/projects). CI has no teamai, so local runs diverged from CI. A new e2e setup file gives each test file a sandboxed HOME (with a git identity), unsets XDG_CONFIG_HOME so XDG paths follow HOME, sets GIT_CONFIG_NOSYSTEM=1, and puts a `teamai` on PATH that runs the dist under test; all are restored afterwards. The remote suite in e2e.test.ts now clones the fixture team repo into the sandbox itself instead of relying on CI preparing the real ~/.teamai. The #808 single-repo case merges with the member's HOME, as a member's hook would run. * fix(pull): retry a resource a member's file held back even at the same revision (#993) A pull that keeps a member's file did not advance the revision, so the next pull would sync in full and deliver once the file was gone. When the checkout was already at that revision (pull --force, or the first pull after an older CLI's), the next pull still took the fast path and the team version never arrived, though the message says a pull brings it. Such a pull now resets the checkout record's revision (the shared revision in user scope), as a forced full sync does. * fix(doctor): report a .git/info that is a regular file as not writable on a dry run (#993) Doctor checks MCP exclusion with a dry run, which never reaches updateFileLocked and reads the unreadable exclude file as empty, so with .git/info a regular file it reported "not injected" and pointed at `teamai pull`. ensureExcludedFromGit's writability check now fails when the closest existing path above the exclude file is not a directory, so doctor's `MCP servers delivered to <tool>` gives the same not-writable reason and fix as pull. * fix(skills): deliver Codex skills into .agents/skills only over teamai's copy (#993) Codex reads the shared .agents/skills, which other tools and the member write to as well. The destination resolver took any existing copy there as teamai's and wrote the team skill over it, silently at init. It now takes an ownership predicate: pull asks judgeCopy against the checkout's record, doctor the team history alone, and teamai remove and uninstall isTeamaiSkillCopy. A copy that is not teamai's is left alone; the team skill goes to .codex/skills/<name>, and every full pull names the conflict. remove and uninstall delete only teamai's copy, in project and user scope. Source skills and the built-in stub keep the old rule for now. * test(doctor): give the older-copy fixtures a team history (#993) Two doctor-delivery-cli cases wrote a stale agent and Cursor rule copy by hand, with no delivery record and no team history: since #993 such a copy is the member's, so doctor reported it as "not teamai's". Each now commits the older version to the team repo first, so the copy is teamai's older render, as the case means. The Cursor case restores the team rule and its copy in a finally block, so a failure no longer breaks the cases after it. * fix(skills): delete only teamai's skill directories on remove, uninstall and pull (#993) teamai remove, uninstall, and pull's sweep of namespace-nested copies of an excluded skill deleted any directory at a team skill's name, including a member's own skill that pull keeps as not teamai's. remove and uninstall now delete a skill directory only when a file under it is on the checkout's record, or isTeamaiSkillCopy proves it (what pull writes today from the team source, or a team version by the history), and name each one they leave. remove judges before deleting the team source, so the local agent's history-less resource cache still removes its own installs. uninstall keeps trusting built-in names and names the local agent's manifest lists. The nested sweep deletes a copy only when removedCopyChanged says it is teamai's and unchanged. * test(uninstall): drop the commitTeamRepo import the merge duplicated (#993) * fix(source): deliver source skills where team skills go (#993) Source skills resolve through the team-skill seam: the agent-exclusion check, skillTargetForTool (Hermes home, OpenClaw workspace, Copilot home), then Codex's shared-destination rule with a real ownership proof against the source repo. Destinations outside the project are recorded as absolute paths inside the tool's home and shared per source across projects. An unrecorded existing copy that is no version of the source skill is the member's and is kept. Copies earlier releases left in the project's .hermes/skills and .openclaw/skills are reclaimed when unchanged, kept and named otherwise. * test(source): changed legacy source copies survive uninstall, remove and withdrawal (#993) * test(pull): pin delivery of an agent held at the team revision once its alias resolves (#993) A pull --force that holds an agent for its model leaves the checkout record at the team revision, so the next pull takes the fast path. The fast path's agent redeploy (#830) already writes the resolved model there, and a copy held before delivery is written as missing; no code change is needed. The test fails when that redeploy is disabled. * fix(uninstall): delete only teamai's rule and agent copies on uninstall, remove agents and pull (#993) uninstall and `teamai remove agents` deleted every rule or agent file at a team name, and pull deleted the namespaced copy beside the author's root copy on tools that do not flatten rules. Each now goes only on the checkout's record or a team version by the history; built-in names stay deletable, and a member's file is kept and named. * fix(packages): leave a tracked .teamai/teamai.lock in place and name it in doctor (#993) Moving a lock git tracks left a deletion in git status. A tracked (or unknown) lock is now copied to the data home instead, and doctor names it with git rm --cached, as it does the tracked hook index. * fix(docs): keep a local doc when the team history cannot be read (#993) The docs prune deleted a file the team no longer has when git could not read the team history. Without proof the file is the member's, as everywhere else. * test(skills): cover an unrecorded older team copy in .agents/skills updated in place for Codex (#993) * ci(e2e): drop the steps that prepared the real HOME the e2e sandbox replaces (#993) The e2e setup file gives every test file a sandbox HOME with its own git identity, and e2e.test.ts clones the fixture repo into it, so the git identity, teamai config and fixture cleanup steps act on a HOME nothing reads. * docs(ci): describe the e2e HOME sandbox in the local e2e setup (#993) * refactor(sync): build every not-teamai's line from one reason (#993) * test(agents): prove the removed and superseded copies teamai's by the team history (#993) * test(pull): give the docs prune fixtures a team history (#993) * fix(source): name the source's version, not a team version, for a member's skill at a source skill's path (#993) * refactor(local-agent): resolve a record's MCP file through recordedFileOf (#993) * fix(coauthor): report a recorded settings file that is not JSON as unreadable, naming it (#993) * test(mcp): wait for the session start's background pass before the git-info fixture cleans up (#993) hook-dispatch leaves a detached --bg-only pass running in the sandbox HOME after the foreground hook exits; it was still writing when afterAll removed the sandbox, so CI failed the suite with ENOTEMPTY. * test(opencode): keep the V1 hooks e2e off the npm registry (#993) With any plugin configured, OpenCode's first request for a directory waits for it to npm-install @opencode-ai/plugin into its config dir. On CI that fetch outlasted the 5 s session request. teamai's plugins import nothing from it, so the fixture records it as installed, and a failed session request now carries the server log. * fix(sync): name a kept copy of a removed resource as the member's or as an edit (#993) judgeRemoval replaces removedCopyChanged with three outcomes: remove, edited (changed since teamai delivered it, or on another checkout's record), and notTeamais (no record, no team version). Pull's tombstone cleanup and the rules sweep now say a member's own file is not teamai's instead of claiming the member changed a teamai copy. * fix(agents): delete a stale same-stem agent sibling only when it is teamai's (#993) removeStaleAgentSiblings deleted every same-stem file with another extension beside a rendered agent, a member's own included. It now goes through judgeRemoval with the agent's origin and the checkout record, and names a sibling it keeps. Built-in agents keep sweeping their own names. * 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) * 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. * 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. * 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. * 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. * 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(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. * 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. * 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) * 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(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. * 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). * 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. * 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(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(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) * 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(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. * 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. * 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(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. * 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(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): 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). * 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(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. * docs: point the kept-edit links in sharing at member-guide's Auto-sync The Auto-sync section moved to member-guide in the docs reorganization, so the in-page anchors #993 added no longer resolve.
5 of 9 tasks
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
* refactor(hooks): create project tool roots for a set of tools SessionStart keeps seeding its one tool through seedProjectAgentRoot. The new createProjectToolRoots takes a set of tools, defaulting to enabledAgents and, when that is empty, to the tool roots the main checkout already has. * feat(init): end init with a pull and create the chosen project tool roots Project-scope init with --agent creates those tools' roots after saving enabledAgents, then init runs the scope's pull so the first session has the team's skills, rules and MCP servers. Without --agent no root is created. Docs and setup skill stop telling members to pull after init. * feat(hooks): sync resources into new worktrees via a git hook * feat(hooks): deliver a new worktree from the cached team clone, refresh the rest after The post-checkout pass now runs pull in an internal inline mode: it skips the team repo fetch when the clone was fetched within the source TTL (24 h, new last-fetch.json stamp beside the clone), reads subscribed sources from their cached clones, waits for another pull's partition lock instead of skipping, and leaves learnings, reports, usage reporting and post-pull scripts to a detached full pull started after it. * feat(hooks): deliver the team's change after git pull The post-merge git hook now runs an inline pull. With a separate team repo it fetches the team repo whatever its fetch stamp says, aborting the fetch after 5 s (internal fetchTimeoutMs pull option, AbortSignal into simple-git), and delivers when the revision moved; a detached full pull then refreshes the team repo past the cap, sources, learnings and reports. In single-repo mode it delivers the working tree git pull updated, with no network and no detached pull. * feat(hooks): record git hook failures for doctor and the next pull A failure inside the silent git hook (team fetch failed or hit the cap, partition lock held past the inline wait, handler error) is written to debug.log and recorded in the project partition. doctor names it with its fix and reports whether the hook is installed; the next interactive pull mentions it once; a successful hook pull, detached retry included, clears it. The post-merge inline lock wait is capped at its fetch cap. * feat(hooks): fall back to a .git/hooks block on older Git, advise under core.hooksPath * feat(hooks): uninstall and pull --dry-run cover the git hook * feat(init): ask which AI tools to set up in interactive project-scope init Project-scope init in a terminal without --agent reuses the single-repo tool picker (Auto = tools installed under HOME). The choice is added to enabledAgents before the tool roots are created, so only the chosen tools' roots appear and the closing pull fills them. --agent and non-interactive runs skip the picker; the latter still create no root. * test: verify agents and team hooks before session startup * docs: require preparation for hosts that skip checkout hooks * fix(hooks): keep existing git hooks intact and report git hook failures - Leave an unreadable or non-executable .git/hooks script alone instead of replacing or enabling it; doctor explains the fallback. - Install the git hook after the agent hooks and propagate its failure with the fix; init reports it and still pulls, hooks inject exits non-zero. - Record why a git hook synced nothing when the project config is unreadable. - Cap the self-mode post-merge lock wait at the same 5 s as the fetch. - Keep a partial delivery failure recorded until a complete sync. - Join detached hook pulls before the e2e sandbox is removed. * fix(hooks): skip teamai's own knowledge worktree in git hooks Detection run inside <main>/.teamai/knowledge-wt resolves that worktree as its own project root, so the config-based guard missed it: a self-mode push fired post-checkout there, delivered into the disposable worktree and left a detached pull running. Exclude the main checkout's .teamai/ for both git events. * fix: address review of the pre-session sync - init --scope user pulls the user scope even inside a project checkout - leave symlinked git hook scripts and their targets untouched - clear a recorded git hook failure only after a pull completes
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
* fix(opencode): add team rules and instructions to V2 sessions through the plugin OpenCode V2 parses `instructions` and ignores it, so a V2 session got none of the team rules or the culture, claudemd and recall blocks. The teamai plugin's V2 setup now registers the session context and compaction hooks and adds the user instruction file and rules, then the nearest project's .opencode/teamai-context.md and .opencode/rules/**/*.md, sorted by path. V1 delivery through `instructions` is unchanged. (#993) * fix(opencode): write the user instruction file beside the Claude fallback for V2 OpenCode V1 reads ~/.claude/CLAUDE.md while ~/.config/opencode/AGENTS.md does not exist, so teamai wrote no OpenCode user file there. V2 reads neither that fallback nor `instructions`. Pull and HTTP prompts now write ~/.config/opencode/teamai-context.md for teamai's plugin in that case too, and still list it nowhere, so V1 gets no duplicate. (#993) * fix(init): set up only the --agent tools in single-repo init (#993) init . wrote .teamai/teamai.yaml (mode: self) before it read the existing project config. With the marker on disk and no config yet, that read ran the clone-time self-heal, which enabled every tool found in HOME, injected their hooks into the repo and saved them; init then merged --agent into that. Read the config once, before the marker is written, and use that snapshot for inheriting user scope, the enabledAgents union, the tool-roots carry-over and the mode-switch settlement. * fix(coauthor): keep the project-scope co-author setting out of shared settings (#993) In project scope only claude writes attribution, to the member-local .claude/settings.local.json; the rest of the Claude settings family is user-scope only, like Codex and Cursor. The next pull removes an attribution an earlier release wrote to a shared project settings file when it is exactly teamai's value and the co-author record lists the file, deleting only that member's text. * docs(coauthor): note a pre-fix shared value stays while no co-author choice exists (#993) * fix(doctor): check OpenCode V2 delivery from the teamai plugin doctor reported the team rules and instructions active on OpenCode V2 because `instructions` listed them, but V2 ignores that key. doctor now reads the major version from `opencode --version` (missing or unparsable counts as V1) and, on V2, checks that teamai's plugin in HOME is the one this build writes, since its context hook is what delivers them. V1 checks are unchanged. The usage guide describes V2 delivery. (#993) * fix(pull): probe live checkouts from recorded roots, not the worktree list (#993) A pull in a linked worktree of a --separate-git-dir repo or a submodule dropped the main checkout's delivery record and workspaces/<id>/, because git worktree list names the git directory there instead of the main checkout. Its next pull then overwrote edited rules without a word. Records and workspace directories now store their checkout root; a full pull keeps one while that root still has a .git, names the same git common dir, and (records) gives the same checkoutKey, so a re-created worktree still starts fresh (#807). Entries without a root (older CLI) are kept. listWorktrees reads --porcelain -z, skipping bare, prunable and common-dir entries, and returns [] when -z is unsupported instead of splitting lines. * fix(init): skip the clone-time self-heal for init in a single-repo clone (#993) A fresh clone whose committed .teamai/teamai.yaml says mode: self ran the self-heal in the preAction queue check and again in initSelfRepo's config read. Either one enabled every tool found in HOME before --agent could choose. init now loads with selfHeal: false in both places; every other command still self-heals. * fix(sync): adopt config entries that equal a team render, keep the member's (#993) An MCP server or a team hook entry teamai has no record of is teamai's only when it equals teamai's render of a team server or hook, today or at any revision in the team repo's history (one hook only). It is then adopted and handled as recorded. Any other one is the member's: kept and named by pull and doctor; a member's same-name MCP server means the team server is not written to that file. `pull --force` no longer overwrites a member's server (`teamai mcp inject --force` still does). This removes the second copy of each team hook a lost hook manifest caused in .claude/settings.local.json and .codex/hooks.json. * docs(sync): describe ownership of unrecorded MCP servers and hook entries (#993) * test(init): cover init . in a single-repo clone with no --agent and no terminal (#993) With the clone self-heal skipped for init, a fresh clone has no config when init runs. Pin that it takes the non-interactive default (the tools found in HOME) instead of prompting or stopping at "already initialized". * test(hooks): cover hook ownership beside the co-author setting in settings.local.json (#993) * fix(pull): prune a workspace directory without a root only when the worktree list names every checkout (#993) contribute, recall, viz, the MCP writers and the local agent create a checkout's workspaces/<id>/ before its first full pull writes root, so a removed worktree that never ran a full pull kept its directory forever (self-mode-worktrees-808). Such a directory now goes when git worktree list -z names every checkout (no non-bare entry is the common dir) and none has its id, as git prints it or realpath'd. It is kept with --separate-git-dir, in a submodule, on git < 2.36, and when it holds local-agent/. * fix(mcp): create a missing .git/info/ before excluding a resolved MCP config (#993) A repository created with an empty template has no .git/info/. The writability check ran `access(W_OK)` on that directory, got ENOENT, and reported it as "not writable", so every team MCP server holding a resolved value was withheld. Check the exclude file when it exists, otherwise its closest existing directory, and let the write create info/. Report "not writable" only for EACCES, EPERM and EROFS, and name the exclude file in the reason and the fix. Applies to pull, doctor, `mcp list` and local-agent installs, which share ensureExcludedFromGit. * fix(mcp): write CodeBuddy's user MCP servers to the file CodeBuddy reads (#993) CodeBuddy reads only the first user MCP file that exists of ~/.codebuddy/.mcp.json, ~/.codebuddy/mcp.json and ~/.codebuddy.json, and teamai always wrote the second, so team servers and the member's own hid each other. In user scope teamai now writes to that first existing file and creates ~/.codebuddy/.mcp.json only when none exists. Each CodeBuddy record in managed-mcp.json names its file; a pull moves teamai's own entries out of a file CodeBuddy no longer reads, uninstall and `teamai mcp remove` follow the record, and doctor and `teamai mcp list` name a shadowed file. * fix(local-agent): install CodeBuddy's user MCP servers in the file CodeBuddy reads (#993) An HTTP-backed team's install_mcp now writes CodeBuddy's user servers to the first existing file of CodeBuddy's lookup order, as a pull does, and records that file. A reinstall moves a server an earlier install left in a file CodeBuddy no longer reads; uninstall_mcp removes it from the recorded file. * fix(migrate): move the team clone's last-fetch stamp out of a superseded install (#993) A linked worktree whose old git-mode install another checkout superseded by switching to single-repo mode keeps the team knowledge in .teamai/ and moves only SUPERSEDED_ENTRIES to .teamai.bak. #964 added last-fetch.json beside the clone, which that list did not name, so it stayed in .teamai/ as an untracked file. The 808 fixture now writes the stamp a #964 release leaves, so the case fails without the fix whatever teamai the developer has installed. * fix(hooks): keep the managed-hooks index and the package lock out of the working tree (#993) getManagedHooksPath built <root>/.teamai/managed-hooks.json in project scope, so the Copilot hook index showed up untracked in every git project and self mode committed it with git add -A. It now resolves per checkout to <dataHome>/workspaces/<id>/managed-hooks.json, beside managed-mcp.json. legacyManagedHooksPath names the old file for the pre-#370 Codex import, the legacy hook sweep and uninstall. migrateLegacyManagedHooks moves its Copilot records (all records in self mode) before hooks are reconciled, removed or uninstalled, and deletes it once empty and untracked; doctor names a tracked one with the git rm --cached command. teamai.lock moves to the data home too (packageLockDir): an older .teamai/teamai.lock is moved on the next install or session-start read, doctor reads it where it is, and a .teamai/.gitignore holding only teamai.lock is removed outside self mode. Self mode's .teamai/.gitignore lists managed-hooks.json, also through its migration. * fix(pull): keep a rule or agent file teamai cannot prove its own (#993) A rule or agent destination that exists with no delivery record is teamai's only when its bytes equal teamai's render of that resource at some revision of the team repo's history (git blob ids, through ticket 04's matchesHistory). Otherwise it is the member's: pull neither writes nor deletes it, names it, and doctor lists it. This covers a checkout whose record key changed (a restore or copy gives .git a new inode), a role switch after that, and a member's own file with a team name. - DeliveryTarget.origin carries the proof; judgeCopy gains a 'member' verdict; isTeamaiCopy and describeMembersFile are the shared seam. - The rules stale sweep and the tombstone cleanup prove an unrecorded copy before deleting it. - A kept copy is worded as an edit when another checkout record lists its path (a record lost to a new key); no record is carried over. - A pull that keeps a member's file does not count as synced, so a plain pull delivers the team version once the file is gone. * fix(mcp): leave an older teamai's ~/.codebuddy/mcp.json that hides ~/.codebuddy.json (#993) Earlier releases always created ~/.codebuddy/mcp.json, so a member's servers in ~/.codebuddy.json stayed hidden. When that file holds only teamai's servers (recorded, or equal to a team render) and a later file of CodeBuddy's lookup order exists, a pull moves the servers there, deletes the file and says so once. A file that also holds a member's server or any other key stays chosen. * fix(remove): judge rule copies by record and team history in teamai remove (#993) teamai remove's rules refresh ran without the checkout's ledger, so it wrote over a member's own file at a team rule's path, and its explicit sweep deleted a member's own file named after the removed rule. It now opens the ledger, passes it to the refresh and names what it kept, and deletes a copy of the removed rule only when it is on record or its bytes are a version from the team history (the author's root copy keeps its placement record as proof). Docs say a personal rule the team never had is kept, and that a pull keeping a member's file syncs in full until it is gone. * fix(pull): keep a skill or doc teamai cannot prove its own (#993) A skill directory with no delivery record is teamai's only when every file in it is today's team file or a version of it from the team repo's history (SKILL.md also as pull repairs its frontmatter); one file of the member's makes the whole directory theirs. A file in the docs mirror at a team doc's path is teamai's only when it is a version of that doc. Anything else is kept and named, not written over or removed by the tombstone cleanup, and doctor lists it. isTeamaiSkillCopy is the ledger-free decision ticket 05 reuses. * docs(skill): keep the ownership sentence clear of the command check (#993) * fix(rules): delete a legacy .md in .cursor/rules only when it is teamai's (#993) Pull's stale sweep and pullItem deleted every .md in a .mdc tool's rules directory, and uninstall every one with a team rule's name, as a copy of the layout before .mdc. A member's own notes.md there went with them, though the usage guide promised it stays. Each now deletes one only when the checkout record lists it, it is a team version from the history verbatim, or it has a built-in rule's name (isLegacyLayoutCopy); any other is kept silently, since Cursor never reads it. teamai remove already applies the proof since 02b. * fix(coauthor): move a pre-fix attribution to settings.local.json when no choice exists (#993) With no co-author choice (the team dropped sharing.coAuthor and the member has none), the reconcile returned before settling shared project files, so an attribution an earlier teamai wrote to a tracked .claude/settings.json stayed there for git add -A to commit. The next pull now moves it to .claude/settings.local.json under the same guards (teamai's exact value, the record lists the file with "strip", only that key is edited), so the member's trailer is unchanged and the tracked file is clean. A value the member already set in settings.local.json is kept. Other Claude-family tools' shared files have no member-local counterpart and wait for a choice. A failed settle now keeps its record so the next pull retries. * fix(git): list sibling worktrees on git before 2.36 (#993) listWorktrees read only `git worktree list --porcelain -z`, so on git without -z it returned [] to every caller. A pull or uninstall then judged the shared .git/info/exclude line from the current checkout alone and dropped /.mcp.json while a sibling worktree's .mcp.json still held a resolved value (#882/#886). Fall back to the newline-split list when -z fails. Liveness is unchanged: completeWorktreeList stays -z only and returns null there. * fix(mcp): report an exclude directory teamai cannot create as not writable, not as a held lock (#993) acquireLock returns false when it cannot create the lock's directory, so updateFileLocked waited out 25 attempts and reported "another teamai command held <file> past the wait". With .git/info a regular file, MCP exclusion blamed a lock nobody held. updateFileLocked now creates the file's directory before taking the lock. EEXIST and ENOTDIR (a path on the way is not a directory) and EACCES, EPERM and EROFS throw a NotWritableError naming the file and the closest existing path above it, without waiting. ensureExcludedFromGit reports it as "<exclude> is not writable, as <path> is not a directory" and withholds the server as before. acquireLock's boolean contract is unchanged for its other callers. The e2e fixtures now use fresh paths per call, so a retried case rebuilds them instead of failing on the first try's. * docs(mcp): say an unrecorded entry under a name the team dropped is not adopted (#993) MCP ownership adopts an unrecorded entry only under a server name the team defines today, so a copy of a since-deleted team server stays as it is. Say so in the usage guide's ownership paragraph, in both languages. * fix(agents): prove an agent copy an older CLI rendered teamai's (#993) The agent ownership proof accepted a team version verbatim or rendered as pull renders it today, with today's aliases. Every member upgrading from 0.26.0 or earlier has no delivery record, and 0.26.0 rendered agents differently: the spec's model as written (no aliases), and before #830 Qoder, Qoder CN, ZCode and OMP took Claude's tool_extras and tclaude and tcodex only their base tool's. Such a copy read as the member's: never updated, named on every pull, and every pull a full sync. agentOrigin now also accepts the unresolved render and the pre-#830 extras render. * fix(pull): keep a member's file when the team deletes the doc at its path (#993) The docs mirror prune deleted every local file the team repo no longer has. At a path the team once had a doc, it now deletes the file only when it is a version of that doc from the team history; any other is kept and named, and doctor no longer lists it as stale. A local-only file at a path the team never had is pruned as before. * test(e2e): isolate HOME and the teamai binary for fixture git The git hooks teamai installs run `PATH="$HOME/.teamai/bin:$PATH" teamai hook-dispatch ...`. E2E fixtures ran git with the real HOME and PATH, so a fixture merge or checkout ran the developer's installed teamai against the real ~/.teamai (it rewrote ~/.teamai/bin/teamai and left fixture projects in ~/.teamai/projects). CI has no teamai, so local runs diverged from CI. A new e2e setup file gives each test file a sandboxed HOME (with a git identity), unsets XDG_CONFIG_HOME so XDG paths follow HOME, sets GIT_CONFIG_NOSYSTEM=1, and puts a `teamai` on PATH that runs the dist under test; all are restored afterwards. The remote suite in e2e.test.ts now clones the fixture team repo into the sandbox itself instead of relying on CI preparing the real ~/.teamai. The #808 single-repo case merges with the member's HOME, as a member's hook would run. * fix(pull): retry a resource a member's file held back even at the same revision (#993) A pull that keeps a member's file did not advance the revision, so the next pull would sync in full and deliver once the file was gone. When the checkout was already at that revision (pull --force, or the first pull after an older CLI's), the next pull still took the fast path and the team version never arrived, though the message says a pull brings it. Such a pull now resets the checkout record's revision (the shared revision in user scope), as a forced full sync does. * fix(doctor): report a .git/info that is a regular file as not writable on a dry run (#993) Doctor checks MCP exclusion with a dry run, which never reaches updateFileLocked and reads the unreadable exclude file as empty, so with .git/info a regular file it reported "not injected" and pointed at `teamai pull`. ensureExcludedFromGit's writability check now fails when the closest existing path above the exclude file is not a directory, so doctor's `MCP servers delivered to <tool>` gives the same not-writable reason and fix as pull. * fix(skills): deliver Codex skills into .agents/skills only over teamai's copy (#993) Codex reads the shared .agents/skills, which other tools and the member write to as well. The destination resolver took any existing copy there as teamai's and wrote the team skill over it, silently at init. It now takes an ownership predicate: pull asks judgeCopy against the checkout's record, doctor the team history alone, and teamai remove and uninstall isTeamaiSkillCopy. A copy that is not teamai's is left alone; the team skill goes to .codex/skills/<name>, and every full pull names the conflict. remove and uninstall delete only teamai's copy, in project and user scope. Source skills and the built-in stub keep the old rule for now. * test(doctor): give the older-copy fixtures a team history (#993) Two doctor-delivery-cli cases wrote a stale agent and Cursor rule copy by hand, with no delivery record and no team history: since #993 such a copy is the member's, so doctor reported it as "not teamai's". Each now commits the older version to the team repo first, so the copy is teamai's older render, as the case means. The Cursor case restores the team rule and its copy in a finally block, so a failure no longer breaks the cases after it. * fix(skills): delete only teamai's skill directories on remove, uninstall and pull (#993) teamai remove, uninstall, and pull's sweep of namespace-nested copies of an excluded skill deleted any directory at a team skill's name, including a member's own skill that pull keeps as not teamai's. remove and uninstall now delete a skill directory only when a file under it is on the checkout's record, or isTeamaiSkillCopy proves it (what pull writes today from the team source, or a team version by the history), and name each one they leave. remove judges before deleting the team source, so the local agent's history-less resource cache still removes its own installs. uninstall keeps trusting built-in names and names the local agent's manifest lists. The nested sweep deletes a copy only when removedCopyChanged says it is teamai's and unchanged. * test(uninstall): drop the commitTeamRepo import the merge duplicated (#993) * fix(source): deliver source skills where team skills go (#993) Source skills resolve through the team-skill seam: the agent-exclusion check, skillTargetForTool (Hermes home, OpenClaw workspace, Copilot home), then Codex's shared-destination rule with a real ownership proof against the source repo. Destinations outside the project are recorded as absolute paths inside the tool's home and shared per source across projects. An unrecorded existing copy that is no version of the source skill is the member's and is kept. Copies earlier releases left in the project's .hermes/skills and .openclaw/skills are reclaimed when unchanged, kept and named otherwise. * test(source): changed legacy source copies survive uninstall, remove and withdrawal (#993) * test(pull): pin delivery of an agent held at the team revision once its alias resolves (#993) A pull --force that holds an agent for its model leaves the checkout record at the team revision, so the next pull takes the fast path. The fast path's agent redeploy (#830) already writes the resolved model there, and a copy held before delivery is written as missing; no code change is needed. The test fails when that redeploy is disabled. * fix(uninstall): delete only teamai's rule and agent copies on uninstall, remove agents and pull (#993) uninstall and `teamai remove agents` deleted every rule or agent file at a team name, and pull deleted the namespaced copy beside the author's root copy on tools that do not flatten rules. Each now goes only on the checkout's record or a team version by the history; built-in names stay deletable, and a member's file is kept and named. * fix(packages): leave a tracked .teamai/teamai.lock in place and name it in doctor (#993) Moving a lock git tracks left a deletion in git status. A tracked (or unknown) lock is now copied to the data home instead, and doctor names it with git rm --cached, as it does the tracked hook index. * fix(docs): keep a local doc when the team history cannot be read (#993) The docs prune deleted a file the team no longer has when git could not read the team history. Without proof the file is the member's, as everywhere else. * test(skills): cover an unrecorded older team copy in .agents/skills updated in place for Codex (#993) * ci(e2e): drop the steps that prepared the real HOME the e2e sandbox replaces (#993) The e2e setup file gives every test file a sandbox HOME with its own git identity, and e2e.test.ts clones the fixture repo into it, so the git identity, teamai config and fixture cleanup steps act on a HOME nothing reads. * docs(ci): describe the e2e HOME sandbox in the local e2e setup (#993) * refactor(sync): build every not-teamai's line from one reason (#993) * test(agents): prove the removed and superseded copies teamai's by the team history (#993) * test(pull): give the docs prune fixtures a team history (#993) * fix(source): name the source's version, not a team version, for a member's skill at a source skill's path (#993) * refactor(local-agent): resolve a record's MCP file through recordedFileOf (#993) * fix(coauthor): report a recorded settings file that is not JSON as unreadable, naming it (#993) * test(mcp): wait for the session start's background pass before the git-info fixture cleans up (#993) hook-dispatch leaves a detached --bg-only pass running in the sandbox HOME after the foreground hook exits; it was still writing when afterAll removed the sandbox, so CI failed the suite with ENOTEMPTY. * test(opencode): keep the V1 hooks e2e off the npm registry (#993) With any plugin configured, OpenCode's first request for a directory waits for it to npm-install @opencode-ai/plugin into its config dir. On CI that fetch outlasted the 5 s session request. teamai's plugins import nothing from it, so the fixture records it as installed, and a failed session request now carries the server log. * fix(sync): name a kept copy of a removed resource as the member's or as an edit (#993) judgeRemoval replaces removedCopyChanged with three outcomes: remove, edited (changed since teamai delivered it, or on another checkout's record), and notTeamais (no record, no team version). Pull's tombstone cleanup and the rules sweep now say a member's own file is not teamai's instead of claiming the member changed a teamai copy. * fix(agents): delete a stale same-stem agent sibling only when it is teamai's (#993) removeStaleAgentSiblings deleted every same-stem file with another extension beside a rendered agent, a member's own included. It now goes through judgeRemoval with the agent's origin and the checkout record, and names a sibling it keeps. Built-in agents keep sweeping their own names. * 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) * 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. * 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. * 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. * 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. * 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(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. * 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. * 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) * 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(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. * 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). * 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. * 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(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(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) * 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(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. * 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. * 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(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. * 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(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): 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). * 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(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. * docs: point the kept-edit links in sharing at member-guide's Auto-sync The Auto-sync section moved to member-guide in the docs reorganization, so the in-page anchors #993 added no longer resolve.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prepare the team's supported resources before the AI tool reads its startup configuration.
flowchart TB subgraph CURRENT[Before] direction LR C1[Start tool] --> C2[Read startup config] --> C3[SessionStart pull] --> C4[Resources arrive late] end subgraph EXPECTED[After] direction LR E1[init / new worktree / git pull] --> E2[Prepare resources] --> E3[Start tool] --> E4[Read prepared config] end CURRENT ~~~ EXPECTED classDef sync fill:#6a4f8f,stroke:#513b6d,color:#fff; classDef late fill:#a33a3a,stroke:#7a2a2a,color:#fff; classDef ready fill:#2f8f4f,stroke:#1f6b39,color:#fff; class C3,E2 sync; class C2,C4 late; class E3,E4 ready; style CURRENT fill:#fff5f4,stroke:#a33a3a,color:#3a2525 style EXPECTED fill:#f1faf3,stroke:#2f8f4f,color:#183e22initfinishes with a pull of the scope it configured, even when--scope userruns inside a project checkout. Project Git hooks prepare worktrees and apply updates aftergit pull. Startup delivery runs inline; the full refresh runs in the background.Interactive init without
--agentReuses single-repo mode's existing
promptForSelfModeAgents. This PR adds the project call and wording.Choice
2enables Claude, creates only.claude/, and fills it before exit. Enter selects Auto. Non-interactive init without--agentcreates no roots.Type of Change
Evidence
Before: startup reads configuration before delivery; team changes leave the previous resources on disk.
After: all five resources pass. Codex parent and child both call MCP, with resource tokens absent from the prompt and no shell or file changes.
Codex project MCP records combine this runtime at
6c330c00with #954 at48c77400in a temporary test branch. Trust was configured in the fixture. #954 and #955 remain excluded; standalone project MCP and automatic hook trust are not claimed.Test Plan
npx tsc --noEmitpassesnpm run lintpassesnpx vitest runpasses, 7,519 passed and 1 skippednpm run buildpassesf9392dba--agent, choice2: all five resources delivered, only.claude/createdBuilt-CLI checks cover init, worktrees, all five updated resources, hook coexistence, failures, dry-run and uninstall. Five Codex parent/child records cover the session cases above. Interactive init passed at
49d16d22. Build, unit tests, typecheck and lint pass atf9392dba.Related Issues
Fixes #963.
Related delivery and trust work: #954, #955.
Merge Danger
Door: two-way
No schema migration. Uninstall removes TeamAI's Git hook entries and blocks.
Blast Radius: startup
Init, worktree creation and post-merge now wait for delivery. Hooks preserve Git's exit status;
doctorand the next interactive pull report failures.Notes for Reviewers
.teamai/, and the reports and learnings checkouts in the project data home.initreports it and still pulls;hooks injectexits non-zero.doctorand each interactive pull report it until then.teamai pull.--worktreeintegration is out of scope.Active sessions may need restarting. Both usage guides and affected skills are updated.