@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.
package/lib/client.js CHANGED
@@ -4066,6 +4066,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4066
4066
  }
4067
4067
  //#endregion
4068
4068
  //#region lib/types/preset-editor-remote.js
4069
+ const promptSections = array(object({
4070
+ id: string(),
4071
+ label: string(),
4072
+ text: string().max(1e6),
4073
+ editable: boolean(),
4074
+ suppressed: boolean().optional()
4075
+ })).max(200);
4069
4076
  const fields = {
4070
4077
  name: string().max(200),
4071
4078
  description: string().max(4e3),
@@ -4088,6 +4095,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4088
4095
  editable: boolean(),
4089
4096
  codex: boolean(),
4090
4097
  codexOptions,
4098
+ promptSections,
4091
4099
  composition: string()
4092
4100
  });
4093
4101
  const catalog = object({
@@ -4137,6 +4145,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4137
4145
  revision: string().optional(),
4138
4146
  composition: string().max(1e6).optional(),
4139
4147
  enableCodex: boolean().optional(),
4148
+ promptSections: promptSections.optional(),
4140
4149
  codexOptions: codexOptionsPatch.optional()
4141
4150
  }), document$1),
4142
4151
  descriptor("create", "rawInput", object({
@@ -4144,13 +4153,83 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4144
4153
  sourceId: string(),
4145
4154
  enableCodex: boolean().optional(),
4146
4155
  composition: string().max(1e6).optional(),
4156
+ promptSections: promptSections.optional(),
4147
4157
  codexOptions: codexOptionsPatch.optional()
4148
4158
  }), document$1)
4149
4159
  ]
4150
4160
  };
4151
4161
  //#endregion
4162
+ //#region lib/types/prompt.js
4163
+ /** Default plugin-owned Codex operating prompt. */
4164
+ const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
4165
+
4166
+ - When searching for text or files, prefer using rg or rg --files respectively because rg is much faster than alternatives like grep. If rg is not available, use the next best alternative.
4167
+
4168
+ ## Editing constraints
4169
+
4170
+ - Default to ASCII when editing or creating files. Only introduce non-ASCII or other Unicode characters when there is a clear justification and the file already uses them.
4171
+ - Add succinct code comments that explain non-obvious code. Do not add comments that merely narrate assignments or control flow.
4172
+ - You may be in a dirty git worktree. Never revert existing changes you did not make unless the user explicitly requests it. If unrelated files are changed, leave them alone.
4173
+
4174
+ ## Planning
4175
+
4176
+ - Use update_plan for work with multiple meaningful steps. Keep the plan current as the task progresses.
4177
+ - Do not use a plan for a trivial one-step request.
4178
+
4179
+ ## dsh session
4180
+
4181
+ - The user and you share one workspace. Inspect the repository and every applicable AGENTS.md before editing.
4182
+
4183
+ ## Task execution
4184
+
4185
+ - Keep the user informed with concise progress updates and lead with the result.
4186
+
4187
+ ## Presenting your work
4188
+
4189
+ - Be concise, direct, friendly, and actionable.
4190
+ - For substantial work, explain what changed and why, then briefly note how the work was verified and what comes next.
4191
+ - Do not dump large files into the conversation; refer to their paths.
4192
+ - Use plain text with short sections only when they improve scanability.
4193
+
4194
+ ## Working principles
4195
+
4196
+ - 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.
4197
+ - 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.
4198
+ - Solve problems by thinking from first principles and at a higher level.
4199
+ `;
4200
+ String.raw`You are Codex, a coding agent based on the {{model}} model. Your working directory is {{cwd}}.`;
4201
+ 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.`;
4202
+ [
4203
+ "You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}.",
4204
+ "When the user refers to \"this page\", \"this GUI\", or \"this app\" without naming another target, they mean this GUI.",
4205
+ "The browser provides no implicit DOM, route, or screenshot context.",
4206
+ "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.",
4207
+ "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.",
4208
+ "Starting another server does not update this GUI.",
4209
+ "The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__.",
4210
+ "Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL."
4211
+ ].join(" ");
4212
+ //#endregion
4213
+ //#region lib/types/client/preset-requests.js
4214
+ /** Only transport failures from a read can be retried without duplicating writes. */
4215
+ function isPresetConnectionError(error) {
4216
+ const message = error instanceof Error ? error.message : String(error);
4217
+ return /Failed to fetch|NetworkError|Load failed|network request failed|no active Connection|connection.*(?:closed|offline)/i.test(message);
4218
+ }
4219
+ async function readPresetWithRetry(read, active) {
4220
+ try {
4221
+ return await read();
4222
+ } catch (error) {
4223
+ if (!isPresetConnectionError(error) || !active()) throw error;
4224
+ await new Promise((resolve) => setTimeout(resolve, 300));
4225
+ if (!active()) throw error;
4226
+ return read();
4227
+ }
4228
+ }
4229
+ //#endregion
4152
4230
  //#region lib/types/client/preset-manager.js
4153
4231
  const catalogCache = /* @__PURE__ */ new WeakMap();
4232
+ const documentCache = /* @__PURE__ */ new WeakMap();
4154
4233
  const CODEX_DEFAULT_ID = "codex-collaboration";
4155
4234
  function unwrap(result) {
4156
4235
  if (result.ok) return result.value;
@@ -4158,7 +4237,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4158
4237
  }
4159
4238
  function equalEditorState(a, b) {
4160
4239
  if (!a || !b) return a === b;
4161
- return a.name === b.name && a.description === b.description && a.systemPrompt === b.systemPrompt && a.inheritPrompt === b.inheritPrompt && a.codex === b.codex && JSON.stringify(a.codexOptions) === JSON.stringify(b.codexOptions);
4240
+ return a.name === b.name && a.description === b.description && a.systemPrompt === b.systemPrompt && a.inheritPrompt === b.inheritPrompt && a.codex === b.codex && JSON.stringify(a.codexOptions) === JSON.stringify(b.codexOptions) && JSON.stringify(a.promptSections) === JSON.stringify(b.promptSections);
4162
4241
  }
4163
4242
  const styles = `
4164
4243
  .codex-preset-editor { display:grid; gap:12px; min-width:0; font-size:13px; }
@@ -4199,8 +4278,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4199
4278
  const [codexEnabled, setCodexEnabled] = (0, react.useState)(false);
4200
4279
  const [busy, setBusy] = (0, react.useState)(false);
4201
4280
  const [error, setError] = (0, react.useState)("");
4281
+ const [errorAction, setErrorAction] = (0, react.useState)("read");
4202
4282
  const [notice, setNotice] = (0, react.useState)("");
4203
4283
  const alive = (0, react.useRef)(true);
4284
+ const request = (0, react.useRef)(0);
4285
+ if (!documentCache.has(presetManager)) documentCache.set(presetManager, /* @__PURE__ */ new Map());
4286
+ const cache = documentCache.get(presetManager);
4204
4287
  const remote = presetManager.remote.codexPresetEditor;
4205
4288
  const dirty = !!draft && (!original || !equalEditorState(draft, original) || codexEnabled !== draft.codex);
4206
4289
  async function run(work) {
@@ -4219,19 +4302,45 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4219
4302
  async function load(id, confirmDirty = true) {
4220
4303
  if (!id) return;
4221
4304
  if (confirmDirty && dirty && !window.confirm(t("pmDiscard"))) return;
4222
- await run(async () => {
4223
- const value = unwrap(await remote.read(id));
4224
- if (!alive.current) return;
4305
+ const ticket = ++request.current;
4306
+ setSelectedId(id);
4307
+ setError("");
4308
+ setNotice("");
4309
+ setErrorAction("read");
4310
+ const accept = (value) => {
4311
+ if (!alive.current || ticket !== request.current) return;
4225
4312
  setSelectedId(id);
4226
4313
  setSourceId(id);
4227
4314
  setOriginal(value);
4228
4315
  setDraft(value);
4229
4316
  setCopyMode(false);
4230
4317
  setCodexEnabled(value.codex);
4231
- });
4318
+ };
4319
+ const cached = cache.get(id);
4320
+ if (cached && Date.now() - cached.time < 6e4) {
4321
+ accept(cached.value);
4322
+ return;
4323
+ }
4324
+ setDraft(void 0);
4325
+ setOriginal(void 0);
4326
+ setBusy(true);
4327
+ try {
4328
+ await presetManager.ready;
4329
+ const value = await readPresetWithRetry(() => remote.read(id).then(unwrap), () => alive.current && ticket === request.current);
4330
+ cache.set(id, {
4331
+ value,
4332
+ time: Date.now()
4333
+ });
4334
+ accept(value);
4335
+ } catch (cause) {
4336
+ if (alive.current && ticket === request.current) setError(String(cause));
4337
+ } finally {
4338
+ if (alive.current && ticket === request.current) setBusy(false);
4339
+ }
4232
4340
  }
4233
4341
  async function refresh() {
4234
- const value = unwrap(await remote.catalog());
4342
+ setErrorAction("read");
4343
+ const value = await readPresetWithRetry(() => remote.catalog().then(unwrap), () => alive.current);
4235
4344
  if (!alive.current) return;
4236
4345
  catalogCache.set(presetManager, value);
4237
4346
  setCatalog(value);
@@ -4263,7 +4372,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4263
4372
  }
4264
4373
  function beginCopy() {
4265
4374
  if (!draft || !sourceId) return;
4266
- if (dirty && !window.confirm(t("pmDiscard"))) return;
4267
4375
  setCopyMode(true);
4268
4376
  setCodexEnabled(draft.codex);
4269
4377
  setOriginal({ ...draft });
@@ -4277,12 +4385,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4277
4385
  }
4278
4386
  function save() {
4279
4387
  if (!draft || busy || !draft.name.trim()) return;
4388
+ setErrorAction("save");
4280
4389
  run(async () => {
4281
4390
  const options = codexEnabled ? draft.codexOptions : void 0;
4282
4391
  const payload = {
4283
4392
  name: draft.name,
4284
4393
  description: draft.description,
4285
4394
  systemPrompt: draft.systemPrompt,
4395
+ promptSections: draft.promptSections.filter((section) => section.editable && (codexEnabled || section.id !== "codex:base")),
4286
4396
  inheritPrompt: draft.inheritPrompt,
4287
4397
  enableCodex: codexEnabled,
4288
4398
  ...options === void 0 ? {} : { codexOptions: options }
@@ -4300,6 +4410,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4300
4410
  setSourceId(value.id);
4301
4411
  setOriginal(value);
4302
4412
  setDraft(value);
4413
+ cache.set(value.id, {
4414
+ value,
4415
+ time: Date.now()
4416
+ });
4303
4417
  setCopyMode(false);
4304
4418
  setCodexEnabled(value.codex);
4305
4419
  setNotice(t("peSaved"));
@@ -4339,7 +4453,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4339
4453
  type: "button",
4340
4454
  disabled: busy,
4341
4455
  onClick: () => {
4342
- run(refresh);
4456
+ if (dirty && !window.confirm(t("pmDiscard"))) return;
4457
+ cache.clear();
4458
+ run(async () => {
4459
+ await refresh();
4460
+ if (selectedId) await load(selectedId, false);
4461
+ });
4343
4462
  },
4344
4463
  children: t("pmRefresh")
4345
4464
  })]
@@ -4362,15 +4481,40 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4362
4481
  selectedRow && (0, react_jsx_runtime.jsx)("p", { children: selectedRow.editable ? t("peEditable") : t("peBuiltinEdit") }),
4363
4482
  error && (0, react_jsx_runtime.jsxs)("div", {
4364
4483
  role: "alert",
4365
- children: [(0, react_jsx_runtime.jsx)("p", { children: error.includes("preset-conflict") ? t("pmConflict") : error.includes("invalid-preset-yaml") ? t("pmYamlError") : t("pmSaveError") }), (0, react_jsx_runtime.jsxs)("details", { children: [(0, react_jsx_runtime.jsx)("summary", { children: t("pmErrorDetails") }), (0, react_jsx_runtime.jsx)("pre", {
4366
- style: { whiteSpace: "pre-wrap" },
4367
- children: error
4368
- })] })]
4484
+ children: [
4485
+ (0, react_jsx_runtime.jsx)("p", { children: errorAction === "read" ? t(isPresetConnectionError(error) ? "peConnectionError" : "peReadError") : error.includes("preset-conflict") ? t("pmConflict") : error.includes("invalid-preset-yaml") ? t("pmYamlError") : t("pmSaveError") }),
4486
+ errorAction === "read" && (0, react_jsx_runtime.jsxs)("div", {
4487
+ className: "pe-row",
4488
+ children: [(0, react_jsx_runtime.jsx)("button", {
4489
+ type: "button",
4490
+ disabled: busy,
4491
+ onClick: () => {
4492
+ if (selectedId) {
4493
+ cache.delete(selectedId);
4494
+ load(selectedId, false);
4495
+ } else run(refresh);
4496
+ },
4497
+ children: t("peRetryRead")
4498
+ }), !draft && isPresetConnectionError(error) && (0, react_jsx_runtime.jsx)("button", {
4499
+ type: "button",
4500
+ onClick: () => window.location.reload(),
4501
+ children: t("peReconnect")
4502
+ })]
4503
+ }),
4504
+ (0, react_jsx_runtime.jsxs)("details", { children: [(0, react_jsx_runtime.jsx)("summary", { children: t("pmErrorDetails") }), (0, react_jsx_runtime.jsx)("pre", {
4505
+ style: { whiteSpace: "pre-wrap" },
4506
+ children: error
4507
+ })] })
4508
+ ]
4369
4509
  }),
4370
4510
  notice && (0, react_jsx_runtime.jsx)("p", {
4371
4511
  role: "status",
4372
4512
  children: notice
4373
4513
  }),
4514
+ busy && !draft && (0, react_jsx_runtime.jsx)("p", {
4515
+ role: "status",
4516
+ children: t("peLoading")
4517
+ }),
4374
4518
  draft && (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
4375
4519
  (0, react_jsx_runtime.jsxs)("label", { children: [t("pmName"), (0, react_jsx_runtime.jsx)("input", {
4376
4520
  value: draft.name,
@@ -4384,13 +4528,47 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4384
4528
  disabled: busy || readOnly,
4385
4529
  onChange: (event) => patch({ description: event.target.value })
4386
4530
  })] }),
4387
- readOnly && (0, react_jsx_runtime.jsx)("button", {
4531
+ !copyMode && (0, react_jsx_runtime.jsx)("button", {
4388
4532
  type: "button",
4389
- className: "pe-primary",
4390
4533
  disabled: busy || !catalog?.authorable,
4391
4534
  onClick: beginCopy,
4392
4535
  children: t("peCreateCopy")
4393
4536
  }),
4537
+ (0, react_jsx_runtime.jsxs)("div", {
4538
+ className: "pe-block",
4539
+ children: [
4540
+ (0, react_jsx_runtime.jsx)("strong", { children: t("peSystemPrompt") }),
4541
+ (0, react_jsx_runtime.jsx)("p", { children: t("peSectionsHint") }),
4542
+ draft.promptSections.map((section) => (0, react_jsx_runtime.jsxs)("details", { children: [
4543
+ (0, react_jsx_runtime.jsxs)("summary", {
4544
+ style: {
4545
+ cursor: "pointer",
4546
+ padding: "6px 0"
4547
+ },
4548
+ children: [section.label, section.suppressed ? ` · ${t("peSuppressed")}` : ""]
4549
+ }),
4550
+ section.id === "harness:source" && (0, react_jsx_runtime.jsx)("p", { children: t("peDshSourcePrompt") }),
4551
+ section.id === "app:web-surface" && (0, react_jsx_runtime.jsx)("p", { children: t("peDshWebPrompt") }),
4552
+ (0, react_jsx_runtime.jsx)("textarea", {
4553
+ "aria-label": section.label,
4554
+ rows: section.id === "codex:base" ? 12 : 5,
4555
+ value: section.text,
4556
+ disabled: busy || readOnly || !section.editable,
4557
+ onChange: (event) => patch({
4558
+ promptSections: draft.promptSections.map((item) => item.id === section.id ? {
4559
+ ...item,
4560
+ text: event.target.value
4561
+ } : item),
4562
+ ...section.id === "codex:base" ? {
4563
+ systemPrompt: event.target.value,
4564
+ inheritPrompt: false
4565
+ } : {}
4566
+ })
4567
+ }),
4568
+ section.suppressed ? (0, react_jsx_runtime.jsx)("p", { children: t("peCompletePersona") }) : !section.editable && (0, react_jsx_runtime.jsx)("p", { children: t("peDynamicPrompt") })
4569
+ ] }, section.id))
4570
+ ]
4571
+ }),
4394
4572
  !readOnly && (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsxs)("div", {
4395
4573
  className: "pe-block",
4396
4574
  children: [
@@ -4401,7 +4579,29 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4401
4579
  type: "checkbox",
4402
4580
  checked: codexEnabled,
4403
4581
  disabled: busy,
4404
- onChange: (event) => setCodexEnabled(event.target.checked)
4582
+ onChange: (event) => {
4583
+ const enabled = event.target.checked;
4584
+ setCodexEnabled(enabled);
4585
+ if (enabled) {
4586
+ const extras = [{
4587
+ id: "codex:base",
4588
+ label: "Codex 操作提示词",
4589
+ text: DEFAULT_CODEX_SYSTEM_PROMPT,
4590
+ editable: true
4591
+ }];
4592
+ patch({ promptSections: [...draft.promptSections.map((s) => s.suppressed ? {
4593
+ ...s,
4594
+ suppressed: void 0,
4595
+ editable: true
4596
+ } : s), ...extras.filter((item) => !draft.promptSections.some((s) => s.id === item.id))] });
4597
+ } else patch({ promptSections: draft.promptSections.filter((s) => original?.promptSections.some((item) => item.id === s.id)).map((s) => {
4598
+ return (original?.promptSections.find((item) => item.id === s.id))?.suppressed ? {
4599
+ ...s,
4600
+ suppressed: true,
4601
+ editable: false
4602
+ } : s;
4603
+ }) });
4604
+ }
4405
4605
  }), (0, react_jsx_runtime.jsxs)("span", { children: [(0, react_jsx_runtime.jsx)("strong", { children: t("peAddCodex") }), (0, react_jsx_runtime.jsx)("small", { children: t("peAddCodexHint") })] })]
4406
4606
  }),
4407
4607
  codexEnabled && options && (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
@@ -4411,15 +4611,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4411
4611
  optionToggle("patchToolEnabled", t("capabilityPatch"), t("capabilityPatchHint"), options, (next) => patch({ codexOptions: next }), busy),
4412
4612
  optionToggle("planToolEnabled", t("capabilityPlan"), t("capabilityPlanHint"), options, (next) => patch({ codexOptions: next }), busy),
4413
4613
  optionToggle("promptEnabled", t("capabilityPrompt"), t("capabilityPromptHint"), options, (next) => patch({ codexOptions: next }), busy),
4414
- options.promptEnabled && (0, react_jsx_runtime.jsxs)("label", { children: [t("promptLabel"), (0, react_jsx_runtime.jsx)("textarea", {
4415
- rows: 10,
4416
- value: draft.systemPrompt,
4417
- disabled: busy,
4418
- onChange: (event) => patch({
4419
- systemPrompt: event.target.value,
4420
- inheritPrompt: false
4421
- })
4422
- })] }),
4423
4614
  (0, react_jsx_runtime.jsx)("p", { children: t("peActivityGlobal") })
4424
4615
  ] })
4425
4616
  ]
@@ -4458,6 +4649,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4458
4649
  //#endregion
4459
4650
  //#region lib/types/client/preset-copy.js
4460
4651
  const presetEn = {
4652
+ peConnectionError: "Could not connect to the local service. Retry loading; if the connection still fails, reconnect the page.",
4653
+ peReadError: "Could not read this preset. Retry loading or refresh the preset list.",
4654
+ peRetryRead: "Retry loading",
4655
+ peReconnect: "Reconnect page",
4656
+ peSystemPrompt: "System prompt sections",
4657
+ 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.",
4658
+ peDynamicPrompt: "This field is an expression; it is preserved without executing it in the editor.",
4659
+ 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.",
4660
+ peDshWebPrompt: "Tells the agent which Web page it is talking through, what “this page” means, and when Web changes need a rebuild or refresh.",
4661
+ peSuppressed: "Not used",
4662
+ peCompletePersona: "This preset uses Persona as its entire system prompt, so this section is excluded.",
4663
+ peLoading: "Reading preset…",
4461
4664
  peTitle: "Preset editor",
4462
4665
  peHierarchy: "Codex mode and other presets are peers. Choose one to edit, or make an editable copy of a built-in preset first.",
4463
4666
  peSelect: "Preset",
@@ -4486,6 +4689,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4486
4689
  pmSave: "Save changes"
4487
4690
  };
4488
4691
  const presetZh = {
4692
+ peConnectionError: "未能连接本地服务。请重试读取;如果仍然失败,请重新连接页面。",
4693
+ peReadError: "无法读取这个预设,请重试读取或刷新预设列表。",
4694
+ peRetryRead: "重试读取",
4695
+ peReconnect: "重新连接页面",
4696
+ peSystemPrompt: "系统提示词",
4697
+ peSectionsHint: "这些模板共同组成当前预设在工具之前的系统提示词。运行时变量、工作区指令和插件提供的说明会在会话中组装。",
4698
+ peDynamicPrompt: "此字段是动态表达式,编辑器保留原值,不执行表达式。",
4699
+ peDshSourcePrompt: "告诉 Agent DSH 源码检出目录在哪里,并与当前工作区区分开;用于检查或扩展 DSH 本身。",
4700
+ peDshWebPrompt: "告诉 Agent 当前通过哪个 Web 页面交互、“这个页面”指什么,以及 Web 修改何时需要重建或刷新。",
4701
+ peSuppressed: "未使用",
4702
+ peCompletePersona: "此预设将 Persona 作为完整系统提示词,因此不使用这一段。",
4703
+ peLoading: "正在读取预设…",
4489
4704
  peTitle: "预设编辑",
4490
4705
  peHierarchy: "Codex 模式和其它预设处于同一级。选择一个预设编辑;内置预设先创建可编辑副本。",
4491
4706
  peSelect: "选择预设",
@@ -4533,7 +4748,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4533
4748
  contextSizeDescription: "Next request capacity in K tokens.",
4534
4749
  contextRestore: "Restore model default",
4535
4750
  promptCardTitle: "Codex Harness",
4536
- promptCardDescription: "Edit presets and their Codex capabilities. Activity status is global.",
4751
+ promptCardDescription: "Edit presets, Codex capabilities, and the operating prompt. Activity status is global.",
4537
4752
  otherCapabilitiesLabel: "Global capabilities",
4538
4753
  capabilityPrompt: "Codex operating prompt",
4539
4754
  capabilityPromptHint: "Inject the editable instructions and persona-first prompt layout.",
@@ -4553,7 +4768,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4553
4768
  capabilityCompactionHint: "Prefer the provider Responses compact endpoint before local compaction.",
4554
4769
  capabilityActivity: "Activity indicator",
4555
4770
  capabilityActivityHint: "Show request, reply, and compaction status beside the conversation.",
4771
+ promptCustomizationLabel: "Prompt customization",
4772
+ personaLabel: "Persona",
4773
+ personaHint: "Deployment identity and role. Supports {{model}} and {{cwd}}.",
4774
+ sourcePromptLabel: "DSH Core source instructions",
4775
+ sourcePromptHint: "Guidance about the DSH checkout and working directory. Supports {{sourceRoot}}.",
4776
+ webPromptLabel: "DSH Core Web instructions",
4777
+ webPromptHint: "Guidance about this Web GUI, HMR, builds, and verification. Supports {{webUrl}}.",
4778
+ promptRestoreAll: "Restore all prompt defaults",
4556
4779
  promptLabel: "Codex operating prompt",
4780
+ promptHint: "This is the Codex operating prompt. Persona and DSH Core instructions are edited separately above.",
4781
+ promptUnsaved: "Unsaved",
4782
+ promptDiscard: "Discard",
4783
+ promptSave: "Save",
4784
+ promptSaving: "Saving...",
4785
+ promptSaveFailed: "Could not save the prompt.",
4557
4786
  promptExpand: "Expand settings",
4558
4787
  promptCollapse: "Collapse settings",
4559
4788
  promptReadOnly: "This settings document is read-only.",
@@ -4572,7 +4801,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4572
4801
  contextSizeDescription: "设置下次请求的上下文容量,单位为 K tokens。",
4573
4802
  contextRestore: "恢复模型默认值",
4574
4803
  promptCardTitle: "Codex Harness",
4575
- promptCardDescription: "编辑预设及其 Codex 能力,活动状态是全局设置。",
4804
+ promptCardDescription: "编辑预设、Codex 能力和操作提示词,活动状态是全局设置。",
4576
4805
  otherCapabilitiesLabel: "全局能力",
4577
4806
  capabilityPrompt: "Codex 操作提示词",
4578
4807
  capabilityPromptHint: "注入可编辑指令,并将 Persona 放在提示词首位。",
@@ -4592,7 +4821,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4592
4821
  capabilityCompactionHint: "优先调用提供商的 Responses compact 端点,失败时回退本地压缩。",
4593
4822
  capabilityActivity: "活动状态",
4594
4823
  capabilityActivityHint: "在对话旁显示请求、回复和压缩状态。",
4824
+ promptCustomizationLabel: "提示词定制",
4825
+ personaLabel: "Persona",
4826
+ personaHint: "定义 Agent 的身份与角色,支持 {{model}} 和 {{cwd}}。",
4827
+ sourcePromptLabel: "DSH Core 源码说明",
4828
+ sourcePromptHint: "说明 DSH 源码检出目录与工作目录,支持 {{sourceRoot}}。",
4829
+ webPromptLabel: "DSH Core Web 说明",
4830
+ webPromptHint: "说明 Web GUI、HMR、构建与验证,支持 {{webUrl}}。",
4831
+ promptRestoreAll: "恢复所有提示词默认值",
4595
4832
  promptLabel: "Codex 操作提示词",
4833
+ promptHint: "这是 Codex 操作提示词。Persona 和 DSH Core 说明在上方分别编辑。",
4834
+ promptUnsaved: "未保存",
4835
+ promptDiscard: "放弃",
4836
+ promptSave: "保存",
4837
+ promptSaving: "保存中...",
4838
+ promptSaveFailed: "提示词保存失败。",
4596
4839
  promptExpand: "展开设置",
4597
4840
  promptCollapse: "收起设置",
4598
4841
  promptReadOnly: "当前设置文件为只读。",
@@ -4646,157 +4889,47 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4646
4889
  })]
4647
4890
  });
4648
4891
  }
4649
- /** Visually separate capability scope while keeping the host's light settings style. */
4650
- function CapabilityGroup({ id, label, children, accent }) {
4651
- const [open, setOpen] = (0, react.useState)(false);
4652
- const panelId = `${id}-panel`;
4653
- return (0, react_jsx_runtime.jsxs)("section", {
4654
- style: {
4655
- display: "grid",
4656
- gap: open ? 4 : 0
4657
- },
4658
- children: [(0, react_jsx_runtime.jsxs)("button", {
4659
- type: "button",
4660
- "aria-expanded": open,
4661
- "aria-controls": panelId,
4662
- onClick: () => {
4663
- setOpen(!open);
4664
- },
4665
- style: {
4666
- display: "flex",
4667
- alignItems: "center",
4668
- gap: 7,
4669
- width: "100%",
4670
- padding: 0,
4671
- border: 0,
4672
- background: "none",
4673
- color: "var(--dsw-alias-label-secondary)",
4674
- font: "inherit",
4675
- textAlign: "left",
4676
- cursor: "pointer"
4677
- },
4678
- children: [
4679
- (0, react_jsx_runtime.jsx)("span", {
4680
- "aria-hidden": "true",
4681
- style: {
4682
- width: 6,
4683
- height: 6,
4684
- flex: "0 0 auto",
4685
- borderRadius: 999,
4686
- background: accent
4687
- }
4688
- }),
4689
- (0, react_jsx_runtime.jsx)("strong", {
4690
- style: {
4691
- color: "var(--dsw-alias-label-secondary)",
4692
- fontSize: 14,
4693
- fontWeight: 600,
4694
- letterSpacing: "0.01em"
4695
- },
4696
- children: label
4697
- }),
4698
- (0, react_jsx_runtime.jsx)("span", {
4699
- "aria-hidden": "true",
4700
- style: {
4701
- color: "var(--dsw-alias-label-tertiary)",
4702
- fontSize: 16
4703
- },
4704
- children: open ? "-" : "+"
4705
- })
4706
- ]
4707
- }), open && (0, react_jsx_runtime.jsx)("div", {
4708
- id: panelId,
4709
- style: {
4710
- display: "grid",
4711
- marginLeft: 5,
4712
- paddingLeft: 12
4713
- },
4714
- children
4715
- })]
4716
- });
4717
- }
4718
- /** Preset editor and global activity control contributed to Settings > Plugins. */
4892
+ /** One editor per preset; only display preferences are global. */
4719
4893
  function PromptSettingsCard(props) {
4720
4894
  const { useSettings, setSetting, presetManager, t } = props;
4721
4895
  const snapshot = useSettings((state) => state);
4722
- const otherCapabilities = [{
4723
- field: "activityIndicatorEnabled",
4724
- label: "capabilityActivity",
4725
- hint: "capabilityActivityHint"
4726
- }];
4727
4896
  const [open, setOpen] = (0, react.useState)(false);
4728
4897
  if (snapshot.status === "unavailable") return null;
4729
- const renderCapability = (capability) => (0, react_jsx_runtime.jsx)(CapabilityToggle, {
4730
- field: capability.field,
4731
- label: t(capability.label),
4732
- hint: t(capability.hint),
4733
- enabled: snapshot.value?.[capability.field] ?? true,
4734
- disabled: !snapshot.writable,
4735
- setSetting
4736
- }, capability.field);
4737
4898
  return (0, react_jsx_runtime.jsxs)("li", {
4738
4899
  style: {
4739
4900
  listStyle: "none",
4740
4901
  border: "1px solid var(--dsw-alias-border-l2)",
4741
4902
  borderRadius: 12,
4742
- background: open ? "var(--dsw-alias-bg-layer-2)" : "var(--dsw-alias-bg-layer-3)",
4743
4903
  overflow: "hidden"
4744
4904
  },
4745
4905
  children: [(0, react_jsx_runtime.jsxs)("button", {
4746
4906
  type: "button",
4747
4907
  "aria-expanded": open,
4748
- "aria-label": `${t(open ? "promptCollapse" : "promptExpand")}: ${t("promptCardTitle")}`,
4749
- onClick: () => {
4750
- setOpen(!open);
4751
- },
4908
+ onClick: () => setOpen(!open),
4752
4909
  style: {
4753
4910
  width: "100%",
4911
+ padding: 16,
4912
+ textAlign: "left",
4754
4913
  border: 0,
4755
4914
  background: "none",
4756
4915
  color: "inherit",
4757
- padding: "14px 16px",
4758
- display: "flex",
4759
- alignItems: "center",
4760
- gap: 12,
4761
- textAlign: "left",
4762
- cursor: "pointer",
4763
- font: "inherit"
4916
+ cursor: "pointer"
4764
4917
  },
4765
- children: [(0, react_jsx_runtime.jsxs)("span", {
4766
- style: {
4767
- flex: 1,
4768
- minWidth: 0,
4769
- display: "flex",
4770
- flexDirection: "column",
4771
- gap: 4
4772
- },
4773
- children: [(0, react_jsx_runtime.jsx)("strong", {
4774
- style: {
4775
- fontSize: 15,
4776
- lineHeight: 1.4
4777
- },
4778
- children: t("promptCardTitle")
4779
- }), (0, react_jsx_runtime.jsx)("span", {
4780
- style: {
4781
- color: "var(--dsw-alias-label-tertiary)",
4782
- fontSize: 13,
4783
- lineHeight: 1.5
4784
- },
4918
+ children: [
4919
+ (0, react_jsx_runtime.jsx)("strong", { children: t("promptCardTitle") }),
4920
+ (0, react_jsx_runtime.jsx)("span", {
4921
+ style: { float: "right" },
4922
+ children: open ? "−" : "+"
4923
+ }),
4924
+ (0, react_jsx_runtime.jsx)("p", {
4925
+ style: { marginBottom: 0 },
4785
4926
  children: t("promptCardDescription")
4786
- })]
4787
- }), (0, react_jsx_runtime.jsx)("span", {
4788
- "aria-hidden": "true",
4789
- style: {
4790
- color: "var(--dsw-alias-label-tertiary)",
4791
- fontSize: 16
4792
- },
4793
- children: open ? "-" : "+"
4794
- })]
4927
+ })
4928
+ ]
4795
4929
  }), open && (0, react_jsx_runtime.jsxs)("div", {
4796
4930
  style: {
4797
- borderTop: "1px solid var(--dsw-alias-border-l2)",
4798
- margin: "0 16px",
4799
- padding: "12px 0"
4931
+ padding: 16,
4932
+ borderTop: "1px solid var(--dsw-alias-border-l2)"
4800
4933
  },
4801
4934
  children: [(0, react_jsx_runtime.jsx)(PresetManagerCard, {
4802
4935
  presetManager,
@@ -4807,30 +4940,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4807
4940
  borderTop: "1px solid var(--dsw-alias-border-l2)",
4808
4941
  paddingTop: 14
4809
4942
  },
4810
- children: [
4811
- (0, react_jsx_runtime.jsx)("summary", {
4812
- style: {
4813
- cursor: "pointer",
4814
- fontWeight: 600,
4815
- marginBottom: 14
4816
- },
4817
- children: t("pmGlobalSettings")
4818
- }),
4819
- !snapshot.writable && (0, react_jsx_runtime.jsx)("p", {
4820
- style: {
4821
- margin: "0 0 10px",
4822
- color: "var(--dsw-alias-label-tertiary)",
4823
- fontSize: 12
4824
- },
4825
- children: t("promptReadOnly")
4826
- }),
4827
- (0, react_jsx_runtime.jsx)(CapabilityGroup, {
4828
- id: "global-capabilities",
4829
- label: t("otherCapabilitiesLabel"),
4830
- accent: "var(--dsw-alias-label-tertiary)",
4831
- children: otherCapabilities.map(renderCapability)
4832
- })
4833
- ]
4943
+ children: [(0, react_jsx_runtime.jsx)("summary", {
4944
+ style: {
4945
+ cursor: "pointer",
4946
+ fontWeight: 600
4947
+ },
4948
+ children: t("pmGlobalSettings")
4949
+ }), (0, react_jsx_runtime.jsx)(CapabilityToggle, {
4950
+ field: "activityIndicatorEnabled",
4951
+ label: t("capabilityActivity"),
4952
+ hint: t("capabilityActivityHint"),
4953
+ enabled: snapshot.value?.activityIndicatorEnabled ?? true,
4954
+ disabled: !snapshot.writable,
4955
+ setSetting
4956
+ })]
4834
4957
  })]
4835
4958
  })]
4836
4959
  });