feat(opencode): add mcpctl config opencode + /mcpctl TUI switcher with bottom project indicator
Some checks failed
CI/CD / lint (pull_request) Successful in 1m7s
CI/CD / test (pull_request) Successful in 1m22s
CI/CD / typecheck (pull_request) Successful in 2m49s
CI/CD / smoke (pull_request) Failing after 1m54s
CI/CD / build (pull_request) Successful in 2m16s
CI/CD / publish (pull_request) Has been skipped
Some checks failed
CI/CD / lint (pull_request) Successful in 1m7s
CI/CD / test (pull_request) Successful in 1m22s
CI/CD / typecheck (pull_request) Successful in 2m49s
CI/CD / smoke (pull_request) Failing after 1m54s
CI/CD / build (pull_request) Successful in 2m16s
CI/CD / publish (pull_request) Has been skipped
This commit is contained in:
38
scripts/generate-opencode-extension.ts
Normal file
38
scripts/generate-opencode-extension.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Generates `src/cli/src/config/opencode-extension.ts`, embedding the opencode
|
||||
* TUI plugin source as a string constant so `mcpctl config opencode` keeps
|
||||
* working from an installed binary with no source tree.
|
||||
*
|
||||
* Regenerate after editing the plugin source:
|
||||
* npx tsx scripts/generate-opencode-extension.ts
|
||||
*/
|
||||
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
||||
import { dirname, join } from 'node:path';
|
||||
|
||||
const scriptsDir = import.meta.dirname;
|
||||
const root = join(scriptsDir, '..');
|
||||
const src = readFileSync(join(root, 'src', 'opencode-ext', 'mcpctl-opencode.tsx'), 'utf-8');
|
||||
|
||||
function embed(s: string) {
|
||||
// JSON.stringify yields a quoted string literal we can inline directly.
|
||||
return JSON.stringify(s);
|
||||
}
|
||||
|
||||
const out = `/**
|
||||
* Embedded source of the mcpctl opencode plugin — DO NOT EDIT BY HAND.
|
||||
* Generated by \`npx tsx scripts/generate-opencode-extension.ts\` from
|
||||
* \`src/opencode-ext/mcpctl-opencode.tsx\`.
|
||||
*
|
||||
* \`mcpctl config opencode\` writes it verbatim into the opencode plugin dir and
|
||||
* registers it in opencode.json, so an installed binary with no source tree can
|
||||
* still provision a working opencode integration.
|
||||
*/
|
||||
export const OPENCODE_PLUGIN_FILENAME = 'mcpctl-switch.tsx' as const;
|
||||
|
||||
export const OPENCODE_PLUGIN = ${embed(src)};
|
||||
`;
|
||||
|
||||
mkdirSync(dirname(join(root, 'src', 'cli', 'src', 'config')), { recursive: true });
|
||||
writeFileSync(join(root, 'src', 'cli', 'src', 'config', 'opencode-extension.ts'), out);
|
||||
console.log('wrote src/cli/src/config/opencode-extension.ts');
|
||||
Reference in New Issue
Block a user