Repository navigation
feat(partition): encode the full project path into the data-home slug - #546
Merged
Merged
Conversation
Project-scope machine data lives in a partition under ~/.teamai/projects/<slug>/, but the slug prefix was only the anchor's basename (e.g. teamai-cli-<hash>), so the directory name did not reveal which project it belonged to — unlike Claude Code's ~/.claude/projects/, whose names encode the full path. Build the prefix from the WHOLE anchor path (leading separator dropped, path separators -> '-'), e.g. /Users/x/Project/app -> Users-x-Project-app-<hash>. The 16-hex sha256 suffix is unchanged, so uniqueness (escape-ambiguous paths, shared basenames) and the slug===dir corrupt check are untouched; the prefix is length-bounded so a very long path can never overflow NAME_MAX. The authoritative reverse lookup remains the per-partition 'anchor' file. Verified end-to-end with the real CLI in an isolated HOME: a partition is laid down under the readable slug, 'status --all' reverse-resolves it to the project path and reports [active], a mismatched dir name is flagged [corrupt], and detection from the project cwd loads the partition config via the new slug.
15 tasks done
jeff-r2026
added a commit
that referenced
this pull request
Sep 14, 2026
A pre-#546 partition stores repo.localPath as an ABSOLUTE path to its team-repo clone (<legacyPartition>/team-repo). resolvePartitionDir renamed the directory but left config.yaml pointing at the now-gone old path, so every later `pull` read the team config from a dead directory and silently skipped the sync ("Team config (teamai.yaml) not found. Skipping.", exit 0) — the project could never sync again after an upgrade. Adoption now rebases repo.localPath onto the new partition (mirroring migrate.ts's rebaseConfigPaths). The rewrite is idempotent and self-healing: a modern install whose localPath already sits in the canonical dir is left untouched, an external clone outside the partition is left untouched, and an adoption interrupted between the rename and the config rewrite is finished by the next command. Reproduced with the real CLI (isolated HOME, real local git team repo): a legacy-named partition + two `pull --force` runs printed "Team config not found. Skipping." (exit 0) before this fix; after it both runs print "Synced 1 skills" and localPath points at the live clone. Regression tests: localPath rebased off the legacy dir / external localPath left alone / modern-install no-op. Verified they fail when the rebase is disabled.
jeff-r2026
added a commit
that referenced
this pull request
Sep 14, 2026
…anding them (#551) * fix(partition): adopt pre-#546 legacy-named partitions instead of stranding them #546 widened the partition slug prefix from the anchor's basename to its whole path but kept the sha256 suffix — without migrating existing installs. On an upgraded CLI, a partition still named <basename>-<hash> (every install created before #546) stops matching projectSlug(anchor): detectProjectConfig finds no config (the project looks uninitialized), planMigration would re-copy a retired workspace into a second, empty partition, and status --all flags the perfectly good data as "corrupt — dir name does not match anchor". Both formats share the same hash, so an anchor's legacy name is computable exactly — no directory scanning. resolvePartitionDir becomes the seam for "the partition that actually holds this project's data" (detection, init, migration): when the canonical current-format directory is absent and a legacy-named one exists, it ATOMICALLY RENAMES the legacy partition into place — a same-parent metadata move, no data copied, and an interruption leaves either name intact. An authoritative current-format partition is never clobbered by a leftover legacy one; a rename that is genuinely impossible (read-only home) keeps serving the legacy directory so no data is stranded. status --all stays read-only and reports a legacy-named partition as "active (legacy name; renamed automatically on next command)" instead of corrupt. Verified end-to-end with the real CLI in an isolated HOME: a legacy .teamai migrates into the readable whole-path slug; status --all reverse-resolves it as [active]; a partition renamed to the pre-#546 format is reported active-legacy (no rename, no corrupt), then adopted by the next command (detection) with data intact, and pull runs through the adopted partition. * fix(partition): rebase repo.localPath when adopting a legacy partition A pre-#546 partition stores repo.localPath as an ABSOLUTE path to its team-repo clone (<legacyPartition>/team-repo). resolvePartitionDir renamed the directory but left config.yaml pointing at the now-gone old path, so every later `pull` read the team config from a dead directory and silently skipped the sync ("Team config (teamai.yaml) not found. Skipping.", exit 0) — the project could never sync again after an upgrade. Adoption now rebases repo.localPath onto the new partition (mirroring migrate.ts's rebaseConfigPaths). The rewrite is idempotent and self-healing: a modern install whose localPath already sits in the canonical dir is left untouched, an external clone outside the partition is left untouched, and an adoption interrupted between the rename and the config rewrite is finished by the next command. Reproduced with the real CLI (isolated HOME, real local git team repo): a legacy-named partition + two `pull --force` runs printed "Team config not found. Skipping." (exit 0) before this fix; after it both runs print "Synced 1 skills" and localPath points at the live clone. Regression tests: localPath rebased off the legacy dir / external localPath left alone / modern-install no-op. Verified they fail when the rebase is disabled. * fix(partition): write the adopted config.yaml atomically to prevent truncation The localPath rebase overwrote config.yaml with a plain (non-atomic) write. By that point the legacy partition has already been renamed away, so config.yaml is the partition's ONLY copy — a write that fails partway (ENOSPC, EFBIG, crash mid-write) truncates it with no source to recover from, and the CLI still prints "Your original data is unchanged, re-run to retry" while the data is in fact corrupt and cannot self-recover. Add writeFileAtomic (same-dir temp + rename, preserving mode) alongside the existing writeJsonAtomic, and use it for the adopted config.yaml. rename(2) is atomic, so a failed write removes the temp file and leaves the original config.yaml byte-for-byte intact; the next command retries the idempotent rebase and converges. Reproduced with the real CLI (isolated HOME, real local git team repo, NO fs mock) by injecting a write failure with RLIMIT_FSIZE=128: before: pull --force reports EFBIG, config.yaml truncated 453 -> 128 bytes, legacy partition already moved, retry after lifting the limit exits 0 but never syncs and cannot recover after: config.yaml preserved at 453 bytes, retry after lifting the limit prints "Synced 1 skills" and localPath points at the live clone Regression test: the localPath rewrite failing mid-write leaves config.yaml intact with no leftover temp file. Verified it fails when the write is made non-atomic. Full suite: 3109 passed, 0 regressions; tsc clean.
SaulMoro
added a commit
to SaulMoro/teamai-cli
that referenced
this pull request
Sep 26, 2026
… partition adoption under --dry-run (Tencent#836) detectProjectConfig now takes the { dryRun } load option that roles set, tags subscribe and tags unsubscribe already pass. Under it, a fresh self-mode clone gets the config bootstrapSelfRepo would write, kept in memory (previewSelfBootstrap), and a pre-Tencent#546 partition is read where it is instead of being renamed. One test hashes HOME, the project (with .git) and state.json around each command on three fixtures.
jeff-r2026
pushed a commit
that referenced
this pull request
Sep 26, 2026
…list (#836) (#837) * fix(tags,roles): honor --dry-run in tags subscribe, tags unsubscribe and roles set (#836) The three commands saved the local config and reset lastPullRev even under the global --dry-run, which is documented as "Preview mode, no changes made". Their siblings (tags add/remove, roles init/add/remove/ update) already return early with a [dry-run] message. The roles set preview names the additional roles it would save, including none, because a real run replaces the existing list. oxlint reported the unused options parameter in tagsSubscribe and tagsUnsubscribe; rolesSet has the same bug but reads options.add. * fix(tags): count namespaced skills in tags list (#836) The "N skill(s) have no tags and are always synced" hint counted the top-level directories under skills/, so a namespace counted as one skill and its skills were not counted at all. It also subtracted the number of tags.yaml entries instead of checking which skills have tags. Count the untagged skills among those pull delivers, using pull's own resolver (resolveDesiredSkills with the member's role context). Pull delivers every skill in the member's namespaces, all of them without roles, whatever its tags; tags only add skills from elsewhere. So roles, exclusions and a name held by both the root and a namespace are counted the way pull counts them. * fix(tags): address review — warn instead of aborting tags list on a malformed manifest (#836) * fix(tags,roles): address review — keep the legacy role migration in memory under --dry-run (#836) * fix(tags,roles): address review — preview the self-mode bootstrap and partition adoption under --dry-run (#836) detectProjectConfig now takes the { dryRun } load option that roles set, tags subscribe and tags unsubscribe already pass. Under it, a fresh self-mode clone gets the config bootstrapSelfRepo would write, kept in memory (previewSelfBootstrap), and a pre-#546 partition is read where it is instead of being renamed. One test hashes HOME, the project (with .git) and state.json around each command on three fixtures. * fix(bootstrap): address review — make no provider auth call in the --dry-run bootstrap preview (#836)
jeff-r2026
pushed a commit
that referenced
this pull request
Sep 27, 2026
…on save and recall use (#853) #837 threaded LoadOptions through the config loaders, and #850 fixes the three commands that still reach them bare (pull, push, status). Three more commands load their config before their own dry-run guard and pass nothing: - contribute (--scope project loads, then --scope user / auto-detect) - session save (same three branches) - recall (detection, the inherited user scope, and the user branch) On a config pending the legacy role migration each of them rewrote ~/.teamai/config.yaml under --dry-run, printing the migration line without any [dry-run] marker; the auto-detect and project branches can also adopt a pre-#546 partition and run the single-repo self-heal bootstrap. loadLocalConfigForScope is the loader #837 missed: it now takes LoadOptions and forwards them to detectProjectConfig and both migrateLegacyRoleConfig calls. Callers that pass nothing behave as before — a real run still migrates in place. Co-authored-by: ydflow <[email protected]>
jeff-r2026
pushed a commit
that referenced
this pull request
Sep 28, 2026
…s and list use (#866) * fix(dry-run): thread { dryRun } through the loaders pull, push, status and list use `--dry-run` is documented as previewing without making changes, and #837 made that true for `tags subscribe`, `tags unsubscribe` and `roles set`. `pull`, `push` and `status` still wrote: each runs its scope-detection block before any dry-run guard, and that block called config loaders that were never given the flag. A preview could therefore persist the legacy role migration, and in a git repo adopt a pre-#546 partition or run the single-repo self-heal bootstrap. The loaders already take LoadOptions — #853 threaded them through `loadLocalConfigForScope` for contribute / session save / recall. These commands simply did not supply the flag. - pull.ts: both loaders take { dryRun: options.dryRun }. - push.ts: autoDetectInit takes it. - status.ts and list: { dryRun: true } unconditionally, because both are read-only and should never migrate, adopt a partition or bootstrap. Callers that pass nothing behave as before, the same compatibility promise #837 made. The one observable change is that the preview path logs, so `status`/`list` now surface a "[dry-run] Would ..." line where a migration or bootstrap is pending; the PR description asks for a decision on that label. Verification: seven new command-level cases, each failing on unmodified main with the identical test file (the project-scope three need a git project with a pre-#546 partition name, which the existing user-scope fixture never reaches); and the issue's own real-CLI reproduction, 6/6 — the control writes the reported fields, this change writes nothing. oxlint --deny-warnings and tsc --noEmit: rc=0 here and rc=0 on unmodified main. Closes #850 * fix(pull,push): a --dry-run must leave a fresh self-mode clone alone Resolves both P1 findings on this PR. pull.ts:1891 - the previewed self-mode config reached lockScope(), whose acquireLock() calls ensureDir() on the lock's parent. On a fresh clone the partition does not exist yet, so the directory was created and stayed: releaseLock removes the lock file, not its parent. The guard sits inside lockScope(), the one choke point all three call sites share. push.ts:731 - the same previewed config ran the whole self-mode setup before pushCore reached its own dry-run guard at push.ts:1577: the sync-lock, migrateSelfModeGitignore(), and the disposable knowledge worktree. Both guards are deliberately narrow. A blanket early return before the git-mode branch would also skip resetToCleanMaster/pullRepo (push.ts:934), which a dry run performs on purpose so it can name the destination the real command would use. Only writes that outlive the command are gated. The preview still reads the uncommitted teamai.yaml that pushCore receives as initialPendingTeamConfig; that block is now pendingSelfTeamConfig(), the identical read, so the preview keeps describing the config edit it exists to describe. Fixture gap, also flagged: dry-run-load-path.test.ts already had a fresh-self-mode-clone fixture, but only tags/roles ran against it. pull and push ran at user scope, or on a project partition that already exists - never on the one shape where acquireLock has something new to create. Two cases added there; the unfixed tree fails them at fs.existsSync(<HOME>/.teamai/projects) with "expected true to be false". Not fixed here, and named in the PR description: pull --dry-run on a fresh clone still creates an empty <HOME>/.teamai/locks/, via listPendingForInstall in utils/pending-learnings.ts. That call is unchanged by this PR and the file is outside its scope; the test declares and counts the entry, so anything else appearing still fails. * test(pull): pin the loader call shape the widened signature produces Fixes the red Lint & Test on the previous head (all four matrix entries). pull-scope-isolation.test.ts asserted the exact argument list of loadLocalConfigForScope, which this change widens to carry LoadOptions: expect(loadLocalConfigForScope).toHaveBeenCalledWith('user'); received ['user', undefined, { dryRun: undefined }] The shape is not a free choice: recall.ts:464 and recall.ts:515 already pass the same third argument, landed with #853, so pull.ts matches the merged precedent. recall-scope-isolation.test.ts never asserts the argument list, which is why the same change left it green. The affected set is derived from the changed symbols rather than from the topic: every test file that mentions loadLocalConfigForScope, detectProjectConfig or autoDetectInit (76 files, 1221 tests). * fix(update): a --dry-run asks the lock for its state instead of taking it `acquireLock` is not a read. It `ensureDir`s the lock's parent, which on a fresh self-mode clone is a `<getDataHome>` partition that does not exist yet — and `releaseLock` removes the lock FILE, not that directory, so the directory outlives the command. Any preview that calls it therefore writes, which is the defect this PR is about (#866). The new `options.dryRun` returns what the preview actually owes its caller: the ANSWER the real run would get. `lockState` already separates `live` (a holder is running) from `stale` and `missing`, and the real run reclaims either of the latter and wins, so `acquireLock(path, { dryRun: true })` is exactly that verdict — no mkdir, no lock file, no reclaim sentinel. Nothing is recorded in `heldLockOwners`, which is what makes the preview safe alongside the existing `releaseLock` calls: it returns at its first line when it holds no owner token for the path, so a preview cannot delete a lock another process owns. No caller passes `dryRun` yet; this commit is the primitive only. * fix(pull,push): acquire the preview's locks read-only, and stop hiding what it reports Supersedes the guards added in cfd7c57. Those guards stopped the writes, and E2E (fork-safe) caught what they cost — 6 failures in push-sync-followups-823.test.ts, all of the same shape: expected '- Scanning local resources...\nNo new or modified resources to push' to contain '[rules] teamai-rule (modified)' A preview that reports no changes for a tree with a deliberately edited team rule is not a conservative preview; it is this PR's own defect with the sign flipped. pull.ts — `lockScope()` returned `true` outright for a dry run, asserting the scope was uncontended. That is a fabricated fact: its callers read `true` as "you hold the lock". It now acquires through the read-only primitive and records the lock for release only when it really took one, so a scope with a live holder is reported as contended and skipped, exactly as a real pull does. push.ts — the self-mode branch returned early for a dry run. Two of the three things it skipped are right to skip and one is not. - the sync-lock: read-only now, at both push.ts:784 (self) and push.ts:839 (git mode). - `migrateSelfModeGitignore()`: still skipped. It rewrites a tracked file in the user's ACTIVE tree, which outlives the preview, and it is idempotent, so the next real push performs it. - the knowledge worktree: MUST run, and that is the correction. `pushCore` adds the active tree's `.teamai/{skills,rules}` as scan sources and diffs them against `localConfig.repo.localPath` (push.ts:1095-1112) — the clean worktree checkout. Outside the worktree those are the same path in self mode, so the diff is empty by construction: skipping the worktree does not report an edit early, it hides the edit. `withKnowledgeWorktree` already removes it in a `finally`, so it stays disposable. Fixture — `push --dry-run` now performs its `git fetch` for real, which leaves `app/.git/FETCH_HEAD` behind. Declared and counted next to the existing `<getDataHome>/locks/` entry, so any OTHER new entry still fails the case.
SaulMoro
added a commit
to SaulMoro/teamai-cli
that referenced
this pull request
Sep 28, 2026
…Tencent#866) Tencent#866 threaded { dryRun } through the loaders pull, push, status and list use. The scope lookups this branch added did not take it, so `teamai --dry-run env list|set|unset|add|remove` and `env exec --dry-run` still persisted the legacy role migration, adopted a pre-Tencent#546 partition or ran the self-mode bootstrap. - resolveConfigForDir takes LoadOptions and passes them to both loaders. - scopeHere/requireScope (env commands) and commandEnvironment (env exec) forward options.dryRun. Without the flag nothing changes: env exec still runs the migrations every command runs (spec Tencent#879 Conflict 12). Five cases added to dry-run-load-path.test.ts; each failed before this change (config.yaml rewritten, partition renamed).
This was referenced Sep 29, 2026
jeff-r2026
pushed a commit
that referenced
this pull request
Sep 29, 2026
…igrations (#893) (#901) * fix(dry-run): load mcp inject and mcp list without persisting a migration (#893) mcp inject loaded its scope bare, so --dry-run still saved a pending role migration, partition rename or self-mode bootstrap. It now forwards dryRun; mcp list is read-only and loads with dryRun: true unconditionally, as status and list do since #866. * fix(dry-run): forward dryRun to the loader in roles init/add/remove/update (#893) roles list is read-only and loads with dryRun: true unconditionally. * fix(dry-run): forward dryRun to the loader in projects add/update/remove (#893) projects list and projects members are read-only and load with dryRun: true. * fix(dry-run): forward dryRun to the loader in tags add/remove (#893) tags list is read-only and loads with dryRun: true. * fix(dry-run): forward dryRun to the loader in source add/remove/add-http (#893) source list and source browse are read-only and load with dryRun: true. source list also reached a second bare load through loadLocalAgentConfig, whose HTTP backfill reads only repo.kind and repo.url; it now loads with dryRun: true, and the migration persists on the next command that writes. * fix(dry-run): forward dryRun to the loader in remove and uninstall (#893) * fix(dry-run): forward dryRun to the loader in packages install (#893) * fix(dry-run): forward dryRun to the loader in import --from-iwiki/mr/claude/repo (#893) --from-repo-list and --from-org reach the same load through importFromRepo. * fix(dry-run): forward dryRun to the codebase loader; --lint and --status load read-only (#893) * fix(dry-run): forward dryRun to the loader in models switch; models list loads read-only (#893) * fix(dry-run): load read-only commands without persisting a migration (#893) hooks list, members, exclude list, recall status and doctor load with dryRun: true unconditionally, as status and list do since #866. * docs(designs): name which commands take the dry-run detection path (#893) * test(dry-run): pin that every loader on a dry-run or read-only path migrates nothing (#893) LOAD_ONLY_COMMANDS gains the read-only commands and the previews that stay clean on the legacy-role fixture. PREVIEWS covers the commands that fail past the loader on that fixture: it asserts only config.yaml, with the same call without --dry-run as the positive control that the load is on the path. * fix(dry-run): forward dryRun through resolveMemberToolRoots for import --from-claude (#893) scanCandidates resolves Claude's tool root before the loader import.ts already fixed, through a bare load in resolveMemberToolRoots, so the dry run still saved the migration. resolveConfigForDir and findUnreadableProjectConfig take the same optional LoadOptions for the read-only callers below; hook and usage callers pass nothing and behave as before. * fix(dry-run): pass dryRun into loadLocalAgentConfig instead of forcing it (#893) Forcing dryRun there made real hook runs print the [dry-run] migration preview and stop persisting it. source list now passes it through describeLocalAgent; every other caller is unchanged. source add-http forwards { dryRun: options.dryRun } like the rest of the file. * fix(dry-run): load skill list/show, webhook list, stats and digest read-only (#893) detectTeam takes optional LoadOptions; the Stop-hook share gate passes none. * docs(designs): name read-only commands by example, not as every list subcommand (#893) * test(dry-run): prove each row reached the load, and cover the remaining changed sites (#893) Every dry-run row now asserts the loader logged its migration preview, so an early return cannot pass. Adds source browse, codebase --lint, skill list/show, webhook list, digest, projects update/remove, import --from-claude, and a config-only table for members, projects members and stats. * fix(dry-run): keep the pre-command migration from adopting a partition on a dry run (#893) The preAction hook passes dryRun to maybeMigrate, but planMigration and queueKeptInCheckout resolved the partition bare, so pull/push --dry-run still renamed a pre-#546 partition. Both now take the option. * fix(dry-run): load skill get/path read-only through the share gate (#893) blockReason fell back to shareGate(), a bare load, when no team was passed; only skill get, skill path and the catalog reach that fallback. The Stop hook still asks shareGate directly and is unchanged. * refactor(dry-run): give loadWebhookConfig the option instead of copying its branch (#893) Also note in loadLocalAgentConfig that dryRun covers only its config.yaml load. * revert(dry-run): leave stats out of this change (#893) stats also loads bare per session through the dashboard scope helpers on the pull/report path; a partial fix would claim more than it does. Tracked in the follow-up issue with the other dry-run gaps. * test(dry-run): cover the pre-command migration and skill get/path share (#893) * refactor(dry-run): give shareGate the option instead of repeating it in blockReason (#893) Also correct the test comment on when the pre-command migration runs. * fix(dry-run): keep loadLocalAgentConfig from writing config.json under dryRun (#893) The option reached only the config.yaml load. The legacy group-binding cleanup, the binding-key canonicalization and the HTTP backfill still saved config.json, so `teamai source list` could rewrite or create it. Under dryRun they now stay in memory, and the cleanup prints a `[dry-run] Would remove` preview instead of `Removed`. * fix(dry-run): keep models list from saving a re-bound beta key (#893) models list loaded the scope read-only but read the team keys through loadTeamValues without the option, so a key a 0.26.0 beta stored under the profile id alone was bound to its gateway and the values file rewritten. It now binds the key in memory only; the next write command saves it.
jeff-r2026
pushed a commit
that referenced
this pull request
Sep 30, 2026
* refactor(entries): let a namespaced entry reader declare its own layout (#879) An entry reader took its directory, file name, activation key and failure wording from its EntryType. It can now declare them as an EntryLayout, defaulting to entryLayout(type), which gives today's values. This lets a later reader read env/secrets.yaml and env/<ns>/secrets.yaml activated by resources.env. No behaviour change: env, hooks, MCP and models resolve and report as before. Part of #875. * refactor(models): share the team values path and stdin reader with a second store getTeamValuesPath takes the store directory (defaulting to models/teams) and keeps its <team>-<hash>.json naming. The piped-stdin reader moves to utils/prompt.ts as readStdin; the --api-key-stdin checks and messages stay in the models command. No behaviour change. Refs #879 (S2), #875 * feat(env): declare team secrets in env/secrets.yaml and show their state (#879) A team repo can declare the secrets its members need, with no value, in env/secrets.yaml and env/<ns>/secrets.yaml (key, optional description and url). They resolve like env.yaml: active through resources.env, a namespace entry replaces the root entry with the same key. The declarations are absent, valid or failed; a broken file fails the secrets only, is reported in secret wording by pull, env list and doctor, and env variables are still delivered. - env list and list env show each declared secret as environment or missing, never its value, --reveal included. - doctor fails "Team secrets can be resolved" on a broken file, and its notes name env/secrets.yaml, not env/env.yaml, for an override or a key repeated in legacy mode (describeEntryNotes takes the reader's layout). - push lists a changed secrets.yaml, in single-repo mode too. - docs/designs/team-secrets.md and .zh-CN.md start here, with the #818 boundary; usage guide, product overview, multi-project, management backend and the admin reference updated. Part of #875. * feat(env): declare a team secret with env add --secret (#879) env add <key> [value] --secret [-d] [--url] [--role|--project] writes env/secrets.yaml or env/<ns>/secrets.yaml with no value; a value is rejected and never printed. env remove removes a declared secret when env.yaml does not set the key, and --secret removes only the declaration for a key both files carry. entryNamespaceFromFlags takes a layout so the --role warning names secrets.yaml. * feat(mcp): keep the entry an earlier pull wrote when a declared secret is missing (#879) The session-start pull inherits the agent's environment, which often lacks the member's shell export, so it removed the MCP entry the interactive pull had written. A server whose only missing variables are declared secrets now keeps its entry and ownership record; it is removed when it leaves mcp.yaml or by removeAll. A failed secrets declaration keeps managed MCP state. * feat(env): keep a member's value for a team secret and resolve it in MCP servers (#879) teamai env set KEY (hidden prompt, --stdin, --from-env VAR) and env unset KEY store a member's value per team repo in ~/.teamai/secrets/teams/, 0600, accepting only keys the scope declares as secrets. ${VAR} in MCP servers resolves a declared secret from that value, then from the member's own environment, which leaves out values a teamai env.sh exported (Conflict 10). A key declared as a secret and set in env.yaml resolves as the secret: its repo value leaves env.sh, the env backup, both list renderers and doctor's expected set (Conflict 13). A failed declaration leaves env.sh and the backup as they are (Conflict 14). env list shows team. * docs(env): document team secret values, storage and MCP resolution (#879) * feat(env): set one value for a team secret for every team on the machine (#879) env set/unset --global keep the value in ~/.teamai/secrets/machine.json. Resolution becomes team value > machine value > the member's environment, for MCP servers and env list (state `global`). In a scope --global still accepts only a declared secret; outside any scope it accepts any valid key and notes that no team declares it yet. * docs(env): document the machine value for team secrets (#879) * feat(mcp): keep project MCP configs with resolved values out of git (#882) A project-scope MCP config that carries a resolved ${VAR} sat untracked and unignored in the business repo, one `git add -A` from committing the token. After the reconcile writes such a file and git would track it, teamai lists its path in the clone's .git/info/exclude inside a marked block (resolved via `git rev-parse --git-path`, so linked worktrees and submodules work). The committed .gitignore is never touched; an ignored path or a config with no resolved value adds nothing; dry runs write nothing. Project-scope uninstall removes only teamai's block, and doctor reports such a file git would still commit. The hook sits after the appliers in reconcileMcpForConfig, outside desiredMcpForTarget/applyJson/applyCodex, so it merges cleanly with #880. * feat(env): name a missing team secret and the command that sets it (#879) Interactive pull, mcp list, env list and doctor print one line per declared secret with no value, naming the MCP servers that use it, `teamai env set KEY` and the declared url. doctor prints it as a note and no longer fails the MCP delivery check for a server skipped only for a missing declared secret. Pull and doctor also note a kept entry that may hold an old value and a key declared as a secret and set in env.yaml. The silent pull prints nothing. The lines come from one envAdvisories() result that later pull notices extend. * docs(env): document the missing-secret advisory in pull, doctor and the lists (#879) * fix(uninstall): count the .git/info/exclude block in the removal plan (#882) The plan now records whether the project's .git/info/exclude holds teamai's MCP config block (gitExcludeBlock). It counts toward isPlanEmpty, is listed in the summary and dry run, and gates the removal, so a plan whose only teamai leftover is the block removes it instead of reporting "Nothing to uninstall". * feat(env): run a command with the directory's team env and secrets via env exec (#879) * docs(env): document env exec, what the command can reach and the ANTHROPIC_* caveat (#879) * fix(tests): isolate Claude config dir from model tests (cherry picked from commit e567ac3) * fix(env): warn when env add --secret updates a declaration an unknown key keeps undeclared (#879) * feat(env): tell agents at session start which team secrets exist and to run their CLIs through env exec (#879) * docs(env): teach agents to use team secrets through env exec and leave values to the member (#879) * feat(env): resolve plain env variables in one order, with a member override (#879) The environment no longer overrides an env.yaml variable in MCP servers, env exec or env.sh. A member sets their value for a team with `teamai env set KEY`; an interactive pull and doctor say when an export differs and is ignored. env.sh exports a literal override and leaves out a --from-env one; doctor's env delivery check expects the same. * docs(env): document the variable order and the member override (#879) * fix(mcp): keep the exclude block until every MCP config is clean (#882) - uninstall keeps a repository's .git/info/exclude block while a config in it could not be parsed and still holds teamai servers, and warns - uninstall finds and removes the block in nested repositories holding an MCP config, across every worktree - the block opens at the last start marker, so an orphaned start never pairs with a later block's end and takes the member's lines - doctor counts only servers the ownership manifest records, not a member's own server under a team name * fix(env): discount an old env.sh export in every later command (#879) A shell opened before a pull keeps the values env.sh exported then. Only the process that rewrote env.sh discounted them, so the next command read the team's old token as the member's own (Conflict 10). Each env.sh now keeps env.sh.exports.json beside it: SHA-256 of KEY=VALUE for the last 20 values per key, mode 0600, never a value. memberEnvironment discounts any recorded export, which replaces the in-memory snapshot. * fix(uninstall): remove the exclude block only once its files are proven clean (#882) A missing or unreadable managed-mcp.json made the MCP cleanup return early without reporting anything, so uninstall removed the block while .mcp.json still held the resolved token. Uninstall now inspects every path the block protects after the cleanup. The block goes only when each one is missing, or parses and holds none of the team's servers that need a resolved ${VAR}. Anything it cannot check keeps the block, with a warning naming the file. This replaces the leftInPlace report from the reconcile, which the check subsumes. * fix(mcp): protect every project MCP config holding a resolved value (#882) Pull, doctor and uninstall each skipped a case they had not inspected and treated it as safe. Now: - pull lists a config in .git/info/exclude whether or not it delivered to it this run: a disabled or undetected tool's file, a team with automatic delivery off, an unreadable mcp.yaml (any teamai entry counts), a failed write to another tool's config, and a lost ownership manifest (the resolved value found in the file) - doctor checks the same files, including one that does not parse, and counts a git error as a failure - git check-ignore failing inside a repository is no longer read as "not tracked": the path is excluded anyway, or teamai warns with git's error - uninstall also keeps the block while a file contains the value (8+ characters, not a path or the login name) of a variable still set in the environment, which finds a server since dropped from mcp.yaml * refactor(env): resolve a scope's env once per command (#879) resolveTeamEnv (src/env-resolution.ts) reads env.yaml, secrets.yaml, both value stores and the env.sh exports once. buildVarTable, the MCP reconcile, envAdvisories, env exec, doctor and pull take that result: an interactive pull resolves once per scope in its env stage and reuses it for MCP and the advisories (was up to four secrets.yaml reads). - Variable and secret values move out of resources/secrets.ts, which now holds declarations only (R3); one StoreResolution<V> and storeEntry (R2); resolveSecretDeclarations takes { active } instead of a tri-state array (R4); reportMissingSecrets lives in env-advisories (X1). - ENV_KEY_RE moves to resources/env-key.ts, so env.ts imports SECRETS_LAYOUT statically (EV1). - env list and `teamai list env` print one listing (env-listing.ts); a variable shows the value it resolves to and its source, team or env.yaml, like a secret (S1). - A failed declaration is never "no secrets": the listings show no variable value then, --reveal included, and a server skipped for a missing variable is kept (S2). - SecretState gains `unreadable` for a store that can't be read, handled with a never check (R1). * fix(mcp): mcp list reports a broken secrets.yaml and exits 1 (#879) A failed declaration read as no secrets, so every server variable came from the raw environment, another team's token included, and mcp list said 'all set' while pull kept MCP frozen. It now names the file, exits 1, and shows a server's variables as 'not resolved' (Conflict 14, C3). * fix(env): env commands outside a scope say so and exit 1 (#879) env list, add, remove, set and unset threw NotInitializedError with a stack trace outside any teamai scope. They now print its message and exit 1; env set/unset --global still work there. * fix(env): env exec refuses a command without -- before it (#879) Commander drops --, so `teamai env exec gh pr list --dry-run` read the command's flag as teamai's and ran nothing. env exec now takes what was typed after `exec`, and without -- before the command it says "Put -- before the command: teamai env exec -- <command>" and exits 2. teamai's own options may still come before --. * feat(doctor): check that the member's secret values can be read (#879) While teams/<team>.json or machine.json can't be read, every secret has no value and MCP keeps what the last pull wrote, yet the MCP check passed and only a pull warning said why. doctor now fails 'Your team secret values can be read' with the reason, for a scope whose secrets or variables read those files. * fix(env): name the unset variable a --from-env secret reads (#879) The missing-secret line told the member to run `teamai env set KEY`, which replaces the reference they chose. For a secret whose deciding entry reads an unset variable it now says: KEY reads VAR, which is not set. Set VAR, or run `teamai env set KEY [--global]` to replace the reference. * test(mcp): env unset keeps the entry, still owned, until a new value (#879) env set, pull, env unset with nothing exported, pull: the entry keeps the old value and the manifest still claims it, so the next value replaces it instead of colliding with a user-owned server. * refactor(env): expected env set/remove failures as values, one wording (#879) - secretInput returns a tagged result; an unexpected stdin or prompt failure propagates instead of printing as a user error (E1). - Every error path in env-commands uses fail() and invalidKeyMessage(), so each exits 1, env add's invalid key included (E2). - removeSecret returns removed | absent | reported: env remove of a variable env.yaml lacks still says it is not found next to a broken secrets.yaml (E3). - env add branches on --secret, not on a missing value (E4). - env unset with declarations that can't be read no longer calls the key a variable (E5). - "Secret is not declared" names the file and the next step (E6). - Messages call the machine store "global value (every team on this machine)", matching --global and the env list label (R5). * refactor(entries): EntryFailure always carries its layout (#879) An optional layout fell back to the type's, so a failure site that forgot it would word a broken secrets.yaml as env's. activeEntryNamespaces now takes the layout and every failure sets it (N1). * refactor(doctor): name entry resolution checks with their layout (#879) The check names were looked up by the layout's message label, so a wording change to a label would silently drop its doctor check. Each entry set now carries its check name (DD1). * refactor(secrets): report an unparsable value store by path only (#879) - Drop src/utils/json-position.ts, a second JSON grammar kept only to print a line and column: a parse error now reports the path alone, which is what the spec asks (never the input), and a disagreement with JSON.parse can no longer leak the parser's quote (SS3). - The unreadable-store error names what to check and the way out, and reads the error code without a cast (SS1). - SecretStore is inferred from its schema (SS2). - The design doc says an unreadable store leaves secrets 'unreadable'. * test(secrets): typed fixtures instead of casts in the new tests (#879) The LocalConfig and TeamaiConfig fixtures in env-exec, mcp-secrets and secret-values are now checked against the types, so a new required field breaks them instead of testing a shape production never has (T1). * docs(env): env set takes variables, listings show sources, exec needs -- (#879) - Usage guide: `env set` accepts an env.yaml variable without --global, not only a declared secret (D1/C2); `env exec` links the resolution order instead of "the order above", which the section never gave (C4). - team-secrets.md intro states the variable order; a --from-env variable override leaves the key out of new shells entirely. - Document the shared listing (variable source, `unreadable`, no values while the declarations fail), `mcp list`'s `not resolved`, the doctor check for an unreadable values file, and `env exec`'s exit 2 without --. * fix(env): refuse env set/unset/list when the project config can't be read (#879) Detection returned null for an unreadable project config, so env set fell back to the user scope and stored the value for that team. Report the file and why, exit 1, and write nothing, as pull and env exec do. * fix(env-exec): exit 128 + signal for a command killed by SIGPIPE or SIGUSR1 (#879) Re-raising SIGPIPE on teamai does nothing (Node ignores it) and SIGUSR1 starts the inspector, so teamai exited 0. Set the shell's exit code first and re-raise only the signals Node ends on. * fix(env-exec): don't send the command a second SIGINT on Ctrl-C (#879) The terminal sends Ctrl-C and Ctrl-\ to the whole foreground process group, so the command already has them; forwarding sent a second SIGINT, which tools such as terraform take as force-quit. Ignore SIGINT and SIGQUIT while the command runs and keep forwarding SIGTERM and SIGHUP. * docs(env): exec signal handling and env set on an unreadable project config (#879) * fix(mcp): judge MCP configs by disk and manifest, not current config (#882) Pull, doctor and uninstall still decided "clean" from the current team config in places. Now one function, resolvedValueEvidence, decides for all three: - a teamai-owned entry still in the file counts when its server has left mcp.yaml, as well as when it needs a resolved ${VAR} or mcp.yaml cannot be read (doctor no longer skips that case) - targets include the built-in location of a tool the team dropped from toolPaths or moved - doctor names a file two tools share once - exclude updates take the existing acquireLock helper, re-read the file and write it atomically, so concurrent commands keep each other's paths - uninstall inspects every worktree of each repository owning a block, including a nested repository's linked worktrees, and applies the manifest rule per worktree - the kept-block warning names each file and why, such as the variable whose value matched * fix(env): the env commands and env exec load config through --dry-run (#866) #866 threaded { dryRun } through the loaders pull, push, status and list use. The scope lookups this branch added did not take it, so `teamai --dry-run env list|set|unset|add|remove` and `env exec --dry-run` still persisted the legacy role migration, adopted a pre-#546 partition or ran the self-mode bootstrap. - resolveConfigForDir takes LoadOptions and passes them to both loaders. - scopeHere/requireScope (env commands) and commandEnvironment (env exec) forward options.dryRun. Without the flag nothing changes: env exec still runs the migrations every command runs (spec #879 Conflict 12). Five cases added to dry-run-load-path.test.ts; each failed before this change (config.yaml rewritten, partition renamed). * fix(secrets): name the team values file by the repo identity hash alone (#879) Renaming team: in teamai.yaml changed <team>-<hash>.json and orphaned every member's values. The secrets store now uses ~/.teamai/secrets/teams/<hash>.json; the models key files keep their names. The path has not shipped, so there is no migration. * fix(env): keep a __proto__ env key through the store, MCP and env exec (#879) ENV_KEY_RE accepts __proto__, but z.record dropped it from the value store, assigning it on an ordinary object hit the inherited setter, and reading it unset returned Object.prototype. The store, the MCP var table and the env exec overlay are now built without a prototype (envTable), and the member's environment and --from-env references are read as own keys (envValue). * fix(env): env list loads config with --dry-run always (#879) env list only reads, so like status and list since #866 it never migrates the config it loads, with or without --dry-run. The dry-run load-path test now runs env list without the flag, which is the case that used to migrate. * revert: drop the #890 cherry-pick from this branch 2e15c3f was picked only to protect the local Claude config while this branch's tests ran; #890 lands it on main on its own. * fix(env): env exec applies no team env while the declarations fail (#879) A legacy GITHUB_TOKEN in env.yaml plus a secrets.yaml that fails gave the command the repo value, though the key may be a declared secret. Like env.sh and the backup (Conflict 14), env exec now overlays nothing on a failed declaration: the command gets the inherited environment, and stderr names the failure. * fix(fs): create the atomic-write temp file with the target mode (#879) writeFileAtomic and writeJsonAtomic wrote the temp file with the umask's default mode (0644 under umask 022) and narrowed it by chmod afterwards, so a secret or model key was readable by other users until then. The temp file is now opened exclusively with the target mode; the chmod stays for the bits the umask removes. * fix(env): env set --dry-run previews without asking for the value (#879) `teamai --dry-run env set KEY` prompted for the value, or read stdin with --stdin, before printing the preview, so it failed without a terminal. The preview now comes first, and no value is read. * fix(env): serialize env set and env unset on the values file (#879) Two env set or env unset runs at once each read the store, changed it and wrote it back, so the later write dropped the other's change. Both now go through updateSecretStore, which takes <store>.lock (the acquireLock helper), re-reads the file inside it and writes the result. A --dry-run takes no lock. * fix(env): keep a secret's stored value from becoming a variable override (#879) Secrets and variable overrides share the team store. env set now records kind: secret | variable from what the scope declares; variable resolution uses only variable entries, secret resolution only secret ones, and an entry without kind counts as a secret. env list flags an entry of the other kind with the fix. * fix(mcp): write an MCP config that holds a resolved value 0600 (#879) writeJsonAtomic preserved an existing file's mode, so a 0644 .mcp.json or ~/.claude.json kept 0644 after teamai wrote a resolved secret into it. A config holding a resolved ${VAR} value (a kept entry included) is now written 0600; one without keeps its mode. * fix(mcp): create the Codex config temp file 0600 (#879) applyCodex wrote config.toml.<pid>.tmp with the umask's mode and chmodded it after, so a resolved secret was briefly readable at 0644. Both Codex writes now go through writeFileAtomic with mode 0600 (random temp name, created with the mode, symlinked targets written through). * docs(env): say env exec ignores a SIGINT or SIGQUIT sent to teamai alone (#879) * fix(mcp): tighten an unchanged config that holds a resolved value to 0600 (#879) * fix(env): mark what each env.sh exported so a value from one no scan finds is not the member's (#879) * fix(env): pass on a SIGINT or SIGQUIT sent to env exec outside the terminal's foreground (#879) * fix(env): keep marking what an env.sh exported before a rewrite dropped it (#879) * docs(env): say a SIGINT sent to a foreground env exec alone is not passed on (#879) * fix(secrets): name the team values file by the configured team repo URL, not teamai.yaml's repo: (#879) A copied or hostile team repo could claim another team's repo: and receive that team's stored values. The secrets file now hashes the URL from the member's own config, normalized so ssh, https and credentialed forms match. The models key store keeps its naming (#894). * fix(env): remove what a teamai env.sh exported from env exec while the declarations fail (#879) An invalid secrets.yaml left the inherited environment untouched, so a shell that had sourced an env.sh still passed the repo's GITHUB_TOKEN to the command. Every inherited value the member-environment rule discounts is now removed, named by key on stderr; the member's own exports stay. * fix(mcp): never write a declared secret into a project MCP config git tracks (#879) .git/info/exclude (#882) stops git add, not a file git already tracks. For such a file the server is skipped for that tool and an entry an earlier pull wrote stays as it is; pull warns, mcp list shows it as withheld and doctor fails the delivery check, each naming the file and git rm --cached. * fix(env): leave no duplicate declaration of a key env add --secret or env remove edits (#879) A key declared twice fails every read of secrets.yaml, and both commands edited only the first declaration. env add --secret now updates the first and removes the rest; env remove removes every one; both say how many. * test: keep the real normalizeRepoUrlForCompare in utils/git mocks the secrets store reaches (#879) * fix(env): keep the port in the URL that names a team's secrets file (#879) normalizeRepoUrlForCompare drops explicit ports, so two team repos on one host with different ports shared one values file and one team's secret reached the other. The file is now named by the URL's scheme family, lowercased host, non-default port and path; only credentials, the ssh user, a trailing .git and slashes are dropped. The scp form and the ssh URL of a repo still share a file; its ssh and https URLs no longer do. The utils/git mocks that kept the real normalizeRepoUrlForCompare for the store are no longer needed and are reverted. * fix(mcp): skip the .git/info/exclude write while another command holds its lock (#882) After the 2.5 s wait for the exclude file's lock, updateExclude wrote without it, so two writers could drop each other's pattern and leave a plaintext MCP config committable. It now writes nothing and reports 'locked': pull warns that the file is not excluded yet and to run `teamai pull` again (doctor's exclude check keeps reporting it meanwhile), and uninstall keeps the block and warns. * fix(uninstall): keep an exclude entry unless its MCP config is proven free of teamai's servers (#882) Uninstall judged a protected file clean from the current mcp.yaml, manifest and resolvable values, so with the manifest lost, the server gone from mcp.yaml and its value unset, a plaintext token looked like the member's own server and the exclusion went. It now fails closed and works per entry: a pattern goes only when its file is gone, holds no server, or holds none of teamai's servers with managed-mcp.json still there to say what teamai wrote. A kept entry is named with its file, why, and how to clean it by hand, since a rerun of uninstall finds no config after a full uninstall. * fix(env): keep http and https team repos in separate secrets files (#879) The store identity mapped https and http to one `http` family and dropped each default port, so `http://host/team.git` and `https://host/team.git` read one file: if the two endpoints serve different repos, one team got the other's stored secrets. The identity now keeps the scheme, still dropping 443 and 80; the ssh forms (`ssh://`, `git+ssh://`, `ssh+git://`, scp) stay one family. * fix(env): strip teamai env.sh exports in env exec when the project config can't be read (#879) With an unreadable project config, env exec passed the inherited environment unchanged, so a value another scope's env.sh exported (a legacy token, a member override) reached the command while the warning said no team values were applied. It now removes what the member-environment rule discounts (env.sh file, record or marker, the env.sh beside the unreadable config included), keeps the member's own exports, and names the removed keys, never values, as the failed-declaration path does. With no config at all the inherited environment is still passed as is. * fix(mcp): exclude a project MCP config from git before writing a resolved value into it (#882) Pull listed the file in .git/info/exclude only after writing the plaintext, and a failed exclusion only warned, so the secret-bearing file stayed eligible for git add -A. The exclusion now comes first; when it cannot be established (exclude file or .git/info not writable, lock held past the wait, file already tracked, git error) the file is left as it was and the warning names the reason and the fix. * fix(mcp): report a server withheld from a file git would commit in mcp list and doctor (#882) * fix(secrets): keep the ssh user in a team's values-file identity (#879) alice@host:team.git and bob@host:team.git can be different repos in each user's home; they no longer share one values file. The scp and ssh:// forms of one user, host, port and path still match; http(s) credentials are still dropped. * fix(env): overlay and remove env exec keys case-insensitively on Windows (#879) Windows environment names are case-insensitive, so a declared api_url left an inherited API_URL in place (Node keeps the first name of a case-folded pair) and a removed secret survived in another case. On win32 a key now replaces or removes every case variant; elsewhere nothing changes. * fix(mcp): report a tracked file on a dry run and a withheld server already installed (#882) Backports #880's merge 0d9f7fa: a dry run (doctor, mcp list) names a tracked file before any pull has listed it, mcp list reports withheld for a server an earlier pull installed, and doctor's withheld note carries the exclusion's own fix instead of the pull --force advice. * fix(mcp): name a tracked MCP config before an unwritable .git/info/exclude (#882) A tracked file needs `git rm --cached` whatever else is wrong, so ensureExcludedFromGit checks gitTracks before the writability check, on a pull and a dry run alike, and lists nothing for it. * fix(mcp): take a project MCP config's exclude line back out once it holds no resolved value (#882) A pull that lists a config in .git/info/exclude and then writes no value into it (it does not parse, a member's server holds the team's name, the write fails) removes the line it added. After a pull or `teamai mcp remove`, a line whose configs are proven clean in every worktree, by the proof uninstall uses (moved to mcp-reconcile.ts), is removed under the lock; one not proven clean stays. A config listed before its write is listed again after it, so a concurrent uninstall that dropped the line between the check and the write does not leave the value unprotected. * fix(secrets): tell an scp path in the ssh user's home from an ssh:// path from the root (#879) git@host:acme/team is relative to the ssh user's home, ssh://git@host/acme/team is absolute; on a plain ssh host they can be different repos, yet they shared one values file. An scp path starting with neither / nor ~ is now keyed as ~/path, the path ssh://host/~/path names; host:/abs and ssh://host/abs still match. The scp form without a user (host:path) is now read as ssh too. * fix(mcp): judge a project MCP config by the manifest as it stood before the pull rewrote it (#882) A pull whose manifest was lost before it ran recreates managed-mcp.json while reconciling, so the clean-file proof read the new record and took the exclude line out of a file still holding a teamai server that left mcp.yaml with its variable unset. The proof now uses this worktree's manifest as read before the reconcile. * fix(mcp): log a rolled-back exclude line at debug level (#882) A line this pull added and took back out, because it wrote no resolved value into the file, was reported as removed although the member never saw it added. Only removing a line an earlier run added stays at info. * fix(mcp): keep a shared exclude line while another worktree's config holds a server (#882) A pull or `teamai mcp remove` judged every linked worktree's MCP config with today's definitions and values. Once a server's ${VAR} became a literal, and the value was no longer set, a pull in worktree A took worktree B's stale token-bearing entry for clean and removed the shared /.mcp.json line, so `git add -A` in B staged the token. These commands now release a line only when the current worktree's file passes the full proof and every other worktree's file is missing or holds no MCP server. `teamai uninstall` keeps its full proof in each worktree. * test(mcp): build the other worktree from the real temp path so the test checks what it names (#882) * fix(env): strip teamai env.sh exports from env exec with no config or an HTTP scope (#879) Neither path applies team values, yet both passed on whatever a sourced teamai env.sh exported, another team's credentials included. Remove every inherited value that is not the member's own, as the unreadable-config path does, and name the removed keys on stderr. * fix(secrets): name a team's values file by the full SHA-256 digest (#879) The file name is the boundary between teams, and 40 bits let a hostile team search for a repo URL whose name matches another team's file and read its values. Nothing has shipped, so no migration. * fix(env): name the env.sh provenance marker by the full SHA-256 of its data home (#879) * test(push): push publishes the secrets.yaml env add --secret leaves (#879) * fix(uninstall): list no worktrees for a project root that no longer exists (#882) buildRemovalPlan now lists every worktree to find teamai's exclude blocks, outside the MCP cleanup's try. simple-git throws synchronously for a missing directory, so a project uninstall whose root is gone crashed; main's #878 test caught it after the merge. * fix(secrets): keep the URL query and fragment in a team's values file name (#879) * fix(mcp): treat an empty, unparsable or tool-less managed-mcp.json as no record (#882) The clean-file proof took any managed-mcp.json on disk as teamai's record, so an empty or truncated one let a pull, `mcp remove` or uninstall judge a file still holding a stale secret-bearing entry clean and drop its exclude line. A file now counts as recorded only when the manifest parses and holds an entry for that tool's file. A project record teamai empties stays as [] so a file left with only the member's own servers can still be released. * fix(env): compare exported, recorded and marked keys case-insensitively on Windows (#879) * fix(uninstall): list no worktrees for a project root that no longer exists (#879) * fix(mcp): keep the exclude line of a config this pull wrote when a later step fails (#882) * fix(mcp): read a check-ignore error as unsafe unless ls-files proves the config untracked (#882) * fix(mcp): report withheld only for targets delivery would write the server to (#882) * docs(mcp): describe the .git/info/exclude block in the setup skill and the stricter git check (#882) * fix(mcp): keep the exclude line of an entry a pull wrote with a resolved value after its definition turns literal (#882) * fix(mcp): judge a nested repository's linked worktree config by its sibling's tool (#882) * feat(mcp): record the project MCP configs a pull wrote a resolved value to in managed-mcp-files.json (#882) * fix(mcp): keep protecting a config a pull wrote under a toolPaths mapping the team has since changed (#882) * fix(mcp): keep a config's exclude line past the pull that rebuilt its lost record (#882) * test(mcp): pin today's exclude rules for a missing, corrupt or locked managed-mcp-files.json (#882) * docs(mcp): describe managed-mcp-files.json and the configs it keeps protected (#882) * refactor(mcp): keep the #882 record edits off the lines #880 changes (#882) * test(mcp): keep excluding a config whose entry a pull kept for a missing declared secret (#875, #882) * fix(mcp): protect a config an older teamai wrote under a mapping an earlier teamai.yaml made (#882) A teamai from before managed-mcp-files.json kept no record of the path it wrote a resolved value to. Once the team changed that toolPaths mapping, no pull visited the file. The first pull on this version now reads every mcpProject path the team repo's history of teamai.yaml mapped, once per worktree: a file under the project root that no current mapping or record reaches, and that holds a resolved value, is listed in .git/info/exclude and recorded. A git error leaves the read for the next pull; a shallow clone reads the history it has. * fix(mcp): keep a rebuilt record from persisting without its note of the file's other servers (#882) When a pull rebuilt a lost managed-mcp.json and could not note the other servers in the file (managed-mcp-files.json locked, an I/O error), it still wrote the rebuilt record, so no later pull knew the record was rebuilt and a stale server's line could go. The same manifest write now marks those records unnoted: the file counts as having no record, so it keeps its line while it holds a server, and the next pull notes them and clears the mark. * fix(mcp): take back a managed-mcp-files.json record for a config the pull then did not write (#882) A pull records a config before writing a resolved value to it. When the write failed or did not happen (the file does not parse), the record stayed, and once the mapping changed a config of the member's own at that path was kept excluded while it held any server. The pull now takes back a record it added for a file it did not write, as it does the file's exclude line; the settle after records it again if the file holds a resolved value anyway. * docs(mcp): describe the teamai.yaml history read, the unnoted rebuilt record and the record a failed write takes back (#882) * refactor(mcp): keep the r3 edits off the lines #880 changes (#882) * fix(mcp): also protect a config an older teamai wrote under a built-in default it has since changed (#882) * fix(mcp): replace a symlinked Codex config instead of writing into the file it links to (#875, #882) * fix(env): drop what a teamai env.sh exported from env exec when env.yaml or the values file fails (#875) * fix(env): on Windows, match a declared secret to an env.yaml variable in any case (#875) * fix(mcp): judge a project MCP config under a symlinked directory where the write lands (#882) The appliers replace the file itself (tmp + rename) but follow its directories. Every git check now judges realFilePath(file), the one resolver the release keying already used: a directory linked out of any repository no longer withholds the servers on git's "not a git repository", and a tracked file there is named with both paths, with a git rm --cached that works (git refuses the path through the link). * docs(mcp): describe how a config under a symlinked directory is kept out of git (#882) * refactor(mcp): keep realFilePath next to existingAncestor, without an import cycle (#882) * refactor(mcp): key each worktree's targets with realFilePath, the one rule for where a write lands (#882) * fix(mcp): judge a config under an earlier teamai.yaml mapping as a recorded file, not by today's records (#882) * fix(mcp): have doctor check the configs earlier teamai.yaml mappings reach until a pull reads them (#882) * docs(mcp): describe how a config under an earlier teamai.yaml mapping is judged, and doctor's check of it (#882) * fix(mcp): record a config under an earlier teamai.yaml mapping that git tracks, and judge it once git no longer does (#882) * fix(mcp): keep judging a recorded config for a tool the team moved while another tool still maps it (#882) * docs(mcp): describe the tracked config an earlier mapping reached, and a moved tool's config another tool still maps (#882) * fix(mcp): find a config an older teamai wrote under an earlier mapping another tool maps today, and judge it by that tool's records (#882) * docs(mcp): describe the history read's configs another tool maps today (#882) * fix(mcp): prove a shared config clean only while every tool that wrote a resolved value there has its record (#882) * fix(env): on Windows, set and unset a key under the name the scope declares, in any case typed (#875) * fix(mcp): judge a built-in location no mapping reaches today as an earlier-mapped file, and a shared config no pull recorded by every tool mapping it (#882) * docs(mcp): describe the built-in location of a moved or dropped tool, and a shared config no pull recorded (#882) * fix(env): on Windows, match a secret's declaration and stored value in any case (#875) * fix(mcp): name the ignore rule that re-includes a config teamai just listed, instead of saying git tracks it (#882) * fix(mcp): judge a moved tool's built-in location another tool maps for that tool too, and hold a config's line while no managed-mcp.json claims its servers (#882) * docs(mcp): describe the no-manifest rule, a moved tool's built-in location another tool maps, and a re-including ignore rule (#882) * fix(env): key a team's values by its repo URL when the configured remote is only an alias (#875) * fix(env): on Windows, recognise a secret's env.yaml value under another case of its name in the environment (#875) * fix(mcp): on Windows, keep an inherited value under another case of a team variable's name out of MCP servers (#875) * fix(env): on Windows, replace and remove every stored entry under another case of the key (#875) * fix(mcp): keep a tool's record as it was when its config does not parse, and take back each tool a write that did not happen recorded (#882) * fix(mcp): mark the records a pull with no managed-mcp.json writes as unnoted until the servers no record claims are noted (#882) * fix(mcp): have doctor judge a record marked unnoted like a missing managed-mcp.json (#882) * fix(mcp): judge a config tools of different formats share in each of their formats before releasing its line (#882) * fix(mcp): note the servers no record claims in the file of a tool whose record a pull writes first, as with no managed-mcp.json at all (#882) * fix(mcp): take back a tool managed-mcp-files.json recorded before a write unless its own records hold a resolved value there (#882) * fix(mcp): treat an installed tool's missing record as lost at every pull and in doctor, not only an empty managed-mcp.json (#882) * fix(mcp): tighten to 0600 every project config the protection pass keeps out of git, not only the ones a pull writes (#879) * fix(mcp): on Windows, fill a placeholder from the variable of the same name in another case (#875) * fix(mcp): note the unclaimed servers under every format of a shared config, and pin an uninstalled tool's leftover config (#882) * fix(mcp): count an uninstalled tool's missing record when no installed tool maps its file, and name a re-including .gitignore rule on a dry run (#882) * fix(mcp): on Windows, match a placeholder to its secret in any case in mcp list and the missing-secret notice (#875) * fix(mcp): scope a shared config's claims to the tools reading the same key, and settle its notes on every format's view (#882) * fix(env): keep a file:// repo's .git suffix in its values file identity: team and team.git are two directories (#875) * fix(env): on Windows, update and remove an env.yaml variable typed in another case (#875) * fix(mcp): keep suspect an uninstalled tool managed-mcp-files.json lists as a writer, though an installed tool maps the file (#882)
This was referenced Oct 11, 2026
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
…Tencent#546) Project-scope machine data lives in a partition under ~/.teamai/projects/<slug>/, but the slug prefix was only the anchor's basename (e.g. teamai-cli-<hash>), so the directory name did not reveal which project it belonged to — unlike Claude Code's ~/.claude/projects/, whose names encode the full path. Build the prefix from the WHOLE anchor path (leading separator dropped, path separators -> '-'), e.g. /Users/x/Project/app -> Users-x-Project-app-<hash>. The 16-hex sha256 suffix is unchanged, so uniqueness (escape-ambiguous paths, shared basenames) and the slug===dir corrupt check are untouched; the prefix is length-bounded so a very long path can never overflow NAME_MAX. The authoritative reverse lookup remains the per-partition 'anchor' file. Verified end-to-end with the real CLI in an isolated HOME: a partition is laid down under the readable slug, 'status --all' reverse-resolves it to the project path and reports [active], a mismatched dir name is flagged [corrupt], and detection from the project cwd loads the partition config via the new slug.
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
… of stranding them (Tencent#551) * fix(partition): adopt pre-Tencent#546 legacy-named partitions instead of stranding them Tencent#546 widened the partition slug prefix from the anchor's basename to its whole path but kept the sha256 suffix — without migrating existing installs. On an upgraded CLI, a partition still named <basename>-<hash> (every install created before Tencent#546) stops matching projectSlug(anchor): detectProjectConfig finds no config (the project looks uninitialized), planMigration would re-copy a retired workspace into a second, empty partition, and status --all flags the perfectly good data as "corrupt — dir name does not match anchor". Both formats share the same hash, so an anchor's legacy name is computable exactly — no directory scanning. resolvePartitionDir becomes the seam for "the partition that actually holds this project's data" (detection, init, migration): when the canonical current-format directory is absent and a legacy-named one exists, it ATOMICALLY RENAMES the legacy partition into place — a same-parent metadata move, no data copied, and an interruption leaves either name intact. An authoritative current-format partition is never clobbered by a leftover legacy one; a rename that is genuinely impossible (read-only home) keeps serving the legacy directory so no data is stranded. status --all stays read-only and reports a legacy-named partition as "active (legacy name; renamed automatically on next command)" instead of corrupt. Verified end-to-end with the real CLI in an isolated HOME: a legacy .teamai migrates into the readable whole-path slug; status --all reverse-resolves it as [active]; a partition renamed to the pre-Tencent#546 format is reported active-legacy (no rename, no corrupt), then adopted by the next command (detection) with data intact, and pull runs through the adopted partition. * fix(partition): rebase repo.localPath when adopting a legacy partition A pre-Tencent#546 partition stores repo.localPath as an ABSOLUTE path to its team-repo clone (<legacyPartition>/team-repo). resolvePartitionDir renamed the directory but left config.yaml pointing at the now-gone old path, so every later `pull` read the team config from a dead directory and silently skipped the sync ("Team config (teamai.yaml) not found. Skipping.", exit 0) — the project could never sync again after an upgrade. Adoption now rebases repo.localPath onto the new partition (mirroring migrate.ts's rebaseConfigPaths). The rewrite is idempotent and self-healing: a modern install whose localPath already sits in the canonical dir is left untouched, an external clone outside the partition is left untouched, and an adoption interrupted between the rename and the config rewrite is finished by the next command. Reproduced with the real CLI (isolated HOME, real local git team repo): a legacy-named partition + two `pull --force` runs printed "Team config not found. Skipping." (exit 0) before this fix; after it both runs print "Synced 1 skills" and localPath points at the live clone. Regression tests: localPath rebased off the legacy dir / external localPath left alone / modern-install no-op. Verified they fail when the rebase is disabled. * fix(partition): write the adopted config.yaml atomically to prevent truncation The localPath rebase overwrote config.yaml with a plain (non-atomic) write. By that point the legacy partition has already been renamed away, so config.yaml is the partition's ONLY copy — a write that fails partway (ENOSPC, EFBIG, crash mid-write) truncates it with no source to recover from, and the CLI still prints "Your original data is unchanged, re-run to retry" while the data is in fact corrupt and cannot self-recover. Add writeFileAtomic (same-dir temp + rename, preserving mode) alongside the existing writeJsonAtomic, and use it for the adopted config.yaml. rename(2) is atomic, so a failed write removes the temp file and leaves the original config.yaml byte-for-byte intact; the next command retries the idempotent rebase and converges. Reproduced with the real CLI (isolated HOME, real local git team repo, NO fs mock) by injecting a write failure with RLIMIT_FSIZE=128: before: pull --force reports EFBIG, config.yaml truncated 453 -> 128 bytes, legacy partition already moved, retry after lifting the limit exits 0 but never syncs and cannot recover after: config.yaml preserved at 453 bytes, retry after lifting the limit prints "Synced 1 skills" and localPath points at the live clone Regression test: the localPath rewrite failing mid-write leaves config.yaml intact with no leftover temp file. Verified it fails when the write is made non-atomic. Full suite: 3109 passed, 0 regressions; tsc clean.
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
…list (Tencent#836) (Tencent#837) * fix(tags,roles): honor --dry-run in tags subscribe, tags unsubscribe and roles set (Tencent#836) The three commands saved the local config and reset lastPullRev even under the global --dry-run, which is documented as "Preview mode, no changes made". Their siblings (tags add/remove, roles init/add/remove/ update) already return early with a [dry-run] message. The roles set preview names the additional roles it would save, including none, because a real run replaces the existing list. oxlint reported the unused options parameter in tagsSubscribe and tagsUnsubscribe; rolesSet has the same bug but reads options.add. * fix(tags): count namespaced skills in tags list (Tencent#836) The "N skill(s) have no tags and are always synced" hint counted the top-level directories under skills/, so a namespace counted as one skill and its skills were not counted at all. It also subtracted the number of tags.yaml entries instead of checking which skills have tags. Count the untagged skills among those pull delivers, using pull's own resolver (resolveDesiredSkills with the member's role context). Pull delivers every skill in the member's namespaces, all of them without roles, whatever its tags; tags only add skills from elsewhere. So roles, exclusions and a name held by both the root and a namespace are counted the way pull counts them. * fix(tags): address review — warn instead of aborting tags list on a malformed manifest (Tencent#836) * fix(tags,roles): address review — keep the legacy role migration in memory under --dry-run (Tencent#836) * fix(tags,roles): address review — preview the self-mode bootstrap and partition adoption under --dry-run (Tencent#836) detectProjectConfig now takes the { dryRun } load option that roles set, tags subscribe and tags unsubscribe already pass. Under it, a fresh self-mode clone gets the config bootstrapSelfRepo would write, kept in memory (previewSelfBootstrap), and a pre-Tencent#546 partition is read where it is instead of being renamed. One test hashes HOME, the project (with .git) and state.json around each command on three fixtures. * fix(bootstrap): address review — make no provider auth call in the --dry-run bootstrap preview (Tencent#836)
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
…on save and recall use (Tencent#853) Tencent#837 threaded LoadOptions through the config loaders, and Tencent#850 fixes the three commands that still reach them bare (pull, push, status). Three more commands load their config before their own dry-run guard and pass nothing: - contribute (--scope project loads, then --scope user / auto-detect) - session save (same three branches) - recall (detection, the inherited user scope, and the user branch) On a config pending the legacy role migration each of them rewrote ~/.teamai/config.yaml under --dry-run, printing the migration line without any [dry-run] marker; the auto-detect and project branches can also adopt a pre-Tencent#546 partition and run the single-repo self-heal bootstrap. loadLocalConfigForScope is the loader Tencent#837 missed: it now takes LoadOptions and forwards them to detectProjectConfig and both migrateLegacyRoleConfig calls. Callers that pass nothing behave as before — a real run still migrates in place. Co-authored-by: ydflow <[email protected]>
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
…s and list use (Tencent#866) * fix(dry-run): thread { dryRun } through the loaders pull, push, status and list use `--dry-run` is documented as previewing without making changes, and Tencent#837 made that true for `tags subscribe`, `tags unsubscribe` and `roles set`. `pull`, `push` and `status` still wrote: each runs its scope-detection block before any dry-run guard, and that block called config loaders that were never given the flag. A preview could therefore persist the legacy role migration, and in a git repo adopt a pre-Tencent#546 partition or run the single-repo self-heal bootstrap. The loaders already take LoadOptions — Tencent#853 threaded them through `loadLocalConfigForScope` for contribute / session save / recall. These commands simply did not supply the flag. - pull.ts: both loaders take { dryRun: options.dryRun }. - push.ts: autoDetectInit takes it. - status.ts and list: { dryRun: true } unconditionally, because both are read-only and should never migrate, adopt a partition or bootstrap. Callers that pass nothing behave as before, the same compatibility promise Tencent#837 made. The one observable change is that the preview path logs, so `status`/`list` now surface a "[dry-run] Would ..." line where a migration or bootstrap is pending; the PR description asks for a decision on that label. Verification: seven new command-level cases, each failing on unmodified main with the identical test file (the project-scope three need a git project with a pre-Tencent#546 partition name, which the existing user-scope fixture never reaches); and the issue's own real-CLI reproduction, 6/6 — the control writes the reported fields, this change writes nothing. oxlint --deny-warnings and tsc --noEmit: rc=0 here and rc=0 on unmodified main. Closes Tencent#850 * fix(pull,push): a --dry-run must leave a fresh self-mode clone alone Resolves both P1 findings on this PR. pull.ts:1891 - the previewed self-mode config reached lockScope(), whose acquireLock() calls ensureDir() on the lock's parent. On a fresh clone the partition does not exist yet, so the directory was created and stayed: releaseLock removes the lock file, not its parent. The guard sits inside lockScope(), the one choke point all three call sites share. push.ts:731 - the same previewed config ran the whole self-mode setup before pushCore reached its own dry-run guard at push.ts:1577: the sync-lock, migrateSelfModeGitignore(), and the disposable knowledge worktree. Both guards are deliberately narrow. A blanket early return before the git-mode branch would also skip resetToCleanMaster/pullRepo (push.ts:934), which a dry run performs on purpose so it can name the destination the real command would use. Only writes that outlive the command are gated. The preview still reads the uncommitted teamai.yaml that pushCore receives as initialPendingTeamConfig; that block is now pendingSelfTeamConfig(), the identical read, so the preview keeps describing the config edit it exists to describe. Fixture gap, also flagged: dry-run-load-path.test.ts already had a fresh-self-mode-clone fixture, but only tags/roles ran against it. pull and push ran at user scope, or on a project partition that already exists - never on the one shape where acquireLock has something new to create. Two cases added there; the unfixed tree fails them at fs.existsSync(<HOME>/.teamai/projects) with "expected true to be false". Not fixed here, and named in the PR description: pull --dry-run on a fresh clone still creates an empty <HOME>/.teamai/locks/, via listPendingForInstall in utils/pending-learnings.ts. That call is unchanged by this PR and the file is outside its scope; the test declares and counts the entry, so anything else appearing still fails. * test(pull): pin the loader call shape the widened signature produces Fixes the red Lint & Test on the previous head (all four matrix entries). pull-scope-isolation.test.ts asserted the exact argument list of loadLocalConfigForScope, which this change widens to carry LoadOptions: expect(loadLocalConfigForScope).toHaveBeenCalledWith('user'); received ['user', undefined, { dryRun: undefined }] The shape is not a free choice: recall.ts:464 and recall.ts:515 already pass the same third argument, landed with Tencent#853, so pull.ts matches the merged precedent. recall-scope-isolation.test.ts never asserts the argument list, which is why the same change left it green. The affected set is derived from the changed symbols rather than from the topic: every test file that mentions loadLocalConfigForScope, detectProjectConfig or autoDetectInit (76 files, 1221 tests). * fix(update): a --dry-run asks the lock for its state instead of taking it `acquireLock` is not a read. It `ensureDir`s the lock's parent, which on a fresh self-mode clone is a `<getDataHome>` partition that does not exist yet — and `releaseLock` removes the lock FILE, not that directory, so the directory outlives the command. Any preview that calls it therefore writes, which is the defect this PR is about (Tencent#866). The new `options.dryRun` returns what the preview actually owes its caller: the ANSWER the real run would get. `lockState` already separates `live` (a holder is running) from `stale` and `missing`, and the real run reclaims either of the latter and wins, so `acquireLock(path, { dryRun: true })` is exactly that verdict — no mkdir, no lock file, no reclaim sentinel. Nothing is recorded in `heldLockOwners`, which is what makes the preview safe alongside the existing `releaseLock` calls: it returns at its first line when it holds no owner token for the path, so a preview cannot delete a lock another process owns. No caller passes `dryRun` yet; this commit is the primitive only. * fix(pull,push): acquire the preview's locks read-only, and stop hiding what it reports Supersedes the guards added in cfd7c57. Those guards stopped the writes, and E2E (fork-safe) caught what they cost — 6 failures in push-sync-followups-823.test.ts, all of the same shape: expected '- Scanning local resources...\nNo new or modified resources to push' to contain '[rules] teamai-rule (modified)' A preview that reports no changes for a tree with a deliberately edited team rule is not a conservative preview; it is this PR's own defect with the sign flipped. pull.ts — `lockScope()` returned `true` outright for a dry run, asserting the scope was uncontended. That is a fabricated fact: its callers read `true` as "you hold the lock". It now acquires through the read-only primitive and records the lock for release only when it really took one, so a scope with a live holder is reported as contended and skipped, exactly as a real pull does. push.ts — the self-mode branch returned early for a dry run. Two of the three things it skipped are right to skip and one is not. - the sync-lock: read-only now, at both push.ts:784 (self) and push.ts:839 (git mode). - `migrateSelfModeGitignore()`: still skipped. It rewrites a tracked file in the user's ACTIVE tree, which outlives the preview, and it is idempotent, so the next real push performs it. - the knowledge worktree: MUST run, and that is the correction. `pushCore` adds the active tree's `.teamai/{skills,rules}` as scan sources and diffs them against `localConfig.repo.localPath` (push.ts:1095-1112) — the clean worktree checkout. Outside the worktree those are the same path in self mode, so the diff is empty by construction: skipping the worktree does not report an edit early, it hides the edit. `withKnowledgeWorktree` already removes it in a `finally`, so it stays disposable. Fixture — `push --dry-run` now performs its `git fetch` for real, which leaves `app/.git/FETCH_HEAD` behind. Declared and counted next to the existing `<getDataHome>/locks/` entry, so any OTHER new entry still fails the case.
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
…igrations (Tencent#893) (Tencent#901) * fix(dry-run): load mcp inject and mcp list without persisting a migration (Tencent#893) mcp inject loaded its scope bare, so --dry-run still saved a pending role migration, partition rename or self-mode bootstrap. It now forwards dryRun; mcp list is read-only and loads with dryRun: true unconditionally, as status and list do since Tencent#866. * fix(dry-run): forward dryRun to the loader in roles init/add/remove/update (Tencent#893) roles list is read-only and loads with dryRun: true unconditionally. * fix(dry-run): forward dryRun to the loader in projects add/update/remove (Tencent#893) projects list and projects members are read-only and load with dryRun: true. * fix(dry-run): forward dryRun to the loader in tags add/remove (Tencent#893) tags list is read-only and loads with dryRun: true. * fix(dry-run): forward dryRun to the loader in source add/remove/add-http (Tencent#893) source list and source browse are read-only and load with dryRun: true. source list also reached a second bare load through loadLocalAgentConfig, whose HTTP backfill reads only repo.kind and repo.url; it now loads with dryRun: true, and the migration persists on the next command that writes. * fix(dry-run): forward dryRun to the loader in remove and uninstall (Tencent#893) * fix(dry-run): forward dryRun to the loader in packages install (Tencent#893) * fix(dry-run): forward dryRun to the loader in import --from-iwiki/mr/claude/repo (Tencent#893) --from-repo-list and --from-org reach the same load through importFromRepo. * fix(dry-run): forward dryRun to the codebase loader; --lint and --status load read-only (Tencent#893) * fix(dry-run): forward dryRun to the loader in models switch; models list loads read-only (Tencent#893) * fix(dry-run): load read-only commands without persisting a migration (Tencent#893) hooks list, members, exclude list, recall status and doctor load with dryRun: true unconditionally, as status and list do since Tencent#866. * docs(designs): name which commands take the dry-run detection path (Tencent#893) * test(dry-run): pin that every loader on a dry-run or read-only path migrates nothing (Tencent#893) LOAD_ONLY_COMMANDS gains the read-only commands and the previews that stay clean on the legacy-role fixture. PREVIEWS covers the commands that fail past the loader on that fixture: it asserts only config.yaml, with the same call without --dry-run as the positive control that the load is on the path. * fix(dry-run): forward dryRun through resolveMemberToolRoots for import --from-claude (Tencent#893) scanCandidates resolves Claude's tool root before the loader import.ts already fixed, through a bare load in resolveMemberToolRoots, so the dry run still saved the migration. resolveConfigForDir and findUnreadableProjectConfig take the same optional LoadOptions for the read-only callers below; hook and usage callers pass nothing and behave as before. * fix(dry-run): pass dryRun into loadLocalAgentConfig instead of forcing it (Tencent#893) Forcing dryRun there made real hook runs print the [dry-run] migration preview and stop persisting it. source list now passes it through describeLocalAgent; every other caller is unchanged. source add-http forwards { dryRun: options.dryRun } like the rest of the file. * fix(dry-run): load skill list/show, webhook list, stats and digest read-only (Tencent#893) detectTeam takes optional LoadOptions; the Stop-hook share gate passes none. * docs(designs): name read-only commands by example, not as every list subcommand (Tencent#893) * test(dry-run): prove each row reached the load, and cover the remaining changed sites (Tencent#893) Every dry-run row now asserts the loader logged its migration preview, so an early return cannot pass. Adds source browse, codebase --lint, skill list/show, webhook list, digest, projects update/remove, import --from-claude, and a config-only table for members, projects members and stats. * fix(dry-run): keep the pre-command migration from adopting a partition on a dry run (Tencent#893) The preAction hook passes dryRun to maybeMigrate, but planMigration and queueKeptInCheckout resolved the partition bare, so pull/push --dry-run still renamed a pre-Tencent#546 partition. Both now take the option. * fix(dry-run): load skill get/path read-only through the share gate (Tencent#893) blockReason fell back to shareGate(), a bare load, when no team was passed; only skill get, skill path and the catalog reach that fallback. The Stop hook still asks shareGate directly and is unchanged. * refactor(dry-run): give loadWebhookConfig the option instead of copying its branch (Tencent#893) Also note in loadLocalAgentConfig that dryRun covers only its config.yaml load. * revert(dry-run): leave stats out of this change (Tencent#893) stats also loads bare per session through the dashboard scope helpers on the pull/report path; a partial fix would claim more than it does. Tracked in the follow-up issue with the other dry-run gaps. * test(dry-run): cover the pre-command migration and skill get/path share (Tencent#893) * refactor(dry-run): give shareGate the option instead of repeating it in blockReason (Tencent#893) Also correct the test comment on when the pre-command migration runs. * fix(dry-run): keep loadLocalAgentConfig from writing config.json under dryRun (Tencent#893) The option reached only the config.yaml load. The legacy group-binding cleanup, the binding-key canonicalization and the HTTP backfill still saved config.json, so `teamai source list` could rewrite or create it. Under dryRun they now stay in memory, and the cleanup prints a `[dry-run] Would remove` preview instead of `Removed`. * fix(dry-run): keep models list from saving a re-bound beta key (Tencent#893) models list loaded the scope read-only but read the team keys through loadTeamValues without the option, so a key a 0.26.0 beta stored under the profile id alone was bound to its gateway and the values file rewritten. It now binds the key in memory only; the next write command saves it.
Walternater
pushed a commit
to Walternater/teamai-cli
that referenced
this pull request
Nov 2, 2026
… (Tencent#880) * refactor(entries): let a namespaced entry reader declare its own layout (Tencent#879) An entry reader took its directory, file name, activation key and failure wording from its EntryType. It can now declare them as an EntryLayout, defaulting to entryLayout(type), which gives today's values. This lets a later reader read env/secrets.yaml and env/<ns>/secrets.yaml activated by resources.env. No behaviour change: env, hooks, MCP and models resolve and report as before. Part of Tencent#875. * refactor(models): share the team values path and stdin reader with a second store getTeamValuesPath takes the store directory (defaulting to models/teams) and keeps its <team>-<hash>.json naming. The piped-stdin reader moves to utils/prompt.ts as readStdin; the --api-key-stdin checks and messages stay in the models command. No behaviour change. Refs Tencent#879 (S2), Tencent#875 * feat(env): declare team secrets in env/secrets.yaml and show their state (Tencent#879) A team repo can declare the secrets its members need, with no value, in env/secrets.yaml and env/<ns>/secrets.yaml (key, optional description and url). They resolve like env.yaml: active through resources.env, a namespace entry replaces the root entry with the same key. The declarations are absent, valid or failed; a broken file fails the secrets only, is reported in secret wording by pull, env list and doctor, and env variables are still delivered. - env list and list env show each declared secret as environment or missing, never its value, --reveal included. - doctor fails "Team secrets can be resolved" on a broken file, and its notes name env/secrets.yaml, not env/env.yaml, for an override or a key repeated in legacy mode (describeEntryNotes takes the reader's layout). - push lists a changed secrets.yaml, in single-repo mode too. - docs/designs/team-secrets.md and .zh-CN.md start here, with the Tencent#818 boundary; usage guide, product overview, multi-project, management backend and the admin reference updated. Part of Tencent#875. * feat(env): declare a team secret with env add --secret (Tencent#879) env add <key> [value] --secret [-d] [--url] [--role|--project] writes env/secrets.yaml or env/<ns>/secrets.yaml with no value; a value is rejected and never printed. env remove removes a declared secret when env.yaml does not set the key, and --secret removes only the declaration for a key both files carry. entryNamespaceFromFlags takes a layout so the --role warning names secrets.yaml. * feat(mcp): keep the entry an earlier pull wrote when a declared secret is missing (Tencent#879) The session-start pull inherits the agent's environment, which often lacks the member's shell export, so it removed the MCP entry the interactive pull had written. A server whose only missing variables are declared secrets now keeps its entry and ownership record; it is removed when it leaves mcp.yaml or by removeAll. A failed secrets declaration keeps managed MCP state. * feat(env): keep a member's value for a team secret and resolve it in MCP servers (Tencent#879) teamai env set KEY (hidden prompt, --stdin, --from-env VAR) and env unset KEY store a member's value per team repo in ~/.teamai/secrets/teams/, 0600, accepting only keys the scope declares as secrets. ${VAR} in MCP servers resolves a declared secret from that value, then from the member's own environment, which leaves out values a teamai env.sh exported (Conflict 10). A key declared as a secret and set in env.yaml resolves as the secret: its repo value leaves env.sh, the env backup, both list renderers and doctor's expected set (Conflict 13). A failed declaration leaves env.sh and the backup as they are (Conflict 14). env list shows team. * docs(env): document team secret values, storage and MCP resolution (Tencent#879) * feat(env): set one value for a team secret for every team on the machine (Tencent#879) env set/unset --global keep the value in ~/.teamai/secrets/machine.json. Resolution becomes team value > machine value > the member's environment, for MCP servers and env list (state `global`). In a scope --global still accepts only a declared secret; outside any scope it accepts any valid key and notes that no team declares it yet. * docs(env): document the machine value for team secrets (Tencent#879) * feat(mcp): keep project MCP configs with resolved values out of git (Tencent#882) A project-scope MCP config that carries a resolved ${VAR} sat untracked and unignored in the business repo, one `git add -A` from committing the token. After the reconcile writes such a file and git would track it, teamai lists its path in the clone's .git/info/exclude inside a marked block (resolved via `git rev-parse --git-path`, so linked worktrees and submodules work). The committed .gitignore is never touched; an ignored path or a config with no resolved value adds nothing; dry runs write nothing. Project-scope uninstall removes only teamai's block, and doctor reports such a file git would still commit. The hook sits after the appliers in reconcileMcpForConfig, outside desiredMcpForTarget/applyJson/applyCodex, so it merges cleanly with Tencent#880. * feat(env): name a missing team secret and the command that sets it (Tencent#879) Interactive pull, mcp list, env list and doctor print one line per declared secret with no value, naming the MCP servers that use it, `teamai env set KEY` and the declared url. doctor prints it as a note and no longer fails the MCP delivery check for a server skipped only for a missing declared secret. Pull and doctor also note a kept entry that may hold an old value and a key declared as a secret and set in env.yaml. The silent pull prints nothing. The lines come from one envAdvisories() result that later pull notices extend. * docs(env): document the missing-secret advisory in pull, doctor and the lists (Tencent#879) * fix(uninstall): count the .git/info/exclude block in the removal plan (Tencent#882) The plan now records whether the project's .git/info/exclude holds teamai's MCP config block (gitExcludeBlock). It counts toward isPlanEmpty, is listed in the summary and dry run, and gates the removal, so a plan whose only teamai leftover is the block removes it instead of reporting "Nothing to uninstall". * feat(env): run a command with the directory's team env and secrets via env exec (Tencent#879) * docs(env): document env exec, what the command can reach and the ANTHROPIC_* caveat (Tencent#879) * fix(tests): isolate Claude config dir from model tests (cherry picked from commit e567ac3) * fix(env): warn when env add --secret updates a declaration an unknown key keeps undeclared (Tencent#879) * feat(env): tell agents at session start which team secrets exist and to run their CLIs through env exec (Tencent#879) * docs(env): teach agents to use team secrets through env exec and leave values to the member (Tencent#879) * feat(env): resolve plain env variables in one order, with a member override (Tencent#879) The environment no longer overrides an env.yaml variable in MCP servers, env exec or env.sh. A member sets their value for a team with `teamai env set KEY`; an interactive pull and doctor say when an export differs and is ignored. env.sh exports a literal override and leaves out a --from-env one; doctor's env delivery check expects the same. * docs(env): document the variable order and the member override (Tencent#879) * fix(mcp): keep the exclude block until every MCP config is clean (Tencent#882) - uninstall keeps a repository's .git/info/exclude block while a config in it could not be parsed and still holds teamai servers, and warns - uninstall finds and removes the block in nested repositories holding an MCP config, across every worktree - the block opens at the last start marker, so an orphaned start never pairs with a later block's end and takes the member's lines - doctor counts only servers the ownership manifest records, not a member's own server under a team name * fix(env): discount an old env.sh export in every later command (Tencent#879) A shell opened before a pull keeps the values env.sh exported then. Only the process that rewrote env.sh discounted them, so the next command read the team's old token as the member's own (Conflict 10). Each env.sh now keeps env.sh.exports.json beside it: SHA-256 of KEY=VALUE for the last 20 values per key, mode 0600, never a value. memberEnvironment discounts any recorded export, which replaces the in-memory snapshot. * fix(uninstall): remove the exclude block only once its files are proven clean (Tencent#882) A missing or unreadable managed-mcp.json made the MCP cleanup return early without reporting anything, so uninstall removed the block while .mcp.json still held the resolved token. Uninstall now inspects every path the block protects after the cleanup. The block goes only when each one is missing, or parses and holds none of the team's servers that need a resolved ${VAR}. Anything it cannot check keeps the block, with a warning naming the file. This replaces the leftInPlace report from the reconcile, which the check subsumes. * fix(mcp): protect every project MCP config holding a resolved value (Tencent#882) Pull, doctor and uninstall each skipped a case they had not inspected and treated it as safe. Now: - pull lists a config in .git/info/exclude whether or not it delivered to it this run: a disabled or undetected tool's file, a team with automatic delivery off, an unreadable mcp.yaml (any teamai entry counts), a failed write to another tool's config, and a lost ownership manifest (the resolved value found in the file) - doctor checks the same files, including one that does not parse, and counts a git error as a failure - git check-ignore failing inside a repository is no longer read as "not tracked": the path is excluded anyway, or teamai warns with git's error - uninstall also keeps the block while a file contains the value (8+ characters, not a path or the login name) of a variable still set in the environment, which finds a server since dropped from mcp.yaml * refactor(env): resolve a scope's env once per command (Tencent#879) resolveTeamEnv (src/env-resolution.ts) reads env.yaml, secrets.yaml, both value stores and the env.sh exports once. buildVarTable, the MCP reconcile, envAdvisories, env exec, doctor and pull take that result: an interactive pull resolves once per scope in its env stage and reuses it for MCP and the advisories (was up to four secrets.yaml reads). - Variable and secret values move out of resources/secrets.ts, which now holds declarations only (R3); one StoreResolution<V> and storeEntry (R2); resolveSecretDeclarations takes { active } instead of a tri-state array (R4); reportMissingSecrets lives in env-advisories (X1). - ENV_KEY_RE moves to resources/env-key.ts, so env.ts imports SECRETS_LAYOUT statically (EV1). - env list and `teamai list env` print one listing (env-listing.ts); a variable shows the value it resolves to and its source, team or env.yaml, like a secret (S1). - A failed declaration is never "no secrets": the listings show no variable value then, --reveal included, and a server skipped for a missing variable is kept (S2). - SecretState gains `unreadable` for a store that can't be read, handled with a never check (R1). * fix(mcp): mcp list reports a broken secrets.yaml and exits 1 (Tencent#879) A failed declaration read as no secrets, so every server variable came from the raw environment, another team's token included, and mcp list said 'all set' while pull kept MCP frozen. It now names the file, exits 1, and shows a server's variables as 'not resolved' (Conflict 14, C3). * fix(env): env commands outside a scope say so and exit 1 (Tencent#879) env list, add, remove, set and unset threw NotInitializedError with a stack trace outside any teamai scope. They now print its message and exit 1; env set/unset --global still work there. * fix(env): env exec refuses a command without -- before it (Tencent#879) Commander drops --, so `teamai env exec gh pr list --dry-run` read the command's flag as teamai's and ran nothing. env exec now takes what was typed after `exec`, and without -- before the command it says "Put -- before the command: teamai env exec -- <command>" and exits 2. teamai's own options may still come before --. * feat(doctor): check that the member's secret values can be read (Tencent#879) While teams/<team>.json or machine.json can't be read, every secret has no value and MCP keeps what the last pull wrote, yet the MCP check passed and only a pull warning said why. doctor now fails 'Your team secret values can be read' with the reason, for a scope whose secrets or variables read those files. * fix(env): name the unset variable a --from-env secret reads (Tencent#879) The missing-secret line told the member to run `teamai env set KEY`, which replaces the reference they chose. For a secret whose deciding entry reads an unset variable it now says: KEY reads VAR, which is not set. Set VAR, or run `teamai env set KEY [--global]` to replace the reference. * test(mcp): env unset keeps the entry, still owned, until a new value (Tencent#879) env set, pull, env unset with nothing exported, pull: the entry keeps the old value and the manifest still claims it, so the next value replaces it instead of colliding with a user-owned server. * refactor(env): expected env set/remove failures as values, one wording (Tencent#879) - secretInput returns a tagged result; an unexpected stdin or prompt failure propagates instead of printing as a user error (E1). - Every error path in env-commands uses fail() and invalidKeyMessage(), so each exits 1, env add's invalid key included (E2). - removeSecret returns removed | absent | reported: env remove of a variable env.yaml lacks still says it is not found next to a broken secrets.yaml (E3). - env add branches on --secret, not on a missing value (E4). - env unset with declarations that can't be read no longer calls the key a variable (E5). - "Secret is not declared" names the file and the next step (E6). - Messages call the machine store "global value (every team on this machine)", matching --global and the env list label (R5). * refactor(entries): EntryFailure always carries its layout (Tencent#879) An optional layout fell back to the type's, so a failure site that forgot it would word a broken secrets.yaml as env's. activeEntryNamespaces now takes the layout and every failure sets it (N1). * refactor(doctor): name entry resolution checks with their layout (Tencent#879) The check names were looked up by the layout's message label, so a wording change to a label would silently drop its doctor check. Each entry set now carries its check name (DD1). * refactor(secrets): report an unparsable value store by path only (Tencent#879) - Drop src/utils/json-position.ts, a second JSON grammar kept only to print a line and column: a parse error now reports the path alone, which is what the spec asks (never the input), and a disagreement with JSON.parse can no longer leak the parser's quote (SS3). - The unreadable-store error names what to check and the way out, and reads the error code without a cast (SS1). - SecretStore is inferred from its schema (SS2). - The design doc says an unreadable store leaves secrets 'unreadable'. * test(secrets): typed fixtures instead of casts in the new tests (Tencent#879) The LocalConfig and TeamaiConfig fixtures in env-exec, mcp-secrets and secret-values are now checked against the types, so a new required field breaks them instead of testing a shape production never has (T1). * docs(env): env set takes variables, listings show sources, exec needs -- (Tencent#879) - Usage guide: `env set` accepts an env.yaml variable without --global, not only a declared secret (D1/C2); `env exec` links the resolution order instead of "the order above", which the section never gave (C4). - team-secrets.md intro states the variable order; a --from-env variable override leaves the key out of new shells entirely. - Document the shared listing (variable source, `unreadable`, no values while the declarations fail), `mcp list`'s `not resolved`, the doctor check for an unreadable values file, and `env exec`'s exit 2 without --. * fix(env): refuse env set/unset/list when the project config can't be read (Tencent#879) Detection returned null for an unreadable project config, so env set fell back to the user scope and stored the value for that team. Report the file and why, exit 1, and write nothing, as pull and env exec do. * fix(env-exec): exit 128 + signal for a command killed by SIGPIPE or SIGUSR1 (Tencent#879) Re-raising SIGPIPE on teamai does nothing (Node ignores it) and SIGUSR1 starts the inspector, so teamai exited 0. Set the shell's exit code first and re-raise only the signals Node ends on. * fix(env-exec): don't send the command a second SIGINT on Ctrl-C (Tencent#879) The terminal sends Ctrl-C and Ctrl-\ to the whole foreground process group, so the command already has them; forwarding sent a second SIGINT, which tools such as terraform take as force-quit. Ignore SIGINT and SIGQUIT while the command runs and keep forwarding SIGTERM and SIGHUP. * docs(env): exec signal handling and env set on an unreadable project config (Tencent#879) * fix(mcp): judge MCP configs by disk and manifest, not current config (Tencent#882) Pull, doctor and uninstall still decided "clean" from the current team config in places. Now one function, resolvedValueEvidence, decides for all three: - a teamai-owned entry still in the file counts when its server has left mcp.yaml, as well as when it needs a resolved ${VAR} or mcp.yaml cannot be read (doctor no longer skips that case) - targets include the built-in location of a tool the team dropped from toolPaths or moved - doctor names a file two tools share once - exclude updates take the existing acquireLock helper, re-read the file and write it atomically, so concurrent commands keep each other's paths - uninstall inspects every worktree of each repository owning a block, including a nested repository's linked worktrees, and applies the manifest rule per worktree - the kept-block warning names each file and why, such as the variable whose value matched * fix(env): the env commands and env exec load config through --dry-run (Tencent#866) Tencent#866 threaded { dryRun } through the loaders pull, push, status and list use. The scope lookups this branch added did not take it, so `teamai --dry-run env list|set|unset|add|remove` and `env exec --dry-run` still persisted the legacy role migration, adopted a pre-Tencent#546 partition or ran the self-mode bootstrap. - resolveConfigForDir takes LoadOptions and passes them to both loaders. - scopeHere/requireScope (env commands) and commandEnvironment (env exec) forward options.dryRun. Without the flag nothing changes: env exec still runs the migrations every command runs (spec Tencent#879 Conflict 12). Five cases added to dry-run-load-path.test.ts; each failed before this change (config.yaml rewritten, partition renamed). * fix(secrets): name the team values file by the repo identity hash alone (Tencent#879) Renaming team: in teamai.yaml changed <team>-<hash>.json and orphaned every member's values. The secrets store now uses ~/.teamai/secrets/teams/<hash>.json; the models key files keep their names. The path has not shipped, so there is no migration. * fix(env): keep a __proto__ env key through the store, MCP and env exec (Tencent#879) ENV_KEY_RE accepts __proto__, but z.record dropped it from the value store, assigning it on an ordinary object hit the inherited setter, and reading it unset returned Object.prototype. The store, the MCP var table and the env exec overlay are now built without a prototype (envTable), and the member's environment and --from-env references are read as own keys (envValue). * fix(env): env list loads config with --dry-run always (Tencent#879) env list only reads, so like status and list since Tencent#866 it never migrates the config it loads, with or without --dry-run. The dry-run load-path test now runs env list without the flag, which is the case that used to migrate. * revert: drop the Tencent#890 cherry-pick from this branch 2e15c3f was picked only to protect the local Claude config while this branch's tests ran; Tencent#890 lands it on main on its own. * fix(env): env exec applies no team env while the declarations fail (Tencent#879) A legacy GITHUB_TOKEN in env.yaml plus a secrets.yaml that fails gave the command the repo value, though the key may be a declared secret. Like env.sh and the backup (Conflict 14), env exec now overlays nothing on a failed declaration: the command gets the inherited environment, and stderr names the failure. * fix(fs): create the atomic-write temp file with the target mode (Tencent#879) writeFileAtomic and writeJsonAtomic wrote the temp file with the umask's default mode (0644 under umask 022) and narrowed it by chmod afterwards, so a secret or model key was readable by other users until then. The temp file is now opened exclusively with the target mode; the chmod stays for the bits the umask removes. * fix(env): env set --dry-run previews without asking for the value (Tencent#879) `teamai --dry-run env set KEY` prompted for the value, or read stdin with --stdin, before printing the preview, so it failed without a terminal. The preview now comes first, and no value is read. * fix(env): serialize env set and env unset on the values file (Tencent#879) Two env set or env unset runs at once each read the store, changed it and wrote it back, so the later write dropped the other's change. Both now go through updateSecretStore, which takes <store>.lock (the acquireLock helper), re-reads the file inside it and writes the result. A --dry-run takes no lock. * fix(env): keep a secret's stored value from becoming a variable override (Tencent#879) Secrets and variable overrides share the team store. env set now records kind: secret | variable from what the scope declares; variable resolution uses only variable entries, secret resolution only secret ones, and an entry without kind counts as a secret. env list flags an entry of the other kind with the fix. * fix(mcp): write an MCP config that holds a resolved value 0600 (Tencent#879) writeJsonAtomic preserved an existing file's mode, so a 0644 .mcp.json or ~/.claude.json kept 0644 after teamai wrote a resolved secret into it. A config holding a resolved ${VAR} value (a kept entry included) is now written 0600; one without keeps its mode. * fix(mcp): create the Codex config temp file 0600 (Tencent#879) applyCodex wrote config.toml.<pid>.tmp with the umask's mode and chmodded it after, so a resolved secret was briefly readable at 0644. Both Codex writes now go through writeFileAtomic with mode 0600 (random temp name, created with the mode, symlinked targets written through). * docs(env): say env exec ignores a SIGINT or SIGQUIT sent to teamai alone (Tencent#879) * fix(mcp): tighten an unchanged config that holds a resolved value to 0600 (Tencent#879) * fix(env): mark what each env.sh exported so a value from one no scan finds is not the member's (Tencent#879) * fix(env): pass on a SIGINT or SIGQUIT sent to env exec outside the terminal's foreground (Tencent#879) * fix(env): keep marking what an env.sh exported before a rewrite dropped it (Tencent#879) * docs(env): say a SIGINT sent to a foreground env exec alone is not passed on (Tencent#879) * fix(secrets): name the team values file by the configured team repo URL, not teamai.yaml's repo: (Tencent#879) A copied or hostile team repo could claim another team's repo: and receive that team's stored values. The secrets file now hashes the URL from the member's own config, normalized so ssh, https and credentialed forms match. The models key store keeps its naming (Tencent#894). * fix(env): remove what a teamai env.sh exported from env exec while the declarations fail (Tencent#879) An invalid secrets.yaml left the inherited environment untouched, so a shell that had sourced an env.sh still passed the repo's GITHUB_TOKEN to the command. Every inherited value the member-environment rule discounts is now removed, named by key on stderr; the member's own exports stay. * fix(mcp): never write a declared secret into a project MCP config git tracks (Tencent#879) .git/info/exclude (Tencent#882) stops git add, not a file git already tracks. For such a file the server is skipped for that tool and an entry an earlier pull wrote stays as it is; pull warns, mcp list shows it as withheld and doctor fails the delivery check, each naming the file and git rm --cached. * fix(env): leave no duplicate declaration of a key env add --secret or env remove edits (Tencent#879) A key declared twice fails every read of secrets.yaml, and both commands edited only the first declaration. env add --secret now updates the first and removes the rest; env remove removes every one; both say how many. * test: keep the real normalizeRepoUrlForCompare in utils/git mocks the secrets store reaches (Tencent#879) * fix(env): keep the port in the URL that names a team's secrets file (Tencent#879) normalizeRepoUrlForCompare drops explicit ports, so two team repos on one host with different ports shared one values file and one team's secret reached the other. The file is now named by the URL's scheme family, lowercased host, non-default port and path; only credentials, the ssh user, a trailing .git and slashes are dropped. The scp form and the ssh URL of a repo still share a file; its ssh and https URLs no longer do. The utils/git mocks that kept the real normalizeRepoUrlForCompare for the store are no longer needed and are reverted. * fix(mcp): skip the .git/info/exclude write while another command holds its lock (Tencent#882) After the 2.5 s wait for the exclude file's lock, updateExclude wrote without it, so two writers could drop each other's pattern and leave a plaintext MCP config committable. It now writes nothing and reports 'locked': pull warns that the file is not excluded yet and to run `teamai pull` again (doctor's exclude check keeps reporting it meanwhile), and uninstall keeps the block and warns. * fix(uninstall): keep an exclude entry unless its MCP config is proven free of teamai's servers (Tencent#882) Uninstall judged a protected file clean from the current mcp.yaml, manifest and resolvable values, so with the manifest lost, the server gone from mcp.yaml and its value unset, a plaintext token looked like the member's own server and the exclusion went. It now fails closed and works per entry: a pattern goes only when its file is gone, holds no server, or holds none of teamai's servers with managed-mcp.json still there to say what teamai wrote. A kept entry is named with its file, why, and how to clean it by hand, since a rerun of uninstall finds no config after a full uninstall. * fix(env): keep http and https team repos in separate secrets files (Tencent#879) The store identity mapped https and http to one `http` family and dropped each default port, so `http://host/team.git` and `https://host/team.git` read one file: if the two endpoints serve different repos, one team got the other's stored secrets. The identity now keeps the scheme, still dropping 443 and 80; the ssh forms (`ssh://`, `git+ssh://`, `ssh+git://`, scp) stay one family. * fix(env): strip teamai env.sh exports in env exec when the project config can't be read (Tencent#879) With an unreadable project config, env exec passed the inherited environment unchanged, so a value another scope's env.sh exported (a legacy token, a member override) reached the command while the warning said no team values were applied. It now removes what the member-environment rule discounts (env.sh file, record or marker, the env.sh beside the unreadable config included), keeps the member's own exports, and names the removed keys, never values, as the failed-declaration path does. With no config at all the inherited environment is still passed as is. * fix(mcp): exclude a project MCP config from git before writing a resolved value into it (Tencent#882) Pull listed the file in .git/info/exclude only after writing the plaintext, and a failed exclusion only warned, so the secret-bearing file stayed eligible for git add -A. The exclusion now comes first; when it cannot be established (exclude file or .git/info not writable, lock held past the wait, file already tracked, git error) the file is left as it was and the warning names the reason and the fix. * fix(mcp): report a server withheld from a file git would commit in mcp list and doctor (Tencent#882) * fix(secrets): keep the ssh user in a team's values-file identity (Tencent#879) alice@host:team.git and bob@host:team.git can be different repos in each user's home; they no longer share one values file. The scp and ssh:// forms of one user, host, port and path still match; http(s) credentials are still dropped. * fix(env): overlay and remove env exec keys case-insensitively on Windows (Tencent#879) Windows environment names are case-insensitive, so a declared api_url left an inherited API_URL in place (Node keeps the first name of a case-folded pair) and a removed secret survived in another case. On win32 a key now replaces or removes every case variant; elsewhere nothing changes. * fix(mcp): report a tracked file on a dry run and a withheld server already installed (Tencent#882) Backports Tencent#880's merge 0d9f7fa: a dry run (doctor, mcp list) names a tracked file before any pull has listed it, mcp list reports withheld for a server an earlier pull installed, and doctor's withheld note carries the exclusion's own fix instead of the pull --force advice. * fix(mcp): name a tracked MCP config before an unwritable .git/info/exclude (Tencent#882) A tracked file needs `git rm --cached` whatever else is wrong, so ensureExcludedFromGit checks gitTracks before the writability check, on a pull and a dry run alike, and lists nothing for it. * fix(mcp): take a project MCP config's exclude line back out once it holds no resolved value (Tencent#882) A pull that lists a config in .git/info/exclude and then writes no value into it (it does not parse, a member's server holds the team's name, the write fails) removes the line it added. After a pull or `teamai mcp remove`, a line whose configs are proven clean in every worktree, by the proof uninstall uses (moved to mcp-reconcile.ts), is removed under the lock; one not proven clean stays. A config listed before its write is listed again after it, so a concurrent uninstall that dropped the line between the check and the write does not leave the value unprotected. * fix(secrets): tell an scp path in the ssh user's home from an ssh:// path from the root (Tencent#879) git@host:acme/team is relative to the ssh user's home, ssh://git@host/acme/team is absolute; on a plain ssh host they can be different repos, yet they shared one values file. An scp path starting with neither / nor ~ is now keyed as ~/path, the path ssh://host/~/path names; host:/abs and ssh://host/abs still match. The scp form without a user (host:path) is now read as ssh too. * fix(mcp): judge a project MCP config by the manifest as it stood before the pull rewrote it (Tencent#882) A pull whose manifest was lost before it ran recreates managed-mcp.json while reconciling, so the clean-file proof read the new record and took the exclude line out of a file still holding a teamai server that left mcp.yaml with its variable unset. The proof now uses this worktree's manifest as read before the reconcile. * fix(mcp): log a rolled-back exclude line at debug level (Tencent#882) A line this pull added and took back out, because it wrote no resolved value into the file, was reported as removed although the member never saw it added. Only removing a line an earlier run added stays at info. * fix(mcp): keep a shared exclude line while another worktree's config holds a server (Tencent#882) A pull or `teamai mcp remove` judged every linked worktree's MCP config with today's definitions and values. Once a server's ${VAR} became a literal, and the value was no longer set, a pull in worktree A took worktree B's stale token-bearing entry for clean and removed the shared /.mcp.json line, so `git add -A` in B staged the token. These commands now release a line only when the current worktree's file passes the full proof and every other worktree's file is missing or holds no MCP server. `teamai uninstall` keeps its full proof in each worktree. * test(mcp): build the other worktree from the real temp path so the test checks what it names (Tencent#882) * fix(env): strip teamai env.sh exports from env exec with no config or an HTTP scope (Tencent#879) Neither path applies team values, yet both passed on whatever a sourced teamai env.sh exported, another team's credentials included. Remove every inherited value that is not the member's own, as the unreadable-config path does, and name the removed keys on stderr. * fix(secrets): name a team's values file by the full SHA-256 digest (Tencent#879) The file name is the boundary between teams, and 40 bits let a hostile team search for a repo URL whose name matches another team's file and read its values. Nothing has shipped, so no migration. * fix(env): name the env.sh provenance marker by the full SHA-256 of its data home (Tencent#879) * test(push): push publishes the secrets.yaml env add --secret leaves (Tencent#879) * fix(uninstall): list no worktrees for a project root that no longer exists (Tencent#882) buildRemovalPlan now lists every worktree to find teamai's exclude blocks, outside the MCP cleanup's try. simple-git throws synchronously for a missing directory, so a project uninstall whose root is gone crashed; main's Tencent#878 test caught it after the merge. * fix(secrets): keep the URL query and fragment in a team's values file name (Tencent#879) * fix(mcp): treat an empty, unparsable or tool-less managed-mcp.json as no record (Tencent#882) The clean-file proof took any managed-mcp.json on disk as teamai's record, so an empty or truncated one let a pull, `mcp remove` or uninstall judge a file still holding a stale secret-bearing entry clean and drop its exclude line. A file now counts as recorded only when the manifest parses and holds an entry for that tool's file. A project record teamai empties stays as [] so a file left with only the member's own servers can still be released. * fix(env): compare exported, recorded and marked keys case-insensitively on Windows (Tencent#879) * fix(uninstall): list no worktrees for a project root that no longer exists (Tencent#879) * fix(mcp): keep the exclude line of a config this pull wrote when a later step fails (Tencent#882) * fix(mcp): read a check-ignore error as unsafe unless ls-files proves the config untracked (Tencent#882) * fix(mcp): report withheld only for targets delivery would write the server to (Tencent#882) * docs(mcp): describe the .git/info/exclude block in the setup skill and the stricter git check (Tencent#882) * fix(mcp): keep the exclude line of an entry a pull wrote with a resolved value after its definition turns literal (Tencent#882) * fix(mcp): judge a nested repository's linked worktree config by its sibling's tool (Tencent#882) * feat(mcp): record the project MCP configs a pull wrote a resolved value to in managed-mcp-files.json (Tencent#882) * fix(mcp): keep protecting a config a pull wrote under a toolPaths mapping the team has since changed (Tencent#882) * fix(mcp): keep a config's exclude line past the pull that rebuilt its lost record (Tencent#882) * test(mcp): pin today's exclude rules for a missing, corrupt or locked managed-mcp-files.json (Tencent#882) * docs(mcp): describe managed-mcp-files.json and the configs it keeps protected (Tencent#882) * refactor(mcp): keep the Tencent#882 record edits off the lines Tencent#880 changes (Tencent#882) * test(mcp): keep excluding a config whose entry a pull kept for a missing declared secret (Tencent#875, Tencent#882) * fix(mcp): protect a config an older teamai wrote under a mapping an earlier teamai.yaml made (Tencent#882) A teamai from before managed-mcp-files.json kept no record of the path it wrote a resolved value to. Once the team changed that toolPaths mapping, no pull visited the file. The first pull on this version now reads every mcpProject path the team repo's history of teamai.yaml mapped, once per worktree: a file under the project root that no current mapping or record reaches, and that holds a resolved value, is listed in .git/info/exclude and recorded. A git error leaves the read for the next pull; a shallow clone reads the history it has. * fix(mcp): keep a rebuilt record from persisting without its note of the file's other servers (Tencent#882) When a pull rebuilt a lost managed-mcp.json and could not note the other servers in the file (managed-mcp-files.json locked, an I/O error), it still wrote the rebuilt record, so no later pull knew the record was rebuilt and a stale server's line could go. The same manifest write now marks those records unnoted: the file counts as having no record, so it keeps its line while it holds a server, and the next pull notes them and clears the mark. * fix(mcp): take back a managed-mcp-files.json record for a config the pull then did not write (Tencent#882) A pull records a config before writing a resolved value to it. When the write failed or did not happen (the file does not parse), the record stayed, and once the mapping changed a config of the member's own at that path was kept excluded while it held any server. The pull now takes back a record it added for a file it did not write, as it does the file's exclude line; the settle after records it again if the file holds a resolved value anyway. * docs(mcp): describe the teamai.yaml history read, the unnoted rebuilt record and the record a failed write takes back (Tencent#882) * refactor(mcp): keep the r3 edits off the lines Tencent#880 changes (Tencent#882) * fix(mcp): also protect a config an older teamai wrote under a built-in default it has since changed (Tencent#882) * fix(mcp): replace a symlinked Codex config instead of writing into the file it links to (Tencent#875, Tencent#882) * fix(env): drop what a teamai env.sh exported from env exec when env.yaml or the values file fails (Tencent#875) * fix(env): on Windows, match a declared secret to an env.yaml variable in any case (Tencent#875) * fix(mcp): judge a project MCP config under a symlinked directory where the write lands (Tencent#882) The appliers replace the file itself (tmp + rename) but follow its directories. Every git check now judges realFilePath(file), the one resolver the release keying already used: a directory linked out of any repository no longer withholds the servers on git's "not a git repository", and a tracked file there is named with both paths, with a git rm --cached that works (git refuses the path through the link). * docs(mcp): describe how a config under a symlinked directory is kept out of git (Tencent#882) * refactor(mcp): keep realFilePath next to existingAncestor, without an import cycle (Tencent#882) * refactor(mcp): key each worktree's targets with realFilePath, the one rule for where a write lands (Tencent#882) * fix(mcp): judge a config under an earlier teamai.yaml mapping as a recorded file, not by today's records (Tencent#882) * fix(mcp): have doctor check the configs earlier teamai.yaml mappings reach until a pull reads them (Tencent#882) * docs(mcp): describe how a config under an earlier teamai.yaml mapping is judged, and doctor's check of it (Tencent#882) * fix(mcp): record a config under an earlier teamai.yaml mapping that git tracks, and judge it once git no longer does (Tencent#882) * fix(mcp): keep judging a recorded config for a tool the team moved while another tool still maps it (Tencent#882) * docs(mcp): describe the tracked config an earlier mapping reached, and a moved tool's config another tool still maps (Tencent#882) * fix(mcp): find a config an older teamai wrote under an earlier mapping another tool maps today, and judge it by that tool's records (Tencent#882) * docs(mcp): describe the history read's configs another tool maps today (Tencent#882) * fix(mcp): prove a shared config clean only while every tool that wrote a resolved value there has its record (Tencent#882) * fix(env): on Windows, set and unset a key under the name the scope declares, in any case typed (Tencent#875) * fix(mcp): judge a built-in location no mapping reaches today as an earlier-mapped file, and a shared config no pull recorded by every tool mapping it (Tencent#882) * docs(mcp): describe the built-in location of a moved or dropped tool, and a shared config no pull recorded (Tencent#882) * fix(env): on Windows, match a secret's declaration and stored value in any case (Tencent#875) * fix(mcp): name the ignore rule that re-includes a config teamai just listed, instead of saying git tracks it (Tencent#882) * fix(mcp): judge a moved tool's built-in location another tool maps for that tool too, and hold a config's line while no managed-mcp.json claims its servers (Tencent#882) * docs(mcp): describe the no-manifest rule, a moved tool's built-in location another tool maps, and a re-including ignore rule (Tencent#882) * fix(env): key a team's values by its repo URL when the configured remote is only an alias (Tencent#875) * fix(env): on Windows, recognise a secret's env.yaml value under another case of its name in the environment (Tencent#875) * fix(mcp): on Windows, keep an inherited value under another case of a team variable's name out of MCP servers (Tencent#875) * fix(env): on Windows, replace and remove every stored entry under another case of the key (Tencent#875) * fix(mcp): keep a tool's record as it was when its config does not parse, and take back each tool a write that did not happen recorded (Tencent#882) * fix(mcp): mark the records a pull with no managed-mcp.json writes as unnoted until the servers no record claims are noted (Tencent#882) * fix(mcp): have doctor judge a record marked unnoted like a missing managed-mcp.json (Tencent#882) * fix(mcp): judge a config tools of different formats share in each of their formats before releasing its line (Tencent#882) * fix(mcp): note the servers no record claims in the file of a tool whose record a pull writes first, as with no managed-mcp.json at all (Tencent#882) * fix(mcp): take back a tool managed-mcp-files.json recorded before a write unless its own records hold a resolved value there (Tencent#882) * fix(mcp): treat an installed tool's missing record as lost at every pull and in doctor, not only an empty managed-mcp.json (Tencent#882) * fix(mcp): tighten to 0600 every project config the protection pass keeps out of git, not only the ones a pull writes (Tencent#879) * fix(mcp): on Windows, fill a placeholder from the variable of the same name in another case (Tencent#875) * fix(mcp): note the unclaimed servers under every format of a shared config, and pin an uninstalled tool's leftover config (Tencent#882) * fix(mcp): count an uninstalled tool's missing record when no installed tool maps its file, and name a re-including .gitignore rule on a dry run (Tencent#882) * fix(mcp): on Windows, match a placeholder to its secret in any case in mcp list and the missing-secret notice (Tencent#875) * fix(mcp): scope a shared config's claims to the tools reading the same key, and settle its notes on every format's view (Tencent#882) * fix(env): keep a file:// repo's .git suffix in its values file identity: team and team.git are two directories (Tencent#875) * fix(env): on Windows, update and remove an env.yaml variable typed in another case (Tencent#875) * fix(mcp): keep suspect an uninstalled tool managed-mcp-files.json lists as a writer, though an installed tool maps the file (Tencent#882)
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.
Why
Project-scope machine data lives in a partition under
~/.teamai/projects/<slug>/, but the slug prefix was only the anchor's basename (e.g.teamai-cli-3c20640ee7801c3f). So the directory name did not reveal which project it belonged to — unlike Claude Code's~/.claude/projects/, whose names encode the full path (-Users-x-Project-app). A user browsing~/.teamai/projects/could not tell partitions apart at a glance.What
projectSlug()now builds the prefix from the whole anchor path (leading separator dropped, path separators →-):The 16-hex sha256 suffix is unchanged, so:
/x/my-projvs/x/my/proj) and shared basenames stay distinct via the hash.slug === dirnamecorrupt check (status.ts) needs no change — the identity still holds.normalizeAnchorbehavior), which is required for correctness, not cosmetic.The prefix is length-bounded (
MAX=180, keeping the identifying tail) so a very long path can never overflowNAME_MAX; the hash still disambiguates two long paths sharing a truncated head. The authoritative reverse lookup remains the per-partitionanchorfile — the readable prefix is a convenience only (lossy + one-way).Test Plan
Unit (
src/__tests__/partition.test.ts, updated + extended):Users-x-Project-teamai-cli-<hash>)≤200) while the hash keeps it uniquetsc --noEmitcleanReal-CLI end-to-end (isolated
HOME,dist/index.js):private-tmp-…-my-demo-app-<hash>teamai status --allreverse-resolves it →project: …/my-demo-app[active][corrupt — dir name does not match anchor]teamai statusfrom the project cwd drives detection → loads the partition config via the new slug (data: ~/.teamai/projects/private-tmp-…-<hash>)Docs
docs/designs/data-directory-layout.md— slug formula + reverse-lookup note updated to match. (<slug>placeholders in usage-guide.* are unchanged — the concept is identical.)