Skip to content

fix: make code mode provider-aware instead of hardcoding GitHub#342

Open
Victor Micó (victor-mico) wants to merge 1 commit into
langchain-ai:mainfrom
victor-mico:fix/code-mode-provider-aware
Open

fix: make code mode provider-aware instead of hardcoding GitHub#342
Victor Micó (victor-mico) wants to merge 1 commit into
langchain-ai:mainfrom
victor-mico:fix/code-mode-provider-aware

Conversation

@victor-mico

Copy link
Copy Markdown
Contributor

What & why

Fixes #341. openwiki code was hardcoded to GitHub in two places, so non-GitHub repos (GitLab, Bitbucket) got GitHub-specific artifacts reintroduced on every run:

  1. .github/workflows/openwiki-update.yml was written unconditionally on both the interactive and --print (CI) paths — forcing pipelines to rm -rf .github before committing.
  2. The <!-- OPENWIKI:START -->…<!-- OPENWIKI:END --> block in AGENTS.md/CLAUDE.md always said "GitHub Actions workflow", which is wrong on other hosts and, because the block is regenerated each run, reverted any manual correction (a recurring misleading diff).

What changed

  • src/code-mode.ts: detect the git host from the repository remote (origin, falling back to any remote), overridable via OPENWIKI_CI_PROVIDER=github|gitlab|bitbucket|none.
    • Write the GitHub Actions workflow only when the host is GitHub.
    • Phrase the OPENWIKI block to match the detected host: GitHub Actions workflow / GitLab pipeline / Bitbucket pipeline / provider-neutral "update job".
    • Undetectable hosts and missing remotes fall back to GitHub, preserving the historical default (backward compatible). Detection failures never throw.
  • examples/: the GitLab and Bitbucket pipelines set OPENWIKI_CI_PROVIDER explicitly and no longer track the now-unwritten .github/workflows/openwiki-update.yml path in their git diff/git add steps.
  • README.md: documents detection behavior and the OPENWIKI_CI_PROVIDER override.

How it was tested

  • Extended test/code-mode.test.ts: workflow is skipped with matching wording for gitlab/bitbucket/none; provider is detected from a real git remote; env override wins over detection; default-to-GitHub when no remote exists.
  • pnpm run format, pnpm run lint, pnpm test all pass locally (254 tests).

🤖 Generated with Claude Code

`openwiki code` always wrote `.github/workflows/openwiki-update.yml` and
hardcoded "GitHub Actions workflow" wording in the AGENTS.md/CLAUDE.md
OPENWIKI block, even on GitLab/Bitbucket repos. This reintroduced
GitHub-specific artifacts on every run that CI then had to scrub.

Detect the git host from the repository remote (overridable via
`OPENWIKI_CI_PROVIDER=github|gitlab|bitbucket|none`) and:
- only write the GitHub Actions workflow when the host is GitHub;
- phrase the OPENWIKI block to match the detected host (GitHub Actions
  workflow / GitLab pipeline / Bitbucket pipeline / neutral update job).

Undetectable hosts and missing remotes fall back to GitHub, preserving
the historical default. The GitLab/Bitbucket example pipelines now set
the provider explicitly and no longer track the GitHub workflow path.

Fixes langchain-ai#341

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread src/code-mode.ts
}

const lower = remoteUrl.toLowerCase();
if (lower.includes("gitlab")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it safe to match on the entire url? should we just be matching on the host part? for example, what if someone has something like:

git@github.com:acme/gitlab-importer.git

Comment thread src/code-mode.ts

// Provider-aware phrasing for the OPENWIKI agent-file block so the sentence is
// accurate on non-GitHub hosts instead of always claiming a GitHub Actions run.
function describeCodeModeUpdateJob(provider: CiProvider): string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does this need a default case?

@colifran Colin Francis (colifran) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR Victor Micó (@victor-mico)! Left a few comments but otherwise looks great.

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.

code mode is hardcoded to GitHub (workflow file + AGENTS.md wording) on non-GitHub repos

2 participants