diff --git a/.github/workflows/shell.yml b/.github/workflows/shell.yml index 014ec8c..0343fc0 100644 --- a/.github/workflows/shell.yml +++ b/.github/workflows/shell.yml @@ -58,6 +58,14 @@ jobs: - name: Run tests/cli-channel-perms.sh run: ./tests/cli-channel-perms.sh + ai-gateway: + name: WP AI Gateway opt-in regression (#173) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run tests/ai-gateway.sh + run: ./tests/ai-gateway.sh + kimaki-agent-fallback: name: Kimaki native agent fallback regression runs-on: ubuntu-latest diff --git a/README.md b/README.md index 7ed6da3..2174f05 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,11 @@ operator-entrypoints/wp-coding-agents-setup/setup.md | `--chat ` | Chat bridge: `kimaki`, `cc-connect`, or `telegram`. | | `--no-chat` | Skip chat bridge setup. | | `--with-homeboy` | Enable optional Homeboy project/lab integration when available. | +| `--with-ai-gateway` | Enable optional [WP AI Gateway](https://github.com/Automattic/wp-ai-gateway) setup for OpenCode runtimes. | +| `--ai-gateway-provider ` | WordPress AI Client backend provider for the gateway route (default: `openai`). | +| `--ai-gateway-model ` | Backend model for the gateway route (default: `gpt-4o-mini`). | +| `--ai-gateway-opencode-model ` | OpenCode-facing gateway model ID (default: `site-default`). | +| `--rotate-ai-gateway-token` | Mint a replacement gateway token instead of reusing `.opencode/wp-ai-gateway.env`. | | `--multisite` | Configure WordPress multisite. | | `--subdomain` | Use subdomain multisite. | | `--no-skills` | Skip installing bundled agent skills. | @@ -169,6 +174,13 @@ Run `./setup.sh --help` for the complete setup surface. OpenCode uses `opencode.json` with Data Machine-composed instruction files. Kimaki is the default chat bridge for OpenCode when chat is enabled. +Pass `--with-ai-gateway` to opt OpenCode into this site's [WP AI Gateway](https://github.com/Automattic/wp-ai-gateway) endpoint. Setup installs the gateway/provider stack, configures the backend route via WP-CLI, mints (or reuses) a gateway token, and writes an OpenAI-compatible `provider.wp-ai-gateway` entry so clients receive only the gateway token while upstream credentials stay in WordPress. Native OpenCode auth is untouched unless gateway mode is opted in. + +```bash +EXISTING_WP=~/Studio/my-site ./setup.sh --local --runtime opencode \ + --with-ai-gateway --ai-gateway-provider openai --ai-gateway-model gpt-4o-mini +``` + ### Claude Code Claude Code uses `CLAUDE.md` with generated `@` includes. A SessionStart hook refreshes the Data Machine memory includes for each session. diff --git a/bridges/_dispatch.sh b/bridges/_dispatch.sh index 7fc4705..3360267 100644 --- a/bridges/_dispatch.sh +++ b/bridges/_dispatch.sh @@ -287,6 +287,35 @@ adopt_service_identity_from_units() { return 0 } +# Redact secret-looking values before printing generated unit/plist diffs. +# Dry-run output is operator-facing and often pasted into chats or PRs. +_redact_secret_diff() { + awk ' + /[^<]*(TOKEN|SECRET|PASSWORD|API_KEY|REFRESH_TOKEN)[^<]*<\/key>/ { + print + redact_next_string = 1 + next + } + redact_next_string && /.*<\/string>/ { + sub(/.*<\/string>/, "") + print + redact_next_string = 0 + next + } + /^[-+ ]Environment=[^=]*(TOKEN|SECRET|PASSWORD|API_KEY|REFRESH_TOKEN)=/ { + sub(/=.*/, "=") + print + next + } + /^[-+ ](OPENAI_API_KEY|KIMAKI_BOT_TOKEN|TELEGRAM_BOT_TOKEN|CC_CONNECT_TOKEN)=/ { + sub(/=.*/, "=") + print + next + } + { print } + ' +} + # _smart_update_systemd_unit [