@shuind/dsh-codex-harness 0.2.7 → 0.2.9

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
@@ -506,6 +506,7 @@ window.__ModuleLoader__.load({
506
506
  ]);
507
507
  if (snapshot.status === "unavailable") return null;
508
508
  const dirty = personaDraft !== currentPersona || sourcePromptDraft !== currentSourcePrompt || webPromptDraft !== currentWebPrompt || draft !== current;
509
+ const canRestore = dirty || currentPersona !== DEFAULT_CODEX_PERSONA || currentSourcePrompt !== DEFAULT_DSH_CORE_SOURCE_PROMPT || currentWebPrompt !== DEFAULT_DSH_CORE_WEB_PROMPT || current !== DEFAULT_CODEX_SYSTEM_PROMPT;
509
510
  const renderCapability = (capability) => (0, react_jsx_runtime.jsx)(CapabilityToggle, {
510
511
  field: capability.field,
511
512
  label: t(capability.label),
@@ -680,7 +681,7 @@ window.__ModuleLoader__.load({
680
681
  children: t("promptCustomizationLabel")
681
682
  }), (0, react_jsx_runtime.jsx)("button", {
682
683
  type: "button",
683
- disabled: !snapshot.writable || saving || !dirty,
684
+ disabled: !snapshot.writable || saving || !canRestore,
684
685
  onClick: () => {
685
686
  reset();
686
687
  },
package/lib/compaction.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
3
- import { settingsNamespace } from "@deepseek-ai/dsh-settings";
4
3
  //#region lib/types/compaction.js
5
4
  /** Codex compaction backend that honors the latest durable request capacity. */
6
5
  /**
@@ -25,7 +24,7 @@ function runCodexCompactionMode(mode, task) {
25
24
  function codexCompactionMode() {
26
25
  return COMPACTION_MODE.getStore();
27
26
  }
28
- const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
27
+ const CODEX_SETTINGS_NAMESPACE = "codex";
29
28
  /** Codex context overrides apply only to GPT-compatible model routes. */
30
29
  function isGptModel(model) {
31
30
  return /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
package/lib/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import z from "@deepseek-ai/schemastery";
2
- import { installSettingsSection, settingsNamespace } from "@deepseek-ai/dsh-settings";
3
2
  import { defineTool } from "@deepseek-ai/dsh-tools";
4
3
  import { randomBytes, randomUUID } from "node:crypto";
5
4
  import { join, resolve } from "node:path";
@@ -1237,7 +1236,7 @@ const CODEX_CONTEXT_MAX = 1e6;
1237
1236
  //#region lib/types/settings.js
1238
1237
  /** Shared host-side Codex settings contract. */
1239
1238
  /** Live Codex controls shared by the Web UI and agent layer. */
1240
- const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
1239
+ const CODEX_SETTINGS_NAMESPACE = "codex";
1241
1240
  /** Default settings exposed even before a Codex session is opened. */
1242
1241
  const CODEX_SETTINGS_ENTRY = {
1243
1242
  fast: false,
@@ -1291,7 +1290,7 @@ const COMPACTION_MODE = (() => {
1291
1290
  function codexCompactionMode() {
1292
1291
  return COMPACTION_MODE.getStore();
1293
1292
  }
1294
- const CODEX_SETTINGS_NAMESPACE$1 = settingsNamespace("codex");
1293
+ const CODEX_SETTINGS_NAMESPACE$1 = "codex";
1295
1294
  /** Codex context overrides apply only to GPT-compatible model routes. */
1296
1295
  function isGptModel$1(model) {
1297
1296
  return /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
@@ -1394,7 +1393,7 @@ const Config = z.object({
1394
1393
  harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
1395
1394
  webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT)
1396
1395
  });
1397
- const LLM_PI_AI_SETTINGS = settingsNamespace("llm-pi-ai");
1396
+ const LLM_PI_AI_SETTINGS = "llm-pi-ai";
1398
1397
  const GPT_REASONING_EFFORTS = {
1399
1398
  low: "low",
1400
1399
  medium: "medium",
@@ -1491,14 +1490,39 @@ function installCodexSettings(ctx, systemPrompt, persona, harnessSourcePrompt, w
1491
1490
  ...entry,
1492
1491
  ...value
1493
1492
  });
1494
- const settings = ctx.get("settings");
1495
- if (settings?.get(CODEX_SETTINGS_NAMESPACE) !== void 0) return { current: () => withDefaults(settings.get(CODEX_SETTINGS_NAMESPACE)) };
1496
1493
  let source = () => entry;
1497
- installSettingsSection(ctx, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, entry, {
1498
- setSource: (current) => {
1499
- source = current;
1500
- },
1501
- onChange: () => {}
1494
+ let attached = false;
1495
+ const attachSettings = (candidate) => {
1496
+ if (attached || candidate === void 0 || candidate === null) return attached;
1497
+ const settings = candidate;
1498
+ if (typeof settings.get === "function") {
1499
+ const get = settings.get.bind(settings);
1500
+ if (get("codex") !== void 0) {
1501
+ source = () => get(CODEX_SETTINGS_NAMESPACE);
1502
+ attached = true;
1503
+ return true;
1504
+ }
1505
+ }
1506
+ if (typeof settings.installSection === "function") {
1507
+ settings.installSection.call(settings, ctx, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, entry, {
1508
+ setSource: (current) => {
1509
+ source = current;
1510
+ },
1511
+ onChange: () => {}
1512
+ });
1513
+ attached = true;
1514
+ return true;
1515
+ }
1516
+ if (typeof settings.register === "function") {
1517
+ const scope = settings.register.call(settings, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, { base: entry });
1518
+ source = () => scope.get();
1519
+ attached = true;
1520
+ return true;
1521
+ }
1522
+ return false;
1523
+ };
1524
+ if (!attachSettings(ctx.get("settings"))) ctx.inject(["settings"], (settingsCtx) => {
1525
+ attachSettings(settingsCtx.settings);
1502
1526
  });
1503
1527
  return { current: () => withDefaults(source()) };
1504
1528
  }
@@ -1555,10 +1579,10 @@ function installCodexContextProjection(ctx, current) {
1555
1579
  sync(session);
1556
1580
  });
1557
1581
  ctx.on("settings/updated", (ns, next) => {
1558
- if (ns === CODEX_SETTINGS_NAMESPACE) syncAll(next.contextWindow);
1582
+ if (ns === "codex") syncAll(next.contextWindow);
1559
1583
  });
1560
1584
  ctx.on("settings/document-updated", (ns) => {
1561
- if (ns === CODEX_SETTINGS_NAMESPACE) syncAll();
1585
+ if (ns === "codex") syncAll();
1562
1586
  });
1563
1587
  syncAll();
1564
1588
  }
package/lib/installer.js CHANGED
@@ -4,7 +4,6 @@ import { homedir } from "node:os";
4
4
  import { dirname, join, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import z from "@deepseek-ai/schemastery";
7
- import { settingsNamespace } from "@deepseek-ai/dsh-settings";
8
7
  //#region lib/types/context.js
9
8
  const CODEX_CONTEXT_MAX = 1e6;
10
9
  //#endregion
@@ -65,7 +64,7 @@ const DEFAULT_DSH_CORE_WEB_PROMPT = [
65
64
  //#region lib/types/settings.js
66
65
  /** Shared host-side Codex settings contract. */
67
66
  /** Live Codex controls shared by the Web UI and agent layer. */
68
- const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
67
+ const CODEX_SETTINGS_NAMESPACE = "codex";
69
68
  /** Default settings exposed even before a Codex session is opened. */
70
69
  const CODEX_SETTINGS_ENTRY = {
71
70
  fast: false,
@@ -238,6 +238,11 @@ export function PromptSettingsCard(props) {
238
238
  || sourcePromptDraft !== currentSourcePrompt
239
239
  || webPromptDraft !== currentWebPrompt
240
240
  || draft !== current;
241
+ const canRestore = dirty
242
+ || currentPersona !== DEFAULT_CODEX_PERSONA
243
+ || currentSourcePrompt !== DEFAULT_DSH_CORE_SOURCE_PROMPT
244
+ || currentWebPrompt !== DEFAULT_DSH_CORE_WEB_PROMPT
245
+ || current !== DEFAULT_CODEX_SYSTEM_PROMPT;
241
246
  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));
242
247
  const save = async () => {
243
248
  setSaving(true);
@@ -312,7 +317,7 @@ export function PromptSettingsCard(props) {
312
317
  gap: 14,
313
318
  paddingTop: 12,
314
319
  borderTop: '1px solid var(--dsw-alias-border-l2)',
315
- }, 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: {
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 || !canRestore, 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: {
316
321
  display: 'flex',
317
322
  justifyContent: 'flex-end',
318
323
  alignItems: 'center',
@@ -1,7 +1,6 @@
1
1
  /** Codex compaction backend that honors the latest durable request capacity. */
2
2
  import { AsyncLocalStorage } from 'node:async_hooks';
3
3
  import BasicCompactionEngine from '@deepseek-ai/dsh-compaction-basic';
4
- import { settingsNamespace } from '@deepseek-ai/dsh-settings';
5
4
  /**
6
5
  * The main plugin entry and the compact-command subpath can be evaluated as
7
6
  * separate bundles. Keep their async context carrier on the process global so
@@ -25,7 +24,7 @@ export function runCodexCompactionMode(mode, task) {
25
24
  export function codexCompactionMode() {
26
25
  return COMPACTION_MODE.getStore();
27
26
  }
28
- const CODEX_SETTINGS_NAMESPACE = settingsNamespace('codex');
27
+ const CODEX_SETTINGS_NAMESPACE = 'codex';
29
28
  /** Codex context overrides apply only to GPT-compatible model routes. */
30
29
  function isGptModel(model) {
31
30
  return /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
@@ -1,6 +1,5 @@
1
1
  /** Codex-compatible prompt overlay and core tools for a dsh agent preset. */
2
2
  import z from '@deepseek-ai/schemastery';
3
- import { installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings';
4
3
  import { defineTool } from '@deepseek-ai/dsh-tools';
5
4
  import { APPLY_PATCH_DESCRIPTION, applyPatchHunks, parsePatch } from "./patch.js";
6
5
  import { renderExecResult, runExecCommand, runWriteStdin } from "./exec.js";
@@ -29,7 +28,7 @@ export const Config = z.object({
29
28
  harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
30
29
  webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),
31
30
  });
32
- const LLM_PI_AI_SETTINGS = settingsNamespace('llm-pi-ai');
31
+ const LLM_PI_AI_SETTINGS = 'llm-pi-ai';
33
32
  const GPT_REASONING_EFFORTS = {
34
33
  low: 'low',
35
34
  medium: 'medium',
@@ -134,17 +133,41 @@ function installCodexSettings(ctx, systemPrompt, persona, harnessSourcePrompt, w
134
133
  ...entry,
135
134
  ...value,
136
135
  });
137
- const settings = ctx.get('settings');
138
- if (settings?.get(CODEX_SETTINGS_NAMESPACE) !== undefined) {
139
- return {
140
- current: () => withDefaults(settings.get(CODEX_SETTINGS_NAMESPACE)),
141
- };
142
- }
143
136
  let source = () => entry;
144
- installSettingsSection(ctx, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, entry, {
145
- setSource: (current) => { source = current; },
146
- onChange: () => { },
147
- });
137
+ let attached = false;
138
+ const attachSettings = (candidate) => {
139
+ if (attached || candidate === undefined || candidate === null)
140
+ return attached;
141
+ const settings = candidate;
142
+ if (typeof settings.get === 'function') {
143
+ const get = settings.get.bind(settings);
144
+ if (get(CODEX_SETTINGS_NAMESPACE) !== undefined) {
145
+ source = () => get(CODEX_SETTINGS_NAMESPACE);
146
+ attached = true;
147
+ return true;
148
+ }
149
+ }
150
+ if (typeof settings.installSection === 'function') {
151
+ settings.installSection.call(settings, ctx, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, entry, {
152
+ setSource: (current) => { source = current; },
153
+ onChange: () => { },
154
+ });
155
+ attached = true;
156
+ return true;
157
+ }
158
+ if (typeof settings.register === 'function') {
159
+ const scope = settings.register.call(settings, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, { base: entry });
160
+ source = () => scope.get();
161
+ attached = true;
162
+ return true;
163
+ }
164
+ return false;
165
+ };
166
+ if (!attachSettings(ctx.get('settings'))) {
167
+ ctx.inject(['settings'], (settingsCtx) => {
168
+ attachSettings(settingsCtx.settings);
169
+ });
170
+ }
148
171
  return { current: () => withDefaults(source()) };
149
172
  }
150
173
  function hasOpenTurn(session) {
@@ -1,7 +1,8 @@
1
1
  /** Shared host-side Codex settings contract. */
2
2
  import z from '@deepseek-ai/schemastery';
3
+ import type { SettingsNamespace } from '@deepseek-ai/dsh-settings';
3
4
  /** Live Codex controls shared by the Web UI and agent layer. */
4
- export declare const CODEX_SETTINGS_NAMESPACE: Branded<"SettingsNamespace">;
5
+ export declare const CODEX_SETTINGS_NAMESPACE: SettingsNamespace;
5
6
  export interface CodexSettings {
6
7
  /** Use the Responses priority service tier for GPT requests. */
7
8
  fast: boolean;
@@ -1,10 +1,9 @@
1
1
  /** Shared host-side Codex settings contract. */
2
2
  import z from '@deepseek-ai/schemastery';
3
- import { settingsNamespace } from '@deepseek-ai/dsh-settings';
4
3
  import { CODEX_CONTEXT_MAX } from "./context.js";
5
4
  import { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, } from "./prompt.js";
6
5
  /** Live Codex controls shared by the Web UI and agent layer. */
7
- export const CODEX_SETTINGS_NAMESPACE = settingsNamespace('codex');
6
+ export const CODEX_SETTINGS_NAMESPACE = 'codex';
8
7
  /** Default settings exposed even before a Codex session is opened. */
9
8
  export const CODEX_SETTINGS_ENTRY = {
10
9
  fast: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuind/dsh-codex-harness",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "Codex coding preset with customizable prompts and tools for DSH.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",