teamai-cli 0.27.0-beta.0 → 0.27.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teamai-cli",
3
- "version": "0.27.0-beta.0",
3
+ "version": "0.27.0-beta.1",
4
4
  "description": "TeamAI — Make Every Team AI Native (skill sync + shared knowledge base, powered by Git)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -81,6 +81,7 @@
81
81
  "@types/node": "^20.17.0",
82
82
  "@types/semver": "^7.8.0",
83
83
  "@vitest/coverage-v8": "^3.2.7",
84
+ "esbuild": "^0.27.3",
84
85
  "fast-check": "^4.10.2",
85
86
  "opencode-ai": "1.18.23",
86
87
  "oxlint": "1.85.0",
@@ -127,6 +127,24 @@ changed since, or push says so for that copy, merge that change into the copy fi
127
127
  the copy and run `teamai pull --force`. The first pull after upgrading, and a
128
128
  new worktree's first pull, still overwrite: nothing is recorded yet.
129
129
 
130
+ In project scope, `init` and `pull` also install a git hook in the repository's
131
+ local git config (`hook.teamai-post-checkout`, `hook.teamai-post-merge`; Git
132
+ 2.54+; older Git without `core.hooksPath` gets a marked block in `.git/hooks/`
133
+ scripts, and with it `teamai doctor` advises), beside any `core.hooksPath` manager or `.git/hooks` script. When a
134
+ worktree is created by `git worktree add` or an app that runs checkout hooks, it creates the project roots
135
+ of `enabledAgents` (else the ones the main checkout has) and pulls into it before
136
+ the command returns, from the team clone as last fetched when that was within
137
+ 24 h; a full pull then runs in the background. A branch switch does nothing.
138
+ After `git pull` it fetches the team repo (5 s cap, then the background pull) and
139
+ delivers; in single-repo mode it delivers what `git pull` brought, offline. It prints nothing and always
140
+ exits 0; a failure inside it is recorded, and `teamai doctor` names it (`Last git
141
+ hook run failed: ...`) with its fix, as does the next interactive `teamai pull`, once.
142
+ `teamai doctor` also reports whether the hook is installed, and why not.
143
+ `pull --dry-run` says when it would install or update the hook, writing nothing;
144
+ `teamai uninstall` removes only teamai's hook entries and blocks. For hosts that
145
+ skip checkout hooks, prepare the worktree before launch; see the new-worktree
146
+ section in `references/troubleshooting.md`.
147
+
130
148
  A team agent (`agents/<name>.yaml`) can set `model: strong`, `model: fast`, or an
131
149
  alias the team defines, instead of one tool's model. The team maps each alias per
132
150
  tool in `models/aliases.yaml`, in that tool's own model value, with an optional effort:
@@ -12,7 +12,7 @@ Generated: do not edit by hand. Regenerate with
12
12
  ## Global options
13
13
 
14
14
  - `-V, --version` — output the version number
15
- - `--dry-run` — Preview mode, no changes made
15
+ - `--dry-run` — Preview mode, no changes made; a command with no preview exits 1 without running
16
16
  - `-v, --verbose` — Verbose output
17
17
 
18
18
  ## init
@@ -253,7 +253,7 @@ Generated: do not edit by hand. Regenerate with
253
253
  - `--base-url <url>` — Personal profiles: new gateway root URL
254
254
  - `--protocol <protocols>` — Personal profiles: serve models over these protocols too
255
255
  - `--model <ids>` — Personal profiles: add model IDs
256
- - `teamai models switch <profile>` — Point agents at a model profile (every compatible agent by default)
256
+ - `teamai models switch [profile]` — Point agents at a model profile (every compatible agent by default); omit the profile to pick one
257
257
  - `--agent <name>` — Only switch this agent. Repeatable or comma-separated.
258
258
  - `--model <id>` — Default model to select (defaults to the first in the profile)
259
259
  - `--dry-run` — Show what would change without writing
@@ -117,13 +117,32 @@ The doc lands in the team's `learnings/` and appears for teammates on their next
117
117
  - Teammates receive it automatically on their next session, or via `teamai pull`.
118
118
 
119
119
  Before listing rules, `push` refreshes copies whose bodies still match a recorded
120
- sync revision. Copilot's generated `applyTo` header does not count as a local
121
- edit: unedited old instructions update in native format, including under
122
- `COPILOT_HOME` in user scope. Genuine local body edits remain push candidates.
120
+ sync revision. The header teamai generates for a tool's own rules format
121
+ (Cursor `.mdc`, JoyCode's own `.mdc`, Copilot `applyTo`, Kiro `inclusion`, Qoder
122
+ `trigger`, CodeBuddy and WorkBuddy `alwaysApply`, Oh My Pi `alwaysApply`/`globs`) does not count as a local edit: unedited old copies update in that
123
+ format, including under `COPILOT_HOME` in user scope. Genuine local body edits remain push candidates.
123
124
  Rule pre-sync leaves tools excluded by `enabledAgents` or `disabledAgents` untouched.
124
125
  When only team `paths` change, `applyTo` refreshes if the local file still matches
125
126
  a recorded version's generated copy; locally edited headers are kept.
126
127
  The copies push refreshes are recorded, so a later `teamai pull` still updates them.
128
+ Oh My Pi and Kiro read only the top of their rules directories, so a namespaced
129
+ rule is written flat there (`rules/fe/style.md` as `fe.style.md`); an edit of that file
130
+ pushes back to `rules/fe/style.md`. Push requires a delivery record for the flat copy.
131
+ A personal file with that name is neither refreshed before push nor offered as
132
+ an edit of the team rule.
133
+ If two namespaced rules flatten to the same name, neither is written; `teamai doctor`
134
+ reports the collision even when no other rule reaches that tool. Rename one in the
135
+ team repo, then run `teamai pull`. Doctor also reports team-owned OpenCode globs
136
+ or inline blocks left after the last rule is removed.
137
+
138
+ A new file in the rules directory of a tool with a rules format of its own
139
+ (Cursor, JoyCode, Copilot, Kiro, Qoder, CodeBuddy, WorkBuddy, Oh My Pi) is the
140
+ member's own rule in that tool's format: push never offers it, and pull leaves
141
+ it. To author a new team rule, write it as a plain `.md` in `.claude/rules/`
142
+ (scope it with `paths:` frontmatter, which teamai renders into each tool's
143
+ format), then run `teamai push`. A YAML comment after an unquoted glob stays
144
+ outside its scope: `paths: **/*.ts # TypeScript files` matches `**/*.ts`, including
145
+ when written as a block-list entry under `paths:`.
127
146
 
128
147
  ## If push is denied
129
148
 
@@ -16,8 +16,11 @@ reports before anything else.
16
16
 
17
17
  This is the #1 onboarding issue. In order:
18
18
 
19
- 1. **Open a fresh session.** Resources sync on **session start** via a hook, not
20
- at init time. An empty skills folder right after `teamai init` is normal.
19
+ 1. **Did init pick this tool?** `teamai init` ends with a pull, but a project-scope
20
+ init creates only the directories of tools named with `--agent` or picked in
21
+ its interactive tool picker. Run without a terminal and without `--agent`, it
22
+ creates none, and a tool's project directory appears when that tool opens a session there. Re-run
23
+ `teamai init <repo> --agent <tool>` to add the tool and fill it now.
21
24
  2. **Sync manually to confirm:**
22
25
  ```bash
23
26
  teamai pull
@@ -28,8 +31,22 @@ This is the #1 onboarding issue. In order:
28
31
  ```bash
29
32
  teamai hooks inject
30
33
  ```
31
- 4. **Wrong scope?** Project-scope hooks are written to your HOME tool settings
32
- (e.g. `~/.claude/settings.json`), not the project folder — that is intentional.
34
+ 4. **Wrong scope?** Project-scope built-in hooks are written to your HOME tool
35
+ settings (e.g. `~/.claude/settings.json`), not the project folder; the team's own
36
+ hooks for Claude Code and Codex go to the main checkout
37
+ (`.claude/settings.local.json`, `.codex/hooks.json`). That is intentional.
38
+ Existing Claude/Codex main-checkout hook files count as installed targets
39
+ even when HOME and current worktree tool roots are missing. Injection and
40
+ pull update team hooks and restore HOME built-ins; removal clears managed
41
+ main-checkout hooks without recreating HOME roots.
42
+ If Git-hook installation fails after writing agent hooks, `hooks inject`,
43
+ `init` and self-repo bootstrap still attempt Codex trust. Injection preserves
44
+ the installation error without reporting overall success. Init reports the
45
+ error and retains exit code 1 while completing local setup, including HTTP
46
+ initialization. Bootstrap records the error in the debug log and continues
47
+ local setup.
48
+ In project scope, `teamai hooks remove` preserves other projects' gated team
49
+ hooks in HOME, while removing the shared built-in hooks.
33
50
  If you initialized project scope but expected machine-wide resources, re-run
34
51
  with `--scope user`.
35
52
  5. **Tool has no hook surface** (e.g. Gemini CLI, JoyCode): there is no auto-sync;
@@ -65,6 +82,34 @@ This is the #1 onboarding issue. In order:
65
82
  `recall` refuses the same way with `Nothing was searched: <file>: <reason>`:
66
83
  no team knowledge was searched, so do not report that the team has none.
67
84
 
85
+ ## "Last git hook run failed: ..." / a new worktree lacks team resources
86
+
87
+ In project scope, teamai's git hook syncs on `git worktree add` and `git pull`
88
+ silently and always exits 0, so its failures surface only here: `teamai doctor`
89
+ names the last one with its fix, and the next interactive `teamai pull` says it
90
+ once. The causes are a team repo fetch that failed or hit the 5 s post-merge
91
+ cap without the background pull finishing it, and another teamai process
92
+ holding the project's sync lock longer than the hook waits, or incomplete resource,
93
+ hook or MCP delivery. Only a complete startup sync clears the recorded failure.
94
+ Run `teamai pull`
95
+ in the checkout (after a stuck pull ends, or once the team repo is reachable);
96
+ `~/.teamai/debug.log` has the details. If doctor reports `Git hook syncs new
97
+ worktrees and git pull` as failing, follow its fix: `teamai pull` installs it.
98
+ Git older than 2.54 has no config hooks: teamai then adds a marked block to
99
+ `.git/hooks/post-checkout` and `post-merge`, unless `core.hooksPath` is set (or a
100
+ hook there is a symlink or not an executable shell script), in which case doctor's fix says to upgrade Git
101
+ or, if the team agrees, to commit its guarded `command -v teamai ... || true`
102
+ line into the manager's post-checkout and post-merge hooks.
103
+ Existing hook contents and permissions stay unchanged; read/write errors propagate
104
+ from `init` and `hooks inject`, and Git-started pulls record them. An unreadable
105
+ project config prevents sync and keeps its reason in `~/.teamai/debug.log`.
106
+
107
+ Hosts that skip checkout hooks need `teamai pull` in the new checkout before the AI
108
+ tool starts. For Codex CLI 0.160.0, use `git worktree add`, run `teamai pull` there, then
109
+ launch `codex exec -C <worktree>`. Its native `codex exec --worktree` path creates
110
+ the checkout without `post-checkout`, so SessionStart sync arrives after startup
111
+ discovery.
112
+
68
113
  ## "KEY is not set. Run `teamai env set KEY`"
69
114
 
70
115
  `pull`, `teamai mcp list`, `teamai env list`, `teamai doctor` and
@@ -142,8 +187,9 @@ broken machine):
142
187
  | Tool | Hooks status | Why |
143
188
  |-----------------------|---------------------------|---------------------------------------------------------------------|
144
189
  | Claude Code (`claude`)| Installed | Fully supported — this is the main, working path |
145
- | Codex | Written but **trust-gated** or skipped | Codex gates non-managed hooks behind an explicit trust step; `teamai doctor` prints a reminder to trust them |
146
- | Cursor | Often not written | Uses its own hook mechanism; broader CLI support is still pending |
190
+ | Codex | Installed and trusted | Codex runs only trusted hooks; teamai trusts the ones it writes through `codex app-server`, and `teamai doctor` names any Codex will not run |
191
+ | Cursor | Installed | Also runs `~/.claude/settings.json`. That copy exits only when `~/.cursor/hooks.json` or the project `.cursor/hooks.json` contains `--tool cursor` |
192
+ | Copilot CLI | Installed in self mode | Also runs a trusted project's `.claude/settings.json`. That copy exits only when `.github/hooks/teamai.json` contains `--tool copilot`. `COPILOT_CLI` alone does not skip |
147
193
  | CodeBuddy / WorkBuddy | Installed | Claude-format hooks in their own `settings.json` |
148
194
 
149
195
  Practical rule: if you set up with `--agent claude`, expect **only** Claude to show
@@ -160,17 +206,31 @@ step — do not assume auto-sync just works.
160
206
 
161
207
  ### Codex
162
208
 
163
- Codex gates non-managed hooks behind an explicit **trust** step. `teamai init` /
164
- `teamai hooks inject` may write the hooks, but Codex won't run them until the user
165
- trusts them (`teamai doctor` prints a reminder when it detects this). Guide the
166
- user to trust the teamai hooks in Codex, then reopen a session. Until then, run
167
- `teamai pull` manually.
209
+ Codex runs a non-managed hook only once it is **trusted**. `teamai init`, `pull`
210
+ and `teamai hooks inject` trust the hooks they write (and, in a project, the main
211
+ checkout, or the current worktree for a bare repository) through `codex app-server`.
212
+ Trust written by a session-start pull applies from the next Codex session. `teamai doctor` names any teamai hook Codex will not
213
+ run. Then: run `teamai pull`; if `codex` is not on PATH or `codexTrustEnabled: false`
214
+ is set in `config.yaml`, guide the user to trust the teamai hooks in Codex `/hooks`,
215
+ then reopen a session. A new linked worktree gets the team hooks from its second
216
+ Codex session (the first creates its `.codex/`). Member hooks with the same command
217
+ are preserved and remain untouched by automatic trust. Codex ownership uses the
218
+ recorded event, position and complete entry. A moved entry is recovered only by a
219
+ unique full-definition match. Legacy records recover only a unique event, matcher
220
+ and command match; `timeout` and `additionalContextLimit` were not recorded.
221
+ Pre-#370 project Codex ownership is imported from the main checkout's
222
+ `.teamai/managed-hooks.json` before reconciliation or direct removal.
223
+ Unrecorded or ambiguous legacy team-hook copies are preserved. Project hook paths follow `toolPaths`;
224
+ Claude uses `settings.local.json` beside its configured settings file. A custom
225
+ Codex path that Codex does not load is reported as `not loaded` by doctor.
168
226
 
169
227
  ### Cursor
170
228
 
171
- Cursor uses its own hook mechanism and may not receive teamai's hooks yet. If
172
- `teamai hooks list` shows Cursor without hooks, treat it as a manual-sync tool: run
173
- `teamai pull` at the start of each session.
229
+ Cursor writes hooks to `~/.cursor/hooks.json` and also runs `~/.claude/settings.json`. `hook-dispatch --tool claude` and team hook commands written for `claude` exit only when `CURSOR_VERSION` is set and `~/.cursor/hooks.json` or `$CURSOR_PROJECT_DIR/.cursor/hooks.json` contains `--tool cursor`. A setup with only Claude has no second copy, so those hooks still run inside Cursor. Claude Code does not set `CURSOR_VERSION`. An already installed team hook picks up the guard on the next `teamai pull` or `teamai hooks inject`. If `teamai hooks list` shows Cursor without hooks, run `teamai pull` at the start of the session.
230
+
231
+ ### Copilot CLI
232
+
233
+ In self mode, teamai writes hooks into the project, and Copilot CLI runs a trusted project's `.claude/settings.json` as well as its own `.github/hooks/teamai.json`. `hook-dispatch --tool claude` and team hook commands written for `claude` exit only when `COPILOT_PROJECT_DIR` is set and that file contains `--tool copilot`. `COPILOT_CLI` is not a signal: Copilot sets it on every subprocess, including a Claude session started from its shell. Copilot does not run `~/.claude/settings.json`, so this duplicate does not happen outside self mode. Re-run `teamai pull` or `teamai hooks inject` so an already installed team hook picks up the guard.
174
234
 
175
235
  ### ChatGPT App
176
236
 
@@ -204,9 +264,11 @@ judge (`TEAMAI_UPVOTE_JUDGE=1`) credits that. `teamai stats` shows each recent
204
264
  session's runs, recalled docs and adopted docs. Per agent:
205
265
 
206
266
  - **Claude Code, Codex (0.134+), CodeBuddy (2.103.1+), WorkBuddy, Qoder,
207
- OpenCode**: both a recall the main agent runs and one the `teamai-recall`
208
- subagent runs are credited when the main agent opens the doc.
209
- - **Cursor, Copilot CLI, ZCode, OMP, Pi**: only a recall the main agent runs
267
+ OpenCode, OMP**: both a recall the main agent runs and one the
268
+ `teamai-recall` subagent runs are credited when the main agent opens the doc.
269
+ On OMP the subagent's recall needs the main session's file on disk, so a
270
+ `--no-session` run credits only the main agent's own recalls.
271
+ - **Cursor, Copilot CLI, ZCode, Pi**: only a recall the main agent runs
210
272
  itself. A subagent's recall is not linked to the main session, and Pi has no
211
273
  TeamAI subagent.
212
274
  - **OpenClaw, Hermes, Kiro, JoyCode**: no PostToolUse hook, so recalls never
@@ -221,3 +283,34 @@ SessionEnd, or at the next `teamai pull`.
221
283
  - `teamai status` shows exactly how local differs from the team repo.
222
284
  - Report unexpected behavior at https://github.com/Tencent/teamai-cli/issues
223
285
  with the agent name, platform, and the step that failed.
286
+
287
+ ## "Pull left an instruction file unchanged"
288
+
289
+ If pull reports incomplete TeamAI markers, it keeps the entire file unchanged.
290
+ Fix the named block so it has exactly one start marker followed by one end
291
+ marker, then run `teamai pull` again. Other files can still sync successfully.
292
+
293
+ Pull keeps retired instruction blocks until every installed tool that wrote the
294
+ file has a working replacement. Repair the named target, extension or plugin
295
+ and run `teamai pull` again. Excluded tools' current and retired files stay
296
+ unchanged and are excluded from doctor's stale-instruction check.
297
+ When a native project file retains a TeamAI block, the session hook skips that
298
+ block, including cached HTTP prompts, until cleanup succeeds. Other blocks
299
+ still reach the hook. Doctor reports malformed markers in retired files;
300
+ repair them before retrying pull.
301
+ If a block's source cannot be resolved, its old block stays even when other
302
+ blocks sync. Repair the source and pull again to complete its migration.
303
+ HTTP prompt commands verify earlier deliveries against the current prompt
304
+ before cleaning shared instructions. Older destination contents do not count;
305
+ culture and recall stay because HTTP prompt commands do not replace them.
306
+ An HTTP prompt sync that cannot clean retired blocks reports a failed ACK and
307
+ keeps its previous cache and manifest for the server's retry.
308
+ OpenClaw HTTP prompts require an existing resolved user workspace, but not an
309
+ existing `AGENTS.md`: the prompt sync creates that file and preserves personal
310
+ text already in it.
311
+
312
+ OpenCode registration saves ownership before activating a new config entry.
313
+ If the state write fails, repair the state directory's permissions and retry
314
+ `teamai pull`; the entry is not activated without its removal ownership.
315
+ If the config write fails, ownership stays available for retry. Entries the
316
+ member already listed are never claimed.
@@ -46,13 +46,17 @@ and create-repo URLs, and the per-provider caveats, and points at
46
46
  install. Let `teamai init` set up every AI tool already installed (omitting
47
47
  `--agent` gives an interactive picker; select all detected tools). **After init,
48
48
  report which agents were set up** — in the user's language, which tools now
49
- auto-start TeamAI, and which detected tools were skipped and why (e.g. Codex
50
- trust-gate, CodeBuddy design). Verify the real per-tool result with
49
+ auto-start TeamAI, which detected tools were skipped and why (e.g. CodeBuddy
50
+ design), and any installed hooks that still need trust (e.g. Codex with
51
+ automatic trust disabled or unavailable). Verify the real per-tool result with
51
52
  `teamai doctor` and `teamai hooks list`.
52
- 3. **After init, resources appear on the NEXT session.** `teamai init` injects a
53
- session-start hook that auto-runs `teamai pull`. Empty skills/rules directories
54
- right after init are normal; they fill in when the user opens a fresh session in
55
- this tool. To sync immediately, run `teamai pull`.
53
+ 3. **`teamai init` ends with a pull.** In user scope, and in project scope for each
54
+ tool named with `--agent` (or picked in init's tool picker when a person runs it
55
+ in a terminal), the team's skills, rules and MCP servers are in place when init
56
+ exits; there is no need to run `teamai pull` after it. Run from an agent shell
57
+ (no terminal), a project-scope init without `--agent` creates no tool directory: a tool's directory appears and
58
+ fills when the user opens that tool in the project. Init also injects a
59
+ session-start hook that keeps resources synced from then on.
56
60
  4. **Finish with `teamai doctor`.** Every setup or onboarding flow ends by running
57
61
  it and resolving what it reports before you call the job done.
58
62
 
@@ -126,11 +126,14 @@ section "Which tools actually get hooks".
126
126
 
127
127
  ## Step 6 — Confirm the skills actually arrived
128
128
 
129
- Team resources sync on **session start**, so they may be empty right after init.
130
- To confirm now:
129
+ `teamai init` ends with a pull, so the team's skills, rules and MCP servers are
130
+ already in place in user scope, and in project scope for each tool named with
131
+ `--agent` or picked in init's interactive tool picker. A project-scope init run
132
+ without a terminal and without `--agent` creates no tool directory; a
133
+ tool's directory fills when the user first opens that tool in the project. To
134
+ confirm:
131
135
 
132
136
  ```bash
133
- teamai pull # sync immediately
134
137
  teamai list # see the team skills / rules / docs you now have
135
138
  ```
136
139
 
@@ -134,7 +134,9 @@ teamai projects remove <id> # remove a project
134
134
 
135
135
  A member gets the union of their role resources and their active project's
136
136
  resources. Admins declare projects in `manifest/projects.yaml` with the commands
137
- above, each of which opens a PR (`--dry-run` previews). After `projects remove`,
137
+ above, each of which opens a PR. Until #971 lands and restores the guard
138
+ classification, `roles init/add/update/remove` and `projects add/update/remove`
139
+ refuse `--dry-run` before pulling the team repo. After `projects remove`,
138
140
  keep the project's content in the team repo until members have pulled: that is
139
141
  what lets their next pull clean up the copies they deployed.
140
142
 
@@ -213,8 +213,9 @@ login` run in an interactive shell (see Step 3).
213
213
  Claude Code"). Omitting `--agent` gives an interactive picker — select **every AI
214
214
  tool already installed** on the machine. Then **report back which agents were set
215
215
  up**, in the user's language: name the tools that will now auto-start TeamAI, and
216
- any detected tool that was skipped and why (e.g. Codex trust-gate,
217
- CodeBuddy/WorkBuddy by design — see the troubleshooting reference, `"$(teamai skill path core)/references/troubleshooting.md"`).
216
+ any detected tool that was skipped and why (e.g. CodeBuddy/WorkBuddy by design),
217
+ and any installed hooks that still need trust (e.g. Codex with automatic trust
218
+ disabled or unavailable). See the troubleshooting reference, `"$(teamai skill path core)/references/troubleshooting.md"`.
218
219
 
219
220
  ## Step 6 — Verify with doctor
220
221
 
@@ -266,9 +267,12 @@ carries counts + tool names only, on a separate branch of that same repo.)
266
267
  URL filled in. The `/teamai` prefix stays as-is; translate the rest:
267
268
  `/teamai Help me join my team's TeamAI, repo URL is <URL>`
268
269
  Tell them to send the URL + this line to each member.
269
- 3. Remind them (in their language): **new resources appear only after opening a
270
- fresh session** in the AI tool. Right after init the skills folder may look
271
- empty — that is expected. To sync now, run `teamai pull`.
270
+ 3. Remind them (in their language): a member's `teamai init` ends with a pull, so
271
+ the team's resources are in place when it exits (in project scope, for each
272
+ tool named with `--agent` or picked in init's tool picker; otherwise a tool's
273
+ directory fills when the
274
+ member first opens that tool in the project). Resources the team adds later
275
+ arrive at the next session start.
272
276
 
273
277
  ## Step 9 — What's next (guide them, don't just list commands)
274
278
 
@@ -14,7 +14,14 @@ machine** (all tools)?"*
14
14
 
15
15
  - **Just this tool** → `--agent <tool>` (use the tool this conversation runs in,
16
16
  e.g. `claude`). Shared resources are removed only if it is the last tool using
17
- them.
17
+ them. An instructions file several tools read (CodeBuddy and WorkBuddy share
18
+ `.codebuddy/rules/teamai-context.md`) is cleaned block by block: a teamai
19
+ block stays while a remaining tool on that file still writes it, so
20
+ `--agent workbuddy` keeps that file while CodeBuddy is installed. The team
21
+ rules in a project's `.codebuddy/rules` are shared the same way. A file an
22
+ earlier release wrote the blocks to, such as the project `AGENTS.md`, loses
23
+ its teamai blocks, since no tool reads them there now. A file teamai created
24
+ goes with its last block; one the user had before stays, even if empty.
18
25
  - **Whole machine** → no `--agent` flag.
19
26
 
20
27
  Reassure them (in their language): *"This only removes things from your computer.
@@ -23,6 +30,8 @@ Your team's repo on the website is untouched — you can rejoin any time with
23
30
 
24
31
  ## Step 2 — Run it (you run it)
25
32
 
33
+ A targeted project exclusion needs the same confirmation even when there are no local files to remove. `--dry-run` and declining confirmation leave the project config unchanged.
34
+
26
35
  Whole machine:
27
36
 
28
37
  ```bash
@@ -51,10 +60,51 @@ and give it your team repo URL."*
51
60
 
52
61
  ## Notes
53
62
 
63
+ - For OpenCode, uninstall also removes the rules globs teamai added to
64
+ `instructions` in `opencode.json`, including the relative `rules/*.md` an
65
+ earlier release wrote in user scope. In a project it removes
66
+ `.opencode/rules/**/*.md` from `.opencode/opencode.json` and the
67
+ `.opencode/rules/*.md` an earlier release wrote to the root `opencode.json`,
68
+ and deletes `.opencode/opencode.json` when nothing else is left in it.
69
+ The user's own entries stay.
70
+ - Uninstall removes the team-rules block from the file a tool with no rules
71
+ format reads in user scope (`~/.codex/AGENTS.md`, `~/.zcode/AGENTS.md`,
72
+ `$DSH_HOME/AGENTS.md`, the OpenClaw workspace `AGENTS.md`,
73
+ `~/.pi/agent/AGENTS.md`, `~/.joycode/rules.txt`), and the file when teamai
74
+ created it for the block alone.
75
+ - Uninstall cleans legacy Codex rule copies at the recorded `toolRoots`
76
+ location, including publishers' bare local filenames, and the copies earlier
77
+ releases left in a project's `.workbuddy/rules` and `.pi/rules`, in
78
+ `.openclaw/rules`, `~/.pi/agent/rules` and `~/.joycode/rules`. It keeps
79
+ edited copies and names them.
80
+ For a rule the team has
81
+ removed, it deletes the copy only if its hash matches the recorded delivery.
82
+ Without that record, it keeps the copy and names it in a warning. Save any
83
+ changes you need, then delete the copy manually.
84
+ - If an OpenCode config entry cannot be removed, repair its config or permissions
85
+ and retry the same uninstall command. Uninstall reports failure and keeps
86
+ its ownership record and shared data directory, even for the last tool.
87
+ - Project uninstall keeps the global Pi and Oh My Pi extensions, Hermes
88
+ plugin and config, and the Codex family's user-level hooks, which the user
89
+ scope, the HTTP agent or another project may use, and names them. If none
90
+ does, run `teamai hooks remove` in the project first: it removes them.
91
+ Targeted project Codex uninstall keeps project config and records its
92
+ exclusion, even without local resources. Legacy project hook copies go.
93
+ User-scope uninstall removes these global channels.
94
+ The retained adapters respect project exclusions, including cached HTTP
95
+ prompt injection and HTTP sync. An excluded tool does not download its
96
+ resources again on the next session start.
97
+ - An enabled, installed Pi, Oh My Pi, Hermes or project Codex also keeps the
98
+ project's shared state in use without a local tool directory. Uninstalling
99
+ another tool preserves that state and the remaining tool's instructions.
54
100
  - Do **not** delete the team repo on the Git platform — uninstall never touches it,
55
101
  and neither should you.
56
102
  - If the user only wants to stop auto-sync for one tool but keep TeamAI otherwise,
57
103
  that is the `--agent <tool>` form, not a full uninstall.
104
+ - In a project, uninstall also removes teamai's git hook: the
105
+ `hook.teamai-post-checkout` / `hook.teamai-post-merge` entries in the repo's git
106
+ config and the `# >>> teamai git hook` block in `.git/hooks/post-checkout` and
107
+ `post-merge`. Other hooks stay; a script left with only its shebang is deleted.
58
108
  - In a project, uninstall also takes teamai's lines out of `.git/info/exclude`
59
109
  (the `# [teamai:mcp-exclude:start]` block) for MCP configs it proves hold no
60
110
  resolved `${VAR}` value. A line names the path a write lands in: for a config