Add opt-in WP AI Gateway setup for OpenCode#174
Open
chubes4 wants to merge 4 commits into
Open
Conversation
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.
Summary
--with-ai-gatewaysetup/upgrade plumbing for OpenCode runtimes, including gateway/provider plugin install, WP-CLI route configuration, token mint/reuse, and OpenCode provider/env configuration.--rotate-ai-gateway-token.Closes #173.
Source checks
providermap entries supportnpm,env,options.baseURL,options.apiKey/env keys, and custommodelsentries. This PR writesprovider.wp-ai-gatewaywith@ai-sdk/openai-compatible,OPENAI_API_KEY, and${OPENAI_BASE_URL}.wp-ai-gatewayWP-CLI surface provideswp ai-gateway configure <provider> <model>,wp ai-gateway token --porcelain, andwp ai-gateway status --format=json; gateway token output is one-time only, so setup stores/reuses the local env file rather than rotating by default.Tests
bash -n setup.sh upgrade.sh lib/ai-gateway.sh bridges/_dispatch.sh bridges/kimaki.sh tests/ai-gateway.sh./tests/ai-gateway.sh./tests/bridge-render.shbash tests/repair-opencode-json.shbash tests/opencode-wrapper-removal.shbash tests/kimaki-agent-fallback.shbash -c 'set -e; fail=0; while IFS= read -r -d "" f; do if ! bash -n "$f"; then echo "FAIL: $f"; fail=1; fi; done < <(find . -type f -name "*.sh" -not -path "./.git/*" -print0); exit "$fail"'SITE_DOMAIN=example.test EXISTING_WP=<tmp>/site ./setup.sh --existing --runtime opencode --with-ai-gateway --ai-gateway-provider openai --ai-gateway-model gpt-4o-mini --dry-run --no-chatEXISTING_WP=<tmp>/site ./upgrade.sh --local --wp-path <tmp>/site --runtime opencode --with-ai-gateway --ai-gateway-provider openai --ai-gateway-model gpt-4o-mini --dry-run --skip-pluginswith output scanned for gateway/Kimaki token leaksSITE_DOMAIN=example.test EXISTING_WP=<tmp>/site ./setup.sh --existing --runtime opencode --with-ai-gateway --ai-gateway-provider wp-ai-gateway --dry-run --no-chatverified rejectedbash -n lib/ai-gateway.sh setup.sh upgrade.sh tests/ai-gateway.sh && ./tests/ai-gateway.shDependency status
Risks
wp-ai-gatewayhas one-time token output only; this PR reuses the local.opencode/wp-ai-gateway.envtoken when present and only rotates with--rotate-ai-gateway-token.EnvironmentFile, so the gateway env is rendered into launchd when gateway mode is opted in; diff output redacts secrets.AI assistance