@vibeapi/api-helper 0.0.99 → 0.0.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e}from"path";import{applyGatewayModels as t,claudeCodeManager as o}from"../claude-code-manager.js";import{backupBeforeWrite as
|
|
1
|
+
import{join as e}from"path";import{applyGatewayModels as t,claudeCodeManager as o}from"../claude-code-manager.js";import{backupBeforeWrite as n}from"./backup.js";import{i18n as a}from"../i18n.js";import{baseModelId as s}from"../model-catalog.js";import{gatewayModelSpecs as i,prettyModelName as r,vendorNames as l}from"../gateway-models.js";import{toolHome as d}from"./types.js";import{spawnSync as c}from"child_process";import{existsSync as u,readFileSync as p}from"fs";import{detectManagedOverrides as m}from"./claude-managed.js";import{installOfficialPlugins as g}from"./claude-plugins.js";import{findInstalls as f,mirrorInstallCommand as h,brandInstallScripts as C}from"./tool-installs.js";import{updateNativeFromMirror as _}from"./claude-native-mirror.js";import{brandEnv as k}from"../brand.js";const j=e(d(),".claude","settings.json"),y=e(d(),".claude.json");let P,S=null,v=()=>0===c("security",["find-generic-password","-s","Claude Code-credentials"],{stdio:"ignore"}).status;export function setClaudeKeychainProbeForTests(e){v=e}export function claudeAccountLoginPresent(){const t=process.env.CLAUDE_CONFIG_DIR?.trim()||e(d(),".claude");if(u(e(t,".credentials.json")))return!0;if("darwin"!==process.platform||k("TEST_HOME"))return!1;try{return v()}catch{return!1}}function x(){try{const t=JSON.parse(p(e(d(),".claude","settings.json"),"utf-8"));return"string"==typeof t.autoUpdatesChannel?t.autoUpdatesChannel:"latest"}catch{return"latest"}}function b(e){if(!e)return;const t=new Set(e.models);return i("claude-code",e.clientModels).filter(e=>t.has(e.id))}const w={command:"claude",npmPackage:"@anthropic-ai/claude-code",native:{binDir:[".local","bin"],updateArgs:["update"],dataDirs:[[".local","share","claude"]],mirrorUpdate:()=>_(x())},mirrorScript:C("claude-code"),brew:"claude-code"};export const claudeCodeAdapter={name:"claude-code",displayName:"Claude Code",command:"claude",installCommand:h(w),upgradeCommand:"claude update",installSpec:w,upgradeHints:e=>"stable"===x()?[a.t("tools.claude_code.stable_channel",{min:e})]:[],configPath:j,wantsModelCatalog:!0,loadPrivateConfig(t){n(j),n(y),P=b(t.catalog),o.loadPrivateConfig(t.apiKey,t.models,t.catalog?.models,P);const a=e(d(),".local","bin","win32"===process.platform?"claude.exe":"claude"),s=f(claudeCodeAdapter.installSpec)[0]?.path??(u(a)?a:null);S=s?g(s):null},unloadPrivateConfig(){n(j),o.unloadPrivateConfig()},detectCurrentConfig:()=>o.detectCurrentConfig(),getConfig:()=>({settings:o.getSettings(),mcp:o.getMCPConfig()}),updateConfig(e){const t=e||{};t.settings&&o.saveSettings(t.settings),t.mcp&&o.saveMCPConfig(t.mcp)},clearPinnedModels:e=>(n(j),o.clearPinnedModels(e?.models)),listedModels(){const e=o.getSettings().modelPicker;return Array.isArray(e?.options)?e.options.map(e=>s(String(e.model))):null},refreshModelMenu(e){const a=o.getSettings(),s=t(a,b(e.catalog));JSON.stringify(s)!==JSON.stringify(a)&&(n(j),o.saveSettings(s))},applyNotes(){const e=[];S?.installed.length&&(e.push({kind:"summary",text:a.t("tools.claude_code.plugins_installed",{count:String(S.installed.length)})}),e.push({kind:"detail",text:S.installed.join(", ")})),"git"===S?.skipped?e.push({kind:"action",text:a.t("tools.claude_code.plugins_need_git")}):("marketplace"===S?.skipped||S?.failed.length)&&e.push({kind:"action",text:a.t("tools.claude_code.plugins_failed")}),P&&P.length>0&&(e.push({kind:"summary",text:a.t("tools.claude_code.gateway_models",{count:String(P.length),vendors:l(P.map(e=>e.id)).join(" / ")})}),e.push({kind:"detail",text:P.map(e=>e.name||r(e.id)).join(", ")})),"win32"!==process.platform||process.env.CLAUDE_CODE_GIT_BASH_PATH||0===c("where",["git"],{windowsHide:!0,stdio:"ignore"}).status||e.push({kind:"action",text:a.t("tools.claude_code.no_git_bash")}),claudeAccountLoginPresent()&&e.push({kind:"detail",text:a.t("tools.claude_code.account_login_overridden")});for(const t of m())e.push({kind:"action",text:a.t("tools.claude_code.managed_override",{source:t.source,keys:t.keys.join(", ")})});for(const t of o.getLastTierFallbacks())e.push({kind:"detail",text:a.t("tools.claude_code.tier_fallback",{tier:t.tier,from:t.from,to:t.to})});return e},backupPaths:()=>[j,y],forceResetPaths:()=>[j]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawnSync as e}from"child_process";import{readFileSync as
|
|
1
|
+
import{spawnSync as e}from"child_process";import{existsSync as t,readFileSync as i}from"fs";import{join as o}from"path";import{logger as s}from"../../utils/logger.js";import{configManager as n}from"../config.js";import{toolHome as r}from"./types.js";import{brandEnv as l,brand as a}from"../brand.js";export const PLUGIN_SOURCES=[...a().pluginMarketplaces,{name:"claude-plugins-official",add:"anthropics/claude-plugins-official",probe:"https://github.com/anthropics/claude-plugins-official.git"}];export const OFFICIAL_PLUGINS=["code-review","feature-dev","frontend-design","pr-review-toolkit","commit-commands","security-guidance","code-simplifier","skill-creator","claude-md-management","claude-code-setup"];const d="official_plugins_offered";let p=(t,i)=>{const n=e(t,i,{env:l("TEST_HOME")?{...process.env,CLAUDE_CONFIG_DIR:o(r(),".claude")}:process.env,encoding:"utf-8",timeout:12e4,windowsHide:!0,stdio:["ignore","pipe","pipe"],shell:"win32"===process.platform&&/\.cmd$/i.test(t)});return 0!==n.status&&s.logError(`claude ${i.join(" ")}`,new Error(`${n.stderr??""}${n.stdout??""}`.trim())),0===n.status},c=t=>0===e("git",["ls-remote","--heads",t],{timeout:8e3,windowsHide:!0,stdio:"ignore"}).status;export function setClaudePluginRunnerForTests(e){p=e}export function setPluginSourceProbeForTests(e){c=e}export function installOfficialPlugins(s){if("1"===l("SKIP_CLAUDE_PLUGINS"))return{installed:[],failed:[],skipped:"disabled"};const a=n.getToolSetting("claude-code",d),u=new Set("string"==typeof a?a.split(",").filter(Boolean):[]),f=function(){try{const e=JSON.parse(i(o(r(),".claude","plugins","installed_plugins.json"),"utf-8"));return new Set(Object.keys(e.plugins??{}).map(e=>e.replace(/@[^@]*$/,"")))}catch{return new Set}}(),m=e=>f.has(e),g=OFFICIAL_PLUGINS.filter(e=>!u.has(e)&&!m(e));if(0===g.length)return{installed:[],failed:[],skipped:null};if("darwin"===process.platform&&0!==e("xcode-select",["-p"],{stdio:"ignore"}).status&&!["/opt/homebrew/bin/git","/usr/local/bin/git"].some(e=>t(e))||0!==e("git",["--version"],{timeout:8e3,windowsHide:!0,stdio:"ignore"}).status)return{installed:[],failed:[],skipped:"git"};const S=PLUGIN_SOURCES.find(e=>c(e.probe));if(!S)return{installed:[],failed:[],skipped:"marketplace"};p(s,["plugin","marketplace","add",S.add]);const h={installed:[],failed:[],skipped:null,source:S.name};for(const e of g)p(s,["plugin","install",`${e}@${S.name}`])?(h.installed.push(e),u.add(e)):h.failed.push(e);for(const e of OFFICIAL_PLUGINS)m(e)&&u.add(e);return n.setToolSetting("claude-code",d,[...u].join(",")),h}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawnSync as t}from"child_process";import{existsSync as e,readFileSync as o}from"fs";import{dirname as n,join as i}from"path";import{fileURLToPath as s}from"url";import{logger as r}from"../../utils/logger.js";import{getCodexRules as l,compareVersions as
|
|
1
|
+
import{spawnSync as t}from"child_process";import{existsSync as e,readFileSync as o}from"fs";import{dirname as n,join as i}from"path";import{fileURLToPath as s}from"url";import{logger as r}from"../../utils/logger.js";import{getCodexRules as l,compareVersions as a}from"../model-registry.js";import{autoCompactTokens as d,modelBlurb as u,prettyModelName as c}from"../gateway-models.js";import{toolHome as p}from"./types.js";import{brandEnv as _,PROVIDER_KEY as m}from"../brand.js";const f=n(s(import.meta.url));export const CODEX_CATALOG_FILE=`${m}-model-catalog.json`;export const codexCatalogPath=()=>i(p(),".codex",CODEX_CATALOG_FILE);function x(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function w(t){try{const e=JSON.parse(t),o=x(e)&&Array.isArray(e.models)?e.models.filter(x):[];return o.length>0?o:null}catch{return null}}export function loadBundledCodexModels(){for(const o of function(){const t=_("CODEX_BIN");if(void 0!==t)return t.trim()?[t.trim()]:[];const e=["codex"];if("win32"===process.platform){const t=process.env.LOCALAPPDATA||i(p(),"AppData","Local");e.push(i(t,"Programs","OpenAI","Codex","bin","codex.exe"))}else e.push(i(p(),".local","bin","codex"));if("darwin"===process.platform)for(const t of["/Applications",i(p(),"Applications")])e.push(i(t,"ChatGPT.app/Contents/Resources/codex-cli/bin/codex")),e.push(i(t,"Codex.app/Contents/Resources/codex"));return e}()){if("codex"!==o&&!e(o))continue;const n={encoding:"utf-8",timeout:2e4,maxBuffer:67108864,windowsHide:!0,stdio:["ignore","pipe","pipe"]},i="win32"===process.platform&&"codex"===o?t("codex debug models --bundled",{...n,shell:!0}):t(o,["debug","models","--bundled"],n);if(0===i.status&&i.stdout){const t=w(i.stdout);if(t)return t}(i.error||0!==i.status)&&r.logError("loadBundledCodexModels",i.error??new Error(`${o} exited ${i.status}`))}return null}export function loadPreviousCodexModels(){const t=g()?.filter(t=>!h(t));return t&&t.length>0?t:null}export function previousGatewayModelIds(){return(g()??[]).filter(h).map(t=>String(t.slug))}function g(){return e(codexCatalogPath())?w(o(codexCatalogPath(),"utf-8")):null}function h(t){return"number"==typeof t.priority&&t.priority>=1e3}let y=null;function b(){if(null!==y)return y;const t=[i(f,"..","..","..","codex-base-instructions.md"),i(f,"..","..","codex-base-instructions.md"),i(f,"codex-base-instructions.md")],n=t.find(t=>e(t));if(!n)throw new Error(`codex-base-instructions.md not found, searched: ${t.join(", ")}`);return y=o(n,"utf-8"),y}function C(t){return"number"==typeof t&&Number.isFinite(t)&&t>0?t:void 0}function v(t,e,o,n){const i=o?t:Math.min(t,e);return{window:i,compact:d(i,n)}}function A(t,e,o,n){const{standardContextWindow:i}=l();let s=C(t.contextWindow)??i;n&&t.id.startsWith("claude-")&&(s=n.has(t.id)?Math.max(s,1e6):Math.min(s,2e5));const{window:r,compact:a}=v(s,i,o,C(t.autoCompactTokens));return{slug:t.id,display_name:t.name||c(t.id),description:u(t.description,{millionContext:r>=1e6})??null,supported_reasoning_levels:[],shell_type:"unified_exec",visibility:"list",supported_in_api:!0,priority:e,additional_speed_tiers:[],service_tiers:[],availability_nux:null,upgrade:null,model_messages:{instructions_template:b()},base_instructions:b(),supports_reasoning_summaries:!0,supports_parallel_tool_calls:!1,prefer_websockets:!1,include_skills_usage_instructions:!1,include_plugin_usage_instructions:!1,include_apps_usage_instructions:!1,default_reasoning_summary:"auto",support_verbosity:!1,default_verbosity:null,apply_patch_tool_type:null,web_search_tool_type:"text",truncation_policy:{mode:"bytes",limit:1e4},supports_image_detail_original:!1,context_window:r,max_context_window:r,auto_compact_token_limit:a,effective_context_window_percent:95,experimental_supported_tools:[],input_modalities:["text","image"],supports_search_tool:!1,supports_experimental_context:!1,use_responses_lite:!1,supports_reasoning_effort_updates:!1,node_repl_auto_review_required:!1,node_repl_disabled:!1}}function M(t,e,o){if("list"!==t.visibility)return t;const n=C(t.context_window);if(!n)return t;const i=C(t.max_context_window)??n,s=o?Math.min(C(e?.contextWindow)??i,i):n,{window:r,compact:l}=v(s,n,!0,C(e?.autoCompactTokens));return{...t,context_window:r,auto_compact_token_limit:l}}export function buildCodexCatalog(t){const{bundled:e,specs:o,oneMillion:n,selectedModel:i}=t,s=t.claudeOneMillion?new Set(t.claudeOneMillion):void 0,r=t.keyModels?new Set(t.keyModels):null,l=new Set(t.gatewayAvailable),d=t=>!r||r.has(t)||t===i,u=t=>l.has(t)||t===i,c=new Map(o.map(t=>[t.id,t])),p=[],_=new Set;for(const t of e){const e="string"==typeof t.slug?t.slug:"";e&&!_.has(e)&&("list"!==t.visibility||d(e))&&(_.add(e),p.push(M(t,c.get(e),n)))}const m=[...o];i&&!c.has(i)&&m.push({id:i});const f=function(t){const e=new Map;for(const o of t){const t=/^claude-([a-z]+)-(.+)$/.exec(o);if(!t)continue;const n=t[2].split("-").filter(t=>/^\d{1,2}$/.test(t)).join("."),i=e.get(t[1]);(!i||a(n,i.version)>0)&&e.set(t[1],{id:o,version:n})}return new Set([...e.values()].map(t=>t.id))}(m.map(t=>t.id).filter(u));for(const t of m)!_.has(t.id)&&u(t.id)&&(t.id.startsWith("claude-")&&!f.has(t.id)&&t.id!==i||(_.add(t.id),p.push(A(t,1e3+p.length,n,s))));return{models:p}}
|
package/dist/locales/en_US.json
CHANGED
|
@@ -411,7 +411,8 @@
|
|
|
411
411
|
"no_git_bash": "Git for Windows not found: Claude Code falls back to PowerShell for commands, which works, but bash commands and scripts won't; install Git (winget install Git.Git, or download from https://registry.npmmirror.com/binary.html?path=git-for-windows/)",
|
|
412
412
|
"plugins_installed": "{{count}} official plugins installed (code review, feature dev, frontend design, …); type / to see them",
|
|
413
413
|
"plugins_failed": "Official plugins could not be installed (GitHub unreachable, most likely); everything else works. Run {{cli}} config claude-code --non-interactive again later",
|
|
414
|
-
"account_login_overridden": "Claude Code on this computer is signed in to a Claude account; the {{brand}} token {{product}} writes takes precedence, so Claude Code uses {{brand}}. To go back to the account, remove the {{brand}} config with {{cli}} config claude-code"
|
|
414
|
+
"account_login_overridden": "Claude Code on this computer is signed in to a Claude account; the {{brand}} token {{product}} writes takes precedence, so Claude Code uses {{brand}}. To go back to the account, remove the {{brand}} config with {{cli}} config claude-code",
|
|
415
|
+
"plugins_need_git": "Official plugins are downloaded with Git, which this computer doesn't have yet (on a Mac, Apple's Command Line Tools); everything else works. Once Git is installed, run {{cli}} config claude-code --non-interactive"
|
|
415
416
|
},
|
|
416
417
|
"model_family": {
|
|
417
418
|
"gpt": "GPT",
|
package/dist/locales/zh_CN.json
CHANGED
|
@@ -411,7 +411,8 @@
|
|
|
411
411
|
"no_git_bash": "没找到 Git for Windows:Claude Code 会改用 PowerShell 执行命令,可以用,但 bash 写法的命令和脚本跑不了;建议安装 Git(winget install Git.Git,或从国内镜像 https://registry.npmmirror.com/binary.html?path=git-for-windows/ 下载)",
|
|
412
412
|
"plugins_installed": "装好 {{count}} 个官方插件(代码审查、功能开发、前端设计等),输入 / 可以看到",
|
|
413
413
|
"plugins_failed": "官方插件没装上(多半是连不上 GitHub),不影响使用;网络好时再运行 {{cli}} config claude-code --non-interactive 即可",
|
|
414
|
-
"account_login_overridden": "这台电脑的 Claude Code 登录过 Claude 官方账号;{{product}} 写入的 {{brand}} 令牌会优先生效,Claude Code 走 {{brand}}。要改回官方账号,用 {{cli}} config claude-code 移除 {{brand}} 配置"
|
|
414
|
+
"account_login_overridden": "这台电脑的 Claude Code 登录过 Claude 官方账号;{{product}} 写入的 {{brand}} 令牌会优先生效,Claude Code 走 {{brand}}。要改回官方账号,用 {{cli}} config claude-code 移除 {{brand}} 配置",
|
|
415
|
+
"plugins_need_git": "官方插件要用 Git 下载,这台电脑还没有 Git(Mac 上要先装好苹果命令行工具),不影响使用;装好 Git 后运行 {{cli}} config claude-code --non-interactive 补装"
|
|
415
416
|
},
|
|
416
417
|
"model_family": {
|
|
417
418
|
"gpt": "GPT",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibeapi/api-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.100",
|
|
4
4
|
"description": "CLI tool for managing AI coding assistants (Claude Code, Codex, OpenClaw, Hermes, AtomCode, Grok Build) with one unified config",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|