Skip to content

fix(push): carry teamai.yaml config changes through push - #323

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
jeff-r2026:fix/push-teamai-yaml
Aug 25, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
jeff-r2026:fix/push-teamai-yaml

Conversation

@jeff-r2026

Copy link
Copy Markdown
Collaborator

Problem

teamai source add (and source remove) edits the team repo's teamai.yaml — writing the sources / publicSkills a team subscribes to — and then prints "Run teamai push to share this change with your team." But teamai push did not handle teamai.yaml at all, so that advice was broken in three compounding ways:

  1. Data loss. push starts by calling resetToCleanMaster, whose git reset --hard sees the dirty teamai.yaml and silently discards the user's source add edit before anything is committed.
  2. Never committed. The push commit file list (gitFiles) is a whitelist of resource dirs (skills/, rules/, env/, …). teamai.yaml is never in it, so even a surviving edit would be ignored.
  3. Config-only exits early. If the user only edited teamai.yaml (no resource changes), push returns at allItems.length === 0 with "No new or modified resources to push" — the change never leaves their machine.

Net effect: subscribing to another team's public skill repo could not actually be shared with the team, and the attempt could destroy the edit.

Fix

All in src/push.ts, on the normal dedicated-repo path (not self mode):

  • Preserve the edit across reset — capture the working-tree teamai.yaml before resetToCleanMaster, then re-write it on top of the freshly pulled default branch.
  • Commit it with resources — add teamai.yaml to gitFiles when the user edited it, so config rides along in the same PR as any skills/rules.
  • Config-only push — new pushTeamConfigOnly() handles the "only teamai.yaml changed" case so source add's advice actually works.

The change is provider-agnostic — no github/gitlab/tgit special-casing. PR/MR creation goes through the existing createPrWithFallback → getProvider(...).createPullRequest(...) abstraction, so GitHub, GitLab, and TGit are all covered by the path that already ships skills.

Docs: also corrected docs/usage-guide.md / .zh-CN.md, which wrongly claimed subscriptions live in the local config.yaml. They live in the team repo's teamai.yaml and are shared via push.

Test Plan

  • npx tsc --noEmit — clean
  • npm run build — clean
  • npx vitest run — full suite green (163 files / 2187 tests), zero regressions
  • New real-git integration test src/__tests__/push-team-config.test.ts — drives real push() against a local bare remote + clone (mocking only the provider PR call): a source add-style edit survives the real git reset --hard and lands on the pushed branch; a no-op push creates no PR.
  • Real CLI end-to-end against git.woa.com (throwaway HOME, isolated from real ~/.teamai): teamai init e2e-test-repo → teamai source add teamai-dev-repo → teamai push --all. The pushed remote branch's teamai.yaml contained sources: e2e-dev; baseline origin/master had none. Test branch and the auto-created MR were cleaned up afterward.

`teamai source add` writes sources/publicSkills into the team repo's
teamai.yaml without committing, then tells the user to run `teamai push`.
But push did not handle teamai.yaml at all:

1. resetToCleanMaster's `git reset --hard` silently destroyed the
   uncommitted edit before it could be committed.
2. teamai.yaml was never in the commit file list (whitelist of resource
   dirs only), so even a surviving edit was ignored.
3. A config-only change (no resource edits) exited early with
   "No new or modified resources to push".

Fixes:
- Capture teamai.yaml working-tree content before reset, restore it on
  top of the freshly pulled branch (survives reset --hard).
- Include teamai.yaml in gitFiles when the user edited it, so it rides
  along in the same PR as resources.
- Add pushTeamConfigOnly() for the config-only case so `source add`'s
  "Run teamai push" advice actually propagates the change.

All provider-agnostic (no github/gitlab/tgit special-casing); PR
creation goes through the existing createPrWithFallback abstraction.

Also fixes the docs claim that sources live in local config.yaml — they
live in the team repo's teamai.yaml and are shared via push.

Tested:
- tsc --noEmit, npm run build, full vitest suite (2187 tests) green
- New real-git integration test (push-team-config.test.ts): source-add
  edit survives real reset --hard and lands on the pushed branch
- Real CLI e2e against git.woa.com: init e2e-test-repo, source add
  teamai-dev-repo, push --all → teamai.yaml with sources reached the
  remote branch; baseline master had none (test branch + MR cleaned up)
@jeff-r2026
jeff-r2026 requested a review from m0Nst3r873 August 25, 2026 08:28
@jeff-r2026
jeff-r2026 merged commit dbb4191 into Tencent:main Aug 25, 2026
7 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
`teamai source add` writes sources/publicSkills into the team repo's
teamai.yaml without committing, then tells the user to run `teamai push`.
But push did not handle teamai.yaml at all:

1. resetToCleanMaster's `git reset --hard` silently destroyed the
   uncommitted edit before it could be committed.
2. teamai.yaml was never in the commit file list (whitelist of resource
   dirs only), so even a surviving edit was ignored.
3. A config-only change (no resource edits) exited early with
   "No new or modified resources to push".

Fixes:
- Capture teamai.yaml working-tree content before reset, restore it on
  top of the freshly pulled branch (survives reset --hard).
- Include teamai.yaml in gitFiles when the user edited it, so it rides
  along in the same PR as resources.
- Add pushTeamConfigOnly() for the config-only case so `source add`'s
  "Run teamai push" advice actually propagates the change.

All provider-agnostic (no github/gitlab/tgit special-casing); PR
creation goes through the existing createPrWithFallback abstraction.

Also fixes the docs claim that sources live in local config.yaml — they
live in the team repo's teamai.yaml and are shared via push.

Tested:
- tsc --noEmit, npm run build, full vitest suite (2187 tests) green
- New real-git integration test (push-team-config.test.ts): source-add
  edit survives real reset --hard and lands on the pushed branch
- Real CLI e2e against git.woa.com: init e2e-test-repo, source add
  teamai-dev-repo, push --all → teamai.yaml with sources reached the
  remote branch; baseline master had none (test branch + MR cleaned up)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant