Repository navigation
feat(git): support generic private repository hosts - #301
Conversation
m0Nst3r873
left a comment
There was a problem hiding this comment.
Thanks for the contribution! A couple of functional notes below (non-blocking). Format/commit-convention items are out of scope for this review.
|
Windows bug: PR #301 assumes On a normal Windows PowerShell session: teamai init git@xxxfails with: Local config saved to undefined/.teamai/config.yaml Please fall back to USERPROFILE or os.homedir() when HOME is missing. |
Review fixes on top of the GitLab provider, rebased onto the generic `git` provider from Tencent#301. Detection order is now known host -> self-hosted GitLab -> `git` transport fallback, so a self-hosted instance keeps the platform features (create repo/MR, fetch MR, list group repos) that the generic provider does not implement. Host handling: - Clone URLs derive from the instance base URL instead of being reassembled from GITLAB_HOST, so scheme (http:// internal deployments), port and relative-URL-root prefixes survive. - fetchGitLabMR queries the host named by the MR URL rather than the configured instance, which previously sent a self-hosted PAT to gitlab.com and read whichever project shared that path. - GITLAB_URL is validated; a scheme-less value used to leave GITLAB_HOST on gitlab.com while every API call threw "Failed to parse URL" from undici. Base URL resolution is lazy so an invalid value fails the GitLab operation instead of crashing every module that imports this one. - Self-hosted host matching tolerates a configured port, since the ssh:// and scp-style URL forms never carry one. Wiring that was implemented but unreachable: - import --from-mr now routes /-/merge_requests/ URLs to the GitLab fetcher (previously "Unsupported MR URL"), and infers the repo URL for the incremental update. - import --from-org resolves the provider through detectProvider instead of a hardcoded `woa.com ? tgit : github`, which sent every GitLab org to the GitHub API. - shallowClone injects GITLAB_TOKEN via http.extraHeader instead of falling through to an anonymous clone, so private repos work; the token stays out of the URL. - teamai doctor checks the GitLab token when provider is gitlab. Correctness: - parseGitLabRepoInput strips GitLab's /-/ route separator, so a URL copied from the browser resolves to the project instead of yielding owner="org/repo/-/tree", repo="main". - createRepo resolves the group by exact path and fails when it cannot, rather than silently creating the project in the personal namespace and reporting success at the wrong location. - listOrgRepos passes include_subgroups=true; GitLab defaults it to false, silently dropping every project nested under a subgroup. - Blank/whitespace tokens read as absent, so isAuthenticated no longer disagrees with the rest of the provider, and a trailing newline from $(cat token) cannot produce an invalid header value. - API error message is English, per the repo output-language rule. Tests: regression coverage for each fix above, plus the first coverage for org.ts and mr-fetch.ts. Co-Authored-By: Shin Yang <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
…#307) Adds a GitLab provider (REST API v4, no external CLI) supporting gitlab.com and self-hosted / enterprise instances: clone, create repo, create MR with reviewer resolution, fetch MR data, and list group repos. Detection order is known host -> self-hosted GitLab (GITLAB_URL / TEAMAI_GITLAB_HOST) -> the generic `git` transport provider, across HTTPS, ssh:// and scp-style URLs. This complements the generic provider from #301, which is transport-only and cannot create repos or merge requests. Includes review fixes: clone and MR URLs honour the instance scheme, port and path prefix; GITLAB_URL is validated and resolved lazily; the MR fetcher queries the host named by the URL; `/-/` route paths are stripped when parsing repo input; group namespaces resolve by exact path and fail rather than falling back to the personal namespace; group listing includes subgroups; blank tokens read as absent. Wires GitLab into the MR-import dispatcher, the org-import provider resolution, shallowClone token injection, and doctor. Co-Authored-By: Shin Yang <[email protected]>
…ut (#308) Two follow-up fixes for the generic Git provider (#301): - parseGenericGitRepoInput accepted scp-style URLs whose user field carried credentials (e.g. "oauth2:token@host:group/repo.git"), returning them verbatim while the HTTPS path already rejected embedded credentials. A colon in the SSH user field is a credential, never a real login, so reject it. Normal "git@host:..." logins are unaffected. - Clone timeout was 120s, shorter than the 180s default used by the shallow-clone path in clone.ts. Large self-hosted repos over slow/VPN links could time out where the equivalent path would not. Align to 180s. Co-authored-by: Claude Fable 5 <[email protected]>
|
Thanks for the clear repro, @MyNameisPI — confirmed and fixed in #309. Root cause: #301 added #309 routes all remaining home lookups through |
PR #301 introduced getUserHome() (HOME → USERPROFILE → os.homedir) but only wired it into types.ts. The rest of the codebase still read a bare `process.env.HOME`, so on a normal Windows session (where only USERPROFILE is set) `teamai init` printed "Local config saved to undefined/..." and then crashed with ERR_INVALID_ARG_TYPE — the exact failure reported on #301. Route every remaining home lookup through getUserHome(). Because it now always returns a non-empty path, drop the dead `if (!home)` guards it made unreachable (including one in uninstall.ts that used to abort the whole command when HOME was unset — i.e. uninstall was fully broken on Windows). Fix getVotesLocalDir(), the import/recall/search-index paths and the debug-log path to build with path.join instead of a hardcoded "/" separator. Harden getUserHome() with a final os.tmpdir() fallback: os.homedir() is documented to return '' when the home can't be resolved, which would make every derived path cwd-relative; the guarantee of a non-empty absolute path is what lets the callers above drop their guards safely. Add a guard test that fails if any source file outside utils/home.ts reads process.env.HOME directly, plus USERPROFILE- and tmpdir-fallback regression tests. Co-Authored-By: Claude Fable 5 <[email protected]>
…309) PR #301 introduced getUserHome() (HOME → USERPROFILE → os.homedir) but only wired it into types.ts. The rest of the codebase still read a bare `process.env.HOME`, so on a normal Windows session (where only USERPROFILE is set) `teamai init` printed "Local config saved to undefined/..." and then crashed with ERR_INVALID_ARG_TYPE — the exact failure reported on #301. Route every remaining home lookup through getUserHome(). Because it now always returns a non-empty path, drop the dead `if (!home)` guards it made unreachable (including one in uninstall.ts that used to abort the whole command when HOME was unset — i.e. uninstall was fully broken on Windows). Fix getVotesLocalDir(), the import/recall/search-index paths and the debug-log path to build with path.join instead of a hardcoded "/" separator. Harden getUserHome() with a final os.tmpdir() fallback: os.homedir() is documented to return '' when the home can't be resolved, which would make every derived path cwd-relative; the guarantee of a non-empty absolute path is what lets the callers above drop their guards safely. Add a guard test that fails if any source file outside utils/home.ts reads process.env.HOME directly, plus USERPROFILE- and tmpdir-fallback regression tests. Co-authored-by: Claude Fable 5 <[email protected]>
* feat(git): support generic private repository hosts * fix(git): address generic provider review comments * fix(git): harden generic provider portability --------- Co-authored-by: liuyuanchuang <[email protected]> Co-authored-by: yoge <[email protected]>
…Tencent#307) Adds a GitLab provider (REST API v4, no external CLI) supporting gitlab.com and self-hosted / enterprise instances: clone, create repo, create MR with reviewer resolution, fetch MR data, and list group repos. Detection order is known host -> self-hosted GitLab (GITLAB_URL / TEAMAI_GITLAB_HOST) -> the generic `git` transport provider, across HTTPS, ssh:// and scp-style URLs. This complements the generic provider from Tencent#301, which is transport-only and cannot create repos or merge requests. Includes review fixes: clone and MR URLs honour the instance scheme, port and path prefix; GITLAB_URL is validated and resolved lazily; the MR fetcher queries the host named by the URL; `/-/` route paths are stripped when parsing repo input; group namespaces resolve by exact path and fail rather than falling back to the personal namespace; group listing includes subgroups; blank tokens read as absent. Wires GitLab into the MR-import dispatcher, the org-import provider resolution, shallowClone token injection, and doctor. Co-Authored-By: Shin Yang <[email protected]>
…ut (Tencent#308) Two follow-up fixes for the generic Git provider (Tencent#301): - parseGenericGitRepoInput accepted scp-style URLs whose user field carried credentials (e.g. "oauth2:token@host:group/repo.git"), returning them verbatim while the HTTPS path already rejected embedded credentials. A colon in the SSH user field is a credential, never a real login, so reject it. Normal "git@host:..." logins are unaffected. - Clone timeout was 120s, shorter than the 180s default used by the shallow-clone path in clone.ts. Large self-hosted repos over slow/VPN links could time out where the equivalent path would not. Align to 180s. Co-authored-by: Claude Fable 5 <[email protected]>
…encent#309) PR Tencent#301 introduced getUserHome() (HOME → USERPROFILE → os.homedir) but only wired it into types.ts. The rest of the codebase still read a bare `process.env.HOME`, so on a normal Windows session (where only USERPROFILE is set) `teamai init` printed "Local config saved to undefined/..." and then crashed with ERR_INVALID_ARG_TYPE — the exact failure reported on Tencent#301. Route every remaining home lookup through getUserHome(). Because it now always returns a non-empty path, drop the dead `if (!home)` guards it made unreachable (including one in uninstall.ts that used to abort the whole command when HOME was unset — i.e. uninstall was fully broken on Windows). Fix getVotesLocalDir(), the import/recall/search-index paths and the debug-log path to build with path.join instead of a hardcoded "/" separator. Harden getUserHome() with a final os.tmpdir() fallback: os.homedir() is documented to return '' when the home can't be resolved, which would make every derived path cwd-relative; the guarantee of a non-empty absolute path is what lets the callers above drop their guards safely. Add a guard test that fails if any source file outside utils/home.ts reads process.env.HOME directly, plus USERPROFILE- and tmpdir-fallback regression tests. Co-authored-by: Claude Fable 5 <[email protected]>
Summary
gitprovider for unknown full HTTPS and SSH repository URLsType of Change
Test Plan
npm run typecheckpassesnpm testpasses (1991 tests)npm run buildpassesRelated Issues
Closes #300
Notes for Reviewers
Generic hosts intentionally do not attempt platform authentication, repository creation, or MR/PR APIs. Git remains the credential boundary, embedded HTTPS credentials are rejected, and branch push succeeds before the existing manual-PR fallback is shown.