@shuind/dsh-codex-harness 0.2.4 → 0.2.5

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
@@ -1206,10 +1206,25 @@ const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
1206
1206
 
1207
1207
  ## Working principles
1208
1208
 
1209
- - 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.
1209
+ - Actively establish the user's current context rather than relying on stale assumptions or prior context. Before committing to an approach that could materially shape the outcome or direction of the work, state the intended path and align it with the user; clarify any material uncertainty first. Then pursue the user's goal through the clearest, most effective path.
1210
1210
  - 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.
1211
1211
  - Solve problems by thinking from first principles and at a higher level.
1212
1212
  `;
1213
+ /** Default deployment Persona template used by the Codex preset. */
1214
+ const DEFAULT_CODEX_PERSONA = String.raw`You are Codex, a coding agent based on the {{model}} model. Your working directory is {{cwd}}.`;
1215
+ /** Default DSH Core source-checkout guidance template. */
1216
+ const DEFAULT_DSH_CORE_SOURCE_PROMPT = String.raw`The DeepSeek Harness implementation checkout is at {{sourceRoot}}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.`;
1217
+ /** Default DSH Web runtime guidance template. */
1218
+ const DEFAULT_DSH_CORE_WEB_PROMPT = [
1219
+ "You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}.",
1220
+ "When the user refers to \"this page\", \"this GUI\", or \"this app\" without naming another target, they mean this GUI.",
1221
+ "The browser provides no implicit DOM, route, or screenshot context.",
1222
+ "The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates.",
1223
+ "Every other change - the apps/web shell and plain packages - requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh.",
1224
+ "Starting another server does not update this GUI.",
1225
+ "The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__.",
1226
+ "Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL."
1227
+ ].join(" ");
1213
1228
  /** Resolve the full plugin-owned prompt, preserving intentional empty overrides. */
1214
1229
  function resolveCodexSystemPrompt(systemPrompt) {
1215
1230
  return systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT;
@@ -1225,6 +1240,9 @@ const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
1225
1240
  /** Default settings exposed even before a Codex session is opened. */
1226
1241
  const CODEX_SETTINGS_ENTRY = {
1227
1242
  fast: false,
1243
+ persona: DEFAULT_CODEX_PERSONA,
1244
+ harnessSourcePrompt: DEFAULT_DSH_CORE_SOURCE_PROMPT,
1245
+ webSurfacePrompt: DEFAULT_DSH_CORE_WEB_PROMPT,
1228
1246
  systemPrompt: DEFAULT_CODEX_SYSTEM_PROMPT,
1229
1247
  promptEnabled: true,
1230
1248
  terminalToolsEnabled: true,
@@ -1237,6 +1255,9 @@ const CODEX_SETTINGS_ENTRY = {
1237
1255
  const CODEX_SETTINGS_SCHEMA = z.object({
1238
1256
  fast: z.boolean().default(false),
1239
1257
  contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX),
1258
+ persona: z.string().default(DEFAULT_CODEX_PERSONA),
1259
+ harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
1260
+ webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),
1240
1261
  systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
1241
1262
  promptEnabled: z.boolean().default(true),
1242
1263
  terminalToolsEnabled: z.boolean().default(true),
@@ -1270,7 +1291,10 @@ const Config = z.object({
1270
1291
  maxOutputBytes: z.number().step(1).min(1).default(DEFAULT_MAX_OUTPUT_BYTES),
1271
1292
  hostedWebSearch: z.boolean().default(true),
1272
1293
  remoteCompact: z.boolean().default(true),
1273
- systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT)
1294
+ systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
1295
+ persona: z.string().default(DEFAULT_CODEX_PERSONA),
1296
+ harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
1297
+ webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT)
1274
1298
  });
1275
1299
  const LLM_PI_AI_SETTINGS = settingsNamespace("llm-pi-ai");
1276
1300
  const GPT_REASONING_EFFORTS = {
@@ -1357,10 +1381,13 @@ function watchConfiguredGptModels(ctx) {
1357
1381
  schedule();
1358
1382
  }
1359
1383
  /** Install the optional settings source used by requests and prompt assembly. */
1360
- function installCodexSettings(ctx, systemPrompt) {
1384
+ function installCodexSettings(ctx, systemPrompt, persona, harnessSourcePrompt, webSurfacePrompt) {
1361
1385
  const entry = {
1362
1386
  ...CODEX_SETTINGS_ENTRY,
1363
- systemPrompt
1387
+ systemPrompt,
1388
+ persona,
1389
+ harnessSourcePrompt,
1390
+ webSurfacePrompt
1364
1391
  };
1365
1392
  const withDefaults = (value) => ({
1366
1393
  ...entry,
@@ -1460,6 +1487,45 @@ function normalizeCodexPromptAssembly(assembly) {
1460
1487
  sections: [persona, ...sections.filter((section) => section.name !== "deployment:persona")]
1461
1488
  };
1462
1489
  }
1490
+ function sectionText(assembly, name) {
1491
+ return assembly.sections.find((candidate) => candidate.name === name)?.text;
1492
+ }
1493
+ function promptVariables(assembly) {
1494
+ const variables = { ...assembly.variables };
1495
+ if (variables.sourceRoot === void 0) {
1496
+ const match = sectionText(assembly, "harness:source")?.match(/^The DeepSeek Harness implementation checkout is at (.+?)\. The checkout location/u);
1497
+ if (match?.[1] !== void 0) variables.sourceRoot = match[1];
1498
+ }
1499
+ if (variables.webUrl === void 0) {
1500
+ const match = sectionText(assembly, "app:web-surface")?.match(/^You are interacting with the user through the DeepSeek Harness Web GUI at (.+?)\. When/u);
1501
+ if (match?.[1] !== void 0) variables.webUrl = match[1];
1502
+ }
1503
+ return variables;
1504
+ }
1505
+ function interpolateCodexPrompt(text, variables) {
1506
+ return text.replace(/\{\{([\w.-]+)\}\}/g, (whole, key) => variables[key] ?? whole);
1507
+ }
1508
+ /** Apply user-editable Persona and DSH Core runtime prompt templates. */
1509
+ function applyCodexPromptOverrides(assembly, settings) {
1510
+ const variables = promptVariables(assembly);
1511
+ const overrides = {
1512
+ "deployment:persona": settings.persona,
1513
+ "harness:source": settings.harnessSourcePrompt,
1514
+ "app:web-surface": settings.webSurfacePrompt
1515
+ };
1516
+ const sections = assembly.sections.map((section) => {
1517
+ const template = overrides[section.name];
1518
+ return template === void 0 ? section : {
1519
+ ...section,
1520
+ text: interpolateCodexPrompt(template, variables)
1521
+ };
1522
+ });
1523
+ return {
1524
+ ...assembly,
1525
+ sections,
1526
+ variables
1527
+ };
1528
+ }
1463
1529
  const CODEX_TOOL_NAMES = {
1464
1530
  terminalToolsEnabled: /* @__PURE__ */ new Set(["exec_command", "write_stdin"]),
1465
1531
  patchToolEnabled: /* @__PURE__ */ new Set(["apply_patch"]),
@@ -1472,11 +1538,11 @@ function applyCodexCapabilitySettings(assembly, settings) {
1472
1538
  if (settings[setting]) continue;
1473
1539
  for (const name of names) disabled.add(name);
1474
1540
  }
1475
- const filtered = disabled.size === 0 ? assembly : {
1541
+ const withOverrides = applyCodexPromptOverrides(disabled.size === 0 ? assembly : {
1476
1542
  ...assembly,
1477
1543
  tools: assembly.tools.filter((tool) => !disabled.has(tool.name))
1478
- };
1479
- return settings.promptEnabled ? normalizeCodexPromptAssembly(filtered) : filtered;
1544
+ }, settings);
1545
+ return settings.promptEnabled ? normalizeCodexPromptAssembly(withOverrides) : withOverrides;
1480
1546
  }
1481
1547
  /** Build the complete plugin-owned prompt, preserving an intentional empty value. */
1482
1548
  function buildCodexSystemPrompt(config = {}) {
@@ -1865,10 +1931,13 @@ function apply(ctx, config = {}) {
1865
1931
  maxOutputBytes: config.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES,
1866
1932
  hostedWebSearch: config.hostedWebSearch ?? true,
1867
1933
  remoteCompact: config.remoteCompact ?? true,
1868
- systemPrompt: config.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT
1934
+ systemPrompt: config.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT,
1935
+ persona: config.persona ?? DEFAULT_CODEX_PERSONA,
1936
+ harnessSourcePrompt: config.harnessSourcePrompt ?? DEFAULT_DSH_CORE_SOURCE_PROMPT,
1937
+ webSurfacePrompt: config.webSurfacePrompt ?? DEFAULT_DSH_CORE_WEB_PROMPT
1869
1938
  };
1870
1939
  if (resolved.codexCore && ctx.fs.sandboxMode !== void 0 && ctx.get("sandboxPolicy") === void 0) throw new Error("codex: a sandboxing filesystem requires ctx.sandboxPolicy");
1871
- const codexSettings = installCodexSettings(ctx, resolved.systemPrompt);
1940
+ const codexSettings = installCodexSettings(ctx, resolved.systemPrompt, resolved.persona, resolved.harnessSourcePrompt, resolved.webSurfacePrompt);
1872
1941
  const execConfig = {
1873
1942
  ...resolved,
1874
1943
  currentSettings: codexSettings.current
@@ -1918,4 +1987,4 @@ var types_default = {
1918
1987
  apply
1919
1988
  };
1920
1989
  //#endregion
1921
- export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, Config, DEFAULT_CODEX_SYSTEM_PROMPT, apply, applyCodexCapabilitySettings, applyCodexRequestSettings, buildCodexSystemPrompt, types_default as default, enrichCodexModel, inject, name, normalizeCodexPromptAssembly, syncCodexContextWindow };
1990
+ export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, Config, DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, apply, applyCodexCapabilitySettings, applyCodexRequestSettings, buildCodexSystemPrompt, types_default as default, enrichCodexModel, inject, name, normalizeCodexPromptAssembly, syncCodexContextWindow };
package/lib/installer.js CHANGED
@@ -42,10 +42,25 @@ const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
42
42
 
43
43
  ## Working principles
44
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.
45
+ - Actively establish the user's current context rather than relying on stale assumptions or prior context. Before committing to an approach that could materially shape the outcome or direction of the work, state the intended path and align it with the user; clarify any material uncertainty first. Then pursue the user's goal through the clearest, most effective path.
46
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
47
  - Solve problems by thinking from first principles and at a higher level.
48
48
  `;
49
+ /** Default deployment Persona template used by the Codex preset. */
50
+ const DEFAULT_CODEX_PERSONA = String.raw`You are Codex, a coding agent based on the {{model}} model. Your working directory is {{cwd}}.`;
51
+ /** Default DSH Core source-checkout guidance template. */
52
+ const DEFAULT_DSH_CORE_SOURCE_PROMPT = String.raw`The DeepSeek Harness implementation checkout is at {{sourceRoot}}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.`;
53
+ /** Default DSH Web runtime guidance template. */
54
+ const DEFAULT_DSH_CORE_WEB_PROMPT = [
55
+ "You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}.",
56
+ "When the user refers to \"this page\", \"this GUI\", or \"this app\" without naming another target, they mean this GUI.",
57
+ "The browser provides no implicit DOM, route, or screenshot context.",
58
+ "The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates.",
59
+ "Every other change - the apps/web shell and plain packages - requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh.",
60
+ "Starting another server does not update this GUI.",
61
+ "The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__.",
62
+ "Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL."
63
+ ].join(" ");
49
64
  //#endregion
50
65
  //#region lib/types/settings.js
51
66
  /** Shared host-side Codex settings contract. */
@@ -54,6 +69,9 @@ const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
54
69
  /** Default settings exposed even before a Codex session is opened. */
55
70
  const CODEX_SETTINGS_ENTRY = {
56
71
  fast: false,
72
+ persona: DEFAULT_CODEX_PERSONA,
73
+ harnessSourcePrompt: DEFAULT_DSH_CORE_SOURCE_PROMPT,
74
+ webSurfacePrompt: DEFAULT_DSH_CORE_WEB_PROMPT,
57
75
  systemPrompt: DEFAULT_CODEX_SYSTEM_PROMPT,
58
76
  promptEnabled: true,
59
77
  terminalToolsEnabled: true,
@@ -66,6 +84,9 @@ const CODEX_SETTINGS_ENTRY = {
66
84
  const CODEX_SETTINGS_SCHEMA = z.object({
67
85
  fast: z.boolean().default(false),
68
86
  contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX),
87
+ persona: z.string().default(DEFAULT_CODEX_PERSONA),
88
+ harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
89
+ webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),
69
90
  systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
70
91
  promptEnabled: z.boolean().default(true),
71
92
  terminalToolsEnabled: z.boolean().default(true),
@@ -8,6 +8,9 @@ declare const LEGACY_OVERLAY_SLOT: "conversation.input.overlay";
8
8
  interface CodexSettings {
9
9
  fast: boolean;
10
10
  contextWindow?: number;
11
+ persona?: string;
12
+ harnessSourcePrompt?: string;
13
+ webSurfacePrompt?: string;
11
14
  systemPrompt?: string;
12
15
  promptEnabled: boolean;
13
16
  terminalToolsEnabled: boolean;
@@ -29,25 +32,32 @@ declare const en: {
29
32
  readonly contextRestore: "Restore model default";
30
33
  readonly promptCardTitle: "Codex Harness";
31
34
  readonly promptCardDescription: "Choose Codex capabilities and customize the operating prompt.";
32
- readonly capabilitiesLabel: "Codex mode capabilities";
35
+ readonly codexOnlyCapabilitiesLabel: "Codex mode only";
36
+ readonly otherCapabilitiesLabel: "Additional capabilities";
33
37
  readonly capabilityPrompt: "Codex operating prompt";
34
- readonly capabilityPromptHint: "Inject the editable instructions and persona-first prompt layout in Codex mode.";
38
+ readonly capabilityPromptHint: "Inject the editable instructions and persona-first prompt layout.";
35
39
  readonly capabilityTerminal: "Terminal tools";
36
- readonly capabilityTerminalHint: "Expose exec_command and write_stdin in Codex mode.";
40
+ readonly capabilityTerminalHint: "Expose exec_command and write_stdin.";
37
41
  readonly capabilityPatch: "Patch tool";
38
- readonly capabilityPatchHint: "Expose apply_patch in Codex mode, using the native Responses grammar when supported.";
42
+ readonly capabilityPatchHint: "Expose apply_patch, using the native Responses grammar when supported.";
39
43
  readonly capabilityPlan: "Plan tool";
40
- readonly capabilityPlanHint: "Expose update_plan for implementation task tracking in Codex mode.";
44
+ readonly capabilityPlanHint: "Expose update_plan for implementation task tracking.";
41
45
  readonly capabilityWebSearch: "Hosted web search";
42
46
  readonly capabilityWebSearchHint: "Use the provider-native Responses web_search tool when available.";
43
47
  readonly capabilityCompaction: "Remote compaction";
44
48
  readonly capabilityCompactionHint: "Prefer the provider Responses compact endpoint before local compaction.";
45
49
  readonly capabilityActivity: "Activity indicator";
46
50
  readonly capabilityActivityHint: "Show request, reply, and compaction status beside the conversation.";
47
- readonly promptLabel: "System prompt";
48
- readonly promptHint: "This is the full prompt owned by this plugin. Persona and DSH tool guidance stay dynamic.";
49
- readonly promptOverridden: "Overridden";
50
- readonly promptReset: "Restore default";
51
+ readonly promptCustomizationLabel: "Prompt customization";
52
+ readonly personaLabel: "Persona";
53
+ readonly personaHint: "Deployment identity and role. Supports {{model}} and {{cwd}}.";
54
+ readonly sourcePromptLabel: "DSH Core source instructions";
55
+ readonly sourcePromptHint: "Guidance about the DSH checkout and working directory. Supports {{sourceRoot}}.";
56
+ readonly webPromptLabel: "DSH Core Web instructions";
57
+ readonly webPromptHint: "Guidance about this Web GUI, HMR, builds, and verification. Supports {{webUrl}}.";
58
+ readonly promptRestoreAll: "Restore all prompt defaults";
59
+ readonly promptLabel: "Codex operating prompt";
60
+ readonly promptHint: "This is the Codex operating prompt. Persona and DSH Core instructions are edited separately above.";
51
61
  readonly promptUnsaved: "Unsaved";
52
62
  readonly promptDiscard: "Discard";
53
63
  readonly promptSave: "Save";
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { useEffect, useLayoutEffect, useState } from 'react';
4
4
  import { createPortal } from 'react-dom';
5
5
  import { CODEX_CONTEXT_MAX, CODEX_CONTEXT_UNIT } from "../context.js";
6
- import { DEFAULT_CODEX_SYSTEM_PROMPT } from "../prompt.js";
6
+ import { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, } from "../prompt.js";
7
7
  import { modelActivity, sameModelActivity } from "./activity.js";
8
8
  const NS = 'codex';
9
9
  const SETTINGS_NAMESPACE = 'codex';
@@ -22,25 +22,32 @@ const en = {
22
22
  contextRestore: 'Restore model default',
23
23
  promptCardTitle: 'Codex Harness',
24
24
  promptCardDescription: 'Choose Codex capabilities and customize the operating prompt.',
25
- capabilitiesLabel: 'Codex mode capabilities',
25
+ codexOnlyCapabilitiesLabel: 'Codex mode only',
26
+ otherCapabilitiesLabel: 'Additional capabilities',
26
27
  capabilityPrompt: 'Codex operating prompt',
27
- capabilityPromptHint: 'Inject the editable instructions and persona-first prompt layout in Codex mode.',
28
+ capabilityPromptHint: 'Inject the editable instructions and persona-first prompt layout.',
28
29
  capabilityTerminal: 'Terminal tools',
29
- capabilityTerminalHint: 'Expose exec_command and write_stdin in Codex mode.',
30
+ capabilityTerminalHint: 'Expose exec_command and write_stdin.',
30
31
  capabilityPatch: 'Patch tool',
31
- capabilityPatchHint: 'Expose apply_patch in Codex mode, using the native Responses grammar when supported.',
32
+ capabilityPatchHint: 'Expose apply_patch, using the native Responses grammar when supported.',
32
33
  capabilityPlan: 'Plan tool',
33
- capabilityPlanHint: 'Expose update_plan for implementation task tracking in Codex mode.',
34
+ capabilityPlanHint: 'Expose update_plan for implementation task tracking.',
34
35
  capabilityWebSearch: 'Hosted web search',
35
36
  capabilityWebSearchHint: 'Use the provider-native Responses web_search tool when available.',
36
37
  capabilityCompaction: 'Remote compaction',
37
38
  capabilityCompactionHint: 'Prefer the provider Responses compact endpoint before local compaction.',
38
39
  capabilityActivity: 'Activity indicator',
39
40
  capabilityActivityHint: 'Show request, reply, and compaction status beside the conversation.',
40
- promptLabel: 'System prompt',
41
- promptHint: 'This is the full prompt owned by this plugin. Persona and DSH tool guidance stay dynamic.',
42
- promptOverridden: 'Overridden',
43
- promptReset: 'Restore default',
41
+ promptCustomizationLabel: 'Prompt customization',
42
+ personaLabel: 'Persona',
43
+ personaHint: 'Deployment identity and role. Supports {{model}} and {{cwd}}.',
44
+ sourcePromptLabel: 'DSH Core source instructions',
45
+ sourcePromptHint: 'Guidance about the DSH checkout and working directory. Supports {{sourceRoot}}.',
46
+ webPromptLabel: 'DSH Core Web instructions',
47
+ webPromptHint: 'Guidance about this Web GUI, HMR, builds, and verification. Supports {{webUrl}}.',
48
+ promptRestoreAll: 'Restore all prompt defaults',
49
+ promptLabel: 'Codex operating prompt',
50
+ promptHint: 'This is the Codex operating prompt. Persona and DSH Core instructions are edited separately above.',
44
51
  promptUnsaved: 'Unsaved',
45
52
  promptDiscard: 'Discard',
46
53
  promptSave: 'Save',
@@ -64,25 +71,32 @@ const zh = {
64
71
  contextRestore: '\u6062\u590d\u6a21\u578b\u9ed8\u8ba4\u503c',
65
72
  promptCardTitle: 'Codex Harness',
66
73
  promptCardDescription: '\u9009\u62e9 Codex \u80fd\u529b\u5e76\u81ea\u5b9a\u4e49\u5b8c\u6574\u7684\u64cd\u4f5c\u63d0\u793a\u8bcd\u3002',
67
- capabilitiesLabel: 'Codex \u6a21\u5f0f\u80fd\u529b',
74
+ codexOnlyCapabilitiesLabel: '\u4ec5\u5728 Codex \u6a21\u5f0f\u4e0b',
75
+ otherCapabilitiesLabel: '\u5176\u4ed6\u80fd\u529b',
68
76
  capabilityPrompt: 'Codex \u64cd\u4f5c\u63d0\u793a\u8bcd',
69
- capabilityPromptHint: '\u4ec5\u5728 Codex \u6a21\u5f0f\u6ce8\u5165\u53ef\u7f16\u8f91\u6307\u4ee4\uff0c\u5e76\u5c06 Persona \u653e\u5728\u63d0\u793a\u8bcd\u9996\u4f4d\u3002',
77
+ capabilityPromptHint: '\u6ce8\u5165\u53ef\u7f16\u8f91\u6307\u4ee4\uff0c\u5e76\u5c06 Persona \u653e\u5728\u63d0\u793a\u8bcd\u9996\u4f4d\u3002',
70
78
  capabilityTerminal: '\u7ec8\u7aef\u5de5\u5177',
71
- capabilityTerminalHint: '\u4ec5\u5728 Codex \u6a21\u5f0f\u63d0\u4f9b exec_command \u548c write_stdin\u3002',
79
+ capabilityTerminalHint: '\u63d0\u4f9b exec_command \u548c write_stdin\u3002',
72
80
  capabilityPatch: '\u8865\u4e01\u5de5\u5177',
73
- capabilityPatchHint: '\u4ec5\u5728 Codex \u6a21\u5f0f\u63d0\u4f9b apply_patch\uff0c\u5e76\u5728\u652f\u6301\u65f6\u4f7f\u7528 Responses \u539f\u751f\u8bed\u6cd5\u3002',
81
+ capabilityPatchHint: '\u63d0\u4f9b apply_patch\uff0c\u5e76\u5728\u652f\u6301\u65f6\u4f7f\u7528 Responses \u539f\u751f\u8bed\u6cd5\u3002',
74
82
  capabilityPlan: '\u8ba1\u5212\u5de5\u5177',
75
- capabilityPlanHint: '\u4ec5\u5728 Codex \u6a21\u5f0f\u63d0\u4f9b update_plan\uff0c\u7528\u4e8e\u8ddf\u8e2a\u5b9e\u65bd\u4efb\u52a1\u3002',
83
+ capabilityPlanHint: '\u63d0\u4f9b update_plan\uff0c\u7528\u4e8e\u8ddf\u8e2a\u5b9e\u65bd\u4efb\u52a1\u3002',
76
84
  capabilityWebSearch: '\u6258\u7ba1\u7f51\u7edc\u641c\u7d22',
77
85
  capabilityWebSearchHint: '\u53ef\u7528\u65f6\u4f7f\u7528\u63d0\u4f9b\u5546\u539f\u751f\u7684 Responses web_search \u5de5\u5177\u3002',
78
86
  capabilityCompaction: '\u8fdc\u7a0b\u4e0a\u4e0b\u6587\u538b\u7f29',
79
87
  capabilityCompactionHint: '\u4f18\u5148\u8c03\u7528\u63d0\u4f9b\u5546\u7684 Responses compact \u7aef\u70b9\uff0c\u5931\u8d25\u65f6\u56de\u9000\u672c\u5730\u538b\u7f29\u3002',
80
88
  capabilityActivity: '\u6d3b\u52a8\u72b6\u6001',
81
89
  capabilityActivityHint: '\u5728\u5bf9\u8bdd\u65c1\u663e\u793a\u8bf7\u6c42\u3001\u56de\u590d\u548c\u538b\u7f29\u72b6\u6001\u3002',
82
- promptLabel: '\u7cfb\u7edf\u63d0\u793a\u8bcd',
83
- promptHint: '\u8fd9\u662f\u672c\u63d2\u4ef6\u8d1f\u8d23\u7684\u5168\u90e8\u63d0\u793a\u8bcd\uff1bPersona \u548c DSH \u5de5\u5177\u6307\u5bfc\u4ecd\u4f1a\u52a8\u6001\u6ce8\u5165\u3002',
84
- promptOverridden: '\u5df2\u8986\u76d6',
85
- promptReset: '\u6062\u590d\u9ed8\u8ba4',
90
+ promptCustomizationLabel: '\u63d0\u793a\u8bcd\u5b9a\u5236',
91
+ personaLabel: 'Persona',
92
+ personaHint: '\u5b9a\u4e49 Agent \u7684\u8eab\u4efd\u4e0e\u89d2\u8272\uff0c\u652f\u6301 {{model}} \u548c {{cwd}}\u3002',
93
+ sourcePromptLabel: 'DSH Core \u6e90\u7801\u8bf4\u660e',
94
+ sourcePromptHint: '\u8bf4\u660e DSH \u6e90\u7801\u68c0\u51fa\u76ee\u5f55\u4e0e\u5de5\u4f5c\u76ee\u5f55\uff0c\u652f\u6301 {{sourceRoot}}\u3002',
95
+ webPromptLabel: 'DSH Core Web \u8bf4\u660e',
96
+ webPromptHint: '\u8bf4\u660e Web GUI\u3001HMR\u3001\u6784\u5efa\u4e0e\u9a8c\u8bc1\uff0c\u652f\u6301 {{webUrl}}\u3002',
97
+ promptRestoreAll: '\u6062\u590d\u6240\u6709\u63d0\u793a\u8bcd\u9ed8\u8ba4\u503c',
98
+ promptLabel: 'Codex \u64cd\u4f5c\u63d0\u793a\u8bcd',
99
+ promptHint: '\u8fd9\u662f Codex \u64cd\u4f5c\u63d0\u793a\u8bcd\u3002Persona \u548c DSH Core \u8bf4\u660e\u5728\u4e0a\u65b9\u5206\u522b\u7f16\u8f91\u3002',
86
100
  promptUnsaved: '\u672a\u4fdd\u5b58',
87
101
  promptDiscard: '\u653e\u5f03',
88
102
  promptSave: '\u4fdd\u5b58',
@@ -101,12 +115,6 @@ function promptFromLayer(layer) {
101
115
  const value = layer['systemPrompt'];
102
116
  return typeof value === 'string' ? value : undefined;
103
117
  }
104
- function hasPromptOverride(layer) {
105
- return typeof layer === 'object'
106
- && layer !== null
107
- && !Array.isArray(layer)
108
- && Object.hasOwn(layer, 'systemPrompt');
109
- }
110
118
  function CapabilityToggle({ field, label, hint, enabled, disabled, setSetting, }) {
111
119
  return (_jsxs("label", { style: {
112
120
  display: 'flex',
@@ -116,35 +124,94 @@ function CapabilityToggle({ field, label, hint, enabled, disabled, setSetting, }
116
124
  cursor: disabled ? 'default' : 'pointer',
117
125
  }, children: [_jsxs("span", { style: { flex: 1, minWidth: 0, display: 'grid', gap: 2 }, children: [_jsx("strong", { style: { fontSize: 13, fontWeight: 500 }, children: label }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 12, lineHeight: 1.45 }, children: hint })] }), _jsx("input", { type: "checkbox", role: "switch", checked: enabled, disabled: disabled, "aria-label": label, onChange: event => { void setSetting(field, event.target.checked); }, style: { marginTop: 3, accentColor: 'var(--dsw-static-blue-500)' } })] }));
118
126
  }
127
+ /** Visually separate capability scope while keeping the host's light settings style. */
128
+ function CapabilityGroup({ label, children, accent }) {
129
+ return (_jsxs("section", { style: {
130
+ display: 'grid',
131
+ gap: 4,
132
+ }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 7, paddingLeft: 2 }, children: [_jsx("span", { "aria-hidden": "true", style: {
133
+ width: 6,
134
+ height: 6,
135
+ flex: '0 0 auto',
136
+ borderRadius: 999,
137
+ background: accent,
138
+ } }), _jsx("strong", { style: {
139
+ color: 'var(--dsw-alias-label-secondary)',
140
+ fontSize: 14,
141
+ fontWeight: 600,
142
+ letterSpacing: '0.01em',
143
+ }, children: label })] }), _jsx("div", { style: {
144
+ display: 'grid',
145
+ marginLeft: 5,
146
+ paddingLeft: 12,
147
+ }, children: children })] }));
148
+ }
149
+ function PromptEditor({ id, label, hint, value, writable, saving, minHeight, onChange, }) {
150
+ return (_jsxs("div", { style: { display: 'grid', gap: 5 }, children: [_jsx("label", { htmlFor: id, style: { fontSize: 13, fontWeight: 500 }, children: label }), _jsx("textarea", { id: id, value: value, disabled: !writable || saving, onChange: event => { onChange(event.target.value); }, spellCheck: false, style: {
151
+ boxSizing: 'border-box',
152
+ width: '100%',
153
+ minHeight,
154
+ resize: 'vertical',
155
+ padding: 10,
156
+ border: '1px solid var(--dsw-alias-border-l2)',
157
+ borderRadius: 8,
158
+ background: 'var(--dsw-alias-bg-layer-3)',
159
+ color: 'var(--dsw-alias-label-primary)',
160
+ font: 'inherit',
161
+ fontSize: 12,
162
+ lineHeight: 1.5,
163
+ } }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 11, lineHeight: 1.45 }, children: hint })] }));
164
+ }
119
165
  /** Full-prompt editor contributed to Settings > Plugins. */
120
166
  export function PromptSettingsCard(props) {
121
167
  const { useSettings, setSetting, unsetSetting, t } = props;
122
168
  const snapshot = useSettings(state => state);
169
+ const currentPersona = snapshot.value?.persona ?? DEFAULT_CODEX_PERSONA;
170
+ const currentSourcePrompt = snapshot.value?.harnessSourcePrompt ?? DEFAULT_DSH_CORE_SOURCE_PROMPT;
171
+ const currentWebPrompt = snapshot.value?.webSurfacePrompt ?? DEFAULT_DSH_CORE_WEB_PROMPT;
123
172
  const current = snapshot.value?.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT;
124
173
  const inherited = promptFromLayer(snapshot.base) ?? DEFAULT_CODEX_SYSTEM_PROMPT;
125
- const overridden = hasPromptOverride(snapshot.user);
126
- const capabilities = [
174
+ const codexOnlyCapabilities = [
127
175
  { field: 'promptEnabled', label: 'capabilityPrompt', hint: 'capabilityPromptHint' },
128
176
  { field: 'terminalToolsEnabled', label: 'capabilityTerminal', hint: 'capabilityTerminalHint' },
129
177
  { field: 'patchToolEnabled', label: 'capabilityPatch', hint: 'capabilityPatchHint' },
130
178
  { field: 'planToolEnabled', label: 'capabilityPlan', hint: 'capabilityPlanHint' },
179
+ ];
180
+ const otherCapabilities = [
131
181
  { field: 'hostedWebSearchEnabled', label: 'capabilityWebSearch', hint: 'capabilityWebSearchHint' },
132
182
  { field: 'remoteCompactionEnabled', label: 'capabilityCompaction', hint: 'capabilityCompactionHint' },
133
183
  { field: 'activityIndicatorEnabled', label: 'capabilityActivity', hint: 'capabilityActivityHint' },
134
184
  ];
135
185
  const [open, setOpen] = useState(false);
186
+ const [personaDraft, setPersonaDraft] = useState(currentPersona);
187
+ const [sourcePromptDraft, setSourcePromptDraft] = useState(currentSourcePrompt);
188
+ const [webPromptDraft, setWebPromptDraft] = useState(currentWebPrompt);
136
189
  const [draft, setDraft] = useState(current);
137
190
  const [saving, setSaving] = useState(false);
138
191
  const [failed, setFailed] = useState(false);
139
- useEffect(() => { setDraft(current); }, [current]);
192
+ useEffect(() => {
193
+ setPersonaDraft(currentPersona);
194
+ setSourcePromptDraft(currentSourcePrompt);
195
+ setWebPromptDraft(currentWebPrompt);
196
+ setDraft(current);
197
+ }, [current, currentPersona, currentSourcePrompt, currentWebPrompt]);
140
198
  if (snapshot.status === 'unavailable')
141
199
  return null;
142
- const dirty = draft !== current;
200
+ const dirty = personaDraft !== currentPersona
201
+ || sourcePromptDraft !== currentSourcePrompt
202
+ || webPromptDraft !== currentWebPrompt
203
+ || draft !== current;
204
+ const renderCapability = (capability) => (_jsx(CapabilityToggle, { field: capability.field, label: t(capability.label), hint: t(capability.hint), enabled: snapshot.value?.[capability.field] ?? true, disabled: !snapshot.writable || saving, setSetting: setSetting }, capability.field));
143
205
  const save = async () => {
144
206
  setSaving(true);
145
207
  setFailed(false);
146
208
  try {
147
- await setSetting('systemPrompt', draft);
209
+ await Promise.all([
210
+ setSetting('persona', personaDraft),
211
+ setSetting('harnessSourcePrompt', sourcePromptDraft),
212
+ setSetting('webSurfacePrompt', webPromptDraft),
213
+ setSetting('systemPrompt', draft),
214
+ ]);
148
215
  }
149
216
  catch {
150
217
  setFailed(true);
@@ -156,12 +223,21 @@ export function PromptSettingsCard(props) {
156
223
  const reset = async () => {
157
224
  setSaving(true);
158
225
  setFailed(false);
226
+ setPersonaDraft(DEFAULT_CODEX_PERSONA);
227
+ setSourcePromptDraft(DEFAULT_DSH_CORE_SOURCE_PROMPT);
228
+ setWebPromptDraft(DEFAULT_DSH_CORE_WEB_PROMPT);
159
229
  setDraft(inherited);
160
230
  try {
161
231
  await unsetSetting('systemPrompt');
232
+ await unsetSetting('persona');
233
+ await unsetSetting('harnessSourcePrompt');
234
+ await unsetSetting('webSurfacePrompt');
162
235
  }
163
236
  catch {
164
237
  setFailed(true);
238
+ setPersonaDraft(currentPersona);
239
+ setSourcePromptDraft(currentSourcePrompt);
240
+ setWebPromptDraft(currentWebPrompt);
165
241
  setDraft(current);
166
242
  }
167
243
  finally {
@@ -192,33 +268,12 @@ export function PromptSettingsCard(props) {
192
268
  background: 'var(--dsw-alias-bg-module-platform)',
193
269
  color: 'var(--dsw-alias-label-secondary)',
194
270
  fontSize: 11,
195
- }, children: t('promptUnsaved') })), _jsx("span", { "aria-hidden": "true", style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 16 }, children: open ? '-' : '+' })] }), open && (_jsxs("div", { style: { borderTop: '1px solid var(--dsw-alias-border-l2)', margin: '0 16px', padding: '12px 0' }, children: [!snapshot.writable && (_jsx("p", { style: { margin: '0 0 10px', color: 'var(--dsw-alias-label-tertiary)', fontSize: 12 }, children: t('promptReadOnly') })), _jsx("strong", { style: { display: 'block', marginBottom: 4, fontSize: 13 }, children: t('capabilitiesLabel') }), _jsx("div", { style: { display: 'grid', marginBottom: 14 }, children: capabilities.map(capability => (_jsx(CapabilityToggle, { field: capability.field, label: t(capability.label), hint: t(capability.hint), enabled: snapshot.value?.[capability.field] ?? true, disabled: !snapshot.writable || saving, setSetting: setSetting }, capability.field))) }), _jsxs("div", { style: {
196
- display: 'flex',
197
- alignItems: 'center',
198
- gap: 8,
199
- marginBottom: 7,
271
+ }, children: t('promptUnsaved') })), _jsx("span", { "aria-hidden": "true", style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 16 }, children: open ? '-' : '+' })] }), open && (_jsxs("div", { style: { borderTop: '1px solid var(--dsw-alias-border-l2)', margin: '0 16px', padding: '12px 0' }, children: [!snapshot.writable && (_jsx("p", { style: { margin: '0 0 10px', color: 'var(--dsw-alias-label-tertiary)', fontSize: 12 }, children: t('promptReadOnly') })), _jsxs("div", { style: { display: 'grid', gap: 16, marginBottom: 14 }, children: [_jsx(CapabilityGroup, { label: t('codexOnlyCapabilitiesLabel'), accent: "var(--dsw-static-blue-500)", children: codexOnlyCapabilities.map(renderCapability) }), _jsx(CapabilityGroup, { label: t('otherCapabilitiesLabel'), accent: "var(--dsw-alias-label-tertiary)", children: otherCapabilities.map(renderCapability) })] }), _jsxs("div", { style: {
272
+ display: 'grid',
273
+ gap: 14,
200
274
  paddingTop: 12,
201
275
  borderTop: '1px solid var(--dsw-alias-border-l2)',
202
- }, children: [_jsx("label", { htmlFor: "codex-system-prompt", style: { flex: 1, fontSize: 13, fontWeight: 500 }, children: t('promptLabel') }), overridden && (_jsxs(_Fragment, { children: [_jsx("span", { style: {
203
- borderRadius: 999,
204
- padding: '1px 8px',
205
- background: 'var(--dsw-alias-bg-module-platform)',
206
- color: 'var(--dsw-alias-label-secondary)',
207
- fontSize: 11,
208
- }, children: t('promptOverridden') }), _jsx("button", { type: "button", disabled: !snapshot.writable || saving, onClick: () => { void reset(); }, style: { border: 0, background: 'none', color: 'var(--dsw-alias-label-secondary)', font: 'inherit', fontSize: 12, cursor: 'pointer' }, children: t('promptReset') })] }))] }), _jsx("textarea", { id: "codex-system-prompt", value: draft, disabled: !snapshot.writable || saving, onChange: event => { setDraft(event.target.value); }, spellCheck: false, style: {
209
- boxSizing: 'border-box',
210
- width: '100%',
211
- minHeight: 320,
212
- resize: 'vertical',
213
- padding: 12,
214
- border: '1px solid var(--dsw-alias-border-l2)',
215
- borderRadius: 8,
216
- background: 'var(--dsw-alias-bg-layer-3)',
217
- color: 'var(--dsw-alias-label-primary)',
218
- fontFamily: 'ui-monospace, SFMono-Regular, Consolas, monospace',
219
- fontSize: 12,
220
- lineHeight: 1.55,
221
- } }), _jsx("p", { style: { margin: '6px 0 12px', color: 'var(--dsw-alias-label-tertiary)', fontSize: 12, lineHeight: 1.5 }, children: t('promptHint') }), _jsxs("div", { style: {
276
+ }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8 }, children: [_jsx("strong", { style: { flex: 1, fontSize: 13 }, children: t('promptCustomizationLabel') }), _jsx("button", { type: "button", disabled: !snapshot.writable || saving || !dirty, onClick: () => { void reset(); }, style: { border: 0, padding: 0, background: 'none', color: 'var(--dsw-alias-label-secondary)', font: 'inherit', fontSize: 11, cursor: 'pointer' }, children: t('promptRestoreAll') })] }), _jsx(PromptEditor, { id: "codex-persona", label: t('personaLabel'), hint: t('personaHint'), value: personaDraft, writable: snapshot.writable, saving: saving, minHeight: 84, onChange: setPersonaDraft }), _jsx(PromptEditor, { id: "codex-harness-source-prompt", label: t('sourcePromptLabel'), hint: t('sourcePromptHint'), value: sourcePromptDraft, writable: snapshot.writable, saving: saving, minHeight: 100, onChange: setSourcePromptDraft }), _jsx(PromptEditor, { id: "codex-web-surface-prompt", label: t('webPromptLabel'), hint: t('webPromptHint'), value: webPromptDraft, writable: snapshot.writable, saving: saving, minHeight: 120, onChange: setWebPromptDraft }), _jsx(PromptEditor, { id: "codex-system-prompt", label: t('promptLabel'), hint: t('promptHint'), value: draft, writable: snapshot.writable, saving: saving, minHeight: 320, onChange: setDraft })] }), _jsxs("div", { style: {
222
277
  display: 'flex',
223
278
  justifyContent: 'flex-end',
224
279
  alignItems: 'center',
@@ -5,7 +5,7 @@ import type { LlmCallConfig } from '@deepseek-ai/dsh-llm';
5
5
  import type { Session } from '@deepseek-ai/dsh-session';
6
6
  import type { PromptAssembly } from '@deepseek-ai/dsh-system-prompt';
7
7
  import type { CodexSettings } from './settings.ts';
8
- export { DEFAULT_CODEX_SYSTEM_PROMPT } from './prompt.ts';
8
+ export { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, } from './prompt.ts';
9
9
  export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA } from './settings.ts';
10
10
  export type { CodexSettings } from './settings.ts';
11
11
  export declare const name = "codex";
@@ -30,6 +30,12 @@ export interface Config {
30
30
  remoteCompact?: boolean;
31
31
  /** Complete plugin-owned Codex operating prompt. */
32
32
  systemPrompt?: string;
33
+ /** Deployment Persona template. */
34
+ persona?: string;
35
+ /** DSH Core source-checkout guidance template. */
36
+ harnessSourcePrompt?: string;
37
+ /** DSH Core Web GUI guidance template. */
38
+ webSurfacePrompt?: string;
33
39
  }
34
40
  /** Runtime configuration schema for the Codex tool bridge. */
35
41
  export declare const Config: z<Config>;