Skip to content

Integrate upstream langchain-ai/openwiki into fork (merge only) - #25

Merged
ayrtonvwf merged 22 commits into
mainfrom
integrate-upstream
Jul 10, 2026
Merged

Integrate upstream langchain-ai/openwiki into fork (merge only)#25
ayrtonvwf merged 22 commits into
mainfrom
integrate-upstream

Conversation

@ayrtonvwf

Copy link
Copy Markdown
Owner

Closes part 1 of #17.

Scope

This PR is the upstream integration merge only — a single merge of langchain-ai/openwiki@main into the fork, with all 12 conflicts resolved and the OKF carrier kept working under upstream's new general-purpose / multi-mode model.

Per the plan in #17, the "make the OKF type taxonomy pluggable per mode" refactor is intentionally deferred to a follow-up PR — it can only be done correctly now that the mode axis exists in the tree (this merge lands it).

What upstream brought in

feat: Make OpenWiki general purpose (#48) (mode axis code/personal + connectors subsystem), openai-chatgpt OAuth provider (langchain-ai#151), non-interactive init/update when stdin isn't a TTY (langchain-ai#153), init/update write-constraint (langchain-ai#230), v3 stream events, configurable provider retries (langchain-ai#239), OPENAI_COMPATIBLE_API_KEY redaction (langchain-ai#245), releases 0.0.3/0.0.4→0.1.0, and dep bumps.

Conflict resolutions (12 files)

  • package.json / pnpm-lock.yaml — kept both dep sets; version auto-resolved to upstream's 0.1.0; lockfile regenerated via pnpm install (not hand-merged).
  • pnpm-workspace.yaml (auto-merge produced a duplicate key) — folded the fork's vite exclusion into upstream's minimumReleaseAgeExclude list; single minimumReleaseAge.
  • CI / examples — kept the fork's manual-only trigger, adopted openwiki code --update --print, preserved the --okf guidance comments.
  • src/constants.ts / src/env.ts — additive keep-both for env keys; kept the fork's OKF taxonomy + resolveOkfEnabled alongside upstream's connector keys + resolveProviderRetryAttempts.
  • src/cli.tsx — took upstream's setupPromise/ensureCodeModeRepoSetup run structure and re-applied the okf option; merged the non-interactive dispatch so --okf-check still renders the interactive OkfCheckView (AND-in !command.okfCheck after upstream's shouldRunNonInteractively type-guard).
  • src/agent/prompt.ts — merged into a single options bag: createSystemPrompt(command, { outputMode?, okf? }), re-inserting the OKF contract section into upstream's rewritten prompt; kept upstream's createModeInstructions(command, outputMode).
  • src/agent/index.ts — additive imports; call site updated to the merged prompt signature.
  • src/agent/utils.ts — kept the fork's visitOpenWikiDirectory snapshot walk but sourced its root from upstream's mode-aware getWikiContentRoot(cwd, outputMode); dropped upstream's now-dead addDirectoryToSnapshot.

Follow-up test adaptations (needed by upstream's API changes)

  • test/agent-okf-integration.test.ts — mock now exposes streamEvents (v3), runs in outputMode: "repository".
  • test/commands.test.ts--init now requires a mode upstream, so the OKF combo test uses code --okf --init.
  • src/startup.ts — exempted --okf-check from the new "interactive chat requires a terminal" non-TTY gate (it is inherently non-interactive).

Verification

pnpm build / typecheck / lint:check / format:check all pass. Tests: 239 passed, 1 failed. The single failure (openai-chatgpt-credentials.test.ts → "needs no setup once token, model, and langsmith are all set") is pre-existing on upstream/main — verified by running the identical test in a pristine upstream/main worktree, where it also fails. It depends on a local ~/.openwiki/onboarding.json; not a regression from this merge.

Watch-list

  • Behavior change: DEFAULT_PROVIDER moves openrouteropenai (the fork never changed it from base; upstream deliberately did — correct 3-way resolution). The fork's CI sets OPENROUTER_API_KEY explicitly, but consider setting OPENWIKI_PROVIDER in the workflow if openrouter should remain the default.
  • Security: upstream's OPENAI_COMPATIBLE_API_KEY redaction (fix: add missing OPENAI_COMPATIBLE_API_KEY to secret redaction langchain-ai/openwiki#245) is preserved.
  • New auth/connectors subsystems arrived clean; the fork's claude.yml sandbox perms / OpenSpec tool allowances may need to permit any new tools/commands they introduce.

Deferred to PR #2 (per #17)

The pluggable-per-mode OKF type taxonomy: DocTypeTaxonomy shape, rename REPO_DOC_TYPESCODE_DOC_TYPES, getTaxonomyForMode(mode), a personal taxonomy, threading it through createSystemPrompt/runOkfPass, and the corresponding test updates.

🤖 Generated with Claude Code

christian-bromann and others added 22 commits July 1, 2026 12:14
Parse LangGraph protocol events directly so agent streaming no longer needs
legacy tuple normalization for message and tool events.
…eam-events

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	src/agent/index.ts
…-ai#196)

Co-authored-by: Colin Francis <131073567+colifran@users.noreply.github.com>
…angchain-ai#153)

* fix: run --init/--update non-interactively when stdin is not a TTY

Ink requires raw-mode stdin, so launching openwiki --init or --update
from CI, cron, or any piped shell without --print rendered the UI,
printed "Raw mode is not supported", and hung without exiting.

The entry point already anticipated non-TTY runs (the startup
credential check gates on `command.print || !process.stdin.isTTY`)
but still routed them into the Ink renderer. Route runnable non-TTY
commands through the existing print path instead, so they execute the
agent, write output to stdout, and exit with a meaningful code.
Interactive chat without a message still requires a TTY.

Fixes langchain-ai#149

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: fail fast with a clear error for non-TTY interactive chat

Bare `openwiki` with a non-TTY stdin used to reach the Ink chat UI, which
needs raw-mode stdin, and died with the cryptic "Raw mode is not
supported" error (or hung). Resolve it to a startup error instead, so the
existing error path prints a clear message to stderr and exits 1.

Suggested in PR langchain-ai#153 review. Help, dry-run, and all TTY behavior are
unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Colin Francis <131073567+colifran@users.noreply.github.com>
…ile tool calls without aborting the run (langchain-ai#122)

* fix: recover from malformed file tool calls

* refactor and rework

* lint

---------

Co-authored-by: Colin Francis <colin.francis@langchain.dev>
Co-authored-by: Colin Francis <131073567+colifran@users.noreply.github.com>
…ware (langchain-ai#224)

* bump deepagents version

* bump langchain version

* middleware no longer needed
* feat: Make general purpose

* cr

* cr

* fix gmail

* make it much better

* add cron hooks

* better ngrok

* write wiki to root

* cr

* Harrison/vibe code (langchain-ai#109)

* some vibe coding

* cr

* cr

* cr

* cr

* fix gh action

---------

Co-authored-by: bracesproul <braceasproul@gmail.com>

* update readme

* fix oauth link clicking

* drop just openwiki --init

* fix: oauth connection flow

* improve prompting

* cr

* cr

* brain->personal (langchain-ai#226)

* cr

* write instructions to INSTRUCTIONS.md file

* cr

---------

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
Co-authored-by: Colin Francis <131073567+colifran@users.noreply.github.com>
…n-ai#245)

The sanitizeDiagnosticText function redacted secrets for 6 provider API keys
but was missing OPENAI_COMPATIBLE_API_KEY. Users of the openai-compatible
provider could have their API keys leaked in error messages.

Added OPENAI_COMPATIBLE_API_KEY_ENV_KEY to both the import and the redaction
loop in diagnostics.ts, and added a test case to verify the redaction works.

Co-authored-by: Test User <test@example.com>
Co-authored-by: Eva <eva@100yen.org>
Co-authored-by: Colin Francis <131073567+colifran@users.noreply.github.com>
* feat: add OpenAI ChatGPT-login provider (Codex OAuth)

Add an `openai-chatgpt` provider that authenticates model calls with a
ChatGPT/Codex OAuth login instead of a metered API key, so usage draws on the
ChatGPT subscription's included Codex usage.

It reuses `@langchain/openai`'s ChatOpenAI Responses-API integration pointed at
the Codex backend (`useResponsesApi` + `zdrEnabled` for `store: false`, base URL
and account/originator/beta headers), so DeepAgents' tool-calling and streaming
keep working with zero changes to the agent harness. Two Codex-backend quirks
are handled at model construction: forcing `stream: true`, and rewriting the
`system` input role to `developer`.

Includes a PKCE browser login + token refresh, an `oauth-login` step in the
existing credential wizard, token persistence in `~/.openwiki/.env`, tests, and
docs.

* feat: make ChatGPT login URL copyable (borderless render + c-to-copy via OSC 52)

* feat: let users paste the ChatGPT OAuth callback URL/code to finish login

Adds a manual-paste fallback to the browser login: while the loopback
callback server waits, the user can paste the redirect URL (or bare code)
into the wizard and press Enter to complete the login in-process. Removes
the need to curl the callback or set up SSH port forwarding on remote hosts.
Whichever arrives first — browser callback or pasted value — wins.

* feat: show ChatGPT account info and re-ask model after login

- Decode the signed-in email and plan (plus/pro/etc.) from the access-token
  JWT, persist them, show them in the ChatGPT login step, and add an
  "account:" line to the run header.
- Continue to the model and LangSmith steps after the ChatGPT login just like
  the API-key providers. Selecting a provider in the wizard now re-asks for the
  model even if one is stored, so a stale model id from a previous provider is
  not carried over.

* refactor: address review feedback on the ChatGPT login provider

- Centralize the CodexTokens <-> env mapping in openai-chatgpt-oauth.ts as
  codexTokensToEnv() and readCodexTokensFromEnv(), and use them from both the
  agent's refresh-at-startup and the credential wizard. The env contract now
  lives next to the type it serializes and is tested with the OAuth flow.
  readCodexTokensFromEnv() also returns null on a partial token set, so a
  leftover access token without an account id no longer looks signed in.
- Move formatChatGptAccount() into the same module and use it from cli.tsx
  instead of a second copy.
- Fix opening the browser on Windows. Under shell: true, cmd treats the & in
  the auth URL's query string as a command separator and mangles the URL. Use
  cmd /c start with a quoted URL and windowsVerbatimArguments instead.

* fix succ login msg

---------

Co-authored-by: Colin Francis <131073567+colifran@users.noreply.github.com>
Co-authored-by: bracesproul <braceasproul@gmail.com>
# Conflicts:
#	.github/workflows/openwiki-update.yml
#	examples/openwiki-update.gitlab-ci.yml
#	examples/openwiki-update.yml
#	package.json
#	pnpm-lock.yaml
#	src/agent/index.ts
#	src/agent/prompt.ts
#	src/agent/utils.ts
#	src/cli.tsx
#	src/commands.ts
#	src/constants.ts
#	src/env.ts
The new upstream startup.test.ts fixture shells out to `git commit` in a
throwaway repo but inherited the developer's global commit.gpgsign, which
fails in the non-TTY test runner (gpg pinentry unavailable). Pin
commit.gpgsign=false in the fixture repo, alongside the user.name/email it
already sets, so the test is independent of local git config.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
needsCredentialSetup folds personal-mode onboarding completeness into its
result, which reads the developer's real ~/.openwiki/onboarding.json. That
made "needs no setup once token, model, and langsmith are all set" fail on
any machine without a completed onboarding file (including a pristine
upstream/main checkout). Mock isOpenWikiOnboardingCompleteSync to true so the
test exercises only the credential-step logic it targets; the missing/expired
token cases still assert true via the credential checks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.