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/container/agent-runner/src/providers/opencode-auth.test.ts
View on GitHubimport { afterEach, describe, expect, it } from 'bun:test';
import fs from 'fs';
import os from 'os';
import path from 'path';
import { initializeOpenCodeAuth } from './opencode-auth.js';
const roots: string[] = [];
function root() {
const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'opencode-auth-'));
roots.push(directory);
return directory;
}
afterEach(() => {
for (const directory of roots.splice(0)) fs.rmSync(directory, { recursive: true, force: true });
});
describe('container-owned OpenCode auth state', () => {
it('creates fresh OAuth placeholders and resets stale state before a restart', () => {
const directory = root();
const auth = path.join(directory, 'opencode/auth.json');
initializeOpenCodeAuth(directory, 'chatgpt');
const expected = {
openai: {
type: 'oauth',
access: 'nc-opencode-token-v1',
refresh: 'nc-opencode-token-v1',
accountId: 'nc-opencode-token-v1',
expires: Date.UTC(2100, 0, 1),
},
};
expect(JSON.parse(fs.readFileSync(auth, 'utf8'))).toEqual(expected);
fs.writeFileSync(auth, '{corrupt or stale');
initializeOpenCodeAuth(directory, 'chatgpt');
expect(JSON.parse(fs.readFileSync(auth, 'utf8'))).toEqual(expected);
expect(fs.statSync(auth).mode & 0o777).toBe(0o600);
expect(fs.readdirSync(path.dirname(auth))).toEqual(['auth.json']);
});
it('clears OAuth on switching to API-key mode and restores it on switching back', () => {
const directory = root();
const auth = path.join(directory, 'opencode/auth.json');
initializeOpenCodeAuth(directory, 'chatgpt');
initializeOpenCodeAuth(directory, 'api-key');
expect(JSON.parse(fs.readFileSync(auth, 'utf8'))).toEqual({});
initializeOpenCodeAuth(directory, 'chatgpt');
expect(JSON.parse(fs.readFileSync(auth, 'utf8')).openai.type).toBe('oauth');
});
it('replaces planted file links without overwriting their targets', () => {
const directory = root();
const unrelated = path.join(directory, 'unrelated');
fs.writeFileSync(unrelated, 'preserve');
fs.mkdirSync(path.join(directory, 'opencode'));
const auth = path.join(directory, 'opencode/auth.json');
fs.symlinkSync(unrelated, auth);
initializeOpenCodeAuth(directory, 'chatgpt');
expect(fs.lstatSync(auth).isFile()).toBe(true);
expect(fs.readFileSync(unrelated, 'utf8')).toBe('preserve');
});
it('rejects a symlinked auth directory without writing through it', () => {
const directory = root();
const target = root();
fs.symlinkSync(target, path.join(directory, 'opencode'));
expect(() => initializeOpenCodeAuth(directory, 'chatgpt')).toThrow('not symlinks');
expect(fs.readdirSync(target)).toEqual([]);
});
it('rejects a linked data root before creating an auth directory in its target', () => {
const directory = root();
const target = root();
const linked = path.join(directory, 'data');
fs.symlinkSync(target, linked);
expect(() => initializeOpenCodeAuth(linked, 'chatgpt')).toThrow('not symlinks');
expect(fs.readdirSync(target)).toEqual([]);
});
});
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 |