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/src/provider-contracts/opencode.ts
View on GitHubimport { readEnvFile } from '../env.js';
import { CLAUDE_COMPATIBLE_HOST_SURFACES } from './claude.js';
import { registerProviderHostContract } from './registry.js';
const NATIVE_MODEL_DOMAINS = [
'api.openai.com',
'chatgpt.com',
'openrouter.ai',
'api.deepseek.com',
'generativelanguage.googleapis.com',
'api.anthropic.com',
];
function configuredEndpoint(): string | undefined {
const env = readEnvFile(['OPENCODE_BASE_URL', 'ANTHROPIC_BASE_URL']);
return (
process.env.OPENCODE_BASE_URL ?? env.OPENCODE_BASE_URL ?? process.env.ANTHROPIC_BASE_URL ?? env.ANTHROPIC_BASE_URL
);
}
// The shared ANTHROPIC_BASE_URL may be another provider's keyed endpoint, so it never pins a port.
function openCodeEndpoint(): string | undefined {
return process.env.OPENCODE_BASE_URL ?? readEnvFile(['OPENCODE_BASE_URL']).OPENCODE_BASE_URL;
}
/** Operator-owned endpoint settings are realized when the host starts. */
export function openCodeModelDomains(endpoint = configuredEndpoint()): string[] {
const domains = [...NATIVE_MODEL_DOMAINS];
if (endpoint && endpoint !== 'native') {
try {
const url = new URL(endpoint);
if (
url.protocol === 'https:' &&
!url.port &&
!url.username &&
!url.password &&
!url.search &&
!url.hash &&
/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/.test(url.hostname)
)
domains.push(url.hostname);
} catch {
/* Invalid endpoints are diagnosed by provider configuration. */
}
}
return [...new Set(domains)];
}
/**
* An endpoint on a non-default port, such as a model server on the host, is
* declared as its exact host:port; the selected gateway decides the scheme. A
* default port leaves no port in the URL or the request, so domains cover it.
*/
export function openCodeModelAuthorities(endpoint = openCodeEndpoint()): string[] {
if (!endpoint || endpoint === 'native') return [];
try {
const url = new URL(endpoint);
if (
(url.protocol === 'http:' || url.protocol === 'https:') &&
url.port &&
!url.username &&
!url.password &&
!url.search &&
!url.hash &&
/^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/.test(url.hostname)
)
return [`${url.hostname}:${url.port}`];
} catch {
/* Invalid endpoints are diagnosed by provider configuration. */
}
return [];
}
registerProviderHostContract('opencode', {
seamVersion: 1,
legacyHostAdapter: 'required',
...CLAUDE_COMPATIBLE_HOST_SURFACES,
modelDomains: openCodeModelDomains(),
modelAuthorities: openCodeModelAuthorities(),
stateVolumes: [
...CLAUDE_COMPATIBLE_HOST_SURFACES.stateVolumes,
{
id: 'opencode-xdg',
directory: 'opencode-xdg',
containerPath: '/opencode-xdg',
scope: 'session',
mode: 'rw',
mountClass: 'allowlisted-extra',
},
],
commands: { nativeAdmin: [], nativeFiltered: [] },
});
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 |