Skip to content

fix: default bare --update to code mode instead of personal#314

Open
Himanshu Kumar (himanshu231204) wants to merge 4 commits into
langchain-ai:mainfrom
himanshu231204:fix/bare-update-requires-mode
Open

fix: default bare --update to code mode instead of personal#314
Himanshu Kumar (himanshu231204) wants to merge 4 commits into
langchain-ai:mainfrom
himanshu231204:fix/bare-update-requires-mode

Conversation

@himanshu231204

@himanshu231204 Himanshu Kumar (himanshu231204) commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #310

Bare openwiki --update (without specifying personal or code mode) defaulted to personal mode, which targeted ~/.openwiki/wiki instead of the current project's openwiki/ directory. This caused the agent to document a completely different, unrelated project that was previously stored in the global wiki.

Root Cause

In src/commands.ts, parseRunCommand defaults mode to "personal" when no mode is specified. For --update, this means the agent runs in personal mode (targeting ~/.openwiki/wiki) even when the user is inside a project directory.

Fix

Added auto-default logic: when a non-chat command (--init or --update) is run without an explicit mode, default to code mode instead of personal. This ensures openwiki --update from a project directory updates the repository's openwiki/ directory as expected.

Before: openwiki --update → personal mode → documents wrong project
After: openwiki --update → code mode → documents current repository

This is consistent with the existing behavior where openwiki (bare, no args) opens interactive chat, and openwiki --init (bare) now also defaults to code mode.

Changes

  • src/commands.ts: Added if (command !== "chat" && modeSource === "default") { mode = "code"; } to auto-default non-chat commands to code mode. Updated help examples.
  • src/agent/prompt.ts: Updated CLI reference to document the new default behavior.
  • src/auth/configure.ts: Updated user-facing messages.
  • src/connectors/write-connector-skill.ts: Updated connector instructions.
  • test/commands.test.ts: Updated tests — bare --update now defaults to code mode, added explicit mode tests.

Impact

  • All CI workflows already use explicit modes (openwiki code --update --print) — no breaking changes for automation
  • Users running openwiki --update from a project directory now get the expected behavior
  • Users who want personal mode must explicitly use openwiki personal --update

Test User added 3 commits July 14, 2026 00:25
The parseEnv function only handled KEY=value format. If a user manually
edited the .openwiki/env file or copied lines from shell scripts, lines
like 'export KEY=value' would be silently skipped.

Added export prefix handling: lines starting with 'export ' now have the
prefix stripped before parsing, so both formats work correctly.
Bare \openwiki --update\ (without specifying personal or code mode)
defaulted to personal mode, which targeted ~/.openwiki/wiki instead of
the current project's openwiki/ directory. This caused the agent to
document a completely different, unrelated project that was previously
stored in the global wiki.

Make bare --update require an explicit mode (--init already had this
requirement). Users must now run either:
- \openwiki personal --update\ to update the local brain wiki
- \openwiki code --update\ to update repository documentation

All CI workflows already use explicit modes (\openwiki code --update
--print\), so this is not a breaking change for automation.

Fixes langchain-ai#310
@himanshu231204 Himanshu Kumar (himanshu231204) changed the title fix: require explicit mode for bare --update command fix: default bare --update to code mode instead of personal Jul 13, 2026
@himanshu231204

Copy link
Copy Markdown
Contributor Author

Colin Francis (@colifran) This PR is ready for review. It resolves the merge conflicts with upstream main and defaults bare openwiki --update to code mode instead of personal mode, fixing #310.

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.

[Bug]: openwiki --update targets the wrong project (documents a different repo than the current working directory)

1 participant