src/vs/platform/agentHost/node/codex/codexCustomizations.ts

153 LOC · 153 covered · 0 uncovered · 18 ranges · 31 concepts · 6 introducers · 19 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filecodexAgent.ts ×13 · 83 introduced LOCcodexAgent.ts ×13codexSessionConfigKeys.test|title=codexSessionConfigKeys resolveSessionConfig preserves legacy read-only permissions on restore|occurrence=1 · 0 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.test|title=codexSessionConfigKeys resolveSessionConfig exposes a single permissions-preset chip|occurrence=1 · 0 introduced LOCcodexSessionConfigKeys.t…codexAgent.ts ×1 · 27 introduced LOCcodexAgent.ts ×1codexAgent.ts ×24 · 89 introduced LOCcodexAgent.ts ×24codexSessionConfigKeys.ts ×1 · 7 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×1 · 2 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×7 · 49 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×1 · 11 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×1 · 2 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×2 · 4 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×3 · 18 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×3 · 19 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×2 · 3 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×2 · 2 introduced LOCcodexSessionConfigKeys.t…codexSessionConfigKeys.ts ×6 · 23 introduced LOCcodexSessionConfigKeys.t…codexAgent.ts ×1 · 2 introduced LOCcodexAgent.ts ×1codexAgent.ts ×1 · 2 introduced LOCcodexAgent.ts ×1codexAgent.ts ×3 · 7 introduced LOCcodexAgent.ts ×3codexAgent.ts ×1 · 2 introduced LOCcodexAgent.ts ×1codexAgent.ts ×1 · 2 introduced LOCcodexAgent.ts ×1codexAgent.ts ×1 · 2 introduced LOCcodexAgent.ts ×1codexAgent.ts ×1 · 10 introduced LOCcodexAgent.ts ×1codexAgent.ts ×8 · 19 introduced LOCcodexAgent.ts ×8codexAgent.ts ×158 · 1640 introduced LOCcodexAgent.ts ×158codexCustomizations.ts ×3 · 32 introduced LOCcodexCustomizations.ts ×…codexCustomizations.ts ×4 · 45 introduced LOCcodexCustomizations.ts ×…codexCustomizations.ts ×1 · 2 introduced LOCcodexCustomizations.ts ×…codexCustomizations.ts ×3 · 12 introduced LOCcodexCustomizations.ts ×…codexCustomizations.ts ×2 · 5 introduced LOCcodexCustomizations.ts ×…codexCustomizations.ts ×5 · 57 introduced LOCcodexCustomizations.ts ×…system|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexCustomizations.test|title=codexCustomizations de-duplicates skills by path across cwd entries and orders scopes repo/user/system|occurrence=1system|occurrence=1 undefined hooks responses yield no containers|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexCustomizations.test|title=codexCustomizations empty / undefined hooks responses yield no containers|occurrence=1 undefined hooks respons… undefined skills responses yield no containers|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexCustomizations.test|title=codexCustomizations empty / undefined skills responses yield no containers|occurrence=1 undefined skills respon…codexCustomizations.test|title=codexCustomizations groups skills by scope into read-only containers, sorted by name|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexCustomizations.test|title=codexCustomizations groups skills by scope into read-only containers, sorted by name|occurrence=1codexCustomizations.test…codexCustomizations.test|title=codexCustomizations hooks project into a single container, de-duped by key and ordered by displayOrder|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexCustomizations.test|title=codexCustomizations hooks project into a single container, de-duped by key and ordered by displayOrder|occurrence=1codexCustomizations.test…codexCustomizations.test|title=codexCustomizations skill child uri is a file uri and id is stable|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexCustomizations.test|title=codexCustomizations skill child uri is a file uri and id is stable|occurrence=1codexCustomizations.test…codexModelRefresh.test|title=CodexAgent model refresh keeps the last known-good models when a periodic refresh fails|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexModelRefresh.test|title=CodexAgent model refresh keeps the last known-good models when a periodic refresh fails|occurrence=1codexModelRefresh.test|t…codexPackagePaths.test|title=codex package paths codexBinaryTriple every suffix produced by codexPackageSuffix maps to a rust target triple|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths codexBinaryTriple every suffix produced by codexPackageSuffix maps to a rust target triple|occurrence=1codexPackagePaths.test|t…codexPackagePaths.test|title=codex package paths codexBinaryTriple returns undefined for unknown suffixes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths codexBinaryTriple returns undefined for unknown suffixes|occurrence=1codexPackagePaths.test|t…codexPackagePaths.test|title=codex package paths codexPackageSuffix every supported (platform, arch) returns the npm optionalDependencies suffix|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths codexPackageSuffix every supported (platform, arch) returns the npm optionalDependencies suffix|occurrence=1codexPackagePaths.test|t…codexPackagePaths.test|title=codex package paths codexPackageSuffix never returns a -musl suffix on Linux (Codex is statically musl-linked)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths codexPackageSuffix never returns a -musl suffix on Linux (Codex is statically musl-linked)|occurrence=1codexPackagePaths.test|t…codexPackagePaths.test|title=codex package paths codexPackageSuffix returns undefined for unsupported platforms and architectures|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths codexPackageSuffix returns undefined for unsupported platforms and architectures|occurrence=1codexPackagePaths.test|t…codex resolves|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths resolveCodexDevSdkRoot returns the directory containing node_modules when @openai/codex resolves|occurrence=1codex resolves|occurrenc…codexPackagePaths.test|title=codex package paths resolveCodexDevSdkRoot returns undefined when resolution throws (e.g. built product without the devDependency)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexPackagePaths.test|title=codex package paths resolveCodexDevSdkRoot returns undefined when resolution throws (e.g. built product without the devDependency)|occurrence=1codexPackagePaths.test|t…codexSessionConfigKeys.test|title=codexSessionConfigKeys expands permissions presets and falls back to legacy axes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexSessionConfigKeys.test|title=codexSessionConfigKeys expands permissions presets and falls back to legacy axes|occurrence=1codexSessionConfigKeys.t…codexSessionConfigKeys.test|title=codexSessionConfigKeys inverts presets and migrates legacy axes without escalating|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexSessionConfigKeys.test|title=codexSessionConfigKeys inverts presets and migrates legacy axes without escalating|occurrence=1codexSessionConfigKeys.t…codexSessionConfigKeys.test|title=codexSessionConfigKeys narrows valid values and rejects invalid values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexSessionConfigKeys.test|title=codexSessionConfigKeys narrows valid values and rejects invalid values|occurrence=1codexSessionConfigKeys.t…codexSessionConfigKeys.test|title=codexSessionConfigKeys resolveSessionConfig exposes a single permissions-preset chip|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexSessionConfigKeys.test|title=codexSessionConfigKeys resolveSessionConfig exposes a single permissions-preset chip|occurrence=1codexSessionConfigKeys.t…codexSessionConfigKeys.test|title=codexSessionConfigKeys resolveSessionConfig preserves legacy read-only permissions on restore|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/codex/codexSessionConfigKeys.test|title=codexSessionConfigKeys resolveSessionConfig preserves legacy read-only permissions on restore|occurrence=1codexSessionConfigKeys.t…Focused file · src/vs/platform/agentHost/node/codex/codexCustomizations.ts · 153 LOCcodex/codexCustomization…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- codexCustomizations.ts ×5
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { URI } from '../../../../base/common/uri.js';
7 > import { CustomizationLoadStatus, CustomizationType, customizationId, type DirectoryCustomization, type HookCustomization, type SkillCustomization } from '../../common/state/sessionState.js';
8 > import type { HookMetadata } from './protocol/generated/v2/HookMetadata.js';
9 > import type { HooksListResponse } from './protocol/generated/v2/HooksListResponse.js';
10 > import type { SkillMetadata } from './protocol/generated/v2/SkillMetadata.js';
11 > import type { SkillScope } from './protocol/generated/v2/SkillScope.js';
12 > import type { SkillsListResponse } from './protocol/generated/v2/SkillsListResponse.js';
13 >
14 > /**
15 > * Codex reports its *effective* skills and hooks through the cwd-scoped
16 > * `skills/list` and `hooks/list` app-server methods (see
17 > * `codex-rs/.../catalog_processor.rs`). Codex natively discovers skills from
18 > * the VS Code `.agents/skills` convention (`<repo>/.agents/skills` at repo
19 > * scope and `~/.agents/skills` at user scope) as well as `.codex` and bundled
20 > * roots. These helpers project those catalogs into the AHP
21 > * {@link DirectoryCustomization} containers that back the workbench
22 > * Customizations surface, so what codex actually loaded is visible alongside
23 > * the MCP servers already surfaced by {@link McpCustomizationController}.
24 > *
25 > * The mappers are pure (no codex round-trip): the {@link CodexAgent} fetches
26 > * the `skills/list` / `hooks/list` responses and feeds them here.
27 > */
28 >
29 > /** Synthetic URI scheme for the per-scope codex skills container. */
30 > const CODEX_SKILLS_SCHEME = 'codex-skills';
31 > /** Synthetic URI scheme for the codex hooks container. */
32 > const CODEX_HOOKS_SCHEME = 'codex-hooks';
33 >
34 > /** Human-facing container name for each {@link SkillScope}. */
35 > function skillScopeContainerName(scope: SkillScope): string { codexCustomizations.ts ×4
36 > switch (scope) {
37 > case 'repo': return 'Repository';
38 > case 'user': return 'User';
39 > case 'system': return 'Built-in';
40 > case 'admin': return 'Admin';
41 > default: return scope;
42 > }
43 > }
45 > /** Stable ordering of scopes so the container list is deterministic. */
46 > const SKILL_SCOPE_ORDER: readonly SkillScope[] = ['repo', 'user', 'system', 'admin'];
47 >
48 > function skillToCustomization(skill: SkillMetadata): SkillCustomization { codexCustomizations.ts ×4
49 > const uri = URI.file(skill.path).toString();
50 > return {
51 > type: CustomizationType.Skill,
52 > id: customizationId(uri),
53 > uri,
54 > name: skill.name,
55 > description: skill.description,
56 > enabled: skill.enabled,
57 > };
58 > }
60 > /**
61 > * Projects a codex `skills/list` response into one read-only
62 > * {@link DirectoryCustomization} container per {@link SkillScope}, each
63 > * carrying its skills as {@link SkillCustomization} children. Skills are
64 > * de-duplicated by their `SKILL.md` path (codex can report the same skill
65 > * for several requested cwds). Scopes with no skills are omitted; the result
66 > * is ordered by {@link SKILL_SCOPE_ORDER}.
67 > */
68 > export function codexSkillsToContainers(response: SkillsListResponse | undefined): DirectoryCustomization[] {
69 > const byScope = new Map<SkillScope, Map<string, SkillMetadata>>(); codexCustomizations.ts ×3
70 > for (const entry of response?.data ?? []) {
71 > for (const skill of entry.skills ?? []) {
72 > let scoped = byScope.get(skill.scope); codexCustomizations.ts ×4
73 > if (!scoped) {
74 > scoped = new Map();
75 > byScope.set(skill.scope, scoped);
76 > }
77 > if (!scoped.has(skill.path)) {
78 > scoped.set(skill.path, skill);
79 > }
80 > }
82 > const containers: DirectoryCustomization[] = [];
83 > for (const scope of SKILL_SCOPE_ORDER) {
84 > const scoped = byScope.get(scope);
85 > if (!scoped || scoped.size === 0) {
86 > continue;
87 > }
88 > const children = [...scoped.values()] codexCustomizations.ts ×4
89 > .sort((a, b) => a.name.localeCompare(b.name))
90 > .map(skillToCustomization);
91 > const containerUri = URI.from({ scheme: CODEX_SKILLS_SCHEME, path: `/${scope}` }).toString();
92 > containers.push({
93 > type: CustomizationType.Directory,
94 > id: customizationId(containerUri),
95 > uri: containerUri,
96 > name: skillScopeContainerName(scope),
97 > enabled: true,
98 > contents: CustomizationType.Skill,
99 > writable: false,
100 > load: { kind: CustomizationLoadStatus.Loaded },
101 > children,
102 > });
103 > }
104 > return containers; codexCustomizations.ts ×3
105 > }
107 > function hookToCustomization(hook: HookMetadata): HookCustomization { codexCustomizations.ts ×3
108 > // A single source file can declare several hooks, so disambiguate with the
109 > // codex hook `key` in the fragment to keep customization ids unique.
110 > const uri = URI.file(hook.sourcePath).with({ fragment: hook.key }).toString();
111 > return {
112 > type: CustomizationType.Hook,
113 > id: customizationId(uri),
114 > uri,
115 > name: hook.eventName,
116 > enabled: hook.enabled,
117 > };
118 > }
120 > /**
121 > * Projects a codex `hooks/list` response into a single read-only
122 > * {@link DirectoryCustomization} container carrying its hooks as
123 > * {@link HookCustomization} children. Hooks are de-duplicated by their codex
124 > * `key`. Returns an empty array when no hooks are configured.
125 > */
126 > export function codexHooksToContainers(response: HooksListResponse | undefined): DirectoryCustomization[] {
127 > const byKey = new Map<string, HookMetadata>(); codexCustomizations.ts ×2
128 > for (const entry of response?.data ?? []) {
129 > for (const hook of entry.hooks ?? []) {
130 > if (!byKey.has(hook.key)) { codexCustomizations.ts ×3
131 > byKey.set(hook.key, hook);
132 > }
133 > }
135 > if (byKey.size === 0) {
136 > return []; codexCustomizations.ts ×1
137 > }
138 > const children = [...byKey.values()] codexCustomizations.ts ×3
139 > .sort((a, b) => Number(a.displayOrder - b.displayOrder) || a.key.localeCompare(b.key))
140 > .map(hookToCustomization);
141 > const containerUri = URI.from({ scheme: CODEX_HOOKS_SCHEME, path: '/hooks' }).toString();
142 > return [{
143 > type: CustomizationType.Directory,
144 > id: customizationId(containerUri),
145 > uri: containerUri,
146 > name: 'Hooks',
147 > enabled: true,
148 > contents: CustomizationType.Hook,
149 > writable: false,
150 > load: { kind: CustomizationLoadStatus.Loaded },
151 > children,
152 > }];
153 > }