@shuind/dsh-codex-harness 0.1.40 → 0.2.1

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.
package/lib/index.js CHANGED
@@ -7,9 +7,6 @@ import { credentialRef } from "@deepseek-ai/dsh-credentials";
7
7
  import { AsyncLocalStorage } from "node:async_hooks";
8
8
  import { isTokenDelta } from "@deepseek-ai/dsh-llm/message";
9
9
  import { z as z$1 } from "zod";
10
- //#region lib/types/context.js
11
- const CODEX_CONTEXT_MAX = 1e6;
12
- //#endregion
13
10
  //#region lib/types/patch.js
14
11
  /** Parser and line-oriented applicator for Codex's `apply_patch` language. */
15
12
  const APPLY_PATCH_DESCRIPTION = "Edits files using Codex patch syntax with Begin/End Patch markers and file update directives. In hunk lines, the first character is the operation marker; repeat a source-leading marker when the source line itself starts with one.";
@@ -1075,6 +1072,67 @@ function registerCodexActivityProjection(ctx) {
1075
1072
  });
1076
1073
  }
1077
1074
  //#endregion
1075
+ //#region lib/types/prompt.js
1076
+ /** Default plugin-owned Codex operating prompt. */
1077
+ const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
1078
+
1079
+ - When searching for text or files, prefer using rg or rg --files respectively because rg is much faster than alternatives like grep. If rg is not available, use the next best alternative.
1080
+
1081
+ ## Editing constraints
1082
+
1083
+ - Default to ASCII when editing or creating files. Only introduce non-ASCII or other Unicode characters when there is a clear justification and the file already uses them.
1084
+ - Add succinct code comments that explain non-obvious code. Do not add comments that merely narrate assignments or control flow.
1085
+ - You may be in a dirty git worktree. Never revert existing changes you did not make unless the user explicitly requests it. If unrelated files are changed, leave them alone.
1086
+
1087
+ ## Planning
1088
+
1089
+ - Use update_plan for work with multiple meaningful steps. Keep the plan current as the task progresses.
1090
+ - Do not use a plan for a trivial one-step request.
1091
+
1092
+ ## dsh session
1093
+
1094
+ - The user and you share one workspace. Inspect the repository and every applicable AGENTS.md before editing.
1095
+
1096
+ ## Task execution
1097
+
1098
+ - Keep the user informed with concise progress updates and lead with the result.
1099
+
1100
+ ## Presenting your work
1101
+
1102
+ - Be concise, direct, friendly, and actionable.
1103
+ - For substantial work, explain what changed and why, then briefly note how the work was verified and what comes next.
1104
+ - Do not dump large files into the conversation; refer to their paths.
1105
+ - Use plain text with short sections only when they improve scanability.
1106
+
1107
+ ## Working principles
1108
+
1109
+ - Ask, align, and clarify first. Gather enough context from the user, then align the approach to achieve the user's goal through the clearest, most effective path.
1110
+ - Keep only the essential logic and core actions. Don't explain or test what was removed or why something wasn't done, especially when writing documentation or communicating. Convey enough valuable information with as few words as possible.
1111
+ - Solve problems by thinking from first principles and at a higher level.
1112
+ `;
1113
+ /** Resolve the full plugin-owned prompt, preserving intentional empty overrides. */
1114
+ function resolveCodexSystemPrompt(systemPrompt) {
1115
+ return systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT;
1116
+ }
1117
+ //#endregion
1118
+ //#region lib/types/context.js
1119
+ const CODEX_CONTEXT_MAX = 1e6;
1120
+ //#endregion
1121
+ //#region lib/types/settings.js
1122
+ /** Shared host-side Codex settings contract. */
1123
+ /** Live Codex controls shared by the Web UI and agent layer. */
1124
+ const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
1125
+ /** Default settings exposed even before a Codex session is opened. */
1126
+ const CODEX_SETTINGS_ENTRY = {
1127
+ fast: false,
1128
+ systemPrompt: DEFAULT_CODEX_SYSTEM_PROMPT
1129
+ };
1130
+ const CODEX_SETTINGS_SCHEMA = z.object({
1131
+ fast: z.boolean().default(false),
1132
+ contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX),
1133
+ systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT)
1134
+ });
1135
+ //#endregion
1078
1136
  //#region lib/types/index.js
1079
1137
  /** Codex-compatible prompt overlay and core tools for a dsh agent preset. */
1080
1138
  const name = "codex";
@@ -1096,16 +1154,9 @@ const Config = z.object({
1096
1154
  maxOutputBytes: z.number().step(1).min(1).default(DEFAULT_MAX_OUTPUT_BYTES),
1097
1155
  hostedWebSearch: z.boolean().default(true),
1098
1156
  remoteCompact: z.boolean().default(true),
1099
- collaborationPrompt: z.boolean().default(false)
1157
+ systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT)
1100
1158
  });
1101
1159
  const LLM_PI_AI_SETTINGS = settingsNamespace("llm-pi-ai");
1102
- /** Live Codex-only request controls shared by the Web controls and agent layer. */
1103
- const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
1104
- const CODEX_SETTINGS_SCHEMA = z.object({
1105
- fast: z.boolean().default(false),
1106
- contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX)
1107
- });
1108
- const CODEX_SETTINGS_ENTRY = { fast: false };
1109
1160
  const GPT_REASONING_EFFORTS = {
1110
1161
  low: "low",
1111
1162
  medium: "medium",
@@ -1189,10 +1240,16 @@ function watchConfiguredGptModels(ctx) {
1189
1240
  });
1190
1241
  schedule();
1191
1242
  }
1192
- /** Install the optional settings source used by the request waterfall. */
1193
- function installCodexSettings(ctx) {
1194
- let source = () => CODEX_SETTINGS_ENTRY;
1195
- installSettingsSection(ctx, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, CODEX_SETTINGS_ENTRY, {
1243
+ /** Install the optional settings source used by requests and prompt assembly. */
1244
+ function installCodexSettings(ctx, systemPrompt) {
1245
+ const entry = {
1246
+ ...CODEX_SETTINGS_ENTRY,
1247
+ systemPrompt
1248
+ };
1249
+ const settings = ctx.get("settings");
1250
+ if (settings?.get(CODEX_SETTINGS_NAMESPACE) !== void 0) return { current: () => settings.get(CODEX_SETTINGS_NAMESPACE) ?? entry };
1251
+ let source = () => entry;
1252
+ installSettingsSection(ctx, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, entry, {
1196
1253
  setSource: (current) => {
1197
1254
  source = current;
1198
1255
  },
@@ -1270,42 +1327,6 @@ function applyCodexRequestSettings(request, settings) {
1270
1327
  ...settings.fast ? { serviceTier: "priority" } : {}
1271
1328
  };
1272
1329
  }
1273
- const CODEX_BASE_PROMPT = String.raw`## General
1274
-
1275
- - When searching for text or files, prefer using rg or rg --files respectively because rg is much faster than alternatives like grep. If rg is not available, use the next best alternative.
1276
-
1277
- ## Editing constraints
1278
-
1279
- - Default to ASCII when editing or creating files. Only introduce non-ASCII or other Unicode characters when there is a clear justification and the file already uses them.
1280
- - Add succinct code comments that explain non-obvious code. Do not add comments that merely narrate assignments or control flow.
1281
- - You may be in a dirty git worktree. Never revert existing changes you did not make unless the user explicitly requests it. If unrelated files are changed, leave them alone.
1282
-
1283
- ## Planning
1284
-
1285
- - Use update_plan for work with multiple meaningful steps. Keep the plan current as the task progresses.
1286
- - Do not use a plan for a trivial one-step request.
1287
-
1288
- ## dsh session
1289
-
1290
- - The user and you share one workspace. Inspect the repository and every applicable AGENTS.md before editing.
1291
-
1292
- ## Task execution
1293
-
1294
- - Keep the user informed with concise progress updates and lead with the result.
1295
-
1296
- ## Presenting your work
1297
-
1298
- - Be concise, direct, friendly, and actionable.
1299
- - For substantial work, explain what changed and why, then briefly note how the work was verified and what comes next.
1300
- - Do not dump large files into the conversation; refer to their paths.
1301
- - Use plain text with short sections only when they improve scanability.
1302
- `;
1303
- const CODEX_COLLABORATION_PROMPT = String.raw`## Working principles
1304
-
1305
- - Ask, align, and clarify first. Gather enough context from the user, then align the approach to achieve the user's goal through the clearest, most effective path.
1306
- - Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done, especially when writing documentation or communicating. Convey enough valuable information with as few words as possible.
1307
- - Solve problems by thinking from first principles and at a higher level.
1308
- `;
1309
1330
  /** Put the agent persona first and omit the generic Harness identity opener. */
1310
1331
  function normalizeCodexPromptAssembly(assembly) {
1311
1332
  const sections = assembly.sections.filter((section) => section.name !== "harness:identity");
@@ -1319,9 +1340,9 @@ function normalizeCodexPromptAssembly(assembly) {
1319
1340
  sections: [persona, ...sections.filter((section) => section.name !== "deployment:persona")]
1320
1341
  };
1321
1342
  }
1322
- /** Build the Codex operating prompt with optional, user-enabled collaboration guidance. */
1343
+ /** Build the complete plugin-owned prompt, preserving an intentional empty value. */
1323
1344
  function buildCodexSystemPrompt(config = {}) {
1324
- return config.collaborationPrompt === true ? `${CODEX_BASE_PROMPT}\n\n${CODEX_COLLABORATION_PROMPT}` : CODEX_BASE_PROMPT;
1345
+ return resolveCodexSystemPrompt(config.systemPrompt);
1325
1346
  }
1326
1347
  const EXEC_COMMAND_DESCRIPTION = "Runs a command in a PTY, returning output, a session ID for ongoing interaction, or a background job ID when requested.";
1327
1348
  const WRITE_STDIN_DESCRIPTION = "Writes characters to an existing unified exec session and returns recent output.";
@@ -1697,12 +1718,12 @@ function apply(ctx, config = {}) {
1697
1718
  maxOutputBytes: config.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES,
1698
1719
  hostedWebSearch: config.hostedWebSearch ?? true,
1699
1720
  remoteCompact: config.remoteCompact ?? true,
1700
- collaborationPrompt: config.collaborationPrompt ?? false
1721
+ systemPrompt: config.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT
1701
1722
  };
1702
1723
  if (ctx.fs.sandboxMode !== void 0 && ctx.get("sandboxPolicy") === void 0) throw new Error("codex: a sandboxing filesystem requires ctx.sandboxPolicy");
1703
1724
  watchConfiguredGptModels(ctx);
1704
1725
  registerCodexActivityProjection(ctx);
1705
- const codexSettings = installCodexSettings(ctx);
1726
+ const codexSettings = installCodexSettings(ctx, resolved.systemPrompt);
1706
1727
  installCodexContextProjection(ctx, codexSettings.current);
1707
1728
  ctx.on("agent/request", async (_payload, next) => {
1708
1729
  return applyCodexRequestSettings(await next(), codexSettings.current());
@@ -1720,7 +1741,7 @@ function apply(ctx, config = {}) {
1720
1741
  ctx.systemPrompt.section({
1721
1742
  name: "codex:base",
1722
1743
  order: 10,
1723
- text: buildCodexSystemPrompt(resolved)
1744
+ text: () => resolveCodexSystemPrompt(codexSettings.current().systemPrompt)
1724
1745
  });
1725
1746
  registerExecTools(ctx, resolved);
1726
1747
  registerPatchTool(ctx);
@@ -1733,4 +1754,4 @@ var types_default = {
1733
1754
  apply
1734
1755
  };
1735
1756
  //#endregion
1736
- export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, Config, apply, applyCodexRequestSettings, buildCodexSystemPrompt, types_default as default, enrichCodexModel, inject, name, normalizeCodexPromptAssembly, syncCodexContextWindow };
1757
+ export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, Config, DEFAULT_CODEX_SYSTEM_PROMPT, apply, applyCodexRequestSettings, buildCodexSystemPrompt, types_default as default, enrichCodexModel, inject, name, normalizeCodexPromptAssembly, syncCodexContextWindow };
package/lib/installer.js CHANGED
@@ -1,12 +1,90 @@
1
- import { copyFileSync, existsSync, mkdirSync, mkdtempSync, renameSync, rmSync } from "node:fs";
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
2
3
  import { homedir } from "node:os";
3
4
  import { dirname, join, resolve } from "node:path";
4
5
  import { fileURLToPath } from "node:url";
6
+ import z from "@deepseek-ai/schemastery";
7
+ import { settingsNamespace } from "@deepseek-ai/dsh-settings";
8
+ //#region lib/types/context.js
9
+ const CODEX_CONTEXT_MAX = 1e6;
10
+ //#endregion
11
+ //#region lib/types/prompt.js
12
+ /** Default plugin-owned Codex operating prompt. */
13
+ const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
14
+
15
+ - When searching for text or files, prefer using rg or rg --files respectively because rg is much faster than alternatives like grep. If rg is not available, use the next best alternative.
16
+
17
+ ## Editing constraints
18
+
19
+ - Default to ASCII when editing or creating files. Only introduce non-ASCII or other Unicode characters when there is a clear justification and the file already uses them.
20
+ - Add succinct code comments that explain non-obvious code. Do not add comments that merely narrate assignments or control flow.
21
+ - You may be in a dirty git worktree. Never revert existing changes you did not make unless the user explicitly requests it. If unrelated files are changed, leave them alone.
22
+
23
+ ## Planning
24
+
25
+ - Use update_plan for work with multiple meaningful steps. Keep the plan current as the task progresses.
26
+ - Do not use a plan for a trivial one-step request.
27
+
28
+ ## dsh session
29
+
30
+ - The user and you share one workspace. Inspect the repository and every applicable AGENTS.md before editing.
31
+
32
+ ## Task execution
33
+
34
+ - Keep the user informed with concise progress updates and lead with the result.
35
+
36
+ ## Presenting your work
37
+
38
+ - Be concise, direct, friendly, and actionable.
39
+ - For substantial work, explain what changed and why, then briefly note how the work was verified and what comes next.
40
+ - Do not dump large files into the conversation; refer to their paths.
41
+ - Use plain text with short sections only when they improve scanability.
42
+
43
+ ## Working principles
44
+
45
+ - Ask, align, and clarify first. Gather enough context from the user, then align the approach to achieve the user's goal through the clearest, most effective path.
46
+ - Keep only the essential logic and core actions. Don't explain or test what was removed or why something wasn't done, especially when writing documentation or communicating. Convey enough valuable information with as few words as possible.
47
+ - Solve problems by thinking from first principles and at a higher level.
48
+ `;
49
+ //#endregion
50
+ //#region lib/types/settings.js
51
+ /** Shared host-side Codex settings contract. */
52
+ /** Live Codex controls shared by the Web UI and agent layer. */
53
+ const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
54
+ /** Default settings exposed even before a Codex session is opened. */
55
+ const CODEX_SETTINGS_ENTRY = {
56
+ fast: false,
57
+ systemPrompt: DEFAULT_CODEX_SYSTEM_PROMPT
58
+ };
59
+ const CODEX_SETTINGS_SCHEMA = z.object({
60
+ fast: z.boolean().default(false),
61
+ contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX),
62
+ systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT)
63
+ });
64
+ //#endregion
5
65
  //#region lib/types/installer.js
6
66
  /** Install the user-visible Codex agent preset supplied by this bundle. */
7
67
  const PRESET_FILES = ["agent.cordis.yml", "preset.yml"];
8
- const SOURCE_PRESET_DIR = fileURLToPath(new URL("../presets/codex/", import.meta.url));
9
- const SOURCE_COLLABORATION_PRESET_DIR = fileURLToPath(new URL("../presets/codex-collaboration/", import.meta.url));
68
+ const MANAGED_SIGNATURE_FILE = ".dsh-codex-harness-managed";
69
+ const BUNDLED_PRESET_ID = "codex-collaboration";
70
+ const LEGACY_PRESET_ID = "codex";
71
+ const SOURCE_PRESET_DIR = fileURLToPath(new URL("../presets/codex-collaboration/", import.meta.url));
72
+ const LEGACY_PRESET_SIGNATURES = /* @__PURE__ */ new Set([
73
+ "2f6222b6c9fed417d0f8fbfef9b221f0c9088c63347466219309c1c2ca2426bb",
74
+ "40ae944220ca57daae93d1483d6cb6264e6847ed77ee84f38171c34c36f0598e",
75
+ "c6a594797f7044c44c09254635b8381f20533cd26a4661239529dc44ec423d0c",
76
+ "2c373798b9cadbda5fb377dab0d43ac5637263546a5a4fc1740752658fdec658",
77
+ "a4062b59ad0e512e1b1b7e80ae56d8cde4efdaa5ba958364a17653ba1ff3c2ed",
78
+ "16016e7f68ee61354de232151be5b6ad0cda1785183ca0c72f9d0946b6a1d6cd",
79
+ "7f72b1bea9b30074788f05d20b841a797a5b29bb945dd1fb0597c8d03eb2b9b9",
80
+ "6a6c8dc2e7a7dbc1ac30ce608a53c238f19066a786f951f9a295ada86e56ed9e"
81
+ ]);
82
+ const BUNDLED_PRESET_SIGNATURES = /* @__PURE__ */ new Set([
83
+ "2a7ef181266e69275d25091adc74dd619af7c7d3577573887aaaecd2663e13c8",
84
+ "d1de30f5c13049621b1c1ae3fb22d35b031797a4762638265822b0ff62749854",
85
+ "b50e1d616f9b4188a33c0da0fe355478b7b75b615f3792c094e2b67995622cf4",
86
+ "6132523d92893f6ae9214b30105e9cc1ba64854df6ca8a84213069eb6c38d286"
87
+ ]);
10
88
  function dshHomePath(...segments) {
11
89
  const configured = process.env.DSH_HOME?.trim();
12
90
  const expanded = configured === void 0 || configured.length === 0 ? join(homedir(), ".dsh") : configured === "~" ? homedir() : configured.startsWith("~/") || configured.startsWith("~\\") ? join(homedir(), configured.slice(2)) : configured;
@@ -14,54 +92,109 @@ function dshHomePath(...segments) {
14
92
  }
15
93
  /** Bundle plugin name for the preset installer. */
16
94
  const name = "codex-preset-installer";
17
- function installPreset(targetDir, sourceDir, presetId) {
18
- if (existsSync(targetDir)) return;
95
+ const inject = ["settings"];
96
+ function presetSignature(directory) {
97
+ if (PRESET_FILES.some((file) => !existsSync(join(directory, file)))) return void 0;
98
+ const hash = createHash("sha256");
99
+ hash.update(readFileSync(join(directory, PRESET_FILES[0])));
100
+ hash.update(Buffer.from([0]));
101
+ hash.update(readFileSync(join(directory, PRESET_FILES[1])));
102
+ return hash.digest("hex");
103
+ }
104
+ function stagePreset(targetDir, sourceDir, presetId) {
19
105
  const parentDir = dirname(targetDir);
20
106
  mkdirSync(parentDir, { recursive: true });
21
107
  const stagingDir = mkdtempSync(join(parentDir, `.${presetId}-`));
22
108
  try {
23
109
  for (const file of PRESET_FILES) copyFileSync(join(sourceDir, file), join(stagingDir, file));
24
- try {
25
- renameSync(stagingDir, targetDir);
26
- } catch (error) {
27
- if (!existsSync(targetDir)) throw error;
28
- }
29
- } finally {
110
+ const signature = presetSignature(stagingDir);
111
+ if (signature === void 0) throw new Error(`incomplete bundled preset: ${sourceDir}`);
112
+ writeFileSync(join(stagingDir, MANAGED_SIGNATURE_FILE), `${signature}\n`);
113
+ return stagingDir;
114
+ } catch (error) {
115
+ rmSync(stagingDir, {
116
+ recursive: true,
117
+ force: true
118
+ });
119
+ throw error;
120
+ }
121
+ }
122
+ function installPreset(targetDir, sourceDir, presetId) {
123
+ const stagingDir = stagePreset(targetDir, sourceDir, presetId);
124
+ try {
125
+ renameSync(stagingDir, targetDir);
126
+ } catch (error) {
127
+ if (!existsSync(targetDir)) throw error;
128
+ rmSync(stagingDir, {
129
+ recursive: true,
130
+ force: true
131
+ });
132
+ }
133
+ }
134
+ function replacePreset(targetDir, sourceDir, presetId) {
135
+ const stagingDir = stagePreset(targetDir, sourceDir, presetId);
136
+ const backupDir = join(dirname(targetDir), `.${presetId}-backup-${randomUUID()}`);
137
+ renameSync(targetDir, backupDir);
138
+ try {
139
+ renameSync(stagingDir, targetDir);
140
+ rmSync(backupDir, {
141
+ recursive: true,
142
+ force: true
143
+ });
144
+ } catch (error) {
30
145
  if (existsSync(stagingDir)) rmSync(stagingDir, {
31
146
  recursive: true,
32
147
  force: true
33
148
  });
149
+ if (!existsSync(targetDir)) renameSync(backupDir, targetDir);
150
+ throw error;
34
151
  }
35
152
  }
153
+ function hasMatchingManagedMarker(targetDir, signature) {
154
+ const marker = join(targetDir, MANAGED_SIGNATURE_FILE);
155
+ return existsSync(marker) && readFileSync(marker, "utf8").trim() === signature;
156
+ }
36
157
  /**
37
- * Install the shipped Codex preset only when the user has not authored one.
158
+ * Install or upgrade the single shipped Codex preset.
38
159
  *
39
160
  * The directory is committed with a staging rename so a failed copy cannot
40
- * leave a half-written preset that hides the mode from the roster. Existing
41
- * directories are intentionally preserved, including user customizations.
161
+ * leave a half-written preset that hides the mode from the roster. A known
162
+ * shipped copy upgrades in place; any changed or unknown copy is preserved.
42
163
  *
43
164
  * @param targetDir - destination preset directory.
44
165
  * @param sourceDir - directory containing the packaged preset files.
45
166
  */
46
- function installCodexPreset(targetDir = dshHomePath(".agent-presets", "codex"), sourceDir = SOURCE_PRESET_DIR) {
47
- installPreset(targetDir, sourceDir, "codex");
167
+ function installCodexPreset(targetDir = dshHomePath(".agent-presets", BUNDLED_PRESET_ID), sourceDir = SOURCE_PRESET_DIR) {
168
+ if (!existsSync(targetDir)) {
169
+ installPreset(targetDir, sourceDir, BUNDLED_PRESET_ID);
170
+ return;
171
+ }
172
+ const signature = presetSignature(targetDir);
173
+ if (signature !== void 0 && (BUNDLED_PRESET_SIGNATURES.has(signature) || hasMatchingManagedMarker(targetDir, signature))) replacePreset(targetDir, sourceDir, BUNDLED_PRESET_ID);
48
174
  }
49
- /** Install the shipped Codex preset with the optional collaboration guidance enabled. */
50
- function installCodexCollaborationPreset(targetDir = dshHomePath(".agent-presets", "codex-collaboration"), sourceDir = SOURCE_COLLABORATION_PRESET_DIR) {
51
- installPreset(targetDir, sourceDir, "codex-collaboration");
175
+ /** Remove an unmodified copy of the retired second Codex mode. */
176
+ function retireLegacyCodexPreset(targetDir = dshHomePath(".agent-presets", LEGACY_PRESET_ID), managedSignatures = LEGACY_PRESET_SIGNATURES) {
177
+ if (!existsSync(targetDir)) return;
178
+ const signature = presetSignature(targetDir);
179
+ if (signature !== void 0 && managedSignatures.has(signature)) rmSync(targetDir, {
180
+ recursive: true,
181
+ force: true
182
+ });
52
183
  }
53
184
  /** Install the preset during profile boot without changing the host tool catalog. */
54
185
  function apply(ctx) {
55
186
  try {
187
+ ctx.settings.register(CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, { base: CODEX_SETTINGS_ENTRY });
56
188
  installCodexPreset();
57
- installCodexCollaborationPreset();
189
+ retireLegacyCodexPreset();
58
190
  } catch (error) {
59
- ctx.logger.warn(`dsh-codex: could not install the Codex presets: ${String(error)}`);
191
+ ctx.logger.warn(`dsh-codex: could not reconcile the Codex preset: ${String(error)}`);
60
192
  }
61
193
  }
62
194
  var installer_default = {
63
195
  name,
196
+ inject,
64
197
  apply
65
198
  };
66
199
  //#endregion
67
- export { apply, installer_default as default, installCodexCollaborationPreset, installCodexPreset, name };
200
+ export { apply, installer_default as default, inject, installCodexPreset, name, retireLegacyCodexPreset };
@@ -1,4 +1,4 @@
1
- /** Browser controls for the Codex request settings mounted by the Host plugin. */
1
+ /** Browser controls for Codex requests and the editable operating prompt. */
2
2
  import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
3
3
  import type { Context } from '@deepseek-ai/cordis';
4
4
  import type { SettingsScope } from '@deepseek-ai/dsh-client-runtime/client';
@@ -8,6 +8,7 @@ declare const LEGACY_OVERLAY_SLOT: "conversation.input.overlay";
8
8
  interface CodexSettings {
9
9
  fast: boolean;
10
10
  contextWindow?: number;
11
+ systemPrompt?: string;
11
12
  }
12
13
  type CodexScope = SettingsScope<CodexSettings>;
13
14
  declare const en: {
@@ -19,6 +20,20 @@ declare const en: {
19
20
  readonly contextSize: "Context size";
20
21
  readonly contextSizeDescription: "Next request capacity in K tokens.";
21
22
  readonly contextRestore: "Restore model default";
23
+ readonly promptCardTitle: "Codex Harness";
24
+ readonly promptCardDescription: "View and customize the complete Codex operating prompt.";
25
+ readonly promptLabel: "System prompt";
26
+ readonly promptHint: "This is the full prompt owned by this plugin. Persona and DSH tool guidance stay dynamic.";
27
+ readonly promptOverridden: "Overridden";
28
+ readonly promptReset: "Restore default";
29
+ readonly promptUnsaved: "Unsaved";
30
+ readonly promptDiscard: "Discard";
31
+ readonly promptSave: "Save";
32
+ readonly promptSaving: "Saving...";
33
+ readonly promptSaveFailed: "Could not save the prompt.";
34
+ readonly promptExpand: "Expand settings";
35
+ readonly promptCollapse: "Collapse settings";
36
+ readonly promptReadOnly: "This settings document is read-only.";
22
37
  readonly activityCompacting: "Compacting context...";
23
38
  readonly activityRequestingModel: "Requesting model...";
24
39
  readonly activityModelReply: "Model replying...";
@@ -34,6 +49,13 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
34
49
  scope: 'session';
35
50
  owner: Record<never, never>;
36
51
  };
52
+ 'settings.plugin.item': {
53
+ kind: 'keyed';
54
+ scope: 'root';
55
+ owner: {
56
+ children?: never;
57
+ };
58
+ };
37
59
  }
38
60
  }
39
61
  interface InputSettingsControlInjected {
@@ -43,6 +65,8 @@ interface InputSettingsControlInjected {
43
65
  setSetting: (field: string, value: unknown) => Promise<void>;
44
66
  unsetSetting: (field: string) => Promise<void>;
45
67
  }
68
+ /** Full-prompt editor contributed to Settings > Plugins. */
69
+ export declare function PromptSettingsCard(props: PropsRuntime<'settings.plugin.item'> & InjectFace<InputSettingsControlInjected> & PropsLocale<'codex'>): import("react").JSX.Element | null;
46
70
  type LegacyOverlayProps = PropsRuntime<typeof LEGACY_OVERLAY_SLOT> & InjectFace<InputSettingsControlInjected> & PropsLocale<'codex'>;
47
71
  type ActivityProps = Pick<LegacyOverlayProps, 'sessionId' | 'useSession' | 'useSessions' | 'useProjection' | 't'>;
48
72
  type ActivityFallback = ReturnType<typeof modelActivity>;
@@ -55,7 +79,7 @@ export declare function ActivityLine({ sessionId, useSession, useSessions, usePr
55
79
  };
56
80
  }): import("react").JSX.Element | null;
57
81
  export declare const inject: string[];
58
- /** Mount all controls through the official composer seats shared by every DSH release. */
82
+ /** Mount request controls and the plugin settings card through shared slots. */
59
83
  export declare function apply(ctx: Context): void;
60
84
  declare const _default: {
61
85
  inject: string[];