Download scripts/lib/bong-native-benchmark.js from VanyaJ/bada-terminal: direct link, hf CLI and curl.
- Browser
- Download file 4.36 kB
-
https://huggingface.co/VanyaJ/bada-terminal/resolve/main/scripts/lib/bong-native-benchmark.js
- Command line
-
hf download hf://VanyaJ/bada-terminal/scripts/lib/bong-native-benchmark.js
-
curl -L -o bong-native-benchmark.js https://huggingface.co/VanyaJ/bada-terminal/resolve/main/scripts/lib/bong-native-benchmark.js
4.36 kB
| // ๊ณต๊ฐ Google ๊ณ์ธก๋ง์ ์ํ ์์ ํ๊ฒฝ. ์ฌ์ฉ์ ์ค์ ยท์๊ฒฉ์ ์๋ฌธ์ ๋ณต์ฌ/์ถ๋ ฅํ์ง ์๋๋ค. | |
| // ์ค๋ช ๋ฌธ์: docs/specs/bong-native-speech-benchmark.md (v1.0.0) | |
| const fs = require('fs'), path = require('path'), crypto = require('crypto'); | |
| const MODEL = 'google/gemini-3.8-flash'; | |
| const RESPONSE = '(๊ฐ์ : ์ฐจ๋ถํจ; ์๋: ๋ณดํต; ์ดํฌ: ์ ์คํ๊ฒ) ์์ ๊ณํ์ ๋จผ์ ํ์ธํ๊ฒ ์ต๋๋ค. ์คํ ์ ์ ์น์ธ์ ๋ฐ๊ฒ ์ต๋๋ค.'; | |
| function claimOutput(root, requested) { | |
| const scratch = fs.realpathSync(path.join(root, 'scratch')), output = path.resolve(root, requested); | |
| const parent = fs.realpathSync(path.dirname(output)); | |
| if (!output.startsWith(path.join(root, 'scratch') + path.sep) || (parent !== scratch && !parent.startsWith(scratch + path.sep))) throw Error('BENCH_OUTPUT'); | |
| fs.writeFileSync(output, '', { flag: 'wx', mode: 0o600 }); return output; | |
| } | |
| function isolatedNative(home, nativeHome) { | |
| const installed = path.join(process.env.XDG_CONFIG_HOME || path.join(nativeHome, '.config'), 'opencode'); | |
| const data = process.env.XDG_DATA_HOME || path.join(nativeHome, '.local/share'); | |
| const protectedFiles = [path.join(installed, 'opencode.json'), path.join(nativeHome, '.opencode/opencode.json'), | |
| path.join(data, 'opencode/auth.json'), path.join(nativeHome, '.claude/settings.json')]; | |
| const hash = file => fs.existsSync(file) ? crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex') : null; | |
| const before = protectedFiles.map(hash), configHome = path.join(home, '.config'), config = path.join(configHome, 'opencode'); | |
| fs.mkdirSync(config, { recursive: true }); | |
| const dependencies = {}, packages = {}; | |
| // ์ค์น๋ ๊ณต๊ฐ JS ํจํค์ง ๋ ๊ฐ๋ง ์ฌ์ฌ์ฉํ์ฌ ๋น HOME์์ ๋ค์ดํฐ๋ธ ์๋ npm ์ค๋น๋ฅผ ํผํ๋ค. | |
| for (const name of ['@opencode-ai/plugin', '@opencode-ai/sdk']) { | |
| const source = path.join(installed, 'node_modules', name), pkg = JSON.parse(fs.readFileSync(path.join(source, 'package.json'))); | |
| fs.cpSync(source, path.join(config, 'node_modules', name), { recursive: true }); | |
| dependencies[name] = pkg.version; packages['node_modules/' + name] = { version: pkg.version }; | |
| } | |
| fs.writeFileSync(path.join(config, 'package.json'), JSON.stringify({ private: true, dependencies }), { mode: 0o600 }); | |
| fs.writeFileSync(path.join(config, 'package-lock.json'), JSON.stringify({ lockfileVersion: 3, packages: { '': { dependencies }, ...packages } }), { mode: 0o600 }); | |
| const cwd = path.join(home, 'public-project'); fs.mkdirSync(cwd); fs.mkdirSync(path.join(cwd, '.git')); | |
| fs.mkdirSync(path.join(home, '.claude')); | |
| const userSettings = path.join(nativeHome, '.claude/settings.json'); | |
| const headroom = fs.existsSync(userSettings) ? JSON.parse(fs.readFileSync(userSettings)).headroom : undefined; | |
| // ํ์ฌ ๋ง์คํน ์ค์ ๋ง ๊ฒฉ๋ฆฌ ๋ณต์ ํ๋ค. ์์ regex๋ฅผ ์์ ์ ์กฐ๊ธฐ ๊ณต๊ฐ๋ฅผ ๊ฐ์ ํ์ง ์๋๋ค. | |
| fs.writeFileSync(path.join(home, '.claude/settings.json'), JSON.stringify(headroom ? { headroom } : {}), { mode: 0o600 }); | |
| const env = { PATH: process.env.PATH, HOME: home, XDG_CONFIG_HOME: configHome, XDG_DATA_HOME: data, | |
| XDG_STATE_HOME: path.join(home, '.state'), XDG_CACHE_HOME: path.join(home, '.cache'), | |
| OPENCODE_DISABLE_AUTOUPDATE: 'true', OPENCODE_DISABLE_MODELS_FETCH: 'true', OPENCODE_DISABLE_DEFAULT_PLUGINS: 'true', | |
| OPENCODE_DISABLE_EXTERNAL_SKILLS: 'true', OPENCODE_DISABLE_CLAUDE_CODE: 'true', OPENCODE_DISABLE_PROJECT_CONFIG: 'true', | |
| OPENCODE_CONFIG_CONTENT: JSON.stringify({ $schema: 'https://opencode.ai/config.json', autoupdate: false, share: 'disabled', | |
| plugin: [], instructions: [], skills: { paths: [] }, enabled_providers: ['google'], disabled_providers: [], model: MODEL, | |
| provider: { google: { models: { 'gemini-3.8-flash': { name: 'Gemini 3.8 Flash', limit: { context: 1048576, output: 1024 } } }, | |
| options: { baseURL: 'https://generativelanguage.googleapis.com/v1beta' } } } }) }; | |
| for (const key of ['SystemRoot', 'COMSPEC', 'PATHEXT', 'TEMP', 'TMP', 'LANG']) if (process.env[key]) env[key] = process.env[key]; | |
| if (process.platform === 'win32') env.USERPROFILE = home; | |
| return { cwd, env, configsUnchanged: () => protectedFiles.every((file, i) => hash(file) === before[i]) }; | |
| } | |
| module.exports = { isolatedNative, claimOutput, MODEL, RESPONSE }; | |