codex-configurator 0.2.4 → 0.2.6

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,53 +1,29 @@
1
1
  import React from 'react';
2
2
  import { Text, Box } from 'ink';
3
3
 
4
- const WORDMARK = [
5
- ' ██████╗ ██████╗ ██████╗ ███████╗██╗ ██╗ ██████╗ ██████╗ ███╗ ██╗███████╗██╗ ██████╗ ██╗ ██╗██████╗ █████╗ ████████╗ ██████╗ ██████╗ ',
6
- '██╔════╝██╔═══██╗██╔══██╗██╔════╝╚██╗██╔╝ ██╔════╝██╔═══██╗████╗ ██║██╔════╝██║██╔════╝ ██║ ██║██╔══██╗██╔══██╗╚══██╔══╝██╔═══██╗██╔══██╗',
7
- '██║ ██║ ██║██║ ██║█████╗ ╚███╔╝ ██║ ██║ ██║██╔██╗ ██║█████╗ ██║██║ ███╗██║ ██║██████╔╝███████║ ██║ ██║ ██║██████╔╝',
8
- '██║ ██║ ██║██║ ██║██╔══╝ ██╔██╗ ██║ ██║ ██║██║╚██╗██║██╔══╝ ██║██║ ██║██║ ██║██╔══██╗██╔══██║ ██║ ██║ ██║██╔══██╗',
9
- '╚██████╗╚██████╔╝██████╔╝███████╗██╔╝ ██╗ ╚██████╗╚██████╔╝██║ ╚████║██║ ██║╚██████╔╝╚██████╔╝██║ ██║██║ ██║ ██║ ╚██████╔╝██║ ██║',
10
- ' ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝',
11
- ];
12
-
13
- export const Header = ({ codexVersion, codexVersionStatus, packageVersion }) =>
14
- React.createElement(
15
- Box,
16
- {
17
- flexDirection: 'column',
18
- paddingX: 1,
19
- marginBottom: 1,
20
- },
21
- React.createElement(
22
- Box,
23
- { flexDirection: 'row', marginBottom: 1, gap: 0, alignItems: 'flex-end' },
24
- React.createElement(
25
- Box,
26
- { flexDirection: 'column' },
27
- ...WORDMARK.map((line, index) =>
28
- React.createElement(Text, { color: 'magentaBright', bold: true, key: `word-${index}` }, line)
29
- )
30
- ),
31
- React.createElement(
32
- Box,
33
- { marginLeft: 1 },
34
- React.createElement(Text, { color: 'gray', bold: true }, `v${packageVersion || 'unknown'}`)
35
- )
36
- ),
37
- React.createElement(
38
- Box,
39
- { flexDirection: 'row' },
40
- React.createElement(Text, { color: 'gray' }, `Codex ${codexVersion}`),
41
- codexVersionStatus
42
- ? codexVersionStatus === 'up to date'
43
- ? React.createElement(
44
- React.Fragment,
45
- null,
46
- React.createElement(Text, { color: 'gray' }, ' ('),
47
- React.createElement(Text, { color: 'green' }, '✓'),
48
- React.createElement(Text, { color: 'gray' }, ` ${codexVersionStatus})`)
49
- )
50
- : React.createElement(Text, { color: 'gray' }, ` (${codexVersionStatus})`)
51
- : null
52
- )
53
- );
4
+ export const Header = ({ packageVersion }) =>
5
+ React.createElement(
6
+ Box,
7
+ {
8
+ flexDirection: 'row',
9
+ paddingX: 1,
10
+ paddingY: 0,
11
+ justifyContent: 'space-between',
12
+ backgroundColor: 'magenta',
13
+ marginBottom: 0,
14
+ },
15
+ React.createElement(
16
+ Box,
17
+ { gap: 1 },
18
+ React.createElement(
19
+ Text,
20
+ { color: 'white', bold: true },
21
+ ' CODEX CONFIGURATOR',
22
+ ),
23
+ React.createElement(
24
+ Text,
25
+ { color: 'white', dimColor: false },
26
+ `v${packageVersion || 'unknown'}`,
27
+ ),
28
+ ),
29
+ );
@@ -1,4 +1,7 @@
1
- import { getReferenceFeatureKeys } from './configReference.js';
1
+ import {
2
+ getReferenceFeatureKeys,
3
+ getReferenceOptionForPath,
4
+ } from './configReference.js';
2
5
 
3
6
  const prettifyFeatureName = (key) =>
4
7
  key
@@ -6,189 +9,50 @@ const prettifyFeatureName = (key) =>
6
9
  .map((segment) => `${segment[0]?.toUpperCase() || ''}${segment.slice(1)}`)
7
10
  .join(' ');
8
11
 
9
- const makeFeatureDefinition = (
10
- key,
11
- short,
12
- usage = 'Uses the feature flag value in your config.',
13
- options = {}
14
- ) => {
15
- const deprecation = options?.deprecation;
16
- const defaultValue = typeof options?.defaultValue === 'boolean' ? options.defaultValue : false;
17
- const isDocumented = options?.isDocumented === true;
12
+ const buildFeatureDefinitionFromReference = (key) => {
13
+ const normalizedKey = String(key || '').trim();
14
+ if (!normalizedKey) {
15
+ return null;
16
+ }
17
+
18
+ const referenceEntry = getReferenceOptionForPath(['features', normalizedKey]);
19
+ if (!referenceEntry) {
20
+ return null;
21
+ }
22
+
23
+ const description = String(referenceEntry.description || '').trim();
24
+ const defaultValue = typeof referenceEntry.defaultValue === 'boolean'
25
+ ? referenceEntry.defaultValue
26
+ : null;
18
27
 
19
28
  return {
20
- key,
21
- short,
22
- usage: deprecation ? `[!] ${deprecation}` : usage,
23
- deprecation,
29
+ key: normalizedKey,
30
+ short: description || 'Official configuration option.',
31
+ usage: null,
32
+ deprecation: referenceEntry.deprecated === true ? 'Deprecated configuration option.' : null,
24
33
  defaultValue,
25
- isDocumented,
34
+ isDocumented: true,
26
35
  };
27
36
  };
28
37
 
29
- export const CONFIG_FEATURE_DEFINITIONS = [
30
- makeFeatureDefinition(
31
- 'apply_patch_freeform',
32
- 'Enable freeform apply_patch style for code edits.',
33
- 'When enabled, patch edits can use larger freeform blocks.',
34
- { isDocumented: true }
35
- ),
36
- makeFeatureDefinition(
37
- 'apps',
38
- 'Enable built-in app/connector features.',
39
- 'Toggle access to app integrations used by Codex.',
40
- { isDocumented: true }
41
- ),
42
- makeFeatureDefinition(
43
- 'apps_mcp_gateway',
44
- 'Use the MCP app gateway.',
45
- 'Route app calls through the MCP gateway when available.',
46
- { isDocumented: true }
47
- ),
48
- makeFeatureDefinition(
49
- 'child_agents_md',
50
- 'Allow child-agent markdown workflows.',
51
- 'Enable loading child-agent instructions from markdown files.',
52
- { isDocumented: true }
53
- ),
54
- makeFeatureDefinition('codex_git_commit', 'Enable Codex-assisted git commit workflows.', 'Allows additional git-oriented agent workflows.'),
55
- makeFeatureDefinition(
56
- 'collab',
57
- 'Enable collaboration mode helpers.',
58
- 'Turn on multi-party collaboration flow features.',
59
- { deprecation: 'collab is deprecated; use [features].multi_agent instead.' }
60
- ),
61
- makeFeatureDefinition(
62
- 'collaboration_modes',
63
- 'Enable multiple collaboration modes.',
64
- 'Allow the assistant to switch between interaction modes.',
65
- { defaultValue: true, isDocumented: true }
66
- ),
67
- makeFeatureDefinition('connectors', 'Enable external connector support.', 'Controls optional third-party connector behavior.'),
68
- makeFeatureDefinition('enable_experimental_windows_sandbox', 'Enable experimental Windows sandbox.', 'Turns on experimental Windows sandbox behavior.'),
69
- makeFeatureDefinition('enable_request_compression', 'Enable request compression.', 'Compress request payloads for matching model endpoints.'),
70
- makeFeatureDefinition('experimental_use_freeform_apply_patch', 'Enable experimental freeform apply_patch usage.', 'Allows experimental patching behavior in edit flows.'),
71
- makeFeatureDefinition('experimental_use_unified_exec_tool', 'Enable experimental unified exec tool.', 'Use unified execution routing when invoking shell tools.'),
72
- makeFeatureDefinition('include_apply_patch_tool', 'Expose the apply_patch tool.', 'Makes apply patch tool calls available to the model.'),
73
- makeFeatureDefinition('js_repl', 'Enable JavaScript REPL.', 'Allow JavaScript-based REPL style tooling.'),
74
- makeFeatureDefinition('js_repl_tools_only', 'Restrict js_repl to tool-only mode.', 'Limits js_repl usage to explicit tool calls.'),
75
- makeFeatureDefinition('memory_tool', 'Enable memory tool support.', 'Allows Codex to use memory-related workflow tools.'),
76
- makeFeatureDefinition(
77
- 'multi_agent',
78
- 'Enable multi-agent support.',
79
- 'Allows multiple coordinated agent contexts.',
80
- { isDocumented: true }
81
- ),
82
- makeFeatureDefinition(
83
- 'personality',
84
- 'Enable personality controls.',
85
- 'Turns on personality-related routing flags.',
86
- { defaultValue: true, isDocumented: true }
87
- ),
88
- makeFeatureDefinition(
89
- 'powershell_utf8',
90
- 'Use UTF-8 in PowerShell sessions.',
91
- 'Keep PowerShell command output in UTF-8 encoding.',
92
- { defaultValue: true, isDocumented: true }
93
- ),
94
- makeFeatureDefinition('prevent_idle_sleep', 'Prevent idle sleep while running.', 'Keeps the system awake during active sessions.'),
95
- makeFeatureDefinition(
96
- 'remote_models',
97
- 'Enable remote model discovery.',
98
- 'Allows loading model lists from remote model providers.',
99
- { isDocumented: true }
100
- ),
101
- makeFeatureDefinition(
102
- 'request_rule',
103
- 'Enable request rule controls.',
104
- 'Turn on request routing/validation policy behavior.',
105
- { defaultValue: true, isDocumented: true }
106
- ),
107
- makeFeatureDefinition('responses_websockets', 'Enable Responses WebSocket transport.', 'Use websocket transport for Responses API calls.'),
108
- makeFeatureDefinition('responses_websockets_v2', 'Enable Responses WebSocket v2 transport.', 'Use the next-generation websocket transport stack.'),
109
- makeFeatureDefinition(
110
- 'runtime_metrics',
111
- 'Enable runtime metrics collection.',
112
- 'Record runtime metrics for analysis and telemetry.',
113
- { isDocumented: true }
114
- ),
115
- makeFeatureDefinition(
116
- 'search_tool',
117
- 'Enable internal search tool.',
118
- 'Turns on the built-in search execution tool.',
119
- { isDocumented: true }
120
- ),
121
- makeFeatureDefinition(
122
- 'shell_snapshot',
123
- 'Enable shell snapshots.',
124
- 'Capture shell environment state before runs.',
125
- { isDocumented: true }
126
- ),
127
- makeFeatureDefinition(
128
- 'shell_tool',
129
- 'Enable shell tool access.',
130
- 'Allows Codex to run shell commands through the tool interface.',
131
- { defaultValue: true, isDocumented: true }
132
- ),
133
- makeFeatureDefinition('shell_zsh_fork', 'Enable zsh forked shell tool.', 'Runs shell commands through a forked zsh process.'),
134
- makeFeatureDefinition('skill_env_var_dependency_prompt', 'Enable environment variable prompts for skills.', 'Prompts when skills require missing environment variables.'),
135
- makeFeatureDefinition('skill_mcp_dependency_install', 'Enable auto install MCP skill dependencies.', 'Installs missing MCP dependencies for skill execution.'),
136
- makeFeatureDefinition('sqlite', 'Enable SQLite support features.', 'Turns SQLite-specific feature behavior on or off.'),
137
- makeFeatureDefinition('steer', 'Enable steering control mode.', 'Allows steering the tool call strategy for some actions.'),
138
- makeFeatureDefinition('undo', 'Enable undo behavior.', 'Expose undo controls for reversible operations.'),
139
- makeFeatureDefinition(
140
- 'unified_exec',
141
- 'Use unified execution layer.',
142
- 'Route execution commands through the unified tool layer.',
143
- { isDocumented: true }
144
- ),
145
- makeFeatureDefinition(
146
- 'use_linux_sandbox_bwrap',
147
- 'Enable Linux bubblewrap sandbox.',
148
- 'Use bwrap for Linux sandbox isolation.',
149
- { isDocumented: true }
150
- ),
151
- makeFeatureDefinition(
152
- 'web_search',
153
- 'Enable web search tool.',
154
- 'Allows the model to call a web search tool.',
155
- { isDocumented: true }
156
- ),
157
- makeFeatureDefinition(
158
- 'web_search_cached',
159
- 'Enable cached web search only.',
160
- 'Restricts web search calls to cached results.',
161
- { isDocumented: true }
162
- ),
163
- makeFeatureDefinition(
164
- 'web_search_request',
165
- 'Enable web search request flow.',
166
- 'Turns on request-mode web search behavior.',
167
- { isDocumented: true }
168
- ),
169
- ];
170
-
171
- const FEATURE_DEFINITION_MAP = CONFIG_FEATURE_DEFINITIONS.reduce((acc, definition) => {
172
- acc[definition.key] = definition;
173
-
174
- return acc;
175
- }, {});
176
-
177
- const DOCUMENTED_REFERENCE_FEATURE_KEYS = getReferenceFeatureKeys();
38
+ const buildFeatureDefinitionMap = () =>
39
+ getReferenceFeatureKeys()
40
+ .map((key) => buildFeatureDefinitionFromReference(key))
41
+ .filter(Boolean)
42
+ .reduce((acc, definition) => {
43
+ acc[definition.key] = definition;
44
+ return acc;
45
+ }, {});
178
46
 
179
47
  export const getConfigFeatureKeys = () => {
180
- if (DOCUMENTED_REFERENCE_FEATURE_KEYS.length > 0) {
181
- return DOCUMENTED_REFERENCE_FEATURE_KEYS;
182
- }
183
-
184
- return CONFIG_FEATURE_DEFINITIONS
185
- .filter((definition) => definition.isDocumented === true)
186
- .map((definition) => definition.key);
48
+ return getReferenceFeatureKeys();
187
49
  };
188
50
 
189
- export const getConfigFeatureDefinition = (key) => FEATURE_DEFINITION_MAP[key];
51
+ export const getConfigFeatureDefinition = (key) =>
52
+ buildFeatureDefinitionMap()[String(key || '').trim()];
190
53
 
191
54
  export const getConfigFeatureDefinitionOrFallback = (key) => {
55
+ const normalizedKey = String(key || '').trim();
192
56
  if (!key) {
193
57
  return {
194
58
  short: `${prettifyFeatureName(String(key))}`,
@@ -199,9 +63,9 @@ export const getConfigFeatureDefinitionOrFallback = (key) => {
199
63
  }
200
64
 
201
65
  return (
202
- FEATURE_DEFINITION_MAP[key] || {
203
- key,
204
- short: prettifyFeatureName(String(key)),
66
+ getConfigFeatureDefinition(normalizedKey) || {
67
+ key: normalizedKey,
68
+ short: prettifyFeatureName(normalizedKey),
205
69
  usage: 'This configured key is not in the official feature list.',
206
70
  defaultValue: false,
207
71
  isDocumented: false,
package/src/configHelp.js CHANGED
@@ -1,77 +1,8 @@
1
- import {
2
- getConfigFeatureDefinition,
3
- getConfigFeatureDefinitionOrFallback,
4
- } from './configFeatures.js';
5
1
  import {
6
2
  getReferenceOptionForPath,
7
- getReferenceCustomIdPlaceholder,
8
- getReferenceDescendantOptions,
9
- getReferenceTableDefinitions,
3
+ getReferenceVariantForPath,
10
4
  } from './configReference.js';
11
5
 
12
- const CONFIG_VALUE_OPTIONS = {
13
- model: [
14
- 'gpt-5.3-codex',
15
- 'gpt-5.3-codex-spark',
16
- 'gpt-5.2-codex',
17
- 'gpt-5.1-codex-max',
18
- 'gpt-5.2',
19
- 'gpt-5.1-codex-mini',
20
- ],
21
- };
22
-
23
- const CONFIG_PATH_EXPLANATIONS = [
24
- {
25
- path: ['projects', '*', 'trust_level'],
26
- short: 'Controls how much trust this project gets for command execution.',
27
- usage: 'Use trusted for known folders, untrusted for extra prompts.',
28
- },
29
- ];
30
-
31
- const CONFIG_PATH_OPTIONS = [
32
- {
33
- path: ['projects', '*', 'trust_level'],
34
- values: ['trusted', 'untrusted'],
35
- explanations: {
36
- trusted: 'Runs with normal trust for this path.',
37
- untrusted: 'Limits risky actions and prompts more often.',
38
- },
39
- },
40
- ];
41
-
42
- const CONFIG_OPTION_EXPLANATIONS = {
43
- model: {
44
- 'gpt-5.3-codex': 'Latest frontier agentic coding model.',
45
- 'gpt-5.3-codex-spark': 'Ultra-fast coding model.',
46
- 'gpt-5.2-codex': 'Frontier agentic coding model.',
47
- 'gpt-5.1-codex-max': 'Codex-optimized flagship for deep and fast reasoning.',
48
- 'gpt-5.2': 'Latest frontier model with improvements across knowledge, reasoning and coding.',
49
- 'gpt-5.1-codex-mini': 'Optimized for codex. Cheaper, faster, but less capable.',
50
- },
51
- trust_level: {
52
- trusted: 'Runs with normal trust for this path.',
53
- untrusted: 'Limits risky actions and prompts more often.',
54
- },
55
- };
56
- const SECTION_PURPOSE_OVERRIDES = {
57
- agents: 'Named agent definitions and per-agent configuration file references.',
58
- apps: 'Per-app enablement rules and tool-level approval controls.',
59
- features: 'Feature flags for optional and experimental Codex behavior.',
60
- feedback: 'Feedback submission settings for Codex surfaces.',
61
- history: 'Session history retention policy and on-disk size limits.',
62
- mcp_servers: 'MCP server definitions, transport settings, and authentication configuration.',
63
- model_providers: 'Model provider definitions, API endpoints, and credential settings.',
64
- notice: 'Visibility toggles for startup and migration notices.',
65
- otel: 'OpenTelemetry exporter configuration for telemetry and traces.',
66
- profiles: 'Named profile overrides you can select per session.',
67
- projects: 'Project/worktree trust settings scoped by filesystem path.',
68
- sandbox_workspace_write: 'Workspace-write sandbox behavior, writable roots, and network access rules.',
69
- shell_environment_policy: 'Shell environment inheritance and variable override policy.',
70
- skills: 'Skill discovery and loading controls.',
71
- tools: 'Tool-related configuration, including legacy compatibility flags.',
72
- tui: 'Terminal UI behavior, notifications, and presentation settings.',
73
- };
74
-
75
6
  const makePathSegments = (segments, key) => {
76
7
  const normalizedSegments = Array.isArray(segments)
77
8
  ? segments.map((segment) => String(segment))
@@ -84,89 +15,9 @@ const makePathSegments = (segments, key) => {
84
15
  return [...normalizedSegments, String(key)];
85
16
  };
86
17
 
87
- const pathMatches = (actualPath, patternPath) =>
88
- actualPath.length === patternPath.length &&
89
- actualPath.every((segment, index) => patternPath[index] === '*' || patternPath[index] === segment);
90
-
91
- const getContextEntry = (segments, key, candidates) => {
92
- const fullPath = makePathSegments(segments, key);
93
- return candidates.find((entry) => pathMatches(fullPath, entry.path)) || null;
94
- };
95
-
96
18
  const getReferenceEntry = (segments, key) => getReferenceOptionForPath(makePathSegments(segments, key));
97
19
 
98
- const formatPlaceholderLabel = (placeholder) => {
99
- const cleaned = String(placeholder || '')
100
- .replace(/^</, '')
101
- .replace(/>$/, '');
102
-
103
- return cleaned || 'id';
104
- };
105
-
106
- const toFirstSentence = (text) => {
107
- const normalized = String(text || '').replace(/\s+/g, ' ').trim();
108
- if (!normalized) {
109
- return '';
110
- }
111
-
112
- const periodIndex = normalized.indexOf('. ');
113
- if (periodIndex < 0) {
114
- return normalized;
115
- }
116
-
117
- return normalized.slice(0, periodIndex + 1);
118
- };
119
-
120
- const getSectionPurposeDescription = (descendantOptions) => {
121
- for (const option of descendantOptions) {
122
- const firstSentence = toFirstSentence(option?.description);
123
- if (firstSentence) {
124
- return firstSentence;
125
- }
126
- }
127
-
128
- return '';
129
- };
130
-
131
- const buildInferredSectionHelp = (segments, key) => {
132
- const sectionPath = makePathSegments(segments, key);
133
- const childDefinitions = getReferenceTableDefinitions(sectionPath);
134
- const descendantOptions = getReferenceDescendantOptions(sectionPath);
135
- const customPlaceholder = getReferenceCustomIdPlaceholder(sectionPath);
136
- const parentCustomPlaceholder = getReferenceCustomIdPlaceholder(sectionPath.slice(0, -1));
137
-
138
- if (childDefinitions.length === 0 && descendantOptions.length === 0 && !customPlaceholder) {
139
- return null;
140
- }
141
-
142
- const rootOverride = sectionPath.length === 1
143
- ? SECTION_PURPOSE_OVERRIDES[sectionPath[0]]
144
- : null;
145
- const customLabel = customPlaceholder ? formatPlaceholderLabel(customPlaceholder) : '';
146
- const bestPurposeDescription = getSectionPurposeDescription(descendantOptions);
147
- const dynamicEntryLabel = parentCustomPlaceholder
148
- ? formatPlaceholderLabel(parentCustomPlaceholder)
149
- : '';
150
- const short = rootOverride
151
- || (dynamicEntryLabel
152
- ? `Configuration for this ${dynamicEntryLabel} entry.`
153
- : '')
154
- || bestPurposeDescription
155
- || (customLabel
156
- ? `Section for custom ${customLabel} entries.`
157
- : 'Section with related settings.');
158
-
159
- return {
160
- short,
161
- usage: null,
162
- };
163
- };
164
-
165
20
  const getReferenceUsage = (entry) => {
166
- if (entry.deprecated) {
167
- return 'This option is deprecated in the official configuration reference.';
168
- }
169
-
170
21
  if (entry.enumValues.length > 0) {
171
22
  return null;
172
23
  }
@@ -196,46 +47,25 @@ const buildReferenceHelp = (entry) => {
196
47
  }
197
48
 
198
49
  return {
199
- short: entry.description || 'Official configuration option.',
50
+ short: String(entry.description || '').trim() || null,
200
51
  usage: getReferenceUsage(entry),
201
- deprecation: entry.deprecated ? entry.description : undefined,
202
52
  };
203
53
  };
204
54
 
205
55
  export const getConfigHelp = (segments, key) => {
206
- const contextHelp = getContextEntry(segments, key, CONFIG_PATH_EXPLANATIONS);
207
- if (contextHelp) {
208
- return contextHelp;
209
- }
210
-
211
56
  const referenceEntry = getReferenceEntry(segments, key);
212
57
  const referenceHelp = buildReferenceHelp(referenceEntry);
213
58
 
214
- if (segments?.[segments.length - 1] === 'features') {
215
- const featureDefinition = getConfigFeatureDefinition(String(key));
216
- if (referenceHelp) {
217
- return {
218
- ...referenceHelp,
219
- usage: featureDefinition?.deprecation || referenceHelp.usage || featureDefinition?.usage || null,
220
- deprecation: featureDefinition?.deprecation || referenceHelp.deprecation,
221
- };
222
- }
223
-
224
- return getConfigFeatureDefinitionOrFallback(key);
225
- }
226
-
227
59
  if (referenceHelp) {
228
60
  return referenceHelp;
229
61
  }
230
62
 
231
- const inferredSectionHelp = buildInferredSectionHelp(segments, key);
232
- if (inferredSectionHelp) {
233
- return inferredSectionHelp;
234
- }
235
-
236
63
  return null;
237
64
  };
238
65
 
66
+ export const getConfigVariantMeta = (segments, key) =>
67
+ getReferenceVariantForPath(makePathSegments(segments, key));
68
+
239
69
  export const getConfigOptions = (segments, key, value, kind) => {
240
70
  if (kind !== 'value') {
241
71
  return null;
@@ -251,29 +81,21 @@ export const getConfigOptions = (segments, key, value, kind) => {
251
81
  return [false, true];
252
82
  }
253
83
 
254
- const context = getContextEntry(segments, key, CONFIG_PATH_OPTIONS);
255
- if (context) {
256
- return context.values;
257
- }
258
-
259
84
  if (referenceEntry?.enumValues?.length > 0) {
260
85
  return referenceEntry.enumValues;
261
86
  }
262
87
 
263
- if (Object.prototype.hasOwnProperty.call(CONFIG_VALUE_OPTIONS, key)) {
264
- return CONFIG_VALUE_OPTIONS[key];
265
- }
266
-
267
88
  return null;
268
89
  };
269
90
 
270
91
  export const getConfigOptionExplanation = (segments, key, option) => {
271
- const context = getContextEntry(segments, key, CONFIG_PATH_OPTIONS);
272
- if (context?.explanations) {
273
- return context.explanations[String(option)] || null;
92
+ const referenceEntry = getReferenceOptionForPath(makePathSegments(segments, key));
93
+ const enumDescription = referenceEntry?.enumOptionDescriptions?.[String(option)];
94
+ if (enumDescription) {
95
+ return enumDescription;
274
96
  }
275
97
 
276
- return CONFIG_OPTION_EXPLANATIONS[key]?.[String(option)] || null;
98
+ return null;
277
99
  };
278
100
 
279
101
  export const getConfigDefaultOption = (segments, key, kind, options) => {
@@ -282,58 +104,20 @@ export const getConfigDefaultOption = (segments, key, kind, options) => {
282
104
  }
283
105
 
284
106
  const fullPath = makePathSegments(segments, key);
285
- const pathKey = fullPath.join('.');
286
- const parentPath = fullPath.slice(0, -1);
287
- const explicitDefaults = {
288
- approval_policy: 'on-request',
289
- cli_auth_credentials_store: 'file',
290
- file_opener: 'vscode',
291
- 'history.persistence': 'save-all',
292
- mcp_oauth_credentials_store: 'auto',
293
- model_reasoning_summary: 'auto',
294
- model_verbosity: 'medium',
295
- personality: 'pragmatic',
296
- sandbox_mode: 'read-only',
297
- 'shell_environment_policy.inherit': 'all',
298
- 'tui.alternate_screen': 'auto',
299
- 'tui.notification_method': 'auto',
300
- };
301
-
302
- if (parentPath[parentPath.length - 1] === 'features') {
303
- const definition = getConfigFeatureDefinition(String(key));
304
- const featureDefault = definition?.defaultValue;
305
-
306
- if (typeof featureDefault === 'boolean') {
307
- return options.some((option) => Object.is(option, featureDefault))
308
- ? featureDefault
309
- : null;
310
- }
311
- }
312
-
313
- if (
314
- fullPath.length >= 3 &&
315
- fullPath[0] === 'projects' &&
316
- fullPath[fullPath.length - 1] === 'trust_level'
317
- ) {
318
- return options.some((option) => option === 'untrusted') ? 'untrusted' : null;
319
- }
320
-
321
- if (pathKey === 'web_search') {
322
- return options.some((option) => option === 'cached') ? 'cached' : null;
107
+ const referenceEntry = getReferenceOptionForPath(fullPath);
108
+ const schemaDefault = referenceEntry?.defaultValue;
109
+ if (schemaDefault === null || schemaDefault === undefined) {
110
+ return null;
323
111
  }
324
112
 
325
- if (
326
- fullPath.length >= 3 &&
327
- fullPath[0] === 'profiles' &&
328
- fullPath[fullPath.length - 1] === 'web_search'
329
- ) {
330
- return options.some((option) => option === 'cached') ? 'cached' : null;
113
+ if (options.some((option) => Object.is(option, schemaDefault))) {
114
+ return schemaDefault;
331
115
  }
332
116
 
333
- if (Object.prototype.hasOwnProperty.call(explicitDefaults, pathKey)) {
334
- const explicitDefault = explicitDefaults[pathKey];
335
- return options.some((option) => Object.is(option, explicitDefault))
336
- ? explicitDefault
117
+ if (typeof schemaDefault !== 'string') {
118
+ const schemaDefaultAsString = String(schemaDefault);
119
+ return options.some((option) => Object.is(option, schemaDefaultAsString))
120
+ ? schemaDefaultAsString
337
121
  : null;
338
122
  }
339
123