xling 0.10.0 → 0.11.0

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{p as e}from"./errors-x3Es7YJ3.js";import{n as t,t as n}from"./editor-DUx1Sby2.js";import{t as r}from"./format-CZL0rRQR.js";import{a as i,c as a,h as o,m as s,s as c}from"./fsStore-D1omjK0d.js";import{t as l}from"./base-Dv8Ajp1w.js";import{t as u}from"./claudeDefault-BP2oPKZC.js";import*as d from"node:fs";import*as f from"node:path";var p=class extends l{toolId=`claude`;async list(e){let t=s(this.validateAndResolvePath(e)),n=f.dirname(t),r=f.basename(t),i=[this.#e(t,e,!0)];if(d.existsSync(n)){let t=d.readdirSync(n,{withFileTypes:!0});for(let a of t){if(!a.isFile()||a.name===r||!this.#r(a.name))continue;let t=f.join(n,a.name);i.push(this.#e(t,e,!1))}}return{type:`files`,files:this.#i(i)}}resolvePath(e){switch(e){case`user`:return`~/.claude/settings.json`;case`project`:return`.claude/settings.json`;case`local`:return`.claude/settings.local.json`;default:throw Error(`Unsupported scope for Claude: ${e}`)}}validateScope(e){return[`user`,`project`,`local`].includes(e)}async switchProfile(t,n,i){let a=s(this.validateAndResolvePath(t)),o=n.trim();if(!o)throw Error(`Variant name cannot be empty`);let l=c(f.dirname(a),o,a);if(!l)throw new e(o);let u=this.readConfig(l),d={};try{d=this.readConfig(a)}catch{d={}}let p=r(d,u);if(i?.preview)return{success:!0,preview:!0,filePath:a,diff:p??void 0,data:{from:l,to:a,hasChanges:!!p},message:p?`Preview generated. Review diff before applying.`:`Current settings already match the selected variant.`};if(!p)return{success:!0,message:`Current settings already match the selected variant.`,filePath:a};let m=i?.backup??!1;return this.writeConfig(a,u,m),{success:!0,message:`Switched to ${f.basename(l)}`,filePath:a,data:{from:l,to:a}}}async edit(e,r){let a=s(this.validateAndResolvePath(e)),l=f.dirname(a),u=r.name?.trim(),p=t(r.ide);i(l);let m=a,h=`default`;if(u&&u!==``&&u!==`default`){let e=c(l,u,a);if(e)m=e;else if(m=f.join(l,`settings.${u}.json`),!d.existsSync(m)){let e=this.#n(a);o(m,e,!1)}h=u}else if(!d.existsSync(m)){let e=this.#n(a);o(m,e,!1)}return await n(p,m),{success:!0,message:`Opened ${h} settings in ${p}`,filePath:m,data:{variant:h,ide:p}}}#e(e,t,n){let r=a(e);return{filename:f.basename(e),variant:this.#t(e),path:e,scope:t,active:n,exists:!!r,size:r?.size,lastModified:r?.lastModified}}#t(e){let t=f.basename(e),n=t.match(/^settings(?:[._-](.+))?\.json$/);return n?n[1]??`default`:t.replace(/\.json$/,``)}#n(e){try{if(d.existsSync(e)){let t=d.readFileSync(e,`utf-8`);return JSON.parse(t)}}catch{}return{...u}}#r(e){return/^settings[._-].+\.json$/.test(e)}#i(e){return e.sort((e,t)=>e.active&&!t.active?-1:!e.active&&t.active?1:e.variant.localeCompare(t.variant))}};export{p as t};
1
+ import{p as e}from"./errors-x3Es7YJ3.js";import{n as t,t as n}from"./editor-DUx1Sby2.js";import{t as r}from"./format-CZL0rRQR.js";import{a as i,c as a,h as o,m as s,s as c}from"./fsStore-D1omjK0d.js";import{t as l}from"./base-Dv8Ajp1w.js";import{t as u}from"./claudeDefault-BP2oPKZC.js";import*as d from"node:fs";import*as f from"node:path";var p=class extends l{toolId=`claude`;async list(e){let t=s(this.validateAndResolvePath(e)),n=f.dirname(t),r=f.basename(t),i=[this.#e(t,e,!0)];if(d.existsSync(n)){let t=d.readdirSync(n,{withFileTypes:!0});for(let a of t){if(!a.isFile()||a.name===r||!this.#r(a.name))continue;let t=f.join(n,a.name);i.push(this.#e(t,e,!1))}}return{type:`files`,files:this.#o(i)}}resolvePath(e){switch(e){case`user`:return`~/.claude/settings.json`;case`project`:return`.claude/settings.json`;case`local`:return`.claude/settings.local.json`;default:throw Error(`Unsupported scope for Claude: ${e}`)}}validateScope(e){return[`user`,`project`,`local`].includes(e)}async switchProfile(t,n,i){let a=s(this.validateAndResolvePath(t)),o=n.trim();if(!o)throw Error(`Variant name cannot be empty`);let l=c(f.dirname(a),o,a);if(!l)throw new e(o);let u=this.readConfig(l),d={};try{d=this.readConfig(a)}catch{d={}}let p=r(d,u);if(i?.preview)return{success:!0,preview:!0,filePath:a,diff:p??void 0,data:{from:l,to:a,hasChanges:!!p},message:p?`Preview generated. Review diff before applying.`:`Current settings already match the selected variant.`};if(!p)return{success:!0,message:`Current settings already match the selected variant.`,filePath:a};let m=i?.backup??!1;return this.writeConfig(a,u,m),{success:!0,message:`Switched to ${f.basename(l)}`,filePath:a,data:{from:l,to:a}}}async edit(e,r){let a=s(this.validateAndResolvePath(e)),l=f.dirname(a),u=r.name?.trim(),p=t(r.ide);i(l);let m=a,h=`default`;if(u&&u!==``&&u!==`default`){let e=c(l,u,a);if(e)m=e;else if(m=f.join(l,`settings.${u}.json`),!d.existsSync(m)){let e=this.#n(a);o(m,e,!1)}h=u}else if(!d.existsSync(m)){let e=this.#n(a);o(m,e,!1)}return await n(p,m),{success:!0,message:`Opened ${h} settings in ${p}`,filePath:m,data:{variant:h,ide:p}}}#e(e,t,n){let r=a(e);return{filename:f.basename(e),variant:this.#t(e),path:e,scope:t,active:n,exists:!!r,size:r?.size,lastModified:r?.lastModified}}#t(e){let t=f.basename(e),n=t.match(/^settings(?:[._-](.+))?\.json$/);return n?n[1]??`default`:t.replace(/\.json$/,``)}#n(e){try{if(d.existsSync(e)){let t=d.readFileSync(e,`utf-8`);return JSON.parse(t)}}catch{}return{...u}}#r(e){return/^settings[._-].+\.json$/.test(e)}getCurrentVariant(e){let t=s(this.validateAndResolvePath(e)),n=f.dirname(t);if(!d.existsSync(t)||!d.existsSync(n))return null;let r;try{r=this.readConfig(t)}catch{return null}let i=d.readdirSync(n,{withFileTypes:!0});for(let e of i){if(!e.isFile()||!this.#r(e.name))continue;let t=f.join(n,e.name);try{let e=this.readConfig(t);if(this.#i(r,e))return this.#t(t)}catch{continue}}return null}#i(e,t){return this.#a(e)===this.#a(t)}#a(e){return typeof e!=`object`||!e?JSON.stringify(e):Array.isArray(e)?`[`+e.map(e=>this.#a(e)).join(`,`)+`]`:`{`+Object.keys(e).sort().map(t=>JSON.stringify(t)+`:`+this.#a(e[t])).join(`,`)+`}`}#o(e){return e.sort((e,t)=>e.active&&!t.active?-1:!e.active&&t.active?1:e.variant.localeCompare(t.variant))}};export{p as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./errors-x3Es7YJ3.js";import{n as t,t as n}from"./editor-DUx1Sby2.js";import{a as r,c as i,f as a,g as o,l as s,m as c,o as l,p as u,r as d,t as f}from"./fsStore-D1omjK0d.js";import{t as p}from"./base-Dv8Ajp1w.js";import*as m from"node:path";const h=`~/.codex/auth-profiles`,g=`~/.codex/auth.json`;var _=class extends p{toolId=`codex`;async list(e){let t=this.validateAndResolvePath(e),n=this.readConfig(t),r=this.#c(n),i=this.listAuthProfiles(),a=l(g),o=typeof n.current_auth_profile==`string`?n.current_auth_profile:a||i.length>0?this.#d():null;return{type:`entries`,entries:{current_provider:typeof n.model_provider==`string`?n.model_provider:null,current_profile:typeof n.current_profile==`string`?n.current_profile:null,current_auth_profile:o,providers:r,auth_profiles:i},filePath:t}}async inspect(e,t){let n=this.validateAndResolvePath(e),r=c(n),a=l(n),o=a?this.#s(n):{},s=a?i(n):null,u=t?.trim();if(u){if(this.isAuthProfile(u)){let e=`${h}/${u}.json`,t=this.#u(e),n=i(e);return{path:c(e),exists:l(e),content:JSON.stringify({mode:`auth`,authProfile:u,authFile:c(e),configFile:r,authData:t},null,2),size:n?.size,lastModified:n?.lastModified}}let e=v(o.model_providers)?o.model_providers:{};if(e[u])return{path:r,exists:a,content:JSON.stringify({mode:`provider`,currentProvider:u,config:e[u]??{}},null,2),size:s?.size,lastModified:s?.lastModified};let t=v(o.profiles)?o.profiles:{};return t[u]?{path:r,exists:a,content:JSON.stringify({mode:`profile`,currentProfile:u,config:t[u]??{}},null,2),size:s?.size,lastModified:s?.lastModified}:{path:r,exists:a,content:JSON.stringify({mode:`not_found`,requested:u,availableProviders:Object.keys(e),availableProfiles:Object.keys(t),availableAuthProfiles:this.listAuthProfiles()},null,2),size:s?.size,lastModified:s?.lastModified}}if(!a)return this.#e(r);if(o.current_profile&&typeof o.current_profile==`string`)return this.#t(o,r,s);if(o.model_provider&&typeof o.model_provider==`string`)return this.#n(o,r,s);let d=typeof o.current_auth_profile==`string`?o.current_auth_profile:null;return d||l(g)?this.#r(d,r,s):this.#i(r,s)}#e(e){if(l(g)){let e=this.#l(),t=this.#d();return{path:c(g),exists:!0,content:JSON.stringify({mode:`auth`,currentAuthProfile:t,authFile:c(g),authData:e},null,2)}}return{path:e,exists:!1}}#t(e,t,n){let r=e.current_profile,i=(v(e.profiles)?e.profiles:{})[r];return{path:t,exists:!0,content:JSON.stringify({mode:`profile`,currentProfile:r,config:v(i)?i:{}},null,2),size:n?.size,lastModified:n?.lastModified}}#n(e,t,n){let r=e.model_provider,i=(v(e.model_providers)?e.model_providers:{})[r];return{path:t,exists:!0,content:JSON.stringify({mode:`provider`,currentProvider:r,config:v(i)?i:{}},null,2),size:n?.size,lastModified:n?.lastModified}}#r(e,t,n){let r=this.#l(),i=e||this.#d();return{path:c(g),exists:!0,content:JSON.stringify({mode:`auth`,currentAuthProfile:i,authFile:c(g),configFile:t,authData:r},null,2),size:n?.size,lastModified:n?.lastModified}}#i(e,t){return{path:e,exists:!0,content:JSON.stringify({mode:`none`,message:`No active provider or auth configured. Run 'codex login' or configure a model_provider.`,configFile:e},null,2),size:t?.size,lastModified:t?.lastModified}}resolvePath(e){switch(e){case`user`:return`~/.codex/config.toml`;default:throw Error(`Unsupported scope for Codex: ${e}`)}}validateScope(e){return e===`user`}async switchProfile(e,t,n){return this.validateAndResolvePath(e),this.isAuthProfile(t)?this.#a(t):this.#o(e,t)}async edit(e,i){let a=this.validateAndResolvePath(e);if(!i.provider){let e=c(a);r(m.dirname(e)),l(a)||this.writeConfig(a,{});let o=t(i.ide);return await n(o,e),{success:!0,message:`Opened Codex config in ${o}`,filePath:e}}let o=i.provider.id?.trim()||i.provider.name?.trim();if(!o)throw Error(`Provider name cannot be empty`);let s=i.provider.base_url?.trim();if(!s)throw Error(`Base URL is required for Codex providers`);let u=i.provider.name?.trim()||o,d=i.provider.experimental_bearer_token?.trim();if(!d)throw Error(`Experimental bearer token is required for Codex providers`);let f=this.#s(a),p=v(f.model_providers)?{...f.model_providers}:{};p[o]={name:u,base_url:s,wire_api:`responses`,experimental_bearer_token:d};let h={...f,model_providers:p};return this.writeConfig(a,h),{success:!0,message:`Added model_providers.${o}`,filePath:c(a),data:p[o]}}listAuthProfiles(){return s(h).filter(e=>e.endsWith(`.json`)).map(e=>e.replace(`.json`,``))}isAuthProfile(e){return l(`${h}/${e}.json`)}saveAuthProfile(e,t=!1){let n=`${h}/${e}.json`;return l(g)?!t&&l(n)?{success:!1,message:`Profile "${e}" already exists. Use --force to overwrite.`}:(r(h),f(g,n),d(g),{success:!0,message:`Saved current auth as profile: ${e}\nauth.json has been removed. You can now login with another account.`,filePath:c(n)}):{success:!1,message:`No auth.json found. Please run 'codex login' first.`}}deleteAuthProfile(e){let t=`${h}/${e}.json`;return l(t)?(d(t),{success:!0,message:`Deleted auth profile: ${e}`}):{success:!1,message:`Auth profile "${e}" not found.`}}getAllSwitchableProfiles(e){let t=this.resolvePath(e),n=[];try{let e=this.readConfig(t),r=e.model_providers;v(r)&&(n=Object.keys(r));let i=e.profiles;v(i)&&(n=[...new Set([...n,...Object.keys(i)])])}catch{}let r=this.listAuthProfiles();return{providers:n,authProfiles:r}}#a(e){let t=`${h}/${e}.json`,n=`~/.codex/config.toml`;if(!l(t))return{success:!1,message:`Auth profile "${e}" not found.`};f(t,g);try{let t=this.#s(n);delete t.model_provider,delete t.current_profile,t.current_auth_profile=e,this.writeConfig(n,t)}catch{this.writeConfig(n,{current_auth_profile:e})}return{success:!0,message:`Switched to auth profile: ${e}`,filePath:c(g)}}#o(e,t){let n=this.resolvePath(e);l(g)&&d(g);let r=this.#s(n);delete r.current_auth_profile;let i=r.profiles,a=(v(i)?i:void 0)?.[t];if(v(a)){let e={...r};for(let[t,n]of Object.entries(a))e[t]=n;return e.current_profile=t,delete e.model_provider,this.writeConfig(n,e),{success:!0,message:`Switched to profile: ${t}`,filePath:c(n)}}delete r.current_profile;let o={...r,model_provider:t};return this.writeConfig(n,o),{success:!0,message:`Switched to provider: ${t}`,filePath:c(n)}}readConfig(e){return u(e)}writeConfig(e,t){o(e,t,!1)}#s(t){try{return this.readConfig(t)}catch(t){if(t instanceof e)return{};throw t}}#c(e){let t=e.model_providers;return v(t)?t:{}}#l(){if(!l(g))return null;try{return a(g)}catch{return null}}#u(e){if(!l(e))return null;try{return a(e)}catch{return null}}#d(){if(!l(g))return`default`;let e;try{e=a(g)}catch{return`default`}if(!e)return`default`;let t=this.listAuthProfiles();for(let n of t){let t=`${h}/${n}.json`;try{let r=a(t);if(this.#f(e,r))return n}catch{continue}}return`default`}#f(e,t){return this.#p(e)===this.#p(t)}#p(e){return typeof e!=`object`||!e?JSON.stringify(e):Array.isArray(e)?`[`+e.map(e=>this.#p(e)).join(`,`)+`]`:`{`+Object.keys(e).sort().map(t=>JSON.stringify(t)+`:`+this.#p(e[t])).join(`,`)+`}`}};const v=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date);export{v as n,_ as t};
@@ -1,4 +1,4 @@
1
- import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{r as e}from"../../format-CZL0rRQR.js";import"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import{t}from"../../codex-CLx2Yb0G.js";import{Command as n,Flags as r}from"@oclif/core";var i=class i extends n{static summary=`Manage saved auth profiles`;static description=`
1
+ import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{r as e}from"../../format-CZL0rRQR.js";import"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import{t}from"../../codex-Kk3Sv7uC.js";import{Command as n,Flags as r}from"@oclif/core";var i=class i extends n{static summary=`Manage saved auth profiles`;static description=`
2
2
  Save, list, and delete auth profiles for Codex.
3
3
  Use settings:switch to switch between auth profiles and providers.
4
4
 
@@ -1,4 +1,4 @@
1
- import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{r as e}from"../../format-CZL0rRQR.js";import"../../config-D0b5Ceh4.js";import{m as t,s as n}from"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import"../../template-DtJFiC8I.js";import"../../xling-DxPgM9hF.js";import"../../codex-CLx2Yb0G.js";import"../../claudeDefault-BP2oPKZC.js";import{t as r}from"../../claude-CWDwrH2t.js";import"../../gemini-2eTblTJ_.js";import{t as i}from"../../dispatcher-Bc9KhwR1.js";import{Args as a,Command as o,Flags as s}from"@oclif/core";import c from"node:fs";import l from"node:path";var u=class u extends o{static summary=`View configuration file contents`;static description=`
1
+ import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{r as e}from"../../format-CZL0rRQR.js";import"../../config-D0b5Ceh4.js";import{m as t,s as n}from"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import"../../template-DtJFiC8I.js";import"../../xling-DxPgM9hF.js";import"../../codex-Kk3Sv7uC.js";import"../../claudeDefault-BP2oPKZC.js";import{t as r}from"../../claude-BqDhM0_U.js";import"../../gemini-2eTblTJ_.js";import{t as i}from"../../dispatcher-DOZzJY8q.js";import{Args as a,Command as o,Flags as s}from"@oclif/core";import c from"node:fs";import l from"node:path";var u=class u extends o{static summary=`View configuration file contents`;static description=`
2
2
  Print the entire configuration file for the selected tool/scope.
3
3
  Output format depends on the file type (JSON, TOML, etc.).
4
4
  `;static examples=[{description:`Print Claude user settings (raw file)`,command:`<%= config.bin %> <%= command.id %> --tool claude --scope user`},{description:`Inspect a Claude variant by name`,command:`<%= config.bin %> <%= command.id %> hxi --tool claude --scope user`},{description:`Dump Codex config as JSON for scripting`,command:`<%= config.bin %> <%= command.id %> --tool codex --json`},{description:`View xling prompt router config (if present)`,command:`<%= config.bin %> <%= command.id %> --tool xling --scope user`}];static args={name:a.string({description:`Claude variant name (optional). Example: settings:get hxi`,required:!1})};static flags={tool:s.string({char:`t`,description:`AI CLI tool to manage`,options:[`claude`,`codex`,`gemini`,`xling`],default:`claude`}),scope:s.string({char:`s`,description:`Configuration scope`,options:[`user`,`project`,`local`,`system`],default:`user`})};async run(){let{args:t,flags:n}=await this.parse(u);try{let r=n.tool,i=n.scope,a=r===`claude`&&t.name?await this.#t(i,t.name):await this.#e(r,i,t.name);if(n.json){this.log(e({success:!0,data:a}));return}if(!a.exists){this.warn(`Config file not found: ${a.path}`);return}a.content?this.log(a.content):this.log(`File is empty.`)}catch(e){this.error(e.message,{exit:1})}}async#e(e,t,n){return(await new i().execute({tool:e,scope:t,action:`inspect`,name:n})).data}async#t(e,i){let a=new r;if(!a.validateScope(e))throw Error(`Invalid scope for Claude: ${e}`);let o=i.trim();if(!o||o===`default`)return this.#e(`claude`,e);let s=t(a.resolvePath(e)),u=l.dirname(s),d=n(u,o)??l.join(u,`settings.${o}.json`);if(!c.existsSync(d))return{path:d,exists:!1};let f=c.statSync(d);return{path:d,exists:!0,content:c.readFileSync(d,`utf-8`),size:f.size,lastModified:f.mtime}}};export{u as default};
@@ -1,4 +1,4 @@
1
- import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{r as e}from"../../format-CZL0rRQR.js";import"../../config-D0b5Ceh4.js";import"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import"../../template-DtJFiC8I.js";import"../../xling-DxPgM9hF.js";import"../../codex-CLx2Yb0G.js";import"../../claudeDefault-BP2oPKZC.js";import"../../claude-CWDwrH2t.js";import"../../gemini-2eTblTJ_.js";import{t}from"../../dispatcher-Bc9KhwR1.js";import{Command as n,Flags as r}from"@oclif/core";var i=class i extends n{static summary=`Inspect configuration file status`;static description=`
1
+ import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{r as e}from"../../format-CZL0rRQR.js";import"../../config-D0b5Ceh4.js";import"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import"../../template-DtJFiC8I.js";import"../../xling-DxPgM9hF.js";import"../../codex-Kk3Sv7uC.js";import"../../claudeDefault-BP2oPKZC.js";import"../../claude-BqDhM0_U.js";import"../../gemini-2eTblTJ_.js";import{t}from"../../dispatcher-DOZzJY8q.js";import{Command as n,Flags as r}from"@oclif/core";var i=class i extends n{static summary=`Inspect configuration file status`;static description=`
2
2
  Display information about the configuration file, including:
3
3
  - File path
4
4
  - Existence status
@@ -1,4 +1,4 @@
1
- import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{i as e,n as t,r as n}from"../../format-CZL0rRQR.js";import"../../config-D0b5Ceh4.js";import"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import"../../template-DtJFiC8I.js";import"../../xling-DxPgM9hF.js";import"../../codex-CLx2Yb0G.js";import"../../claudeDefault-BP2oPKZC.js";import"../../claude-CWDwrH2t.js";import"../../gemini-2eTblTJ_.js";import{t as r}from"../../dispatcher-Bc9KhwR1.js";import{Command as i,Flags as a}from"@oclif/core";var o=class o extends i{static summary=`List all settings for a tool`;static description=`
1
+ import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{i as e,n as t,r as n}from"../../format-CZL0rRQR.js";import"../../config-D0b5Ceh4.js";import"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import"../../template-DtJFiC8I.js";import"../../xling-DxPgM9hF.js";import"../../codex-Kk3Sv7uC.js";import"../../claudeDefault-BP2oPKZC.js";import"../../claude-BqDhM0_U.js";import"../../gemini-2eTblTJ_.js";import{t as r}from"../../dispatcher-DOZzJY8q.js";import{Command as i,Flags as a}from"@oclif/core";var o=class o extends i{static summary=`List all settings for a tool`;static description=`
2
2
  Display all configuration settings for the specified AI CLI tool.
3
3
  Supports multiple scopes (user, project, local, system).
4
4
  For Codex, output includes model providers and saved auth profiles.
@@ -1,4 +1,4 @@
1
- import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{r as e}from"../../format-CZL0rRQR.js";import"../../config-D0b5Ceh4.js";import"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import"../../template-DtJFiC8I.js";import"../../xling-DxPgM9hF.js";import"../../codex-CLx2Yb0G.js";import"../../claudeDefault-BP2oPKZC.js";import"../../claude-CWDwrH2t.js";import"../../gemini-2eTblTJ_.js";import{t}from"../../dispatcher-Bc9KhwR1.js";import{Command as n,Flags as r}from"@oclif/core";import i from"node:readline/promises";import{stdin as a,stdout as o}from"node:process";var s=class s extends n{static summary=`Edit settings or add model providers`;static description=`
1
+ import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{r as e}from"../../format-CZL0rRQR.js";import"../../config-D0b5Ceh4.js";import"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import"../../template-DtJFiC8I.js";import"../../xling-DxPgM9hF.js";import"../../codex-Kk3Sv7uC.js";import"../../claudeDefault-BP2oPKZC.js";import"../../claude-BqDhM0_U.js";import"../../gemini-2eTblTJ_.js";import{t}from"../../dispatcher-DOZzJY8q.js";import{Command as n,Flags as r}from"@oclif/core";import i from"node:readline/promises";import{stdin as a,stdout as o}from"node:process";var s=class s extends n{static summary=`Edit settings or add model providers`;static description=`
2
2
  Create or open settings files for AI CLI tools in your preferred editor,
3
3
  or interactively add Codex model providers.
4
4
 
@@ -1,4 +1,4 @@
1
- import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{r as e}from"../../format-CZL0rRQR.js";import"../../config-D0b5Ceh4.js";import"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import"../../template-DtJFiC8I.js";import{t}from"../../xling-DxPgM9hF.js";import{t as n}from"../../codex-CLx2Yb0G.js";import"../../claudeDefault-BP2oPKZC.js";import"../../claude-CWDwrH2t.js";import"../../gemini-2eTblTJ_.js";import{t as r}from"../../dispatcher-Bc9KhwR1.js";import{Args as i,Command as a,Flags as o}from"@oclif/core";import s from"node:readline/promises";import{stdin as c,stdout as l}from"node:process";var u=class u extends a{static summary=`Switch between profiles or settings variants`;static description=`
1
+ import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{r as e}from"../../format-CZL0rRQR.js";import"../../config-D0b5Ceh4.js";import"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import"../../template-DtJFiC8I.js";import{t}from"../../xling-DxPgM9hF.js";import{t as n}from"../../codex-Kk3Sv7uC.js";import"../../claudeDefault-BP2oPKZC.js";import{t as r}from"../../claude-BqDhM0_U.js";import"../../gemini-2eTblTJ_.js";import{t as i}from"../../dispatcher-DOZzJY8q.js";import{Args as a,Command as o,Flags as s}from"@oclif/core";import c from"node:readline/promises";import{stdin as l,stdout as u}from"node:process";var d=class d extends o{static summary=`Switch between profiles or settings variants`;static description=`
2
2
  Switch to a different profile configuration for Codex,
3
3
  activate a specific settings.<variant>.json for Claude,
4
4
  or switch the default model for Xling prompt router.
@@ -10,7 +10,7 @@ import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import{r as e}
10
10
 
11
11
  For Xling, you can switch between any model from configured providers.
12
12
  Run without arguments for interactive selection.
13
- `;static examples=[{description:`Switch Codex to an auth profile (saved login)`,command:`<%= config.bin %> <%= command.id %> personal --tool codex`},{description:`Switch Codex to a provider`,command:`<%= config.bin %> <%= command.id %> my-provider --tool codex`},{description:`Interactive selection for Codex`,command:`<%= config.bin %> <%= command.id %> --tool codex`},{description:`Activate a Claude variant (user scope)`,command:`<%= config.bin %> <%= command.id %> hxi --tool claude --scope user`},{description:`Force-apply Claude variant and emit JSON for scripts`,command:`<%= config.bin %> <%= command.id %> hxi --tool claude --scope user --force --json`},{description:`Keep a backup while switching Claude settings`,command:`<%= config.bin %> <%= command.id %> stable --tool claude --backup`},{description:`Interactive model selection for Xling`,command:`<%= config.bin %> <%= command.id %> --tool xling`},{description:`Switch Xling default model directly`,command:`<%= config.bin %> <%= command.id %> claude-sonnet-4-20250514 --tool xling`}];static args={profile:i.string({description:`Profile name to switch to`,required:!1})};static flags={tool:o.string({char:`t`,description:`AI CLI tool to manage`,options:[`claude`,`codex`,`gemini`,`xling`],default:`claude`}),scope:o.string({char:`s`,description:`Configuration scope`,options:[`user`,`project`,`local`,`system`],default:`user`}),json:o.boolean({description:`Output JSON instead of interactive text`,default:!1}),force:o.boolean({description:`Skip confirmation prompts (Claude only)`,default:!1}),backup:o.boolean({description:`Create a .bak backup when switching (Claude only)`,default:!1})};async run(){let{args:e,flags:t}=await this.parse(u),n=new r,i=e.profile;i||=(t.json&&this.error(`Profile is required when using --json output.`,{exit:1}),await this.#t(n,t));try{let e=t.tool===`claude`?await this.#e(n,i,t):await n.execute({tool:t.tool,scope:t.scope,action:`switch-profile`,profile:i});if(!e)return;this.#l(e,i,t)}catch(e){this.error(e.message,{exit:1})}}async#e(e,t,n){n.json&&!n.force&&this.error(`--json requires --force when switching Claude settings.`,{exit:1});let r=await e.execute({tool:`claude`,scope:n.scope,action:`switch-profile`,profile:t,switchOptions:{preview:!0}});if(r.diff)this.log(`Proposed changes:
14
- `+r.diff);else return this.log(`No differences detected. Current settings already match the selected variant.`),r;let i=!!n.backup;if(!n.force&&!i){let e=await this.#s();if(e===`cancel`)return this.log(`Switch cancelled.`),null;i=e===`backup`}let a=await e.execute({tool:`claude`,scope:n.scope,action:`switch-profile`,profile:t,switchOptions:{backup:i}});return a.diff=r.diff,a}async#t(e,t){let n=t.tool,r=t.scope,i=[];n===`claude`?i=await this.#n(e,r):n===`codex`?i=await this.#r(r):n===`xling`?i=await this.#i(r):this.error(`Interactive selection is not supported for tool: ${n}`,{exit:1}),i.length||this.error(`No available profiles found for the selected tool.`,{exit:1}),this.log(`Select a profile to switch to:`),i.forEach((e,t)=>{this.log(` ${t+1}) ${e}`)});let a=s.createInterface({input:c,output:l});try{for(;;){let e=(await a.question(`Enter number or name: `)).trim().toLowerCase(),t=Number.parseInt(e,10);if(Number.isInteger(t)&&t>=1&&t<=i.length){let e=i[t-1];return n===`codex`?this.#a(e):n===`xling`?this.#o(e):e}let r=i.find(t=>t.toLowerCase()===e);if(r)return n===`codex`?this.#a(r):n===`xling`?this.#o(r):r;if(n===`codex`){let t=i.find(t=>this.#a(t).toLowerCase()===e);if(t)return this.#a(t)}if(n===`xling`){let t=i.find(t=>this.#o(t).toLowerCase()===e);if(t)return this.#o(t)}this.log(`Invalid selection. Please try again.`)}}finally{a.close()}}async#n(e,t){let n=await e.execute({tool:`claude`,scope:t,action:`list`});return this.#c(n.data)?n.data.files.filter(e=>!e.active).map(e=>e.variant).filter(Boolean):[]}async#r(e){let{providers:t,authProfiles:r}=new n().getAllSwitchableProfiles(e),i=[];if(r.length>0)for(let e of r)i.push(`[auth] ${e}`);if(t.length>0)for(let e of t)i.push(`[provider] ${e}`);return i}async#i(e){let n=new t,r=n.getAllModels(e);r.length===0&&this.error(`No models found. Please configure providers in ~/.claude/xling.json first.
15
- Run: xling settings:set --tool xling`,{exit:1});let i=n.getDefaultModel(e);return r.map(e=>e.model===i?`${e.label} (current)`:e.label)}#a(e){let t=e.match(/^\[(auth|provider)\]\s+(.+)$/);return t?t[2]:e}#o(e){let t=e.replace(/ \(current\)$/,``),n=t.match(/^\[.+?\]\s+(.+)$/);return n?n[1]:t}async#s(){let e=s.createInterface({input:c,output:l});try{for(;;){let t=(await e.question(`Choose action ([o]verwrite/[b]ackup/[c]ancel): `)).trim().toLowerCase();if([`overwrite`,`backup`,`cancel`].includes(t))return t;if([`o`,`b`,`c`].includes(t))return{o:`overwrite`,b:`backup`,c:`cancel`}[t]}}finally{e.close()}}#c(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`files`&&`files`in e&&Array.isArray(e.files))}#l(t,n,r){if(r.json){this.log(e(t));return}if(t.preview){this.log(`Preview only. No changes applied.`),t.diff&&this.log(t.diff);return}this.log(t.message??`Switched to profile: ${n}`),t.filePath&&this.log(` File: ${t.filePath}`),t.diff&&this.log(`Applied diff:
16
- `+t.diff)}};export{u as default};
13
+ `;static examples=[{description:`Switch Codex to an auth profile (saved login)`,command:`<%= config.bin %> <%= command.id %> personal --tool codex`},{description:`Switch Codex to a provider`,command:`<%= config.bin %> <%= command.id %> my-provider --tool codex`},{description:`Interactive selection for Codex`,command:`<%= config.bin %> <%= command.id %> --tool codex`},{description:`Activate a Claude variant (user scope)`,command:`<%= config.bin %> <%= command.id %> hxi --tool claude --scope user`},{description:`Force-apply Claude variant and emit JSON for scripts`,command:`<%= config.bin %> <%= command.id %> hxi --tool claude --scope user --force --json`},{description:`Keep a backup while switching Claude settings`,command:`<%= config.bin %> <%= command.id %> stable --tool claude --backup`},{description:`Interactive model selection for Xling`,command:`<%= config.bin %> <%= command.id %> --tool xling`},{description:`Switch Xling default model directly`,command:`<%= config.bin %> <%= command.id %> claude-sonnet-4-20250514 --tool xling`}];static args={profile:a.string({description:`Profile name to switch to`,required:!1})};static flags={tool:s.string({char:`t`,description:`AI CLI tool to manage`,options:[`claude`,`codex`,`gemini`,`xling`],default:`claude`}),scope:s.string({char:`s`,description:`Configuration scope`,options:[`user`,`project`,`local`,`system`],default:`user`}),json:s.boolean({description:`Output JSON instead of interactive text`,default:!1}),force:s.boolean({description:`Skip confirmation prompts (Claude only)`,default:!1}),backup:s.boolean({description:`Create a .bak backup when switching (Claude only)`,default:!1})};async run(){let{args:e,flags:t}=await this.parse(d),n=new i,r=e.profile;r||=(t.json&&this.error(`Profile is required when using --json output.`,{exit:1}),await this.#t(n,t));try{let e=t.tool===`claude`?await this.#e(n,r,t):await n.execute({tool:t.tool,scope:t.scope,action:`switch-profile`,profile:r});if(!e)return;this.#l(e,r,t)}catch(e){this.error(e.message,{exit:1})}}async#e(e,t,n){n.json&&!n.force&&this.error(`--json requires --force when switching Claude settings.`,{exit:1});let r=await e.execute({tool:`claude`,scope:n.scope,action:`switch-profile`,profile:t,switchOptions:{preview:!0}});if(r.diff)this.log(`Proposed changes:
14
+ `+r.diff);else return this.log(`No differences detected. Current settings already match the selected variant.`),r;let i=!!n.backup;if(!n.force&&!i){let e=await this.#s();if(e===`cancel`)return this.log(`Switch cancelled.`),null;i=e===`backup`}let a=await e.execute({tool:`claude`,scope:n.scope,action:`switch-profile`,profile:t,switchOptions:{backup:i}});return a.diff=r.diff,a}async#t(e,t){let n=t.tool,r=t.scope,i=[];n===`claude`?i=await this.#n(e,r):n===`codex`?i=await this.#r(r):n===`xling`?i=await this.#i(r):this.error(`Interactive selection is not supported for tool: ${n}`,{exit:1}),i.length||this.error(`No available profiles found for the selected tool.`,{exit:1}),this.log(`Select a profile to switch to:`),i.forEach((e,t)=>{this.log(` ${t+1}) ${e}`)});let a=c.createInterface({input:l,output:u});try{for(;;){let e=(await a.question(`Enter number or name: `)).trim().toLowerCase(),t=Number.parseInt(e,10);if(Number.isInteger(t)&&t>=1&&t<=i.length)return this.#o(n,i[t-1]);let r=i.find(t=>t.toLowerCase()===e);if(r)return this.#o(n,r);let o=i.find(t=>this.#o(n,t).toLowerCase()===e);if(o)return this.#o(n,o);this.log(`Invalid selection. Please try again.`)}}finally{a.close()}}async#n(e,t){let n=await e.execute({tool:`claude`,scope:t,action:`list`});if(!this.#c(n.data))return[];let i=new r().getCurrentVariant(t);return n.data.files.filter(e=>!e.active&&e.variant).map(e=>e.variant===i?`${e.variant} (current)`:e.variant)}async#r(e){let t=new n,{providers:r,authProfiles:i}=t.getAllSwitchableProfiles(e),a=await t.list(e),o=a.type===`entries`?a.entries:{},s=o.current_auth_profile,c=o.current_provider,l=o.current_profile,u=[];if(i.length>0)for(let e of i){let t=e===s;u.push(`[auth] ${e}${t?` (current)`:``}`)}if(r.length>0)for(let e of r){let t=e===c||e===l;u.push(`[provider] ${e}${t?` (current)`:``}`)}return u}async#i(e){let n=new t,r=n.getAllModels(e);r.length===0&&this.error(`No models found. Please configure providers in ~/.claude/xling.json first.
15
+ Run: xling settings:set --tool xling`,{exit:1});let i=n.getDefaultModel(e);return r.map(e=>e.model===i?`${e.label} (current)`:e.label)}#a(e){return e.replace(/ \(current\)$/,``)}#o(e,t){let n=this.#a(t);switch(e){case`claude`:return n;case`codex`:{let e=n.match(/^\[(auth|provider)\]\s+(.+)$/);return e?e[2]:n}case`xling`:{let e=n.match(/^\[.+?\]\s+(.+)$/);return e?e[1]:n}default:return n}}async#s(){let e=c.createInterface({input:l,output:u});try{for(;;){let t=(await e.question(`Choose action ([o]verwrite/[b]ackup/[c]ancel): `)).trim().toLowerCase();if([`overwrite`,`backup`,`cancel`].includes(t))return t;if([`o`,`b`,`c`].includes(t))return{o:`overwrite`,b:`backup`,c:`cancel`}[t]}}finally{e.close()}}#c(e){return!!(e&&typeof e==`object`&&`type`in e&&e.type===`files`&&`files`in e&&Array.isArray(e.files))}#l(t,n,r){if(r.json){this.log(e(t));return}if(t.preview){this.log(`Preview only. No changes applied.`),t.diff&&this.log(t.diff);return}this.log(t.message??`Switched to profile: ${n}`),t.filePath&&this.log(` File: ${t.filePath}`),t.diff&&this.log(`Applied diff:
16
+ `+t.diff)}};export{d as default};
@@ -1 +1 @@
1
- import{Command as e}from"@oclif/core";var t=`0.10.0`,n=class extends e{static summary=`Show the current xling version`;static description=`Displays the version from package.json.`;static examples=[{description:`Print the installed CLI version`,command:`<%= config.bin %> <%= command.id %>`},{description:`Shortcut using the built-in flag`,command:`<%= config.bin %> --version`}];async run(){this.log(t??`unknown`)}};export{n as default};
1
+ import{Command as e}from"@oclif/core";var t=`0.11.0`,n=class extends e{static summary=`Show the current xling version`;static description=`Displays the version from package.json.`;static examples=[{description:`Print the installed CLI version`,command:`<%= config.bin %> <%= command.id %>`},{description:`Shortcut using the built-in flag`,command:`<%= config.bin %> --version`}];async run(){this.log(t??`unknown`)}};export{n as default};
@@ -1,4 +1,4 @@
1
- import{n as e}from"../../cli-BevqZj-b.js";import"../../errors-x3Es7YJ3.js";import"../../runner-QW_B2Hqh.js";import"../../base-Cb8gvSZx.js";import"../../claude-CgDMZ5NR.js";import"../../codex-Czpk7Br1.js";import"../../gemini-Bf13TKO0.js";import{t}from"../../dispatcher-KWhvzTOg.js";import{Command as n,Flags as r}from"@oclif/core";var i=class i extends n{static summary=`eXecute AI CLI tools (defaults to Claude Code with yolo)`;static description=`
1
+ import"../../errors-x3Es7YJ3.js";import"../../runner-QW_B2Hqh.js";import"../../base-Cb8gvSZx.js";import"../../claude-CgDMZ5NR.js";import"../../codex-Czpk7Br1.js";import"../../gemini-Bf13TKO0.js";import{t as e}from"../../dispatcher-KWhvzTOg.js";import{Command as t,Flags as n}from"@oclif/core";var r=class r extends t{static summary=`eXecute AI CLI tools (defaults to Claude Code with yolo)`;static description=`
2
2
  Quick launcher for Claude Code, Codex, or Gemini CLI with yolo mode enabled by default.
3
3
 
4
4
  Just run "xling x" to start Claude Code instantly!
@@ -29,4 +29,4 @@ import{n as e}from"../../cli-BevqZj-b.js";import"../../errors-x3Es7YJ3.js";impor
29
29
  $ xling x --no-yolo # Start Claude without yolo
30
30
  $ xling x -- chat "Hello" # Start Claude with arguments
31
31
  $ xling x -t codex -C /path # Start Codex in specific directory
32
- `;static examples=[{description:`Start Claude Code instantly (default)`,command:`<%= config.bin %> <%= command.id %>`},{description:`Continue last conversation`,command:`<%= config.bin %> <%= command.id %> -c`},{description:`Resume a conversation from list`,command:`<%= config.bin %> <%= command.id %> -r`},{description:`Start Claude with hxi settings variant`,command:`<%= config.bin %> <%= command.id %> -s hxi`},{description:`Continue last Codex session`,command:`<%= config.bin %> <%= command.id %> -t codex -c`},{description:`Start Codex with oss profile`,command:`<%= config.bin %> <%= command.id %> -t codex -s oss`},{description:`Start Gemini CLI (auto-accept actions)`,command:`<%= config.bin %> <%= command.id %> -t gemini`},{description:`Resume latest Gemini session`,command:`<%= config.bin %> <%= command.id %> -t gemini -c`},{description:`Start Claude without yolo mode`,command:`<%= config.bin %> <%= command.id %> --no-yolo`},{description:`Start Claude and pass arguments`,command:`<%= config.bin %> <%= command.id %> -- chat "Hello, how are you?"`},{description:`Start Codex in specific directory`,command:`<%= config.bin %> <%= command.id %> -t codex -C /path/to/project`}];static flags={tool:r.string({description:`AI CLI tool to launch`,char:`t`,options:[`claude`,`codex`,`gemini`],default:`claude`}),yolo:r.boolean({description:`Enable yolo mode (skip permission prompts)`,default:!0,allowNo:!0}),continue:r.boolean({description:`Continue last conversation/session`,char:`c`,exclusive:[`resume`]}),resume:r.boolean({description:`Resume from conversation/session list`,char:`r`,exclusive:[`continue`]}),cwd:r.string({description:`Working directory for the launched process`,char:`C`}),settings:r.string({description:`Settings configuration (Claude: variant name or file path; Codex: profile name; Gemini: model name)`,char:`s`})};static strict=!1;async run(){let{flags:n,argv:r}=await this.parse(i),a=e(r);try{let e=await new t().execute({tool:n.tool,yolo:n.yolo,continue:n.continue,resume:n.resume,cwd:n.cwd,settings:n.settings,args:a});e.success?(this.log(e.message??`Launched successfully`),e.command&&n.yolo&&this.log(`\nCommand: ${e.command}`)):this.error(e.message??`Launch failed`,{exit:1})}catch(e){this.error(e.message,{exit:1})}}};export{i as default};
32
+ `;static examples=[{description:`Start Claude Code instantly (default)`,command:`<%= config.bin %> <%= command.id %>`},{description:`Continue last conversation`,command:`<%= config.bin %> <%= command.id %> -c`},{description:`Resume a conversation from list`,command:`<%= config.bin %> <%= command.id %> -r`},{description:`Start Claude with hxi settings variant`,command:`<%= config.bin %> <%= command.id %> -s hxi`},{description:`Continue last Codex session`,command:`<%= config.bin %> <%= command.id %> -t codex -c`},{description:`Start Codex with oss profile`,command:`<%= config.bin %> <%= command.id %> -t codex -s oss`},{description:`Start Gemini CLI (auto-accept actions)`,command:`<%= config.bin %> <%= command.id %> -t gemini`},{description:`Resume latest Gemini session`,command:`<%= config.bin %> <%= command.id %> -t gemini -c`},{description:`Start Claude without yolo mode`,command:`<%= config.bin %> <%= command.id %> --no-yolo`},{description:`Start Claude and pass arguments`,command:`<%= config.bin %> <%= command.id %> -- chat "Hello, how are you?"`},{description:`Start Codex in specific directory`,command:`<%= config.bin %> <%= command.id %> -t codex -C /path/to/project`}];static flags={tool:n.string({description:`AI CLI tool to launch`,char:`t`,options:[`claude`,`codex`,`gemini`],default:`claude`}),yolo:n.boolean({description:`Enable yolo mode (skip permission prompts)`,default:!0,allowNo:!0}),continue:n.boolean({description:`Continue last conversation/session`,char:`c`,exclusive:[`resume`]}),resume:n.boolean({description:`Resume from conversation/session list`,char:`r`,exclusive:[`continue`]}),cwd:n.string({description:`Working directory for the launched process`,char:`C`}),settings:n.string({description:`Settings configuration (Claude: variant name or file path; Codex: profile name; Gemini: model name)`,char:`s`})};static strict=!1;async run(){let{flags:t,argv:n}=await this.parse(r),i=n;try{let n=await new e().execute({tool:t.tool,yolo:t.yolo,continue:t.continue,resume:t.resume,cwd:t.cwd,settings:t.settings,args:i});n.success?(this.log(n.message??`Launched successfully`),n.command&&t.yolo&&this.log(`\nCommand: ${n.command}`)):this.error(n.message??`Launch failed`,{exit:1})}catch(e){this.error(e.message,{exit:1})}}};export{r as default};
@@ -1 +1 @@
1
- import{h as e,l as t,m as n}from"./errors-x3Es7YJ3.js";import{t as r}from"./xling-DxPgM9hF.js";import{t as i}from"./codex-CLx2Yb0G.js";import{t as a}from"./claude-CWDwrH2t.js";import{t as o}from"./gemini-2eTblTJ_.js";var s=class{#e;constructor(){this.#e=new Map,this.#e.set(`claude`,new a),this.#e.set(`codex`,new i),this.#e.set(`gemini`,new o),this.#e.set(`xling`,new r)}async execute(e){let r=this.#t(e.tool);switch(e.action){case`list`:return{success:!0,data:await r.list(e.scope)};case`switch-profile`:if(!e.profile)throw new t(`Profile is required for switch-profile action`);if(!r.switchProfile)throw new n(`switch-profile`,e.tool);return await r.switchProfile(e.scope,e.profile,e.switchOptions);case`edit`:if(!r.edit)throw new n(`edit`,e.tool);return await r.edit(e.scope,{name:e.name,ide:e.ide,provider:e.provider});case`inspect`:if(!r.inspect)throw new n(`inspect`,e.tool);return{success:!0,data:await r.inspect(e.scope,e.name)};default:throw new n(e.action)}}#t(t){let n=this.#e.get(t);if(!n)throw new e(t);return n}registerAdapter(e){this.#e.set(e.toolId,e)}getSupportedTools(){return Array.from(this.#e.keys())}};export{s as t};
1
+ import{h as e,l as t,m as n}from"./errors-x3Es7YJ3.js";import{t as r}from"./xling-DxPgM9hF.js";import{t as i}from"./codex-Kk3Sv7uC.js";import{t as a}from"./claude-BqDhM0_U.js";import{t as o}from"./gemini-2eTblTJ_.js";var s=class{#e;constructor(){this.#e=new Map,this.#e.set(`claude`,new a),this.#e.set(`codex`,new i),this.#e.set(`gemini`,new o),this.#e.set(`xling`,new r)}async execute(e){let r=this.#t(e.tool);switch(e.action){case`list`:return{success:!0,data:await r.list(e.scope)};case`switch-profile`:if(!e.profile)throw new t(`Profile is required for switch-profile action`);if(!r.switchProfile)throw new n(`switch-profile`,e.tool);return await r.switchProfile(e.scope,e.profile,e.switchOptions);case`edit`:if(!r.edit)throw new n(`edit`,e.tool);return await r.edit(e.scope,{name:e.name,ide:e.ide,provider:e.provider});case`inspect`:if(!r.inspect)throw new n(`inspect`,e.tool);return{success:!0,data:await r.inspect(e.scope,e.name)};default:throw new n(e.action)}}#t(t){let n=this.#e.get(t);if(!n)throw new e(t);return n}registerAdapter(e){this.#e.set(e.toolId,e)}getSupportedTools(){return Array.from(this.#e.keys())}};export{s as t};
@@ -30,6 +30,11 @@ declare class ClaudeAdapter extends BaseAdapter {
30
30
  */
31
31
  switchProfile(scope: Scope, profile: string, options?: SwitchOptions): Promise<SettingsResult>;
32
32
  edit(scope: Scope, options: EditOptions): Promise<SettingsResult>;
33
+ /**
34
+ * Find which variant matches the current settings.json by comparing content
35
+ * Returns the variant name if found, null otherwise
36
+ */
37
+ getCurrentVariant(scope: Scope): string | null;
33
38
  }
34
39
  //#endregion
35
40
  export { ClaudeAdapter };
@@ -1 +1 @@
1
- import"../../../errors-x3Es7YJ3.js";import"../../../editor-DUx1Sby2.js";import"../../../format-CZL0rRQR.js";import"../../../fsStore-D1omjK0d.js";import"../../../base-Dv8Ajp1w.js";import"../../../claudeDefault-BP2oPKZC.js";import{t as e}from"../../../claude-CWDwrH2t.js";export{e as ClaudeAdapter};
1
+ import"../../../errors-x3Es7YJ3.js";import"../../../editor-DUx1Sby2.js";import"../../../format-CZL0rRQR.js";import"../../../fsStore-D1omjK0d.js";import"../../../base-Dv8Ajp1w.js";import"../../../claudeDefault-BP2oPKZC.js";import{t as e}from"../../../claude-BqDhM0_U.js";export{e as ClaudeAdapter};
@@ -1 +1 @@
1
- import"../../../errors-x3Es7YJ3.js";import"../../../editor-DUx1Sby2.js";import"../../../fsStore-D1omjK0d.js";import"../../../base-Dv8Ajp1w.js";import{n as e,t}from"../../../codex-CLx2Yb0G.js";export{t as CodexAdapter,e as isConfigObject};
1
+ import"../../../errors-x3Es7YJ3.js";import"../../../editor-DUx1Sby2.js";import"../../../fsStore-D1omjK0d.js";import"../../../base-Dv8Ajp1w.js";import{n as e,t}from"../../../codex-Kk3Sv7uC.js";export{t as CodexAdapter,e as isConfigObject};
@@ -1 +1 @@
1
- import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import"../../format-CZL0rRQR.js";import"../../config-D0b5Ceh4.js";import"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import"../../template-DtJFiC8I.js";import"../../xling-DxPgM9hF.js";import"../../codex-CLx2Yb0G.js";import"../../claudeDefault-BP2oPKZC.js";import"../../claude-CWDwrH2t.js";import"../../gemini-2eTblTJ_.js";import{t as e}from"../../dispatcher-Bc9KhwR1.js";export{e as SettingsDispatcher};
1
+ import"../../errors-x3Es7YJ3.js";import"../../editor-DUx1Sby2.js";import"../../format-CZL0rRQR.js";import"../../config-D0b5Ceh4.js";import"../../fsStore-D1omjK0d.js";import"../../base-Dv8Ajp1w.js";import"../../template-DtJFiC8I.js";import"../../xling-DxPgM9hF.js";import"../../codex-Kk3Sv7uC.js";import"../../claudeDefault-BP2oPKZC.js";import"../../claude-BqDhM0_U.js";import"../../gemini-2eTblTJ_.js";import{t as e}from"../../dispatcher-DOZzJY8q.js";export{e as SettingsDispatcher};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xling",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Unified CLI for AI tools: settings management, API proxy with load balancing, multi-model discussions",
5
5
  "homepage": "https://github.com/kingsword09/xling/tree/main#readme",
6
6
  "bugs": {
@@ -1 +0,0 @@
1
- import{t as e}from"./errors-x3Es7YJ3.js";import{n as t,t as n}from"./editor-DUx1Sby2.js";import{a as r,c as i,d as a,f as o,g as s,l as c,m as l,o as u,p as d,r as f,t as p}from"./fsStore-D1omjK0d.js";import{t as m}from"./base-Dv8Ajp1w.js";import*as h from"node:path";const g=`~/.codex/auth-profiles`,_=`~/.codex/auth.json`;var v=class extends m{toolId=`codex`;async list(e){let t=this.validateAndResolvePath(e),n=this.readConfig(t),r=this.#c(n),i=this.listAuthProfiles(),a=u(_),o=typeof n.current_auth_profile==`string`?n.current_auth_profile:a||i.length>0?this.#d():null;return{type:`entries`,entries:{current_provider:typeof n.model_provider==`string`?n.model_provider:null,current_profile:typeof n.current_profile==`string`?n.current_profile:null,current_auth_profile:o,providers:r,auth_profiles:i},filePath:t}}async inspect(e,t){let n=this.validateAndResolvePath(e),r=l(n),a=u(n),o=a?this.#s(n):{},s=a?i(n):null,c=t?.trim();if(c){if(this.isAuthProfile(c)){let e=`${g}/${c}.json`,t=this.#u(e),n=i(e);return{path:l(e),exists:u(e),content:JSON.stringify({mode:`auth`,authProfile:c,authFile:l(e),configFile:r,authData:t},null,2),size:n?.size,lastModified:n?.lastModified}}let e=y(o.model_providers)?o.model_providers:{};if(e[c])return{path:r,exists:a,content:JSON.stringify({mode:`provider`,currentProvider:c,config:e[c]??{}},null,2),size:s?.size,lastModified:s?.lastModified};let t=y(o.profiles)?o.profiles:{};return t[c]?{path:r,exists:a,content:JSON.stringify({mode:`profile`,currentProfile:c,config:t[c]??{}},null,2),size:s?.size,lastModified:s?.lastModified}:{path:r,exists:a,content:JSON.stringify({mode:`not_found`,requested:c,availableProviders:Object.keys(e),availableProfiles:Object.keys(t),availableAuthProfiles:this.listAuthProfiles()},null,2),size:s?.size,lastModified:s?.lastModified}}if(!a)return this.#e(r);if(o.current_profile&&typeof o.current_profile==`string`)return this.#t(o,r,s);if(o.model_provider&&typeof o.model_provider==`string`)return this.#n(o,r,s);let d=typeof o.current_auth_profile==`string`?o.current_auth_profile:null;return d||u(_)?this.#r(d,r,s):this.#i(r,s)}#e(e){if(u(_)){let e=this.#l(),t=this.#d();return{path:l(_),exists:!0,content:JSON.stringify({mode:`auth`,currentAuthProfile:t,authFile:l(_),authData:e},null,2)}}return{path:e,exists:!1}}#t(e,t,n){let r=e.current_profile,i=(y(e.profiles)?e.profiles:{})[r];return{path:t,exists:!0,content:JSON.stringify({mode:`profile`,currentProfile:r,config:y(i)?i:{}},null,2),size:n?.size,lastModified:n?.lastModified}}#n(e,t,n){let r=e.model_provider,i=(y(e.model_providers)?e.model_providers:{})[r];return{path:t,exists:!0,content:JSON.stringify({mode:`provider`,currentProvider:r,config:y(i)?i:{}},null,2),size:n?.size,lastModified:n?.lastModified}}#r(e,t,n){let r=this.#l(),i=e||this.#d();return{path:l(_),exists:!0,content:JSON.stringify({mode:`auth`,currentAuthProfile:i,authFile:l(_),configFile:t,authData:r},null,2),size:n?.size,lastModified:n?.lastModified}}#i(e,t){return{path:e,exists:!0,content:JSON.stringify({mode:`none`,message:`No active provider or auth configured. Run 'codex login' or configure a model_provider.`,configFile:e},null,2),size:t?.size,lastModified:t?.lastModified}}resolvePath(e){switch(e){case`user`:return`~/.codex/config.toml`;default:throw Error(`Unsupported scope for Codex: ${e}`)}}validateScope(e){return e===`user`}async switchProfile(e,t,n){return this.validateAndResolvePath(e),this.isAuthProfile(t)?this.#a(t):this.#o(e,t)}async edit(e,i){let a=this.validateAndResolvePath(e);if(!i.provider){let e=l(a);r(h.dirname(e)),u(a)||this.writeConfig(a,{});let o=t(i.ide);return await n(o,e),{success:!0,message:`Opened Codex config in ${o}`,filePath:e}}let o=i.provider.id?.trim()||i.provider.name?.trim();if(!o)throw Error(`Provider name cannot be empty`);let s=i.provider.base_url?.trim();if(!s)throw Error(`Base URL is required for Codex providers`);let c=i.provider.name?.trim()||o,d=i.provider.experimental_bearer_token?.trim();if(!d)throw Error(`Experimental bearer token is required for Codex providers`);let f=this.#s(a),p=y(f.model_providers)?{...f.model_providers}:{};p[o]={name:c,base_url:s,wire_api:`responses`,experimental_bearer_token:d};let m={...f,model_providers:p};return this.writeConfig(a,m),{success:!0,message:`Added model_providers.${o}`,filePath:l(a),data:p[o]}}listAuthProfiles(){return c(g).filter(e=>e.endsWith(`.json`)).map(e=>e.replace(`.json`,``))}isAuthProfile(e){return u(`${g}/${e}.json`)}saveAuthProfile(e,t=!1){let n=`${g}/${e}.json`;return u(_)?!t&&u(n)?{success:!1,message:`Profile "${e}" already exists. Use --force to overwrite.`}:(r(g),p(_,n),f(_),{success:!0,message:`Saved current auth as profile: ${e}\nauth.json has been removed. You can now login with another account.`,filePath:l(n)}):{success:!1,message:`No auth.json found. Please run 'codex login' first.`}}deleteAuthProfile(e){let t=`${g}/${e}.json`;return u(t)?(f(t),{success:!0,message:`Deleted auth profile: ${e}`}):{success:!1,message:`Auth profile "${e}" not found.`}}getAllSwitchableProfiles(e){let t=this.resolvePath(e),n=[];try{let e=this.readConfig(t),r=e.model_providers;y(r)&&(n=Object.keys(r));let i=e.profiles;y(i)&&(n=[...new Set([...n,...Object.keys(i)])])}catch{}let r=this.listAuthProfiles();return{providers:n,authProfiles:r}}#a(e){let t=`${g}/${e}.json`,n=`~/.codex/config.toml`;if(!u(t))return{success:!1,message:`Auth profile "${e}" not found.`};p(t,_);try{let t=this.#s(n);delete t.model_provider,delete t.current_profile,t.current_auth_profile=e,this.writeConfig(n,t)}catch{this.writeConfig(n,{current_auth_profile:e})}return{success:!0,message:`Switched to auth profile: ${e}`,filePath:l(_)}}#o(e,t){let n=this.resolvePath(e);u(_)&&f(_);let r=this.#s(n);delete r.current_auth_profile;let i=r.profiles,a=(y(i)?i:void 0)?.[t];if(y(a)){let e={...r};for(let[t,n]of Object.entries(a))e[t]=n;return e.current_profile=t,delete e.model_provider,this.writeConfig(n,e),{success:!0,message:`Switched to profile: ${t}`,filePath:l(n)}}delete r.current_profile;let o={...r,model_provider:t};return this.writeConfig(n,o),{success:!0,message:`Switched to provider: ${t}`,filePath:l(n)}}readConfig(e){return d(e)}writeConfig(e,t){s(e,t,!1)}#s(t){try{return this.readConfig(t)}catch(t){if(t instanceof e)return{};throw t}}#c(e){let t=e.model_providers;return y(t)?t:{}}#l(){if(!u(_))return null;try{return o(_)}catch{return null}}#u(e){if(!u(e))return null;try{return o(e)}catch{return null}}#d(){if(!u(_))return`default`;let e;try{e=a(_)}catch{return`default`}let t=this.listAuthProfiles();for(let n of t){let t=`${g}/${n}.json`;try{let r=a(t);if(e===r)return n}catch{continue}}return`default`}};const y=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date);export{y as n,v as t};