Skip to content

fix(pull): point a kept agent or rule folder copy at the team folder, not at push - #1905

Closed
Walternater wants to merge 4 commits into
Tencent:mainfrom
Walternater:fix/kept-folder-edit-at
Closed

Walternater wants to merge 4 commits into
Tencent:mainfrom
Walternater:fix/kept-folder-edit-at

Conversation

@Walternater

Copy link
Copy Markdown
Collaborator

Summary

Fixes the first of the five bugs in #1880. Pull keeps an edited copy of a delivered agent or rule folder and told the member to share it with teamai push — which takes nothing from it, because the folder is edited in the team repo (AgentsHandler.scanLocalForPush at src/resources/agents.ts:427, RulesHandler.scanLocalForPush at src/resources/rules.ts:82, and docs/guide/sharing.md says the same). The member follows the advice, push answers "No new or modified resources to push", and nothing is shared.

The kept copy's message now names the team folder the change is made in, so the member is told where to make it instead of being pointed at a command that ignores it.

Type of Change

  • Bug fix (non-breaking change that fixes a bug)

What changed

  • src/resources/delivered-copies.ts — keepsEditedCopy records editAt (the team folder) for a folder copy, on both paths that push a kept entry; reportKept words that copy from it. Every other kept copy keeps its message.
  • src/types.ts — ResourceItem.folder documented itself as "Rules only", but agent folders set it too (src/resources/agents.ts:784). The comment now says both, which is what makes one condition cover agent and rule folders. The field's meaning does not change.
  • src/__tests__/e2e/pull-keeps-edits-822.test.ts — a case in the file that already owns this behaviour.

Test plan

Proof is a failing test first, extended into the existing pull-keeps-edits-822.test.ts (AGENTS.md "Proof for a bug fix is a failing test first"):

  • New case, on main: npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/pull-keeps-edits-822.test.ts -t "rule folder" → fails, the output tells the member to Share it with \teamai push``.
  • Negative control: with the source change stashed and the CLI rebuilt, the case fails again; restoring it returns 13/13.
  • After the change: 13/13 in that file. delivered-copies and agent-folders units: 31/31. npx tsc --noEmit clean, npm run lint passes.

Real CLI in a verify world (20261116T040738-a6b4d3, build 84561fb0+dirty): a team repo carrying rules/api-style/RULE.md, one pull to deliver it, the member appends a line to .claude/rules/api-style.md, the team bumps RULE.md, a second pull prints:

⚠ [workspace] Kept <project>/.claude/rules/api-style.md: you changed it, and the version teamai
would deploy there (rules/api-style/RULE.md) has changed since. Edit rules/api-style/ in the team
repo and let the next pull deliver it; push takes nothing from this copy. Or delete your copy and
run `teamai pull --force` to take the team version.

The ledger reports one LEAK, and it is not this change: ~/.claude/plugins/claude-hud/transcript-cache/… (a plugin of the shell the world ran in) names the world. Everything else under (e) is the known #1808 set.

Hit every surface

  • Tools: the message is per copy, not per tool. The world ran Claude Code; the Cursor render of the same folder takes the same path, since the kept entries are recorded before any tool renders.
  • Scopes: user and project. The world ran workspace scope; the guard is in keepsEditedCopy, which both scopes call.
  • Team repo modes: git in the world. http teams are read-only and never reach this path.
  • Layers: a default, a team-root replacement and a namespace folder all arrive as one ResourceItem.folder, so all three get the new wording.
  • OS: macOS local, Linux and Windows in CI. No path arithmetic changed; path.posix.dirname matches how relativePath is spelled.

Notes for reviewers

Disclosure

Implemented with AI assistance (Claude Code); every line reviewed and tested by the author.

… not at push

Pull kept an edited copy of a delivered agent or rule folder and told the member
to share it with `teamai push`, which takes nothing from it — the folder is
edited in the team repo (`AgentsHandler.scanLocalForPush`,
`RulesHandler.scanLocalForPush`). The message now names that folder instead.

`keepsEditedCopy` records the team folder a folder copy's change is made in, and
`reportKept` words that copy from it. Every other kept copy keeps its message.

`ResourceItem.folder` documented itself as rules-only, but agent folders set it
too (`agents.ts:784`), which is what made one condition cover both.

Co-Authored-By: Claude Code <[email protected]>
@github-actions

Copy link
Copy Markdown
  • [P2 non-blocking] src/resources/delivered-copies.ts:863 — Editing the team folder does not guarantee that the next pull delivers it: classifyCopy still preserves a local copy differing from both the recorded and incoming versions. For example, merging the member’s extra line into team Version two leaves their local Version one plus that line protected. Tell members to save their edits in the team folder, then delete the delivered copy and pull, rather than presenting deletion only as an alternative.

Testing documentation is sufficient: the description records failing-first coverage, unit tests, lint, type checking, and a representative real-CLI verify-world run. No testing-record finding. No PR code was executed.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generated by AI during triage.

Reviewed at 0553859. The message now names the right place, and only its last step needs to change.

What I checked. I ran the built CLI with this head and the merge-base (84561fb) on a team repo with an agent folder (agents/reviewer/) and a rule folder (rules/api-style/):

  1. pull, then the member edits both delivered copies, then teamai push --all. Both builds print "No new or modified resources to push", as you say.
  2. The team changes RULE.md, then pull. Main says to share the copy with teamai push. This head names rules/api-style/ and agents/reviewer/ in the team repo, which is the fix #1880 asks for.
  3. I followed the new advice: the team folders took the member's line, then pull. The agent copy now matches and is taken back. The rule copy is kept again, with the same warning. One more team change, then pull: kept again, same warning.
  4. rm .claude/rules/api-style.md and teamai pull --force delivers the team version with the member's line, and later pulls deliver normally.

CI is green at this head. #1908 fixes another part of #1880 and shares no file with this one.

[P1 blocking] "let the next pull deliver it" doesn't happen (delivered-copies.ts:863). We agree with the CI review here, and we'd make it blocking, since it fits this PR. classifyCopy (:56-63) keeps any copy whose bytes match neither the recorded hash nor the incoming one. A copy the member changed still carries the team's old text, so moving the change into the team folder doesn't make the bytes equal. A member who does what the message says gets the same message on every pull, which is the loop this PR set out to end. Step 4 is what works, so the message could say that in one instruction:

`Push takes nothing from this copy: make your change in ${editAt} in the team repo, `
  + 'then delete your copy and run `teamai pull --force` to take the team version.'

The new test's toContain('Edit rules/api-style/ in the team repo') would follow the new wording.

[P2 non-blocking] teamai doctor still says "A copy changed by you is kept by pull: share it with teamai push" (doctor-delivery.ts:174-178). For a rule or agent folder copy, that's the same wrong advice. It shows only beside another failing check, and I checked it by reading the code only.

[P3 nit]

  • A kept folder copy the team hasn't changed now prints a warning where main printed info (delivered-copies.ts:860). #1880 keeps info for that form, so (teamChanged ? log.warn : log.info) would match it.
  • The new case covers the rule folder only, and its not.toContain can't fail on main: that scenario prints the "Merge that change…" form there, not the text the assertion excludes. The positive assertions do the work.

CI review. One P2, the finding above. We agree, and we'd raise it to blocking.

Merge risk. Low. One log message and an optional field on an internal record. No sync state changes.

…e edit is not enough

classifyCopy keeps any copy whose bytes match neither the record nor what
teamai would write now. A member who moves their change into the team folder
leaves the copy unchanged, so every later pull keeps it again: the message
promised a delivery that never came.

The copy goes instead, after the edit lands in the team repo. doctor's advice
for CHANGED_BY_YOU names the team folder for a folder copy too, and a kept
folder copy the team has not changed stays `info` as on main.

Co-Authored-By: Claude Code <[email protected]>
@github-actions

Copy link
Copy Markdown

No new confident findings in the scoped diff.

  • Resolved: The earlier finding is fixed: the advice now says to make the change in the team folder, then delete the delivered copy and run teamai pull --force.
  • Testing: The description documents sufficient testing, including failing-first coverage, unit tests, lint, type checking, and a representative real-CLI verify-world run. The older build reference is not blocking under the review rules.

No PR code was run, built, or installed.

@Walternater

Copy link
Copy Markdown
Collaborator Author

Both findings fixed in e9477a6.

[P1 blocking] "let the next pull deliver it" doesn't happen — you're right, and the reason is exactly classifyCopy: moving the edit into the team folder leaves the copy's bytes unchanged, so the next pull keeps it again. The message now asks for the step your step 4 proved:

Push takes nothing from this copy: make your change in rules/api-style/ in the team repo,
then delete your copy and run `teamai pull --force` to take the team version.

[P2 non-blocking] doctor's advice now names the team folder when the kept copy is an agent or rule folder, and leaves teamai push in the sentence for every other copy.

[P3 nit] A kept folder copy the team has not changed is back on log.info; the warn is only the teamChanged form.

Real-CLI record (world 20261117T050005-c1df04, built from this head). A rule folder rules/api-style/, the member appends a line to its copy, the team changes RULE.md:

⚠ [workspace] Kept …/.claude/rules/api-style.md: you changed it, and the version teamai would deploy
there (rules/api-style/RULE.md) has changed since. Push takes nothing from this copy: make your change
in rules/api-style/ in the team repo, then delete your copy and run `teamai pull --force` to take the
team version.

Then following it — the line lands in the team folder, the copy is deleted, teamai pull --force:

✔ [workspace] Synced 1 rule(s)
delivered copy: # API style / Version two. / My extra line.

No second warning; the member's line arrives. The new doctor test fails on this head before the fix (share it with teamai push`` where the team folder belongs) and passes after.

The ledger reports one LEAK, real HOME names this world (the claude-hud transcript cache in my own ~/.claude, outside the world); the leftover lines after uninstall are the known #1808 set.

@Walternater

Copy link
Copy Markdown
Collaborator Author

Fixed in 409d0a4c, the wording you proposed, taken as the whole instruction:

Push takes nothing from this copy: make your change in <folder> in the team repo,
then delete your copy and run `teamai pull --force`.

You're right that "let the next pull deliver it" was the wrong promise — a kept copy's bytes match neither hash, so moving the edit into the team folder cannot make the next pull treat it as deliverable, and a member following the old sentence would meet the same line every pull. Both steps are now in one direction, and the e2e test (pull-keeps-edits-822.test.ts:438) asserts the full sentence rather than the two fragments that let the old promise stand.

[P2] teamai doctor: its folder branch carried the same gap one clause later — "make your change in the team folder, then delete your copy and run teamai pull --force" — which left the purpose of the --force unstated. It now ends run \teamai pull --force` to take the team version.The other branch ("share it withteamai push`") is unchanged, since a file copy is still pushable.

[P3] The log level was already (teamChanged ? log.warn : log.info) at this head — delivered-copies.ts:866 — so a kept folder copy the team hasn't changed prints at info, matching #1880.

Checks: pull-keeps-edits-822.test.ts 13/13 (e2e config), doctor-delivery.test.ts 71/71, tsc --noEmit clean.

The CI review's P1 is the same finding, so this resolves both.

@github-actions

Copy link
Copy Markdown
  • [P1 blocking] src/__tests__/e2e/pull-keeps-edits-822.test.ts:438 — The new test requires then delete your copy and run \teamai pull --force` to take the team version., but reportKeptnow ends that sentence immediately after`teamai pull --force`.` This assertion fails with the current implementation. Align the assertion and emitted message.

Resolved: The earlier advice finding is fixed: members are now told to edit the team folder, then delete the delivered copy and pull.

Testing: The description includes a representative real-CLI verify-world record, so no missing-record finding. Its older build reference is not blocking.

No PR code was run, built, or installed.

409d0a4 dropped it from reportKept while the E2E assertion took it, so the
test failed at that head, and the message a member reads no longer said what
`pull --force` takes. The copy of every other kept resource names it, in the
same function.

Co-Authored-By: Claude Code <[email protected]>
@github-actions

Copy link
Copy Markdown

No new confident findings in the scoped diff.

  • Resolved: The advice now tells members to edit the team folder, then delete the delivered copy and pull.
  • Resolved: The E2E assertion now matches the emitted message, including “to take the team version.”
  • Testing: The description includes a representative real-CLI verify-world record, so no missing-record finding. Its older build reference is not blocking under the review rules.

No PR code was run, built, or installed.

@Walternater

Copy link
Copy Markdown
Collaborator Author

The P1 is real and was mine: 409d0a4 removed "to take the team version." from reportKept while the E2E assertion took the longer wording, so npm run test:e2e -- pull-keeps-edits-822 failed at that head. It is back in 655b5f6 — the copy of every other kept resource names what pull --force takes, a few lines below in the same function, so the folder copy saying less was the outlier rather than the target.

Confirmed locally at 655b5f6: npm run test:e2e -- pull-keeps-edits-822 13/13, delivered-copies.test.ts + doctor-rules-delivery.test.ts 105/105, typecheck and lint pass.

On the P2: the advice is now the sequence you asked for — make the change in the team folder, then delete the copy and pull --force — rather than deletion as an alternative. Both halves are needed: classifyCopy keeps any copy differing from the record and from the incoming version, so deleting is what lets the team version land, and --force is what makes the pull look at a scope it would otherwise skip.

@XY-code1

Copy link
Copy Markdown
Collaborator

Triage status: ready for a fresh maintainer review.

  • The findings from the earlier requested-changes review were addressed in later commits.
  • The latest automated review reports no remaining findings.
  • CI is green.
  • A representative real-CLI verify-world record is present.
  • There are no merge conflicts.

The earlier requested-changes review still blocks merging, so this needs a new review from someone with write access.

@jeff-r2026

Copy link
Copy Markdown
Collaborator

因超过一周无活动且 review 未完成关闭。SaulMoro 在 2026-11-16 的 CHANGES_REQUESTED 之后,维护者复审一直未处理(最后一条 XY-code1 2026-11-18 19:14 记为 ready for maintainer review),7 天无进展。如仍需要,欢迎重新提 PR 到最新 main。

@jeff-r2026 jeff-r2026 closed this Nov 26, 2026
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.

4 participants