@shuind/dsh-codex-harness 0.2.16 → 0.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,16 @@
1
1
  export declare const presetEn: {
2
+ readonly peConnectionError: "Could not connect to the local service. Retry loading; if the connection still fails, reconnect the page.";
3
+ readonly peReadError: "Could not read this preset. Retry loading or refresh the preset list.";
4
+ readonly peRetryRead: "Retry loading";
5
+ readonly peReconnect: "Reconnect page";
6
+ readonly peSystemPrompt: "System prompt sections";
7
+ readonly peSectionsHint: "These templates contribute to this preset’s system prompt before the tools. Runtime variables, workspace instructions and plugin-provided guidance are assembled when the conversation runs.";
8
+ readonly peDynamicPrompt: "This field is an expression; it is preserved without executing it in the editor.";
9
+ readonly peDshSourcePrompt: "Tells the agent where the DSH source checkout is and keeps it separate from the current workspace. It is used when inspecting or extending DSH itself.";
10
+ readonly peDshWebPrompt: "Tells the agent which Web page it is talking through, what “this page” means, and when Web changes need a rebuild or refresh.";
11
+ readonly peSuppressed: "Not used";
12
+ readonly peCompletePersona: "This preset uses Persona as its entire system prompt, so this section is excluded.";
13
+ readonly peLoading: "Reading preset…";
2
14
  readonly peTitle: "Preset editor";
3
15
  readonly peHierarchy: "Codex mode and other presets are peers. Choose one to edit, or make an editable copy of a built-in preset first.";
4
16
  readonly peSelect: "Preset";
@@ -1,4 +1,16 @@
1
1
  export const presetEn = {
2
+ peConnectionError: 'Could not connect to the local service. Retry loading; if the connection still fails, reconnect the page.',
3
+ peReadError: 'Could not read this preset. Retry loading or refresh the preset list.',
4
+ peRetryRead: 'Retry loading',
5
+ peReconnect: 'Reconnect page',
6
+ peSystemPrompt: 'System prompt sections',
7
+ peSectionsHint: 'These templates contribute to this preset’s system prompt before the tools. Runtime variables, workspace instructions and plugin-provided guidance are assembled when the conversation runs.',
8
+ peDynamicPrompt: 'This field is an expression; it is preserved without executing it in the editor.',
9
+ peDshSourcePrompt: 'Tells the agent where the DSH source checkout is and keeps it separate from the current workspace. It is used when inspecting or extending DSH itself.',
10
+ peDshWebPrompt: 'Tells the agent which Web page it is talking through, what “this page” means, and when Web changes need a rebuild or refresh.',
11
+ peSuppressed: 'Not used',
12
+ peCompletePersona: 'This preset uses Persona as its entire system prompt, so this section is excluded.',
13
+ peLoading: 'Reading preset…',
2
14
  peTitle: 'Preset editor',
3
15
  peHierarchy: 'Codex mode and other presets are peers. Choose one to edit, or make an editable copy of a built-in preset first.',
4
16
  peSelect: 'Preset',
@@ -27,6 +39,18 @@ export const presetEn = {
27
39
  pmSave: 'Save changes',
28
40
  };
29
41
  export const presetZh = {
42
+ peConnectionError: '未能连接本地服务。请重试读取;如果仍然失败,请重新连接页面。',
43
+ peReadError: '无法读取这个预设,请重试读取或刷新预设列表。',
44
+ peRetryRead: '重试读取',
45
+ peReconnect: '重新连接页面',
46
+ peSystemPrompt: '系统提示词',
47
+ peSectionsHint: '这些模板共同组成当前预设在工具之前的系统提示词。运行时变量、工作区指令和插件提供的说明会在会话中组装。',
48
+ peDynamicPrompt: '此字段是动态表达式,编辑器保留原值,不执行表达式。',
49
+ peDshSourcePrompt: '告诉 Agent DSH 源码检出目录在哪里,并与当前工作区区分开;用于检查或扩展 DSH 本身。',
50
+ peDshWebPrompt: '告诉 Agent 当前通过哪个 Web 页面交互、“这个页面”指什么,以及 Web 修改何时需要重建或刷新。',
51
+ peSuppressed: '未使用',
52
+ peCompletePersona: '此预设将 Persona 作为完整系统提示词,因此不使用这一段。',
53
+ peLoading: '正在读取预设…',
30
54
  peTitle: '预设编辑',
31
55
  peHierarchy: 'Codex 模式和其它预设处于同一级。选择一个预设编辑;内置预设先创建可编辑副本。',
32
56
  peSelect: '选择预设',
@@ -1,6 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from 'react';
3
+ import { DEFAULT_CODEX_SYSTEM_PROMPT } from "../prompt.js";
4
+ import { isPresetConnectionError, readPresetWithRetry } from "./preset-requests.js";
3
5
  const catalogCache = new WeakMap();
6
+ const documentCache = new WeakMap();
4
7
  const CODEX_DEFAULT_ID = 'codex-collaboration';
5
8
  function unwrap(result) {
6
9
  if (result.ok)
@@ -12,7 +15,8 @@ function equalEditorState(a, b) {
12
15
  return a === b;
13
16
  return a.name === b.name && a.description === b.description && a.systemPrompt === b.systemPrompt
14
17
  && a.inheritPrompt === b.inheritPrompt && a.codex === b.codex
15
- && JSON.stringify(a.codexOptions) === JSON.stringify(b.codexOptions);
18
+ && JSON.stringify(a.codexOptions) === JSON.stringify(b.codexOptions)
19
+ && JSON.stringify(a.promptSections) === JSON.stringify(b.promptSections);
16
20
  }
17
21
  const styles = `
18
22
  .codex-preset-editor { display:grid; gap:12px; min-width:0; font-size:13px; }
@@ -42,8 +46,13 @@ export function PresetManagerCard({ presetManager, t }) {
42
46
  const [codexEnabled, setCodexEnabled] = useState(false);
43
47
  const [busy, setBusy] = useState(false);
44
48
  const [error, setError] = useState('');
49
+ const [errorAction, setErrorAction] = useState('read');
45
50
  const [notice, setNotice] = useState('');
46
51
  const alive = useRef(true);
52
+ const request = useRef(0);
53
+ if (!documentCache.has(presetManager))
54
+ documentCache.set(presetManager, new Map());
55
+ const cache = documentCache.get(presetManager);
47
56
  const remote = presetManager.remote.codexPresetEditor;
48
57
  const dirty = !!draft && (!original || !equalEditorState(draft, original) || codexEnabled !== draft.codex);
49
58
  async function run(work) {
@@ -69,9 +78,13 @@ export function PresetManagerCard({ presetManager, t }) {
69
78
  return;
70
79
  if (confirmDirty && dirty && !window.confirm(t('pmDiscard')))
71
80
  return;
72
- await run(async () => {
73
- const value = unwrap(await remote.read(id));
74
- if (!alive.current)
81
+ const ticket = ++request.current;
82
+ setSelectedId(id);
83
+ setError('');
84
+ setNotice('');
85
+ setErrorAction('read');
86
+ const accept = (value) => {
87
+ if (!alive.current || ticket !== request.current)
75
88
  return;
76
89
  setSelectedId(id);
77
90
  setSourceId(id);
@@ -79,10 +92,33 @@ export function PresetManagerCard({ presetManager, t }) {
79
92
  setDraft(value);
80
93
  setCopyMode(false);
81
94
  setCodexEnabled(value.codex);
82
- });
95
+ };
96
+ const cached = cache.get(id);
97
+ if (cached && Date.now() - cached.time < 60_000) {
98
+ accept(cached.value);
99
+ return;
100
+ }
101
+ setDraft(undefined);
102
+ setOriginal(undefined);
103
+ setBusy(true);
104
+ try {
105
+ await presetManager.ready;
106
+ const value = await readPresetWithRetry(() => remote.read(id).then(unwrap), () => alive.current && ticket === request.current);
107
+ cache.set(id, { value, time: Date.now() });
108
+ accept(value);
109
+ }
110
+ catch (cause) {
111
+ if (alive.current && ticket === request.current)
112
+ setError(String(cause));
113
+ }
114
+ finally {
115
+ if (alive.current && ticket === request.current)
116
+ setBusy(false);
117
+ }
83
118
  }
84
119
  async function refresh() {
85
- const value = unwrap(await remote.catalog());
120
+ setErrorAction('read');
121
+ const value = await readPresetWithRetry(() => remote.catalog().then(unwrap), () => alive.current);
86
122
  if (!alive.current)
87
123
  return;
88
124
  catalogCache.set(presetManager, value);
@@ -111,8 +147,6 @@ export function PresetManagerCard({ presetManager, t }) {
111
147
  function beginCopy() {
112
148
  if (!draft || !sourceId)
113
149
  return;
114
- if (dirty && !window.confirm(t('pmDiscard')))
115
- return;
116
150
  setCopyMode(true);
117
151
  setCodexEnabled(draft.codex);
118
152
  setOriginal({ ...draft });
@@ -121,9 +155,11 @@ export function PresetManagerCard({ presetManager, t }) {
121
155
  function save() {
122
156
  if (!draft || busy || !draft.name.trim())
123
157
  return;
158
+ setErrorAction('save');
124
159
  void run(async () => {
125
160
  const options = codexEnabled ? draft.codexOptions : undefined;
126
161
  const payload = { name: draft.name, description: draft.description, systemPrompt: draft.systemPrompt,
162
+ promptSections: draft.promptSections.filter(section => section.editable && (codexEnabled || section.id !== 'codex:base')),
127
163
  inheritPrompt: draft.inheritPrompt, enableCodex: codexEnabled, ...(options === undefined ? {} : { codexOptions: options }) };
128
164
  const value = unwrap(await (copyMode
129
165
  ? remote.create({ ...payload, sourceId })
@@ -134,6 +170,7 @@ export function PresetManagerCard({ presetManager, t }) {
134
170
  setSourceId(value.id);
135
171
  setOriginal(value);
136
172
  setDraft(value);
173
+ cache.set(value.id, { value, time: Date.now() });
137
174
  setCopyMode(false);
138
175
  setCodexEnabled(value.codex);
139
176
  setNotice(t('peSaved'));
@@ -150,7 +187,31 @@ export function PresetManagerCard({ presetManager, t }) {
150
187
  const selectedRow = catalog?.presets.find(row => row.id === selectedId);
151
188
  const readOnly = !!draft && !draft.editable && !copyMode;
152
189
  const options = draft?.codexOptions;
153
- return _jsxs("section", { className: "codex-preset-editor", "aria-label": t('peTitle'), "aria-busy": busy, children: [_jsx("style", { children: styles }), _jsxs("div", { className: "pe-row", style: { justifyContent: 'space-between' }, children: [_jsx("strong", { children: t('peTitle') }), _jsx("button", { type: "button", disabled: busy, onClick: () => { void run(refresh); }, children: t('pmRefresh') })] }), _jsx("p", { children: t('peHierarchy') }), _jsxs("label", { children: [t('peSelect'), _jsxs("select", { value: selectedId, disabled: busy || !catalog, onChange: event => { void load(event.target.value); }, children: [_jsx("option", { value: "", children: t('peSelectPlaceholder') }), catalog?.presets.map(row => _jsxs("option", { value: row.id, children: [row.name, row.editable ? '' : ` · ${t('pmBuiltIn')}`] }, row.id))] })] }), selectedRow && _jsx("p", { children: selectedRow.editable ? t('peEditable') : t('peBuiltinEdit') }), error && _jsxs("div", { role: "alert", children: [_jsx("p", { children: error.includes('preset-conflict') ? t('pmConflict') : error.includes('invalid-preset-yaml') ? t('pmYamlError') : t('pmSaveError') }), _jsxs("details", { children: [_jsx("summary", { children: t('pmErrorDetails') }), _jsx("pre", { style: { whiteSpace: 'pre-wrap' }, children: error })] })] }), notice && _jsx("p", { role: "status", children: notice }), draft && _jsxs(_Fragment, { children: [_jsxs("label", { children: [t('pmName'), _jsx("input", { value: draft.name, maxLength: 200, disabled: busy || readOnly, onChange: event => patch({ name: event.target.value }) })] }), _jsxs("label", { children: [t('pmDescription'), _jsx("input", { value: draft.description, maxLength: 4000, disabled: busy || readOnly, onChange: event => patch({ description: event.target.value }) })] }), readOnly && _jsx("button", { type: "button", className: "pe-primary", disabled: busy || !catalog?.authorable, onClick: beginCopy, children: t('peCreateCopy') }), !readOnly && _jsxs(_Fragment, { children: [_jsxs("div", { className: "pe-block", children: [_jsx("strong", { children: t('peCodexSection') }), !draft.codex && _jsxs("label", { className: "pe-toggle", children: [_jsx("input", { type: "checkbox", checked: codexEnabled, disabled: busy, onChange: event => setCodexEnabled(event.target.checked) }), _jsxs("span", { children: [_jsx("strong", { children: t('peAddCodex') }), _jsx("small", { children: t('peAddCodexHint') })] })] }), codexEnabled && options && _jsxs(_Fragment, { children: [optionToggle('hostedWebSearchEnabled', t('capabilityWebSearch'), t('capabilityWebSearchHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('remoteCompactionEnabled', t('capabilityCompaction'), t('capabilityCompactionHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('terminalToolsEnabled', t('capabilityTerminal'), t('capabilityTerminalHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('patchToolEnabled', t('capabilityPatch'), t('capabilityPatchHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('planToolEnabled', t('capabilityPlan'), t('capabilityPlanHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('promptEnabled', t('capabilityPrompt'), t('capabilityPromptHint'), options, next => patch({ codexOptions: next }), busy), options.promptEnabled && _jsxs("label", { children: [t('promptLabel'), _jsx("textarea", { rows: 10, value: draft.systemPrompt, disabled: busy, onChange: event => patch({ systemPrompt: event.target.value, inheritPrompt: false }) })] }), _jsx("p", { children: t('peActivityGlobal') })] })] }), _jsxs("div", { className: "pe-row", children: [_jsx("button", { type: "button", className: "pe-primary", disabled: busy || !catalog?.authorable || !draft.name.trim() || !dirty, onClick: save, children: copyMode ? t('peSaveCopy') : t('pmSave') }), copyMode && _jsx("button", { type: "button", disabled: busy, onClick: () => { void load(sourceId, false); }, children: t('pmCancel') }), !copyMode && _jsx("button", { type: "button", disabled: busy, onClick: () => { void load(draft.id, false); }, children: t('pmCancel') })] })] })] })] });
190
+ return _jsxs("section", { className: "codex-preset-editor", "aria-label": t('peTitle'), "aria-busy": busy, children: [_jsx("style", { children: styles }), _jsxs("div", { className: "pe-row", style: { justifyContent: 'space-between' }, children: [_jsx("strong", { children: t('peTitle') }), _jsx("button", { type: "button", disabled: busy, onClick: () => { if (dirty && !window.confirm(t('pmDiscard')))
191
+ return; cache.clear(); void run(async () => { await refresh(); if (selectedId)
192
+ await load(selectedId, false); }); }, children: t('pmRefresh') })] }), _jsx("p", { children: t('peHierarchy') }), _jsxs("label", { children: [t('peSelect'), _jsxs("select", { value: selectedId, disabled: busy || !catalog, onChange: event => { void load(event.target.value); }, children: [_jsx("option", { value: "", children: t('peSelectPlaceholder') }), catalog?.presets.map(row => _jsxs("option", { value: row.id, children: [row.name, row.editable ? '' : ` · ${t('pmBuiltIn')}`] }, row.id))] })] }), selectedRow && _jsx("p", { children: selectedRow.editable ? t('peEditable') : t('peBuiltinEdit') }), error && _jsxs("div", { role: "alert", children: [_jsx("p", { children: errorAction === 'read'
193
+ ? t(isPresetConnectionError(error) ? 'peConnectionError' : 'peReadError')
194
+ : error.includes('preset-conflict') ? t('pmConflict') : error.includes('invalid-preset-yaml') ? t('pmYamlError') : t('pmSaveError') }), errorAction === 'read' && _jsxs("div", { className: "pe-row", children: [_jsx("button", { type: "button", disabled: busy, onClick: () => { if (selectedId) {
195
+ cache.delete(selectedId);
196
+ void load(selectedId, false);
197
+ }
198
+ else
199
+ void run(refresh); }, children: t('peRetryRead') }), !draft && isPresetConnectionError(error) && _jsx("button", { type: "button", onClick: () => window.location.reload(), children: t('peReconnect') })] }), _jsxs("details", { children: [_jsx("summary", { children: t('pmErrorDetails') }), _jsx("pre", { style: { whiteSpace: 'pre-wrap' }, children: error })] })] }), notice && _jsx("p", { role: "status", children: notice }), busy && !draft && _jsx("p", { role: "status", children: t('peLoading') }), draft && _jsxs(_Fragment, { children: [_jsxs("label", { children: [t('pmName'), _jsx("input", { value: draft.name, maxLength: 200, disabled: busy || readOnly, onChange: event => patch({ name: event.target.value }) })] }), _jsxs("label", { children: [t('pmDescription'), _jsx("input", { value: draft.description, maxLength: 4000, disabled: busy || readOnly, onChange: event => patch({ description: event.target.value }) })] }), !copyMode && _jsx("button", { type: "button", disabled: busy || !catalog?.authorable, onClick: beginCopy, children: t('peCreateCopy') }), _jsxs("div", { className: "pe-block", children: [_jsx("strong", { children: t('peSystemPrompt') }), _jsx("p", { children: t('peSectionsHint') }), draft.promptSections.map(section => _jsxs("details", { children: [_jsxs("summary", { style: { cursor: 'pointer', padding: '6px 0' }, children: [section.label, section.suppressed ? ` · ${t('peSuppressed')}` : ''] }), section.id === 'harness:source' && _jsx("p", { children: t('peDshSourcePrompt') }), section.id === 'app:web-surface' && _jsx("p", { children: t('peDshWebPrompt') }), _jsx("textarea", { "aria-label": section.label, rows: section.id === 'codex:base' ? 12 : 5, value: section.text, disabled: busy || readOnly || !section.editable, onChange: event => patch({ promptSections: draft.promptSections.map(item => item.id === section.id ? { ...item, text: event.target.value } : item),
200
+ ...(section.id === 'codex:base' ? { systemPrompt: event.target.value, inheritPrompt: false } : {}) }) }), section.suppressed ? _jsx("p", { children: t('peCompletePersona') }) : !section.editable && _jsx("p", { children: t('peDynamicPrompt') })] }, section.id))] }), !readOnly && _jsxs(_Fragment, { children: [_jsxs("div", { className: "pe-block", children: [_jsx("strong", { children: t('peCodexSection') }), !draft.codex && _jsxs("label", { className: "pe-toggle", children: [_jsx("input", { type: "checkbox", checked: codexEnabled, disabled: busy, onChange: event => {
201
+ const enabled = event.target.checked;
202
+ setCodexEnabled(enabled);
203
+ if (enabled) {
204
+ const extras = [
205
+ { id: 'codex:base', label: 'Codex 操作提示词', text: DEFAULT_CODEX_SYSTEM_PROMPT, editable: true },
206
+ ];
207
+ patch({ promptSections: [...draft.promptSections.map(s => s.suppressed ? { ...s, suppressed: undefined, editable: true } : s), ...extras.filter(item => !draft.promptSections.some(s => s.id === item.id))] });
208
+ }
209
+ else
210
+ patch({ promptSections: draft.promptSections.filter(s => original?.promptSections.some(item => item.id === s.id)).map(s => {
211
+ const source = original?.promptSections.find(item => item.id === s.id);
212
+ return source?.suppressed ? { ...s, suppressed: true, editable: false } : s;
213
+ }) });
214
+ } }), _jsxs("span", { children: [_jsx("strong", { children: t('peAddCodex') }), _jsx("small", { children: t('peAddCodexHint') })] })] }), codexEnabled && options && _jsxs(_Fragment, { children: [optionToggle('hostedWebSearchEnabled', t('capabilityWebSearch'), t('capabilityWebSearchHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('remoteCompactionEnabled', t('capabilityCompaction'), t('capabilityCompactionHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('terminalToolsEnabled', t('capabilityTerminal'), t('capabilityTerminalHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('patchToolEnabled', t('capabilityPatch'), t('capabilityPatchHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('planToolEnabled', t('capabilityPlan'), t('capabilityPlanHint'), options, next => patch({ codexOptions: next }), busy), optionToggle('promptEnabled', t('capabilityPrompt'), t('capabilityPromptHint'), options, next => patch({ codexOptions: next }), busy), _jsx("p", { children: t('peActivityGlobal') })] })] }), _jsxs("div", { className: "pe-row", children: [_jsx("button", { type: "button", className: "pe-primary", disabled: busy || !catalog?.authorable || !draft.name.trim() || !dirty, onClick: save, children: copyMode ? t('peSaveCopy') : t('pmSave') }), copyMode && _jsx("button", { type: "button", disabled: busy, onClick: () => { void load(sourceId, false); }, children: t('pmCancel') }), !copyMode && _jsx("button", { type: "button", disabled: busy, onClick: () => { void load(draft.id, false); }, children: t('pmCancel') })] })] })] })] });
154
215
  }
155
216
  export default PresetManagerCard;
156
217
  //# sourceMappingURL=preset-manager.js.map
@@ -0,0 +1,4 @@
1
+ /** Only transport failures from a read can be retried without duplicating writes. */
2
+ export declare function isPresetConnectionError(error: unknown): boolean;
3
+ export declare function readPresetWithRetry<T>(read: () => Promise<T>, active: () => boolean): Promise<T>;
4
+ //# sourceMappingURL=preset-requests.d.ts.map
@@ -0,0 +1,19 @@
1
+ /** Only transport failures from a read can be retried without duplicating writes. */
2
+ export function isPresetConnectionError(error) {
3
+ const message = error instanceof Error ? error.message : String(error);
4
+ return /Failed to fetch|NetworkError|Load failed|network request failed|no active Connection|connection.*(?:closed|offline)/i.test(message);
5
+ }
6
+ export async function readPresetWithRetry(read, active) {
7
+ try {
8
+ return await read();
9
+ }
10
+ catch (error) {
11
+ if (!isPresetConnectionError(error) || !active())
12
+ throw error;
13
+ await new Promise(resolve => setTimeout(resolve, 300));
14
+ if (!active())
15
+ throw error;
16
+ return read();
17
+ }
18
+ }
19
+ //# sourceMappingURL=preset-requests.js.map
@@ -32,6 +32,7 @@ export interface Config {
32
32
  systemPrompt?: string;
33
33
  /** Explicit per-preset operating prompt; overrides the shared prompt only. */
34
34
  presetPrompt?: string;
35
+ presetSections?: import('./prompt-sections.ts').Config;
35
36
  /** Per-preset Codex capability overrides. Omitted values follow shared settings. */
36
37
  promptEnabled?: boolean;
37
38
  terminalToolsEnabled?: boolean;
@@ -9,6 +9,7 @@ import { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SO
9
9
  import { CODEX_SETTINGS_ENTRY, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, } from "./settings.js";
10
10
  import { codexCompactionMode } from "./compaction.js";
11
11
  import { CodexPresetEditor } from "./preset-editor.js";
12
+ import { applyPromptSections, Config as PromptSectionsConfig } from "./prompt-sections.js";
12
13
  export { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, } from "./prompt.js";
13
14
  export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA } from "./settings.js";
14
15
  export const name = 'codex';
@@ -44,6 +45,7 @@ export const Config = z.object({
44
45
  remoteCompact: z.boolean().default(true),
45
46
  systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
46
47
  presetPrompt: z.string(),
48
+ presetSections: PromptSectionsConfig,
47
49
  promptEnabled: z.boolean(),
48
50
  terminalToolsEnabled: z.boolean(),
49
51
  patchToolEnabled: z.boolean(),
@@ -719,7 +721,7 @@ export function apply(ctx, config = {}) {
719
721
  }));
720
722
  }
721
723
  if (resolved.codexCore) {
722
- ctx.on('system-prompt/assemble', async (_assembly, _context, next) => applyCodexCapabilitySettings(await next(), codexSettings.current()));
724
+ ctx.on('system-prompt/assemble', async (_assembly, _context, next) => applyPromptSections(applyCodexCapabilitySettings(await next(), codexSettings.current()), config.presetSections ?? {}));
723
725
  ctx.systemPrompt.section({
724
726
  name: 'codex:base',
725
727
  order: 10,
@@ -5,6 +5,14 @@ export interface PresetFields {
5
5
  systemPrompt: string;
6
6
  inheritPrompt: boolean;
7
7
  }
8
+ export interface PresetPromptSection {
9
+ id: string;
10
+ label: string;
11
+ text: string;
12
+ editable: boolean;
13
+ /** Excluded by a complete Persona; shown for inspection, never saved as an active section. */
14
+ suppressed?: boolean;
15
+ }
8
16
  /** Codex capabilities stored with a preset. Activity status stays global. */
9
17
  export interface CodexPresetOptions {
10
18
  promptEnabled: boolean;
@@ -21,17 +29,20 @@ export interface PresetEditorDocument extends PresetFields {
21
29
  codex: boolean;
22
30
  codexOptions: CodexPresetOptions;
23
31
  composition: string;
32
+ promptSections: PresetPromptSection[];
24
33
  }
25
34
  export interface PresetEditorInput extends PresetFields {
26
35
  id: string;
27
36
  revision?: string;
28
37
  composition?: string;
29
38
  enableCodex?: boolean;
39
+ promptSections?: PresetPromptSection[];
30
40
  codexOptions?: Partial<CodexPresetOptions>;
31
41
  }
32
42
  export interface PresetCreateInput extends PresetFields {
33
43
  sourceId: string;
34
44
  enableCodex?: boolean;
45
+ promptSections?: PresetPromptSection[];
35
46
  composition?: string;
36
47
  codexOptions?: Partial<CodexPresetOptions>;
37
48
  }
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ const promptSections = z.array(z.object({ id: z.string(), label: z.string(), text: z.string().max(1_000_000), editable: z.boolean(), suppressed: z.boolean().optional() })).max(200);
2
3
  const fields = {
3
4
  name: z.string().max(200), description: z.string().max(4000),
4
5
  systemPrompt: z.string().max(1_000_000), inheritPrompt: z.boolean(),
@@ -8,7 +9,7 @@ const codexOptions = z.object({
8
9
  planToolEnabled: z.boolean(), hostedWebSearchEnabled: z.boolean(), remoteCompactionEnabled: z.boolean(),
9
10
  });
10
11
  const codexOptionsPatch = codexOptions.partial();
11
- const document = z.object({ ...fields, id: z.string(), revision: z.string(), editable: z.boolean(), codex: z.boolean(), codexOptions, composition: z.string() });
12
+ const document = z.object({ ...fields, id: z.string(), revision: z.string(), editable: z.boolean(), codex: z.boolean(), codexOptions, promptSections, composition: z.string() });
12
13
  const catalog = z.object({
13
14
  presets: z.array(z.object({ id: z.string(), name: z.string(), description: z.string(),
14
15
  editable: z.boolean(), isDefault: z.boolean() })),
@@ -29,8 +30,8 @@ export default {
29
30
  descriptors: [
30
31
  descriptor('catalog', undefined, z.unknown(), catalog),
31
32
  descriptor('read', 'id', z.string(), document),
32
- descriptor('update', 'rawInput', z.object({ ...fields, id: z.string(), revision: z.string().optional(), composition: z.string().max(1_000_000).optional(), enableCodex: z.boolean().optional(), codexOptions: codexOptionsPatch.optional() }), document),
33
- descriptor('create', 'rawInput', z.object({ ...fields, sourceId: z.string(), enableCodex: z.boolean().optional(), composition: z.string().max(1_000_000).optional(), codexOptions: codexOptionsPatch.optional() }), document),
33
+ descriptor('update', 'rawInput', z.object({ ...fields, id: z.string(), revision: z.string().optional(), composition: z.string().max(1_000_000).optional(), enableCodex: z.boolean().optional(), promptSections: promptSections.optional(), codexOptions: codexOptionsPatch.optional() }), document),
34
+ descriptor('create', 'rawInput', z.object({ ...fields, sourceId: z.string(), enableCodex: z.boolean().optional(), composition: z.string().max(1_000_000).optional(), promptSections: promptSections.optional(), codexOptions: codexOptionsPatch.optional() }), document),
34
35
  ],
35
36
  };
36
37
  //# sourceMappingURL=preset-editor-remote.js.map
@@ -1,6 +1,7 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
3
- import type { CodexPresetOptions, PresetCatalog, PresetCreateInput, PresetEditorInput, PresetEditorDocument } from './preset-contract.ts';
3
+ import type { CodexSettings } from './settings.ts';
4
+ import type { CodexPresetOptions, PresetCatalog, PresetCreateInput, PresetEditorInput, PresetEditorDocument, PresetPromptSection } from './preset-contract.ts';
4
5
  export type { PresetEditorInput, PresetEditorDocument } from './preset-contract.ts';
5
6
  export declare const DEFAULT_CODEX_PRESET_OPTIONS: CodexPresetOptions;
6
7
  export interface ResolvedPresetForEditor {
@@ -8,8 +9,13 @@ export interface ResolvedPresetForEditor {
8
9
  trust: 'system' | 'user';
9
10
  path: string;
10
11
  broken?: string;
12
+ name?: string;
13
+ description?: string;
11
14
  }
12
15
  export interface AgentPresetsForEditor {
16
+ list?(): Promise<ResolvedPresetForEditor[]>;
17
+ readonly defaultId?: string;
18
+ readonly authorable?: boolean;
13
19
  resolve(id: string): Promise<ResolvedPresetForEditor>;
14
20
  readDocument(id: string): Promise<{
15
21
  content: string;
@@ -34,6 +40,9 @@ export interface AgentPresetsForEditor {
34
40
  trust: 'system' | 'user';
35
41
  }[];
36
42
  }
43
+ export declare function readPromptSections(content: string, shared?: Partial<CodexSettings>): PresetPromptSection[];
44
+ /** Patch the contributing fields, not a disconnected secondary prompt. */
45
+ export declare function patchPromptSections(content: string, sections: PresetPromptSection[]): string;
37
46
  export declare function readCodexPresetOptions(content: string): CodexPresetOptions;
38
47
  export declare function supportsCodex(content: string): boolean;
39
48
  /** Structural validation only: executable tags stay inert until DSH mounts a selected preset. */
@@ -47,6 +56,8 @@ export declare function patchPresetMetadata(content: string, name: string, descr
47
56
  export declare class CodexPresetEditor extends TypertRemoteService {
48
57
  static inject: string[];
49
58
  private readonly agentPresets;
59
+ private sharedSettings?;
60
+ private indexed?;
50
61
  constructor(ctx: Context, _config?: undefined);
51
62
  catalog(): Promise<PresetCatalog>;
52
63
  read(id: string): Promise<PresetEditorDocument>;