@@ -109,9 +109,7 @@ import { resolveProfile } from "./profiles.js";
109109
110110// Per-call token ceiling for inference sources, shared by agent creation
111111// (runner.ts) and live provider switching (the /agent modal) so a live switch
112- // cannot silently revert it. CL-10672 review: kept as the shared fallback —
113- // it is NOT an always-overridden default; ProviderSettings.maxTokens is the
114- // optional override and an unset value resolves to this ceiling.
112+ // cannot silently revert it.
115113export const SOURCE_MAX_TOKENS = 16384 ;
116114
117115// Credential-cell placeholder for keyless local providers (e.g. Ollama). The
@@ -162,9 +160,8 @@ function applyPersistedOAuthDefaults(
162160
163161// OAuth entries in settings.json carry no credentials; they work only while a
164162// matching auth-store profile exists. Drop orphans in memory so a removed
165- // profile does not pin resolution to an unauthenticatable provider. Called
166- // only from applyOAuthProviderProjections (plus its tests).
167- function dropOrphanedOAuthEntries (
163+ // profile does not pin resolution to an unauthenticatable provider.
164+ export function dropOrphanedOAuthEntries (
168165 settings : Settings | null ,
169166 projected : Record < string , ProviderSettings > ,
170167) : Settings | null {
@@ -200,8 +197,8 @@ function isHandNamedProviderEntry(
200197}
201198
202199// Overlay live OAuth profile projections onto settings for runtime provider
203- // resolution. Called only from applyOAuthProviderProjections (plus its tests) .
204- function overlayOAuthProjections (
200+ // resolution. Exported for tests; loadConfig is the only production caller .
201+ export function overlayOAuthProjections (
205202 settings : Settings | null ,
206203 projected : Record < string , ProviderSettings > ,
207204) : Settings | null {
@@ -216,28 +213,6 @@ function overlayOAuthProjections(
216213 } ;
217214}
218215
219- // The one ordered OAuth projection chain for runtime provider resolution,
220- // folding the three dedicated helpers at the layer that owns them
221- // (loadConfig): (1) persisted defaultModel defaults merge into the live
222- // projections, (2) credential-less orphan entries are dropped from settings
223- // (only when the projections came from the home auth stores), (3) the
224- // projections overlay onto the surviving settings without overwriting
225- // hand-named API-key rows. Exposed for tests.
226- export function applyOAuthProviderProjections (
227- settings : Settings | null ,
228- projectedProviderSettings : Record < string , ProviderSettings > ,
229- options : { dropOrphans : boolean } ,
230- ) : Settings | null {
231- const projected = applyPersistedOAuthDefaults (
232- settings ,
233- projectedProviderSettings ,
234- ) ;
235- const liveSettings = options . dropOrphans
236- ? dropOrphanedOAuthEntries ( settings , projected )
237- : settings ;
238- return overlayOAuthProjections ( liveSettings , projected ) ;
239- }
240-
241216function hasExaEntry ( servers : MCPServerSettingsEntry [ ] | undefined ) : boolean {
242217 return (
243218 servers ?. some ( ( server ) => server . name === EXA_MCP_SERVER_NAME ) === true
@@ -730,15 +705,6 @@ export interface UnconfiguredConfig {
730705 settingsDiagnostics ?: SettingsLoadDiagnostic [ ] ;
731706}
732707
733- // Skip-permissions spellings. `--dangerously-skip-permissions` is the
734- // canonical process-only flag; `--yolo` is a kept alias (`/yolo` is the
735- // persistent settings writer — a separate surface). One flag, one setting
736- // (`dangerouslySkipPermissions`); the parse consults one alias set.
737- const SKIP_PERMISSIONS_FLAGS : ReadonlySet < string > = new Set ( [
738- "--dangerously-skip-permissions" ,
739- "--yolo" ,
740- ] ) ;
741-
742708/** Printed for `corbits --help` / `-h`. Keep in sync with docs/IMPLEMENTATION.md. */
743709export const CLI_HELP_TEXT = `corbits — coding agent CLI
744710
@@ -867,9 +833,6 @@ export async function loadConfig(
867833 let resumeMode : "id" | "pick" | undefined ;
868834 let resumeSessionId : string | undefined ;
869835 const leading = args [ 0 ] ;
870- // One exec verb: `exec` is canonical; `run` is a kept alias (help names
871- // both). One resume verb: `resume` is canonical; `continue` is a kept
872- // alias of the same flow.
873836 if ( leading === "exec" || leading === "run" ) {
874837 command = "exec" ;
875838 args . shift ( ) ;
@@ -878,8 +841,6 @@ export async function loadConfig(
878841 // Bare resume opens the list; a session id is the only direct-resume path.
879842 // Invalid non-flag positionals error instead of falling through (a
880843 // free-form token would otherwise become task while skipInitialTask is set).
881- // A following --pick/--list falls through to the loop's single resume
882- // branch, where it is a kept alias of the bare --resume picker flow.
883844 const next = args . slice ( ) [ 0 ] ;
884845 if ( next !== undefined && ! isFlagToken ( next ) ) {
885846 if ( ! isSessionId ( next ) ) {
@@ -895,10 +856,9 @@ export async function loadConfig(
895856 }
896857 }
897858
898- // `-p` is the exec one-shot alias in any position (`-p --provider …`,
859+ // `-p` is the exec one-shot path in any position (`-p --provider …`,
899860 // `--model … -p …`). Detect it before value flags so exec-only options
900- // that appear before `-p` still see exec mode; the loop keeps the token
901- // out of the task positionals.
861+ // that appear before `-p` still see exec mode.
902862 if ( args . includes ( "-p" ) ) {
903863 if ( leading === "resume" || leading === "continue" ) {
904864 throw new Error (
@@ -970,13 +930,11 @@ export async function loadConfig(
970930 continue ;
971931 }
972932
973- if ( SKIP_PERMISSIONS_FLAGS . has ( arg ) ) {
933+ if ( arg === "--dangerously-skip-permissions" || arg === "--yolo" ) {
974934 dangerouslySkipPermissions = true ;
975935 continue ;
976936 }
977937 if ( arg === "--auto" ) {
978- // Explicit re-assertion of the on-by-default auto mode. Kept because
979- // sequence order still matters (`--no-auto --auto` re-enables).
980938 auto = true ;
981939 continue ;
982940 }
@@ -985,15 +943,9 @@ export async function loadConfig(
985943 continue ;
986944 }
987945 if ( arg === "-p" ) {
988- // `-p` alias of exec: the pre-scan already fixed command="exec"; the
989- // token must stay out of the task positionals.
990946 continue ;
991947 }
992948 if ( arg === "--resume" || arg === "--pick" || arg === "--list" ) {
993- // One resume verb: `--resume` carries the optional session id (exec
994- // requires it; interactive bare `--resume` opens the picker, the alias
995- // for `resume <session-id>`). `--pick`/`--list` are kept aliases of that
996- // bare picker flow and may not follow a session id.
997949 if ( arg === "--resume" ) {
998950 if ( resumeMode === "id" ) {
999951 throw new Error ( "cannot combine a session id with --resume" ) ;
@@ -1020,8 +972,6 @@ export async function loadConfig(
1020972 } else if ( resumeMode !== undefined ) {
1021973 resumeMode = "pick" ;
1022974 } else {
1023- // Without the resume verb these spellings are not in flow; preserve
1024- // the previous fallthrough as an unrecognized flag.
1025975 throw new Error ( `unrecognized flag: ${ arg } ` ) ;
1026976 }
1027977 continue ;
@@ -1059,7 +1009,7 @@ export async function loadConfig(
10591009 useOAuthProfiles
10601010 ? await Promise . all ( [ listCodexProfiles ( ) , listXaiProfiles ( ) ] )
10611011 : [ [ ] , [ ] ] ;
1062- const projectedOAuthProviders = {
1012+ let projectedOAuthProviders = {
10631013 ...codexProvidersAsSettings ( codexProfiles ) ,
10641014 ...xaiProvidersAsSettings ( xaiProfiles ) ,
10651015 } ;
@@ -1089,11 +1039,16 @@ export async function loadConfig(
10891039 settings ?. dangerouslySkipPermissions === true ;
10901040 dangerouslySkipPermissions =
10911041 dangerouslySkipPermissions || settings ?. dangerouslySkipPermissions === true ;
1092- // Single ordered projection chain (see applyOAuthProviderProjections).
1093- const settingsForResolution : Settings | null = applyOAuthProviderProjections (
1042+ projectedOAuthProviders = applyPersistedOAuthDefaults (
10941043 settings ,
10951044 projectedOAuthProviders ,
1096- { dropOrphans : useOAuthProfiles } ,
1045+ ) ;
1046+ const liveSettings = useOAuthProfiles
1047+ ? dropOrphanedOAuthEntries ( settings , projectedOAuthProviders )
1048+ : settings ;
1049+ const settingsForResolution : Settings | null = overlayOAuthProjections (
1050+ liveSettings ,
1051+ projectedOAuthProviders ,
10971052 ) ;
10981053
10991054 // The per-repo selection file still applies on top of --config: that file
0 commit comments