@shuind/dsh-codex-harness 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.
@@ -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,38 @@ 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.',
29
+ capabilityFast: 'Fast mode control',
30
+ capabilityFastHint: 'Show the Fast mode switch beside the conversation composer.',
31
+ compactRemote: 'Remote compaction',
32
+ compactRemoteHint: 'Use the provider remote compaction endpoint first.',
33
+ compactLocal: 'Local compaction',
34
+ compactLocalHint: 'Use the DSH text-summary compaction engine directly.',
28
35
  capabilityTerminal: 'Terminal tools',
29
- capabilityTerminalHint: 'Expose exec_command and write_stdin in Codex mode.',
36
+ capabilityTerminalHint: 'Expose exec_command and write_stdin.',
30
37
  capabilityPatch: 'Patch tool',
31
- capabilityPatchHint: 'Expose apply_patch in Codex mode, using the native Responses grammar when supported.',
38
+ capabilityPatchHint: 'Expose apply_patch, using the native Responses grammar when supported.',
32
39
  capabilityPlan: 'Plan tool',
33
- capabilityPlanHint: 'Expose update_plan for implementation task tracking in Codex mode.',
40
+ capabilityPlanHint: 'Expose update_plan for implementation task tracking.',
34
41
  capabilityWebSearch: 'Hosted web search',
35
42
  capabilityWebSearchHint: 'Use the provider-native Responses web_search tool when available.',
36
43
  capabilityCompaction: 'Remote compaction',
37
44
  capabilityCompactionHint: 'Prefer the provider Responses compact endpoint before local compaction.',
38
45
  capabilityActivity: 'Activity indicator',
39
46
  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',
47
+ promptCustomizationLabel: 'Prompt customization',
48
+ personaLabel: 'Persona',
49
+ personaHint: 'Deployment identity and role. Supports {{model}} and {{cwd}}.',
50
+ sourcePromptLabel: 'DSH Core source instructions',
51
+ sourcePromptHint: 'Guidance about the DSH checkout and working directory. Supports {{sourceRoot}}.',
52
+ webPromptLabel: 'DSH Core Web instructions',
53
+ webPromptHint: 'Guidance about this Web GUI, HMR, builds, and verification. Supports {{webUrl}}.',
54
+ promptRestoreAll: 'Restore all prompt defaults',
55
+ promptLabel: 'Codex operating prompt',
56
+ promptHint: 'This is the Codex operating prompt. Persona and DSH Core instructions are edited separately above.',
44
57
  promptUnsaved: 'Unsaved',
45
58
  promptDiscard: 'Discard',
46
59
  promptSave: 'Save',
@@ -64,25 +77,38 @@ const zh = {
64
77
  contextRestore: '\u6062\u590d\u6a21\u578b\u9ed8\u8ba4\u503c',
65
78
  promptCardTitle: 'Codex Harness',
66
79
  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',
80
+ codexOnlyCapabilitiesLabel: '\u4ec5\u5728 Codex \u6a21\u5f0f\u4e0b',
81
+ otherCapabilitiesLabel: '\u5176\u4ed6\u80fd\u529b',
68
82
  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',
83
+ capabilityPromptHint: '\u6ce8\u5165\u53ef\u7f16\u8f91\u6307\u4ee4\uff0c\u5e76\u5c06 Persona \u653e\u5728\u63d0\u793a\u8bcd\u9996\u4f4d\u3002',
84
+ capabilityFast: '\u663e\u793a Fast \u6a21\u5f0f',
85
+ capabilityFastHint: '\u5728\u5bf9\u8bdd\u8f93\u5165\u533a\u65c1\u663e\u793a Fast \u5f00\u5173\u3002',
86
+ compactRemote: '\u8fdc\u7a0b\u538b\u7f29',
87
+ compactRemoteHint: '\u4f18\u5148\u4f7f\u7528\u63d0\u4f9b\u5546\u7684\u8fdc\u7a0b\u538b\u7f29\u7aef\u70b9\u3002',
88
+ compactLocal: '\u672c\u5730\u538b\u7f29',
89
+ compactLocalHint: '\u76f4\u63a5\u4f7f\u7528 DSH \u6587\u672c\u6458\u8981\u538b\u7f29\u5f15\u64ce\u3002',
70
90
  capabilityTerminal: '\u7ec8\u7aef\u5de5\u5177',
71
- capabilityTerminalHint: '\u4ec5\u5728 Codex \u6a21\u5f0f\u63d0\u4f9b exec_command \u548c write_stdin\u3002',
91
+ capabilityTerminalHint: '\u63d0\u4f9b exec_command \u548c write_stdin\u3002',
72
92
  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',
93
+ capabilityPatchHint: '\u63d0\u4f9b apply_patch\uff0c\u5e76\u5728\u652f\u6301\u65f6\u4f7f\u7528 Responses \u539f\u751f\u8bed\u6cd5\u3002',
74
94
  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',
95
+ capabilityPlanHint: '\u63d0\u4f9b update_plan\uff0c\u7528\u4e8e\u8ddf\u8e2a\u5b9e\u65bd\u4efb\u52a1\u3002',
76
96
  capabilityWebSearch: '\u6258\u7ba1\u7f51\u7edc\u641c\u7d22',
77
97
  capabilityWebSearchHint: '\u53ef\u7528\u65f6\u4f7f\u7528\u63d0\u4f9b\u5546\u539f\u751f\u7684 Responses web_search \u5de5\u5177\u3002',
78
98
  capabilityCompaction: '\u8fdc\u7a0b\u4e0a\u4e0b\u6587\u538b\u7f29',
79
99
  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
100
  capabilityActivity: '\u6d3b\u52a8\u72b6\u6001',
81
101
  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',
102
+ promptCustomizationLabel: '\u63d0\u793a\u8bcd\u5b9a\u5236',
103
+ personaLabel: 'Persona',
104
+ personaHint: '\u5b9a\u4e49 Agent \u7684\u8eab\u4efd\u4e0e\u89d2\u8272\uff0c\u652f\u6301 {{model}} \u548c {{cwd}}\u3002',
105
+ sourcePromptLabel: 'DSH Core \u6e90\u7801\u8bf4\u660e',
106
+ sourcePromptHint: '\u8bf4\u660e DSH \u6e90\u7801\u68c0\u51fa\u76ee\u5f55\u4e0e\u5de5\u4f5c\u76ee\u5f55\uff0c\u652f\u6301 {{sourceRoot}}\u3002',
107
+ webPromptLabel: 'DSH Core Web \u8bf4\u660e',
108
+ webPromptHint: '\u8bf4\u660e Web GUI\u3001HMR\u3001\u6784\u5efa\u4e0e\u9a8c\u8bc1\uff0c\u652f\u6301 {{webUrl}}\u3002',
109
+ promptRestoreAll: '\u6062\u590d\u6240\u6709\u63d0\u793a\u8bcd\u9ed8\u8ba4\u503c',
110
+ promptLabel: 'Codex \u64cd\u4f5c\u63d0\u793a\u8bcd',
111
+ promptHint: '\u8fd9\u662f Codex \u64cd\u4f5c\u63d0\u793a\u8bcd\u3002Persona \u548c DSH Core \u8bf4\u660e\u5728\u4e0a\u65b9\u5206\u522b\u7f16\u8f91\u3002',
86
112
  promptUnsaved: '\u672a\u4fdd\u5b58',
87
113
  promptDiscard: '\u653e\u5f03',
88
114
  promptSave: '\u4fdd\u5b58',
@@ -101,12 +127,6 @@ function promptFromLayer(layer) {
101
127
  const value = layer['systemPrompt'];
102
128
  return typeof value === 'string' ? value : undefined;
103
129
  }
104
- function hasPromptOverride(layer) {
105
- return typeof layer === 'object'
106
- && layer !== null
107
- && !Array.isArray(layer)
108
- && Object.hasOwn(layer, 'systemPrompt');
109
- }
110
130
  function CapabilityToggle({ field, label, hint, enabled, disabled, setSetting, }) {
111
131
  return (_jsxs("label", { style: {
112
132
  display: 'flex',
@@ -116,35 +136,126 @@ function CapabilityToggle({ field, label, hint, enabled, disabled, setSetting, }
116
136
  cursor: disabled ? 'default' : 'pointer',
117
137
  }, 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
138
  }
139
+ /** Visually separate capability scope while keeping the host's light settings style. */
140
+ function CapabilityGroup({ id, label, children, accent }) {
141
+ const [open, setOpen] = useState(false);
142
+ const panelId = `${id}-panel`;
143
+ return (_jsxs("section", { style: {
144
+ display: 'grid',
145
+ gap: open ? 4 : 0,
146
+ }, children: [_jsxs("button", { type: "button", "aria-expanded": open, "aria-controls": panelId, onClick: () => { setOpen(!open); }, style: {
147
+ display: 'flex',
148
+ alignItems: 'center',
149
+ gap: 7,
150
+ width: '100%',
151
+ padding: 0,
152
+ border: 0,
153
+ background: 'none',
154
+ color: 'var(--dsw-alias-label-secondary)',
155
+ font: 'inherit',
156
+ textAlign: 'left',
157
+ cursor: 'pointer',
158
+ }, children: [_jsx("span", { "aria-hidden": "true", style: {
159
+ width: 6,
160
+ height: 6,
161
+ flex: '0 0 auto',
162
+ borderRadius: 999,
163
+ background: accent,
164
+ } }), _jsx("strong", { style: {
165
+ color: 'var(--dsw-alias-label-secondary)',
166
+ fontSize: 14,
167
+ fontWeight: 600,
168
+ letterSpacing: '0.01em',
169
+ }, children: label }), _jsx("span", { "aria-hidden": "true", style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 16 }, children: open ? '-' : '+' })] }), open && (_jsx("div", { id: panelId, style: {
170
+ display: 'grid',
171
+ marginLeft: 5,
172
+ paddingLeft: 12,
173
+ }, children: children }))] }));
174
+ }
175
+ function PromptEditor({ id, label, hint, value, writable, saving, minHeight, onChange, }) {
176
+ const [open, setOpen] = useState(false);
177
+ const labelId = `${id}-label`;
178
+ const panelId = `${id}-panel`;
179
+ return (_jsxs("div", { style: { display: 'grid', gap: open ? 8 : 0 }, children: [_jsxs("button", { type: "button", "aria-expanded": open, "aria-controls": panelId, onClick: () => { setOpen(!open); }, style: {
180
+ display: 'flex',
181
+ alignItems: 'center',
182
+ gap: 8,
183
+ width: '100%',
184
+ padding: 0,
185
+ border: 0,
186
+ background: 'none',
187
+ color: 'var(--dsw-alias-label-primary)',
188
+ font: 'inherit',
189
+ fontSize: 13,
190
+ fontWeight: 500,
191
+ textAlign: 'left',
192
+ cursor: 'pointer',
193
+ }, children: [_jsx("span", { id: labelId, style: { flex: 1 }, children: label }), _jsx("span", { "aria-hidden": "true", style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 16 }, children: open ? '-' : '+' })] }), open && (_jsxs("div", { id: panelId, style: { display: 'grid', gap: 5 }, children: [_jsx("textarea", { id: id, "aria-labelledby": labelId, value: value, disabled: !writable || saving, onChange: event => { onChange(event.target.value); }, spellCheck: false, style: {
194
+ boxSizing: 'border-box',
195
+ width: '100%',
196
+ minHeight,
197
+ resize: 'vertical',
198
+ padding: 10,
199
+ border: '1px solid var(--dsw-alias-border-l2)',
200
+ borderRadius: 8,
201
+ background: 'var(--dsw-alias-bg-layer-3)',
202
+ color: 'var(--dsw-alias-label-primary)',
203
+ font: 'inherit',
204
+ fontSize: 12,
205
+ lineHeight: 1.5,
206
+ } }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 11, lineHeight: 1.45 }, children: hint })] }))] }));
207
+ }
119
208
  /** Full-prompt editor contributed to Settings > Plugins. */
120
209
  export function PromptSettingsCard(props) {
121
210
  const { useSettings, setSetting, unsetSetting, t } = props;
122
211
  const snapshot = useSettings(state => state);
212
+ const currentPersona = snapshot.value?.persona ?? DEFAULT_CODEX_PERSONA;
213
+ const currentSourcePrompt = snapshot.value?.harnessSourcePrompt ?? DEFAULT_DSH_CORE_SOURCE_PROMPT;
214
+ const currentWebPrompt = snapshot.value?.webSurfacePrompt ?? DEFAULT_DSH_CORE_WEB_PROMPT;
123
215
  const current = snapshot.value?.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT;
124
216
  const inherited = promptFromLayer(snapshot.base) ?? DEFAULT_CODEX_SYSTEM_PROMPT;
125
- const overridden = hasPromptOverride(snapshot.user);
126
- const capabilities = [
217
+ const codexOnlyCapabilities = [
218
+ { field: 'fastModeControlEnabled', label: 'capabilityFast', hint: 'capabilityFastHint' },
127
219
  { field: 'promptEnabled', label: 'capabilityPrompt', hint: 'capabilityPromptHint' },
128
220
  { field: 'terminalToolsEnabled', label: 'capabilityTerminal', hint: 'capabilityTerminalHint' },
129
221
  { field: 'patchToolEnabled', label: 'capabilityPatch', hint: 'capabilityPatchHint' },
130
222
  { field: 'planToolEnabled', label: 'capabilityPlan', hint: 'capabilityPlanHint' },
223
+ ];
224
+ const otherCapabilities = [
131
225
  { field: 'hostedWebSearchEnabled', label: 'capabilityWebSearch', hint: 'capabilityWebSearchHint' },
132
226
  { field: 'remoteCompactionEnabled', label: 'capabilityCompaction', hint: 'capabilityCompactionHint' },
133
227
  { field: 'activityIndicatorEnabled', label: 'capabilityActivity', hint: 'capabilityActivityHint' },
134
228
  ];
135
229
  const [open, setOpen] = useState(false);
230
+ const [personaDraft, setPersonaDraft] = useState(currentPersona);
231
+ const [sourcePromptDraft, setSourcePromptDraft] = useState(currentSourcePrompt);
232
+ const [webPromptDraft, setWebPromptDraft] = useState(currentWebPrompt);
136
233
  const [draft, setDraft] = useState(current);
137
234
  const [saving, setSaving] = useState(false);
138
235
  const [failed, setFailed] = useState(false);
139
- useEffect(() => { setDraft(current); }, [current]);
236
+ useEffect(() => {
237
+ setPersonaDraft(currentPersona);
238
+ setSourcePromptDraft(currentSourcePrompt);
239
+ setWebPromptDraft(currentWebPrompt);
240
+ setDraft(current);
241
+ }, [current, currentPersona, currentSourcePrompt, currentWebPrompt]);
140
242
  if (snapshot.status === 'unavailable')
141
243
  return null;
142
- const dirty = draft !== current;
244
+ const dirty = personaDraft !== currentPersona
245
+ || sourcePromptDraft !== currentSourcePrompt
246
+ || webPromptDraft !== currentWebPrompt
247
+ || draft !== current;
248
+ 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
249
  const save = async () => {
144
250
  setSaving(true);
145
251
  setFailed(false);
146
252
  try {
147
- await setSetting('systemPrompt', draft);
253
+ await Promise.all([
254
+ setSetting('persona', personaDraft),
255
+ setSetting('harnessSourcePrompt', sourcePromptDraft),
256
+ setSetting('webSurfacePrompt', webPromptDraft),
257
+ setSetting('systemPrompt', draft),
258
+ ]);
148
259
  }
149
260
  catch {
150
261
  setFailed(true);
@@ -156,12 +267,21 @@ export function PromptSettingsCard(props) {
156
267
  const reset = async () => {
157
268
  setSaving(true);
158
269
  setFailed(false);
270
+ setPersonaDraft(DEFAULT_CODEX_PERSONA);
271
+ setSourcePromptDraft(DEFAULT_DSH_CORE_SOURCE_PROMPT);
272
+ setWebPromptDraft(DEFAULT_DSH_CORE_WEB_PROMPT);
159
273
  setDraft(inherited);
160
274
  try {
161
275
  await unsetSetting('systemPrompt');
276
+ await unsetSetting('persona');
277
+ await unsetSetting('harnessSourcePrompt');
278
+ await unsetSetting('webSurfacePrompt');
162
279
  }
163
280
  catch {
164
281
  setFailed(true);
282
+ setPersonaDraft(currentPersona);
283
+ setSourcePromptDraft(currentSourcePrompt);
284
+ setWebPromptDraft(currentWebPrompt);
165
285
  setDraft(current);
166
286
  }
167
287
  finally {
@@ -192,33 +312,12 @@ export function PromptSettingsCard(props) {
192
312
  background: 'var(--dsw-alias-bg-module-platform)',
193
313
  color: 'var(--dsw-alias-label-secondary)',
194
314
  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,
315
+ }, 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, { id: "codex-only-capabilities", label: t('codexOnlyCapabilitiesLabel'), accent: "var(--dsw-static-blue-500)", children: codexOnlyCapabilities.map(renderCapability) }), _jsx(CapabilityGroup, { id: "other-capabilities", label: t('otherCapabilitiesLabel'), accent: "var(--dsw-alias-label-tertiary)", children: otherCapabilities.map(renderCapability) })] }), _jsxs("div", { style: {
316
+ display: 'grid',
317
+ gap: 14,
200
318
  paddingTop: 12,
201
319
  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: {
320
+ }, 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
321
  display: 'flex',
223
322
  justifyContent: 'flex-end',
224
323
  alignItems: 'center',
@@ -231,7 +330,10 @@ export function PromptSettingsCard(props) {
231
330
  function FastModeFallback(props) {
232
331
  const { useSettings, setSetting, t } = props;
233
332
  const snapshot = useSettings(state => state);
333
+ const visible = snapshot.value?.fastModeControlEnabled ?? true;
234
334
  const fast = snapshot.value?.fast ?? false;
335
+ if (!visible)
336
+ return null;
235
337
  return (_jsxs("button", { type: "button", role: "switch", disabled: snapshot.writable === false, "aria-checked": fast, "aria-label": fast ? t('fastOn') : t('fastOff'), title: fast ? t('fastOn') : t('fastOff'), onClick: () => { void setSetting('fast', !fast); }, style: {
236
338
  boxSizing: 'border-box',
237
339
  display: 'inline-flex',
@@ -466,10 +568,35 @@ function LegacyOverlay(props) {
466
568
  const contextWindow = contextWindowFromProjection(useProjection);
467
569
  return (_jsxs(_Fragment, { children: [contextDialog !== null && createPortal(_jsx(ContextSizeControl, { contextWindow: contextWindow, sessionId: sessionId, useSessions: useSessions, useSettings: useSettings, setSetting: setSetting, unsetSetting: unsetSetting, t: t }), contextDialog, 'codex-context-size'), turnStatusPosition !== null && typeof document !== 'undefined' && document.body !== null && createPortal(_jsx(ActivityLine, { sessionId: sessionId, useSession: useSession, useSessions: useSessions, useProjection: useProjection, useSettings: useSettings, t: t, position: turnStatusPosition }), document.body, 'codex-activity')] }));
468
570
  }
469
- export const inject = ['slots', 'locale', 'settingsScope'];
571
+ export const inject = ['commandUi', 'sessions', 'slots', 'locale', 'settingsScope'];
470
572
  /** Mount request controls and the plugin settings card through shared slots. */
471
573
  export function apply(ctx) {
472
574
  ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'codex client: dictionaries');
575
+ const commandUi = ctx.get('commandUi');
576
+ const sessions = ctx.get('sessions');
577
+ const t = ctx.locale.bind(NS);
578
+ const sessionFor = (session) => sessions.binding(session.sessionId)?.session;
579
+ ctx.effect(() => commandUi.decorate({
580
+ name: 'compact',
581
+ available: session => sessionFor(session) !== undefined,
582
+ ui: {
583
+ kind: 'popupSelect',
584
+ options: async () => [
585
+ { id: 'remote', label: t('compactRemote'), detail: t('compactRemoteHint') },
586
+ { id: 'local', label: t('compactLocal'), detail: t('compactLocalHint') },
587
+ ],
588
+ onSelect: async (option, session) => {
589
+ const live = sessionFor(session);
590
+ if (live === undefined)
591
+ throw new Error('this session is not materialized yet');
592
+ const result = await live.command(`/compact ${option.id}`);
593
+ if (!result.ok)
594
+ throw new Error(`compact mode switch failed: ${result.error.code}: ${result.error.message}`);
595
+ if (!result.value.matched)
596
+ throw new Error('the host offers no /compact command');
597
+ },
598
+ },
599
+ }), 'codex client: /compact mode picker');
473
600
  const settings = ctx.settingsScope.bind({ namespace: SETTINGS_NAMESPACE });
474
601
  const injected = () => ({
475
602
  hooks: { settings },
@@ -0,0 +1,13 @@
1
+ /** Codex-aware `/compact` command with an optional transport preference. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ /** Replace the Core command inside the Codex compaction scope. */
4
+ export declare function apply(ctx: Context): void;
5
+ export declare const name = "compact-command";
6
+ export declare const inject: string[];
7
+ declare const _default: {
8
+ name: string;
9
+ inject: string[];
10
+ apply: typeof apply;
11
+ };
12
+ export default _default;
13
+ //# sourceMappingURL=compact-command.d.ts.map
@@ -0,0 +1,79 @@
1
+ /** Codex-aware `/compact` command with an optional transport preference. */
2
+ import { ManualCompactionError } from '@deepseek-ai/dsh-compaction';
3
+ import { runCodexCompactionMode } from "./compaction.js";
4
+ const USAGE = 'Usage: /compact [remote|local]';
5
+ /** Convert expected backend failures into the same concise command results as DSH Core. */
6
+ function expectedFailure(error) {
7
+ switch (error.code) {
8
+ case 'busy':
9
+ return { kind: 'error', text: 'Compaction is unavailable because this process has an active compaction, or the agent is not idle.' };
10
+ case 'cancelled':
11
+ return { kind: 'error', text: 'Compaction cancelled.' };
12
+ case 'changed':
13
+ return { kind: 'error', text: 'Compaction could not replace the selected history because it changed. The conversation is unchanged.' };
14
+ case 'summary':
15
+ return { kind: 'error', text: 'Compaction could not produce a useful summary. The conversation is unchanged; the attempt is recorded in the session log.' };
16
+ case 'commit':
17
+ return { kind: 'error', text: 'Compaction did not finish cleanly; inspect the current session state before retrying.' };
18
+ case 'persistence':
19
+ return { kind: 'error', text: 'Compaction finished, but the session could not be saved.' };
20
+ default:
21
+ return { kind: 'error', text: `Unknown compaction failure: ${String(error.code)}` };
22
+ }
23
+ }
24
+ function modeOf(rawInput) {
25
+ const value = rawInput.trim().toLowerCase();
26
+ if (value === '')
27
+ return undefined;
28
+ if (value === 'remote' || value === 'local')
29
+ return value;
30
+ return 'invalid';
31
+ }
32
+ async function executeCompact(ctx, invocation) {
33
+ const mode = modeOf(invocation.rawInput);
34
+ if (mode === 'invalid')
35
+ return { kind: 'error', text: USAGE };
36
+ const compact = () => ctx.compaction.compactNow(invocation.agent, invocation.signal, invocation.commandId);
37
+ try {
38
+ const result = mode === undefined ? await compact() : await runCodexCompactionMode(mode, compact);
39
+ if (result === null)
40
+ return { kind: 'success', text: 'No compactable history yet.' };
41
+ return {
42
+ kind: 'success',
43
+ text: `Compacted ${result.shadowedSeqs.length} history items (~${result.shadowedTokenCount} tokens).`,
44
+ sourceEventSeq: result.summarySeq,
45
+ };
46
+ }
47
+ catch (error) {
48
+ if (invocation.signal.aborted)
49
+ return { kind: 'error', text: 'Compaction cancelled.' };
50
+ if (error instanceof ManualCompactionError)
51
+ return expectedFailure(error);
52
+ throw error;
53
+ }
54
+ }
55
+ /** Replace the Core command inside the Codex compaction scope. */
56
+ export function apply(ctx) {
57
+ const commands = ctx.commands;
58
+ const active = new Set();
59
+ const handler = (invocation) => {
60
+ const operation = executeCompact(ctx, invocation);
61
+ active.add(operation);
62
+ const retire = () => { active.delete(operation); };
63
+ operation.then(retire, retire);
64
+ return operation;
65
+ };
66
+ ctx.effect(function* () {
67
+ yield async () => { await Promise.allSettled(active); };
68
+ yield commands.register({
69
+ name: 'compact',
70
+ description: 'Compact older conversation history, optionally using remote or local mode',
71
+ input: { hint: '[remote|local]' },
72
+ handler,
73
+ });
74
+ }, 'codex compact command lifecycle');
75
+ }
76
+ export const name = 'compact-command';
77
+ export const inject = ['commands', 'compaction'];
78
+ export default { name, inject, apply };
79
+ //# sourceMappingURL=compact-command.js.map
@@ -3,6 +3,12 @@ import { Context } from '@deepseek-ai/cordis';
3
3
  import BasicCompactionEngine from '@deepseek-ai/dsh-compaction-basic';
4
4
  import type { CompactionResult, CompactionTrigger } from '@deepseek-ai/dsh-compaction';
5
5
  import type { Agent } from '@deepseek-ai/dsh-agent';
6
+ /** Per-command compaction preference propagated into the LLM stream seam. */
7
+ export type CodexCompactionMode = 'remote' | 'local';
8
+ /** Run one manual compaction with an explicit local/remote preference. */
9
+ export declare function runCodexCompactionMode<T>(mode: CodexCompactionMode, task: () => Promise<T>): Promise<T>;
10
+ /** Read the explicit preference for the current compaction stream, if any. */
11
+ export declare function codexCompactionMode(): CodexCompactionMode | undefined;
6
12
  /**
7
13
  * Keep the upstream compaction policy, retention, overflow recovery, and
8
14
  * transaction implementation intact. The scoped LLM seam changes only the
@@ -2,6 +2,15 @@
2
2
  import { AsyncLocalStorage } from 'node:async_hooks';
3
3
  import BasicCompactionEngine from '@deepseek-ai/dsh-compaction-basic';
4
4
  import { settingsNamespace } from '@deepseek-ai/dsh-settings';
5
+ const COMPACTION_MODE = new AsyncLocalStorage();
6
+ /** Run one manual compaction with an explicit local/remote preference. */
7
+ export function runCodexCompactionMode(mode, task) {
8
+ return COMPACTION_MODE.run(mode, task);
9
+ }
10
+ /** Read the explicit preference for the current compaction stream, if any. */
11
+ export function codexCompactionMode() {
12
+ return COMPACTION_MODE.getStore();
13
+ }
5
14
  const CODEX_SETTINGS_NAMESPACE = settingsNamespace('codex');
6
15
  /** Codex context overrides apply only to GPT-compatible model routes. */
7
16
  function isGptModel(model) {
@@ -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>;