Repository navigation
feat(source): compile a Google Drive folder into the local wiki - #278
Open
kalyan-fireweave wants to merge 2 commits into
Open
kalyan-fireweave wants to merge 2 commits into
kalyan-fireweave wants to merge 2 commits into
Conversation
Bindings stay in config and credentials stay in env files, so a remote object can recompile through the existing add path without a new storage backend. Co-authored-by: Cursor <cursoragent@cursor.com>
Sign-in stays on loopback and writes the refresh token only into the knowledge base env file, so a binding can be saved without putting a secret in the wiki. Co-authored-by: Cursor <cursoragent@cursor.com>
11 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #275.
This branch includes the unmerged S3 work from #277 (commit
6f8d0be). Merge #277 first. The Drive-only commit is2ebeb18. OneDrive (#276) stays a vote card. This is separate from #61, which asks to store the wiki itself on S3-compatible storage.A maintainer needs to add the
connector:gdrivelabel so the Workbench vote search for unshipped providers can find this issue. This account cannot create labels on VectifyAI/OpenKB.Summary
Problem
The Workbench shows Google Drive as a GitHub vote card. There is no way to bring a folder from the user's own Drive into the local wiki through the existing compile path.
Fix
openkb source add gdrive --name NAME --folder FOLDER. The folder is a URL or a raw id from the user's own Drive. Shared Drives are out of scope.OPENKB_GDRIVE_CLIENT_ID,OPENKB_GDRIVE_CLIENT_SECRET, andOPENKB_GDRIVE_REFRESH_TOKEN. The refresh token is written by sign-in into<kb>/.envonly, through the existing mode0600env merge (openkb/envfile.py). The global config env stays read-only. Secrets are not written toconfig.yaml, the wiki, orconnector-state.json.127.0.0.1:7567with PKCE and a state parameter. The redirect sent to Google ishttp://127.0.0.1:7567/callback. Google's desktop-app guide documentshttp://127.0.0.1:<port>for installed apps, and a Desktop client has no redirect-URI field. Scope isdrive.readonly.--non-interactivenever opens a browser; add and sync then succeed only when a refresh token is already stored.add_single_file. The registry key isgdrive://{folderId}/{path from that folder}. Google Docs without an extension are skipped. Transient token and file failures retry 3 times.google-api-python-client==2.201.0andgoogle-auth==2.62.1are the optionalgdriveextra. Tests inject a fake client and do not import the SDK. CI'suv sync --locked --extra dev --extra apidoes not install them.non_interactive=True. A Workbench save without a refresh token returns 400 and tells the user to sign in with the CLI. It does not open a browser.Evidence
openkb source add gdriveonce. Saving without a refresh token shows "Sign-in is required" and writes no binding. With a binding present, the card listsnotes,gdrive://1AbCdefghij/, "Not synced since this change", Sync, Remove, and Add another. Sync without a token records that sign-in error on the card. Remove clears the binding and leaveswiki/index.mdin place. The same strings render in Chinese.Verification
Results here: ruff check passed, ruff format check passed, mypy reported no issues in 69 files, pytest 1281 passed.
The web build passed (
i18n:check,tsc -b,vite build).Test plan
uv run ruff check .uv run ruff format --check .uv run mypy openkbuv run pytestcd frontend && npm ci && npm run buildOPENKB_GDRIVE_CLIENT_IDandOPENKB_GDRIVE_CLIENT_SECRETin<kb>/.env, runopenkb source add gdrive, thenopenkb source syncopenkb source add gdrive --non-interactivewith no refresh token fails before writing the bindingopenkb source removeleaves compiled pages in the wikiconnector:gdrivelabelMerge Danger
Door: two-way
The command, the router, and the card can be reverted. A binding already saved under
connectors:withprovider: gdriveis ignored by a build that does not read it. Pages already compiled stay in the wiki, which is the same result asopenkb source remove. The refresh token in<kb>/.envis left in place on revert.Blast Radius: ingest
Local
openkb addis unchanged. The new libraries are an extra, so the core install and CI's lockeddev+apisync do not install them.oauth.pyis the shared loopback OneDrive will reuse; this pull request does not add OneDrive. The env-file writer moved fromapi_config.pyintoopenkb/envfile.pyso sign-in does not import FastAPI. REST config patch still calls that same function.Made with Cursor