PowerShell text splitter example
Example of splitting PowerShell code:
from langchain_text_splitters import Language, RecursiveCharacterTextSplitter
POWERSHELL_CODE = """
$directoryPath = Get-Location
$items = Get-ChildItem -Path $directoryPath
$files = $items | Where-Object { -not $_.PSIsContainer }
$sortedFiles = $files | Sort-Object LastWriteTime
foreach ($file in $sortedFiles) {
Write-Output ("Name: " + $file.Name + " | Last Write Time: " + $file.LastWriteTime)
}
"""
powershell_splitter = RecursiveCharacterTextSplitter.from_language(
language=Language.POWERSHELL, chunk_size=100, chunk_overlap=0
)
powershell_docs = powershell_splitter.create_documents([POWERSHELL_CODE])
This respects PowerShell loop and variable assignment boundaries.
Visual Basic 6 text splitter example
Example of splitting Visual Basic 6 code:
from langchain_text_splitters import Language, RecursiveCharacterTextSplitter
VISUALBASIC6_CODE = """Option Explicit
Public Sub HelloWorld()
MsgBox "Hello, World!"
End Sub
Private Function Add(a As Integer, b As Integer) As Integer
Add = a + b
End Function
"""
visualbasic6_splitter = RecursiveCharacterTextSplitter.from_language(
Language.VISUALBASIC6,
chunk_size=128,
chunk_overlap=0,
)
visualbasic6_docs = visualbasic6_splitter.create_documents([VISUALBASIC6_CODE])
This respects Visual Basic 6 subroutine and function boundaries.
Language-specific separators for Python
Python text splitter uses the separators ["\nclass ", "\ndef ", "\n\tdef ", "\n\n", "\n", " ", ""] in order, attempting to split at class definitions first, then function definitions, then double newlines, then single newlines, then spaces, and finally as a last resort breaking in the middle of a word.
Core conceptual guides in LangChain documentation
The documentation provides conceptual overviews covering: Memory (persistence of interactions within and across threads), Context engineering (methods for providing AI applications the right information and tools), Graph API (LangGraph's declarative graph-building API), and Functional API (building agents as a single function).
OpenWiki empty updates tracking and pull request suppression
OpenWiki tracks wiki content in openwiki/.last-update.json and only rewrites that file when the wiki actually changes. If a scheduled --update run does not result in changes, the wiki files remain the same and the CI does not open a pull request.
OpenWiki automated update workflow destinations by provider
OpenWiki documentation updates can be automated with scheduled workflows for GitHub Actions, GitLab CI, or Bitbucket Pipelines. For GitHub Actions, copy the example file openwiki-update.yml from the OpenWiki repository examples to .github/workflows/openwiki-update.yml. For GitLab CI, copy openwiki-update.gitlab-ci.yml to .gitlab-ci.yml or include it from an existing pipeline. For Bitbucket Pipelines, copy openwiki-update.bitbucket-pipelines.yml to bitbucket-pipelines.yml and then schedule the openwiki-update custom pipeline.
OpenWiki CI update command and environment variables
To run documentation updates in CI, use the command: openwiki code --update --print. The --update flag creates the initial openwiki/ docs if they do not exist yet, as long as the workflow provides required provider and model environment variables. Do not run --init in CI. Required environment variables include a provider API key (or Copilot OAuth token for keyless providers), OPENWIKI_PROVIDER, and OPENWIKI_MODEL_ID. Optional environment variable LANGSMITH_API_KEY can be set for tracing.
OpenWiki telemetry disabling in CI
Scheduled and CI runs of OpenWiki send anonymous reliability telemetry under a shared CI identifier. To disable telemetry in CI, set the environment variable OPENWIKI_TELEMETRY_DISABLED=1. This line can be uncommented in the example workflow files.
OpenWiki scheduled workflow files included in pull request
The scheduled workflow includes generated wiki files (AGENTS.md, CLAUDE.md) and the workflow itself in the documentation pull request when those files change.
Schedule stores cron expressions for connector sources
A schedule is an optional cron expression for a connector source to refresh on a recurring interval, such as refreshing Gmail or web search. OpenWiki stores cron expressions and related setup details in ~/.openwiki/onboarding.json with other onboarding preferences like selected template, connected sources, and per-source ingestion notes.
macOS LaunchAgent support for schedules
On macOS, OpenWiki can install supported schedules as user LaunchAgents under ~/Library/LaunchAgents/. Those jobs run openwiki --update --print and write logs under ~/.openwiki/logs/.
Global personal wiki instructions location
Global personal wiki instructions are saved in ~/.openwiki/INSTRUCTIONS.md during onboarding.
Connector ingestion process writes to ~/.openwiki/connectors/
During an ingestion run, connector tools write raw data and manifests under ~/.openwiki/connectors/<connector>/raw/, then source-specific agent runs update the wiki from those local files.
Multiple instances of same source with different names
The same source can be configured more than once. For example, add one web search source for AI research and another for NBA news. OpenWiki stores them as separate instances such as web-search-1 and web-search-2.
Authentication commands for connectors
OpenWiki provides these authentication commands: openwiki auth notion, openwiki auth gmail, openwiki auth x, openwiki auth slack. These run a local browser OAuth flow for providers that require it. OpenWiki saves returned tokens to ~/.openwiki/.env, creates connector config when possible, and discovers MCP tools for MCP-backed providers.
Authentication requirements by provider
Slack and Gmail require app client credentials to already be set in ~/.openwiki/.env. Notion uses dynamic client registration for hosted MCP. X uses OAuth 2.0 with PKCE. After openwiki auth gmail, the Google connector can ingest Gmail directly with no MCP transport setup.
Advanced retry helpers for authentication
OpenWiki provides advanced retry helpers: openwiki auth configure <provider> and openwiki auth tools <provider>.
Slack OAuth HTTPS redirect setup with ngrok
Slack OAuth can require an HTTPS redirect URL. OpenWiki provides openwiki ngrok start to set up the tunnel, or openwiki ngrok start https://your-domain.ngrok.app with a fixed domain. OpenWiki saves OPENWIKI_HTTPS_OAUTH_REDIRECT_URI and prints the callback URL to register in Slack. X/Twitter and Gmail auth ignore that HTTPS override and keep using the local callback at http://127.0.0.1:53682/callback by default.
Credential storage location and permissions
OpenWiki stores secrets under directory ~/.openwiki (mode 0o700) and file ~/.openwiki/.env (mode 0o600). Common connector-related keys include Gmail, Notion, Slack, and X OAuth tokens, plus TAVILY_API_KEY for web search.
OAuth callback configuration environment variables
Optional OAuth callback settings are stored as environment variables: OPENWIKI_OAUTH_CALLBACK_PORT (local callback port) and OPENWIKI_HTTPS_OAUTH_REDIRECT_URI (Slack HTTPS callback URL).
Cron schedule management commands on macOS
On macOS, manage connector schedules with: openwiki cron list (list schedules), openwiki cron pause <source|all> (pause schedules), openwiki cron resume <source|all> (resume schedules), openwiki cron delete <source|all> (delete schedules). The cron delete command removes the saved schedule for a source from ~/.openwiki/onboarding.json and unloads its LaunchAgent. It does not remove auth, connector config, raw data, or wiki content.
Ingest commands to pull data into wiki
Ingestion commands pull raw data into ~/.openwiki/connectors/ and synthesize updates into the personal wiki: openwiki ingest all, openwiki ingest web-search, openwiki ingest web-search-2. Sources can be refreshed from chat or with openwiki personal --update after sources are configured.
Connector secrets stored in environment variables via .env file
Connector secrets are referenced by environment variable name and stored in ~/.openwiki/.env. Connector config files should never contain raw secret values.
Built-in connector sources and credentials
Built-in sources in OpenWiki include: git-repo (local paths), x (OAuth user-context credentials), notion (Notion OAuth via hosted MCP), google (Gmail OAuth), web-search (TAVILY_API_KEY), hackernews (None), and slack (Slack app client credentials + OAuth).
Personal mode builds local wiki from configured sources
OpenWiki personal mode builds a local personal brain wiki in ~/.openwiki/wiki from configured sources such as local repositories, Gmail, Notion, web search, Hacker News, Slack, and X/Twitter.
Personal mode CLI commands
OpenWiki personal mode supports these CLI commands: openwiki personal (runs the command), openwiki personal --init (initialization), openwiki personal --update (refresh from configured sources), openwiki personal --update with a string argument for custom messages.
First-run onboarding setup tasks
During first-run onboarding, users can configure an inference provider, API key, and model; set a LangSmith API key; set up connectors for supported sources; and choose a wiki template, customize its scope, and save per-source ingestion notes and schedules.
OpenWiki purpose and audience
OpenWiki is a CLI that writes and maintains a Markdown wiki for your codebase or personal knowledge. Coding agents use that wiki as durable context, so they spend less time and fewer tokens rediscovering architecture, integrations, and other repository details. Humans can read the same docs, but agents are the primary audience.
Install OpenWiki CLI
Install OpenWiki globally using npm: npm install -g openwiki. On Windows, prefer npm or pnpm. Installing with Bun can fall back to compiling the native better-sqlite3 dependency and may require Visual Studio Build Tools with the Desktop development with C++ workload.
Initialize OpenWiki in repository
From the repository root, run openwiki --init. On the first interactive run, OpenWiki prompts for an inference provider and model, the provider API key or equivalent credentials, and an optional LangSmith API key for tracing. OpenWiki saves its configuration and secrets to ~/.openwiki/.env.
OpenWiki generated wiki structure
OpenWiki writes documentation to openwiki/ in the repository, including a quickstart entrypoint and topic pages. It also maintains an AGENTS.md and CLAUDE.md at the repository root, adding a block that instructs coding agents to consult the wiki for codebase context.
OpenWiki INSTRUCTIONS.md file
Repository-specific wiki instructions live in openwiki/INSTRUCTIONS.md. OpenWiki reads this file for scope and priorities. To change it, edit the file directly or ask OpenWiki in chat to change the brief (for example, openwiki "Update openwiki/INSTRUCTIONS.md to focus on the public API"). Normal --init and --update runs do not rewrite this file.
Visualize OpenWiki documentation
To explore the wiki in a browser, run openwiki visualize. This opens a local interactive node graph with a side-by-side Markdown reader.
Update OpenWiki documentation
Refresh documentation after code changes by running openwiki --update. For automated updates in CI, use the appropriate configuration as documented in the Automate updates guide.
OpenWiki personal wiki mode
To initialize a local personal brain instead of repository docs, run openwiki personal --init. Personal mode writes to ~/.openwiki/wiki and can ingest configured connectors such as local git repositories, Gmail, Notion, web search, Hacker News, and X/Twitter.
OpenWiki interactive session
Run bare openwiki to open an interactive session in code mode for the current repository. Pass a message to start with a request: openwiki "Please generate documentation for this repository".
OpenWiki one-shot non-interactive run
Use openwiki -p "Summarize what you can do" or openwiki --print for a one-shot non-interactive run that prints the final assistant output and exits.
OpenWiki interactive chat commands
In OpenWiki chat, use /api-key to update the current provider API key and /langsmith-key to update or clear LangSmith tracing credentials.
Configure LangSmith tracing for OpenWiki
During onboarding, provide a LangSmith API key to trace OpenWiki runs to a LangSmith project named openwiki. Set these values in ~/.openwiki/.env or the process environment: LANGSMITH_API_KEY=your-key, LANGCHAIN_TRACING_V2=true, LANGCHAIN_PROJECT=openwiki.
LangChain reference documentation includes chat models, tools, and agents
The LangChain API reference documentation covers chat models, tools, agents, and more. Complete references are available for both Python and JavaScript/TypeScript libraries.
LangGraph reference documentation includes graph APIs, state management, and checkpointing
The LangGraph API reference documentation covers graph APIs, state management, checkpointing, and more. Complete references are available for both Python and JavaScript/TypeScript libraries.
MCP Adapter allows Model Context Protocol tools in LangChain and LangGraph
The MCP Adapter enables using Model Context Protocol (MCP) tools within LangChain and LangGraph applications. Implementations are available for both Python and JavaScript/TypeScript.