Skip to content

fix(clone): enable long paths for every clone teamai starts on Windows - #1954

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
mosifu:fix/clone-longpaths-windows
Nov 26, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
mosifu:fix/clone-longpaths-windows

Conversation

@mosifu

@mosifu mosifu commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Every git clone teamai starts now carries core.longpaths=true on Windows.

#1518 gave the shared Git clients that setting, but all seven clone paths start git through
spawnSync, so a team repo holding a path longer than MAX_PATH still fails the very first
teamai init — and docs/guide/windows.md documents that as something the user has to fix with
git config --global core.longpaths true. With this change the workaround is no longer needed.

Reproduction

Windows, Node 22.22.2, Git for Windows (no core.longpaths in any config):

# a team repo whose deepest file is at a 200-character relative path,
# cloned into a 78-character target: 279 characters in all
$ git clone D:\tmp-lp3\s D:\tttt…\repo
fatal: cannot create directory at 'aaa…/aaa…/aaa…/aaa…': Filename too long
warning: Clone succeeded, but checkout failed.
$ echo $?
128

$ git -c core.longpaths=true clone D:\tmp-lp3\s D:\tttt…\repo
$ echo $?
0

GenericGitProvider.cloneRepo turns that 128 into git clone failed: … Filename too long, so
teamai init stops with a half-checked-out team repo behind it.

What changed

  • src/utils/git.ts exports longPathConfig() and longPathArgs() so the two spellings cannot
    drift: createGit/createGitWithBlockTimeout keep taking the config, and a clone that starts
    git itself takes -c core.longpaths=true ahead of the subcommand.
  • The seven clone sites use it: src/clone.ts (shallowClone), providers/git, providers/github,
    providers/gitlab, providers/gitcode, providers/cnb (both the token and the credential-helper
    branch), providers/tgit.
  • docs/guide/windows.md, docs/guide/zh-CN/windows.md: the init-clone caveat is gone.

Test Plan

$ npx tsc --noEmit
(clean)

$ npx oxlint <the 14 changed files>
Found 0 warnings and 0 errors.

$ node scripts/check-docs.mjs
Documentation checks passed.

$ npx vitest run src/__tests__/git.test.ts src/__tests__/clone.test.ts \
    src/__tests__/generic-git-provider.test.ts src/__tests__/cnb-provider.test.ts
Test Files  4 passed (4)
     Tests  132 passed (132)

The new cases are load-bearing: reverting the two call sites makes them fail
(6 failed | 37 passed), and longPathArgs is asserted per platform the same way #1518 asserted
the simple-git config.

Real-CLI record: not available from this machine. npm run verify:world refuses to start here —
A world needs a POSIX shell; Windows is not supported. Say so in the PR instead. The reproduction
above is the same git invocation the provider makes, run against a real long path.

npm run lint on this checkout is red with 26 teamai(family-facts) errors, all in
packages/tool-*/src/facts.ts — the Windows false positive #1927 fixes. Unrelated to this change,
which is why the lint evidence above is scoped to the changed files.

Verification — real CLI, both sides of the fix

npm run verify:world marks Windows UNVERIFIABLE by its own verdict table, and this change is
process.platform === 'win32': a POSIX world cannot reach the code under test. So the pair the
harness asks for was produced with the real CLI on Windows instead — same workspace depth, same
command, one build from main and one from this branch.

Fixture: a bare team repo whose only content sits at a 120-character relative path; the workspace
puts the clone target at 319 characters, past MAX_PATH. url.<local>.insteadOf maps
https://teamai.test/team/repo.git to that local repo so no network is involved.

Before — main (dist built from main, no change):

$ node dist/index.js init https://teamai.test/team/repo.git --provider git --agent claude
- Cloning team repo...
× Clone failed: git clone failed: Cloning into '...\ws-before\.teamai\team-repo'...
  fatal: cannot write keep file '.../team-repo/.git/objects/pack/pack-ce34ac76....keep': Filename too long
  fatal: fetch-pack: invalid index-pack output
exit 1

After — this branch:

$ node dist/index.js init https://teamai.test/team/repo.git --provider git --agent claude
- Cloning team repo...
√ Team repo cloned
✔ Registered as team member: t
✔ teamai initialized successfully!
exit 0

Same binary shape (tsup output, node dist/index.js), same HOME, same workspace depth. The only
difference is the -c core.longpaths=true this branch passes to the clone.

Related Issues

Follows #1518, which covered the shared clients.

  • npx tsc --noEmit passes
  • npm run lint passes on the changed files (0 warnings and 0 errors)
  • The test files that cover what I changed pass
  • Added/updated tests for the change
  • Runtime change: real-CLI record — the pair above (main fails with Filename too long, this branch clones); the verify world itself reports Windows as UNVERIFIABLE, which is why the record is the real CLI on the platform the change is for

@mosifu

mosifu commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

A process question rather than a bump on the change itself: the four workflows on this PR (CI, Code Erosion, Agent Context Budget, Agent Wait Budget) have sat at action_required since 11-18, because a first-time contributor's run needs an approval. Authorize trigger and the open-source scan are already green.

Could someone approve the run when convenient? No code is waiting on my side — tsc, oxlint on the changed files, check-docs, the four affected test files (132 passed) and a mutation check are all green locally, but the workflow run has never happened, so the PR currently shows nothing to review.

@mosifu
mosifu force-pushed the fix/clone-longpaths-windows branch from d45c23e to 09f66cc Compare November 24, 2026 11:46
@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Missing required real-CLI verification — PR description. This diff changes runtime behavior, but the description explicitly provides no verification-world record. The direct git clone reproduction does not exercise teamai’s CLI. This violates the Code Review Rules requirement for runtime changes; provide one representative real-CLI run in a supported POSIX world.

  • [P2 non-blocking] Claimed coverage does not match the diff — src/clone.ts:290, src/providers/gitlab/gitlab-api.ts:225. The description claims seven clone sites and both Windows guides changed, but the specified diff contains only these two clone-site updates and no guide changes. Include the missing changes or correct the description so reviewers can accurately assess the delivered fix.

  • [P2 non-blocking] Unrelated runtime changes violate surgical scope — src/utils/git.ts:1479, src/clone.ts:74, src/providers/gitlab/gitlab-api.ts:255. The working-tree backup cleanup/error changes and credential-redaction changes do not implement Windows long-path support. Split them into separate PRs; the Code Review Rules explicitly require every changed line to trace to the PR’s stated goal.

Review was read-only; nothing from the PR was run, built, or installed.

@mosifu
mosifu force-pushed the fix/clone-longpaths-windows branch from 09f66cc to 55c0170 Compare November 24, 2026 11:48
@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Required real-CLI verification is still missing — PR description. This changes runtime behavior, but the test plan explicitly contains no real-CLI record. The direct git clone reproduction does not exercise teamai. This violates the Code Review Rules requirement for runtime changes; provide one representative real-CLI run in a supported POSIX verification world.

  • [P2 non-blocking] Unrelated runtime changes remain — src/utils/git.ts:1494, src/clone.ts:74, src/providers/gitlab/gitlab-api.ts:255. Working-tree backup cleanup/error handling and credential redaction do not implement Windows long-path support. Split these changes and their tests into separate PRs, as required by the surgical-scope rule.

Resolved: The earlier coverage mismatch is fixed: the current diff updates all seven named clone paths, both CNB branches, and both Windows guides.

Review was read-only; nothing from the PR was run, built, or installed.

The shared Git clients carry core.longpaths since Tencent#1518, but all seven clone
sites start git through spawnSync, so the first `teamai init` still failed with
"Filename too long" for a team repo holding a path past MAX_PATH, and the
Windows guide asked the member to set the option globally first.

longPathConfig() and longPathArgs() keep the two spellings in one place: the
clients take the config, and a clone takes `-c core.longpaths=true` ahead of the
subcommand, where a git-level option has to sit.
@mosifu
mosifu force-pushed the fix/clone-longpaths-windows branch from 55c0170 to 177e0ae Compare November 24, 2026 11:50
@github-actions

Copy link
Copy Markdown
  • [P1 blocking] Required real-CLI verification remains missing — PR description. This changes runtime behavior, but the test plan explicitly supplies no verification-world record. The direct git clone reproduction does not exercise teamai’s CLI. This violates the Code Review Rules requirement for a representative real-CLI run; provide one from a supported POSIX environment.

Resolved: The coverage mismatch is fixed: all seven named clone paths, including both CNB branches, and both Windows guides are updated. The unrelated backup-cleanup/error-handling and credential-redaction changes are absent from the current diff.

No additional confident bugs found. Review was read-only; nothing from the PR was run, built, or installed.

@mosifu

mosifu commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

On the real-CLI requirement: the description now carries the record, and it is a pair.

npm run verify:world cannot produce it for this change. Its own verdict table lists Windows under UNVERIFIABLE ("a prerequisite is missing (a tool, a sign-in, Windows)"), and this diff is process.platform === 'win32' — a POSIX world never reaches the line under test. docs/dev/agent-sessions.md says the same thing from the other side: "Windows has no CI: test it through the seams that take a platform".

So the pair was produced with the real CLI on Windows instead: a bare team repo whose content sits at a 120-character relative path, a workspace that puts the clone target at 319 characters, and url.<local>.insteadOf pointing https://teamai.test/team/repo.git at it, so nothing touches the network.

  • main's build: × Clone failed: ... fatal: cannot write keep file ... Filename too long, exit 1.
  • This branch's build: √ Team repo cloned, ✔ teamai initialized successfully!, exit 0.

Same workspace depth, same command, tsup output on both sides; the only difference is the -c core.longpaths=true this branch passes. If a maintainer would rather see it inside a world, the change would have to be proved on a POSIX host with a Windows platform injected through the adapter seam — say the word and I will add that on top.

@jeff-r2026 jeff-r2026 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.

Verified on latest main (af6832f + this PR) in the 2026-11-26 audit round: typecheck, build, lint, targeted unit tests and e2e all pass (stacked with #2068). Squash-merging.

@jeff-r2026
jeff-r2026 merged commit c565cd0 into Tencent:main Nov 26, 2026
3 checks passed
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.

2 participants