nanocoai/nanoclaw / .claude/skills/add-opencode
add-opencode
VerifiedUse OpenCode as an agent provider. OpenRouter, OpenAI, Google, DeepSeek, etc. via OpenCode config — not the Anthropic Agent SDK. Per group via `ncl groups config update --provider opencode`; host passes OPENCODE_* and XDG mount when spawning containers.
payload/scripts/opencode-vault.ts
View on GitHubimport { getCredentialStore } from '../setup/gateways/credential-store.js';
import type { GatewayCredentialConnection, GatewayCredentialTarget } from '../setup/gateways/credential-store.js';
import { OPENCODE_CREDENTIAL_PLACEHOLDER } from '../src/providers/opencode-auth-stub.js';
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
/** What OpenCode knows about a credential: destination, header scheme, and for ChatGPT its public OAuth client. */
export type OpenCodeSecret = DistributiveOmit<GatewayCredentialTarget, 'proxyValue'>;
export type OpenCodeVault = GatewayCredentialConnection;
export type KeyInjection = Extract<GatewayCredentialTarget, { kind: 'api-key' }>['injection'];
export function apiKeyInjection(provider: string): KeyInjection {
if (provider === 'google') return { headerName: 'x-goog-api-key', valueFormat: '{value}' };
if (provider === 'anthropic') return { headerName: 'x-api-key', valueFormat: '{value}' };
if (['openai', 'openrouter', 'deepseek'].includes(provider))
return { headerName: 'Authorization', valueFormat: 'Bearer {value}' };
throw new Error(
`API-key setup does not yet support the ${provider} authentication scheme. Choose openai, openrouter, deepseek, google, or anthropic. For an OpenAI-compatible service, choose Local or self-hosted.`,
);
}
/**
* Every OpenCode credential goes through the selected gateway's connection.
* Resolution is lazy so setup can finish selecting the gateway before the
* first credential prompt; there is no gateway-specific branch here and no
* fallback when the selected gateway cannot connect.
*/
export function createOpenCodeVault(target: OpenCodeSecret, root = process.cwd()): OpenCodeVault {
let connection: Promise<GatewayCredentialConnection> | undefined;
const resolve = () =>
(connection ??= getCredentialStore(root).then((store) => {
if (!store.connection) throw new Error('The selected gateway does not support provider credential connections.');
return store.connection({
...target,
proxyValue: OPENCODE_CREDENTIAL_PLACEHOLDER,
provider: 'opencode',
} as GatewayCredentialTarget);
}));
return {
find: async (options) => (await resolve()).find(options),
save: async (value) => (await resolve()).save(value),
keep: async () => (await resolve()).keep(),
};
}
// Matches the native OpenAI plugin in the skill-pinned OpenCode 1.18.25.
export const CHATGPT_SECRET: OpenCodeSecret = {
name: 'OpenCode ChatGPT',
kind: 'oauth',
host: 'chatgpt.com',
oauth: {
profile: 'chatgpt',
clientId: 'app_EMoamEEZ73f0CkXaXp7hrann',
tokenEndpoint: 'https://auth.openai.com/oauth/token',
},
};
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 469k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |