@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.
- package/README.md +49 -49
- package/cordis.patch.yml +11 -11
- package/lib/client.js +378 -114
- package/lib/compaction.js +10 -1
- package/lib/index.js +184 -19
- package/lib/installer.js +24 -1
- package/lib/types/client/index.d.ts +26 -9
- package/lib/types/client/index.js +183 -56
- package/lib/types/compact-command.d.ts +13 -0
- package/lib/types/compact-command.js +79 -0
- package/lib/types/compaction.d.ts +6 -0
- package/lib/types/compaction.js +9 -0
- package/lib/types/index.d.ts +7 -1
- package/lib/types/index.js +81 -16
- package/lib/types/patch.js +15 -15
- package/lib/types/prompt.d.ts +6 -0
- package/lib/types/prompt.js +50 -35
- package/lib/types/settings.d.ts +8 -0
- package/lib/types/settings.js +9 -1
- package/package.json +260 -247
- package/presets/codex-collaboration/agent.cordis.yml +197 -197
- package/presets/codex-collaboration/preset.yml +3 -3
package/lib/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import { mkdirSync, writeFileSync } from "node:fs";
|
|
|
9
9
|
import { homedir } from "node:os";
|
|
10
10
|
import { isTokenDelta } from "@deepseek-ai/dsh-llm/message";
|
|
11
11
|
import { z as z$1 } from "zod";
|
|
12
|
+
import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
|
|
12
13
|
//#region lib/types/patch.js
|
|
13
14
|
/** Parser and line-oriented applicator for Codex's `apply_patch` language. */
|
|
14
15
|
const APPLY_PATCH_DESCRIPTION = "Edits files using Codex patch syntax with Begin/End Patch markers and file update directives. In hunk lines, the first character is the operation marker; repeat a source-leading marker when the source line itself starts with one.";
|
|
@@ -535,7 +536,7 @@ function serviceTierOf(options) {
|
|
|
535
536
|
const value = options.serviceTier;
|
|
536
537
|
return typeof value === "string" ? value : void 0;
|
|
537
538
|
}
|
|
538
|
-
function isGptModel$
|
|
539
|
+
function isGptModel$2(model) {
|
|
539
540
|
return typeof model === "string" && /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
|
|
540
541
|
}
|
|
541
542
|
function settingsOf(ctx) {
|
|
@@ -813,11 +814,11 @@ function hasRemoteCompaction(body) {
|
|
|
813
814
|
});
|
|
814
815
|
}
|
|
815
816
|
function canPatchBody(body, options) {
|
|
816
|
-
return isGptModel$
|
|
817
|
+
return isGptModel$2(body.model) && (options.hostedWebSearch !== false && hasWebSearchTool(body) || hasRemoteCompaction(body) || options.customApplyPatch !== false && hasFunctionApplyPatchTool(body) && canRewriteApplyPatchHistory(body));
|
|
817
818
|
}
|
|
818
819
|
/** Add provider options that older pi-ai adapters do not copy themselves. */
|
|
819
820
|
function applyRequestWireOptions(body, options) {
|
|
820
|
-
if (options.serviceTier === void 0 || !isGptModel$
|
|
821
|
+
if (options.serviceTier === void 0 || !isGptModel$2(body.model)) return body;
|
|
821
822
|
return {
|
|
822
823
|
...body,
|
|
823
824
|
service_tier: options.serviceTier
|
|
@@ -1206,10 +1207,25 @@ const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
|
|
|
1206
1207
|
|
|
1207
1208
|
## Working principles
|
|
1208
1209
|
|
|
1209
|
-
-
|
|
1210
|
+
- Actively establish the user's current context rather than relying on stale assumptions or prior context. Before committing to an approach that could materially shape the outcome or direction of the work, state the intended path and align it with the user; clarify any material uncertainty first. Then pursue the user's goal through the clearest, most effective path.
|
|
1210
1211
|
- Keep only the essential logic and core actions. Don't explain or test what was removed or why something wasn't done, especially when writing documentation or communicating. Convey enough valuable information with as few words as possible.
|
|
1211
1212
|
- Solve problems by thinking from first principles and at a higher level.
|
|
1212
1213
|
`;
|
|
1214
|
+
/** Default deployment Persona template used by the Codex preset. */
|
|
1215
|
+
const DEFAULT_CODEX_PERSONA = String.raw`You are Codex, a coding agent based on the {{model}} model. Your working directory is {{cwd}}.`;
|
|
1216
|
+
/** Default DSH Core source-checkout guidance template. */
|
|
1217
|
+
const DEFAULT_DSH_CORE_SOURCE_PROMPT = String.raw`The DeepSeek Harness implementation checkout is at {{sourceRoot}}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.`;
|
|
1218
|
+
/** Default DSH Web runtime guidance template. */
|
|
1219
|
+
const DEFAULT_DSH_CORE_WEB_PROMPT = [
|
|
1220
|
+
"You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}.",
|
|
1221
|
+
"When the user refers to \"this page\", \"this GUI\", or \"this app\" without naming another target, they mean this GUI.",
|
|
1222
|
+
"The browser provides no implicit DOM, route, or screenshot context.",
|
|
1223
|
+
"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.",
|
|
1224
|
+
"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.",
|
|
1225
|
+
"Starting another server does not update this GUI.",
|
|
1226
|
+
"The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__.",
|
|
1227
|
+
"Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL."
|
|
1228
|
+
].join(" ");
|
|
1213
1229
|
/** Resolve the full plugin-owned prompt, preserving intentional empty overrides. */
|
|
1214
1230
|
function resolveCodexSystemPrompt(systemPrompt) {
|
|
1215
1231
|
return systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT;
|
|
@@ -1225,6 +1241,10 @@ const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
|
|
|
1225
1241
|
/** Default settings exposed even before a Codex session is opened. */
|
|
1226
1242
|
const CODEX_SETTINGS_ENTRY = {
|
|
1227
1243
|
fast: false,
|
|
1244
|
+
fastModeControlEnabled: true,
|
|
1245
|
+
persona: DEFAULT_CODEX_PERSONA,
|
|
1246
|
+
harnessSourcePrompt: DEFAULT_DSH_CORE_SOURCE_PROMPT,
|
|
1247
|
+
webSurfacePrompt: DEFAULT_DSH_CORE_WEB_PROMPT,
|
|
1228
1248
|
systemPrompt: DEFAULT_CODEX_SYSTEM_PROMPT,
|
|
1229
1249
|
promptEnabled: true,
|
|
1230
1250
|
terminalToolsEnabled: true,
|
|
@@ -1236,7 +1256,11 @@ const CODEX_SETTINGS_ENTRY = {
|
|
|
1236
1256
|
};
|
|
1237
1257
|
const CODEX_SETTINGS_SCHEMA = z.object({
|
|
1238
1258
|
fast: z.boolean().default(false),
|
|
1259
|
+
fastModeControlEnabled: z.boolean().default(true),
|
|
1239
1260
|
contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX),
|
|
1261
|
+
persona: z.string().default(DEFAULT_CODEX_PERSONA),
|
|
1262
|
+
harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
|
|
1263
|
+
webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),
|
|
1240
1264
|
systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
|
|
1241
1265
|
promptEnabled: z.boolean().default(true),
|
|
1242
1266
|
terminalToolsEnabled: z.boolean().default(true),
|
|
@@ -1247,6 +1271,88 @@ const CODEX_SETTINGS_SCHEMA = z.object({
|
|
|
1247
1271
|
activityIndicatorEnabled: z.boolean().default(true)
|
|
1248
1272
|
});
|
|
1249
1273
|
//#endregion
|
|
1274
|
+
//#region lib/types/compaction.js
|
|
1275
|
+
/** Codex compaction backend that honors the latest durable request capacity. */
|
|
1276
|
+
const COMPACTION_MODE = new AsyncLocalStorage();
|
|
1277
|
+
/** Read the explicit preference for the current compaction stream, if any. */
|
|
1278
|
+
function codexCompactionMode() {
|
|
1279
|
+
return COMPACTION_MODE.getStore();
|
|
1280
|
+
}
|
|
1281
|
+
const CODEX_SETTINGS_NAMESPACE$1 = settingsNamespace("codex");
|
|
1282
|
+
/** Codex context overrides apply only to GPT-compatible model routes. */
|
|
1283
|
+
function isGptModel$1(model) {
|
|
1284
|
+
return /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
|
|
1285
|
+
}
|
|
1286
|
+
/** Read the live Codex capacity without requiring a custom LLM service API. */
|
|
1287
|
+
function configuredContextWindow(ctx) {
|
|
1288
|
+
const settings = ctx.get("settings");
|
|
1289
|
+
if (settings?.get === void 0) return { available: false };
|
|
1290
|
+
const value = settings?.get?.(CODEX_SETTINGS_NAMESPACE$1);
|
|
1291
|
+
return {
|
|
1292
|
+
available: true,
|
|
1293
|
+
...value?.contextWindow !== void 0 && Number.isSafeInteger(value.contextWindow) && value.contextWindow > 0 ? { value: value.contextWindow } : {}
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
/** Read an explicit capacity persisted in the request header when settings are unavailable. */
|
|
1297
|
+
function requestContextWindow(session, provider, model) {
|
|
1298
|
+
const config = session.requestHeader()?.config;
|
|
1299
|
+
if (config?.provider !== provider || config.model !== model) return void 0;
|
|
1300
|
+
const value = config.contextWindow;
|
|
1301
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : void 0;
|
|
1302
|
+
}
|
|
1303
|
+
/** Resolve the capacity currently in force for an active Codex compaction. */
|
|
1304
|
+
function activeContextWindow(ctx, activeSession, provider, model) {
|
|
1305
|
+
const session = activeSession.getStore();
|
|
1306
|
+
const requestContext = session?.requestContext();
|
|
1307
|
+
const configured = isGptModel$1(model) ? configuredContextWindow(ctx) : { available: false };
|
|
1308
|
+
return configured.available ? configured.value : (session === void 0 ? void 0 : requestContextWindow(session, provider, model)) ?? (requestContext?.provider === provider && requestContext.model === model ? requestContext.contextWindow : void 0);
|
|
1309
|
+
}
|
|
1310
|
+
/** Overlay capacity lookup and auxiliary summary requests for compaction. */
|
|
1311
|
+
function withDurableContextCapacity(llm, ctx, activeSession) {
|
|
1312
|
+
return new Proxy(llm, { get(target, property) {
|
|
1313
|
+
if (property === "resolveModelInfo") return async (provider, model, signal) => {
|
|
1314
|
+
const info = await target.resolveModelInfo(provider, model, signal);
|
|
1315
|
+
const contextWindow = activeContextWindow(ctx, activeSession, provider, model);
|
|
1316
|
+
if (contextWindow === void 0) return info;
|
|
1317
|
+
return {
|
|
1318
|
+
...info,
|
|
1319
|
+
context: {
|
|
1320
|
+
...info.context,
|
|
1321
|
+
contextWindow
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
};
|
|
1325
|
+
if (property === "stream") return (options) => {
|
|
1326
|
+
const contextWindow = activeContextWindow(ctx, activeSession, options.provider, options.model);
|
|
1327
|
+
if (contextWindow === void 0 || options.contextWindow === contextWindow) return target.stream(options);
|
|
1328
|
+
return target.stream({
|
|
1329
|
+
...options,
|
|
1330
|
+
contextWindow
|
|
1331
|
+
});
|
|
1332
|
+
};
|
|
1333
|
+
const value = Reflect.get(target, property, target);
|
|
1334
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
1335
|
+
} });
|
|
1336
|
+
}
|
|
1337
|
+
(class extends BasicCompactionEngine {
|
|
1338
|
+
static inject = BasicCompactionEngine.inject;
|
|
1339
|
+
static Config = BasicCompactionEngine.Config;
|
|
1340
|
+
activeSession;
|
|
1341
|
+
constructor(ctx, config = {}) {
|
|
1342
|
+
const activeSession = new AsyncLocalStorage();
|
|
1343
|
+
const llm = ctx.get("llm");
|
|
1344
|
+
if (llm === void 0) throw new Error("codex compaction requires ctx.llm");
|
|
1345
|
+
super(ctx.extend({ llm: withDurableContextCapacity(llm, ctx, activeSession) }), config);
|
|
1346
|
+
this.activeSession = activeSession;
|
|
1347
|
+
}
|
|
1348
|
+
compactIfNeeded(agent, trigger, signal) {
|
|
1349
|
+
return this.activeSession.run(agent.session, () => super.compactIfNeeded(agent, trigger, signal));
|
|
1350
|
+
}
|
|
1351
|
+
compactNow(agent, signal, sourceCommandId) {
|
|
1352
|
+
return this.activeSession.run(agent.session, () => super.compactNow(agent, signal, sourceCommandId));
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1355
|
+
//#endregion
|
|
1250
1356
|
//#region lib/types/index.js
|
|
1251
1357
|
/** Codex-compatible prompt overlay and core tools for a dsh agent preset. */
|
|
1252
1358
|
const name = "codex";
|
|
@@ -1270,7 +1376,10 @@ const Config = z.object({
|
|
|
1270
1376
|
maxOutputBytes: z.number().step(1).min(1).default(DEFAULT_MAX_OUTPUT_BYTES),
|
|
1271
1377
|
hostedWebSearch: z.boolean().default(true),
|
|
1272
1378
|
remoteCompact: z.boolean().default(true),
|
|
1273
|
-
systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT)
|
|
1379
|
+
systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
|
|
1380
|
+
persona: z.string().default(DEFAULT_CODEX_PERSONA),
|
|
1381
|
+
harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
|
|
1382
|
+
webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT)
|
|
1274
1383
|
});
|
|
1275
1384
|
const LLM_PI_AI_SETTINGS = settingsNamespace("llm-pi-ai");
|
|
1276
1385
|
const GPT_REASONING_EFFORTS = {
|
|
@@ -1357,10 +1466,13 @@ function watchConfiguredGptModels(ctx) {
|
|
|
1357
1466
|
schedule();
|
|
1358
1467
|
}
|
|
1359
1468
|
/** Install the optional settings source used by requests and prompt assembly. */
|
|
1360
|
-
function installCodexSettings(ctx, systemPrompt) {
|
|
1469
|
+
function installCodexSettings(ctx, systemPrompt, persona, harnessSourcePrompt, webSurfacePrompt) {
|
|
1361
1470
|
const entry = {
|
|
1362
1471
|
...CODEX_SETTINGS_ENTRY,
|
|
1363
|
-
systemPrompt
|
|
1472
|
+
systemPrompt,
|
|
1473
|
+
persona,
|
|
1474
|
+
harnessSourcePrompt,
|
|
1475
|
+
webSurfacePrompt
|
|
1364
1476
|
};
|
|
1365
1477
|
const withDefaults = (value) => ({
|
|
1366
1478
|
...entry,
|
|
@@ -1460,6 +1572,51 @@ function normalizeCodexPromptAssembly(assembly) {
|
|
|
1460
1572
|
sections: [persona, ...sections.filter((section) => section.name !== "deployment:persona")]
|
|
1461
1573
|
};
|
|
1462
1574
|
}
|
|
1575
|
+
function sectionText(assembly, name) {
|
|
1576
|
+
return assembly.sections.find((candidate) => candidate.name === name)?.text;
|
|
1577
|
+
}
|
|
1578
|
+
function promptVariables(assembly) {
|
|
1579
|
+
const variables = { ...assembly.variables };
|
|
1580
|
+
if (variables.sourceRoot === void 0) {
|
|
1581
|
+
const match = sectionText(assembly, "harness:source")?.match(/^The DeepSeek Harness implementation checkout is at (.+?)\. The checkout location/u);
|
|
1582
|
+
if (match?.[1] !== void 0) variables.sourceRoot = match[1];
|
|
1583
|
+
}
|
|
1584
|
+
if (variables.webUrl === void 0) {
|
|
1585
|
+
const match = sectionText(assembly, "app:web-surface")?.match(/^You are interacting with the user through the DeepSeek Harness Web GUI at (.+?)\. When/u);
|
|
1586
|
+
if (match?.[1] !== void 0) variables.webUrl = match[1];
|
|
1587
|
+
}
|
|
1588
|
+
return variables;
|
|
1589
|
+
}
|
|
1590
|
+
function interpolateCodexPrompt(text, variables) {
|
|
1591
|
+
return text.replace(/\{\{([\w.-]+)\}\}/g, (whole, key) => variables[key] ?? whole);
|
|
1592
|
+
}
|
|
1593
|
+
/** Apply user-editable Persona and DSH Core runtime prompt templates. */
|
|
1594
|
+
function applyCodexPromptOverrides(assembly, settings) {
|
|
1595
|
+
const overrides = {
|
|
1596
|
+
"deployment:persona": settings.persona,
|
|
1597
|
+
"harness:source": settings.harnessSourcePrompt,
|
|
1598
|
+
"app:web-surface": settings.webSurfacePrompt
|
|
1599
|
+
};
|
|
1600
|
+
const defaults = {
|
|
1601
|
+
"deployment:persona": DEFAULT_CODEX_PERSONA,
|
|
1602
|
+
"harness:source": DEFAULT_DSH_CORE_SOURCE_PROMPT,
|
|
1603
|
+
"app:web-surface": DEFAULT_DSH_CORE_WEB_PROMPT
|
|
1604
|
+
};
|
|
1605
|
+
if (!Object.entries(overrides).some(([name, text]) => text !== void 0 && text !== defaults[name])) return assembly;
|
|
1606
|
+
const variables = promptVariables(assembly);
|
|
1607
|
+
const sections = assembly.sections.map((section) => {
|
|
1608
|
+
const template = overrides[section.name];
|
|
1609
|
+
return template === void 0 || template === defaults[section.name] ? section : {
|
|
1610
|
+
...section,
|
|
1611
|
+
text: interpolateCodexPrompt(template, variables)
|
|
1612
|
+
};
|
|
1613
|
+
});
|
|
1614
|
+
return {
|
|
1615
|
+
...assembly,
|
|
1616
|
+
sections,
|
|
1617
|
+
variables
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1463
1620
|
const CODEX_TOOL_NAMES = {
|
|
1464
1621
|
terminalToolsEnabled: /* @__PURE__ */ new Set(["exec_command", "write_stdin"]),
|
|
1465
1622
|
patchToolEnabled: /* @__PURE__ */ new Set(["apply_patch"]),
|
|
@@ -1472,11 +1629,11 @@ function applyCodexCapabilitySettings(assembly, settings) {
|
|
|
1472
1629
|
if (settings[setting]) continue;
|
|
1473
1630
|
for (const name of names) disabled.add(name);
|
|
1474
1631
|
}
|
|
1475
|
-
const
|
|
1632
|
+
const withOverrides = applyCodexPromptOverrides(disabled.size === 0 ? assembly : {
|
|
1476
1633
|
...assembly,
|
|
1477
1634
|
tools: assembly.tools.filter((tool) => !disabled.has(tool.name))
|
|
1478
|
-
};
|
|
1479
|
-
return settings.promptEnabled ? normalizeCodexPromptAssembly(
|
|
1635
|
+
}, settings);
|
|
1636
|
+
return settings.promptEnabled ? normalizeCodexPromptAssembly(withOverrides) : withOverrides;
|
|
1480
1637
|
}
|
|
1481
1638
|
/** Build the complete plugin-owned prompt, preserving an intentional empty value. */
|
|
1482
1639
|
function buildCodexSystemPrompt(config = {}) {
|
|
@@ -1865,10 +2022,13 @@ function apply(ctx, config = {}) {
|
|
|
1865
2022
|
maxOutputBytes: config.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES,
|
|
1866
2023
|
hostedWebSearch: config.hostedWebSearch ?? true,
|
|
1867
2024
|
remoteCompact: config.remoteCompact ?? true,
|
|
1868
|
-
systemPrompt: config.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT
|
|
2025
|
+
systemPrompt: config.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT,
|
|
2026
|
+
persona: config.persona ?? DEFAULT_CODEX_PERSONA,
|
|
2027
|
+
harnessSourcePrompt: config.harnessSourcePrompt ?? DEFAULT_DSH_CORE_SOURCE_PROMPT,
|
|
2028
|
+
webSurfacePrompt: config.webSurfacePrompt ?? DEFAULT_DSH_CORE_WEB_PROMPT
|
|
1869
2029
|
};
|
|
1870
2030
|
if (resolved.codexCore && ctx.fs.sandboxMode !== void 0 && ctx.get("sandboxPolicy") === void 0) throw new Error("codex: a sandboxing filesystem requires ctx.sandboxPolicy");
|
|
1871
|
-
const codexSettings = installCodexSettings(ctx, resolved.systemPrompt);
|
|
2031
|
+
const codexSettings = installCodexSettings(ctx, resolved.systemPrompt, resolved.persona, resolved.harnessSourcePrompt, resolved.webSurfacePrompt);
|
|
1872
2032
|
const execConfig = {
|
|
1873
2033
|
...resolved,
|
|
1874
2034
|
currentSettings: codexSettings.current
|
|
@@ -1886,16 +2046,21 @@ function apply(ctx, config = {}) {
|
|
|
1886
2046
|
}
|
|
1887
2047
|
ctx.on("llm/stream", ((options, next) => {
|
|
1888
2048
|
const settings = codexSettings.current();
|
|
1889
|
-
const
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
2049
|
+
const contextWindow = options.contextWindow ?? settings.contextWindow;
|
|
2050
|
+
const compactionMode = codexCompactionMode();
|
|
2051
|
+
const legacySafeNext = () => repairLegacyPiAiContextOverflow(next(), options.model, contextWindow);
|
|
2052
|
+
if (options.purpose === "compaction" && isGptModel(options.model)) {
|
|
2053
|
+
if (compactionMode === "remote" || compactionMode !== "local" && resolved.remoteCompact && settings.remoteCompactionEnabled) return remoteCompactStream(ctx, options, legacySafeNext, {
|
|
2054
|
+
hostedWebSearch: resolved.hostedWebSearch && settings.hostedWebSearchEnabled,
|
|
2055
|
+
customApplyPatch: settings.patchToolEnabled
|
|
2056
|
+
});
|
|
2057
|
+
return legacySafeNext();
|
|
2058
|
+
}
|
|
1894
2059
|
if (options.purpose === void 0 && isGptModel(options.model)) return repairLegacyPiAiContextOverflow(hostedWebSearchStream(next, {
|
|
1895
2060
|
serviceTier: options.serviceTier,
|
|
1896
2061
|
hostedWebSearch: resolved.hostedWebSearch && settings.hostedWebSearchEnabled,
|
|
1897
2062
|
customApplyPatch: settings.patchToolEnabled
|
|
1898
|
-
}), options.model,
|
|
2063
|
+
}), options.model, contextWindow);
|
|
1899
2064
|
return next();
|
|
1900
2065
|
}));
|
|
1901
2066
|
}
|
|
@@ -1918,4 +2083,4 @@ var types_default = {
|
|
|
1918
2083
|
apply
|
|
1919
2084
|
};
|
|
1920
2085
|
//#endregion
|
|
1921
|
-
export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, Config, DEFAULT_CODEX_SYSTEM_PROMPT, apply, applyCodexCapabilitySettings, applyCodexRequestSettings, buildCodexSystemPrompt, types_default as default, enrichCodexModel, inject, name, normalizeCodexPromptAssembly, syncCodexContextWindow };
|
|
2086
|
+
export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, Config, DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, apply, applyCodexCapabilitySettings, applyCodexRequestSettings, buildCodexSystemPrompt, types_default as default, enrichCodexModel, inject, name, normalizeCodexPromptAssembly, syncCodexContextWindow };
|
package/lib/installer.js
CHANGED
|
@@ -42,10 +42,25 @@ const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
|
|
|
42
42
|
|
|
43
43
|
## Working principles
|
|
44
44
|
|
|
45
|
-
-
|
|
45
|
+
- Actively establish the user's current context rather than relying on stale assumptions or prior context. Before committing to an approach that could materially shape the outcome or direction of the work, state the intended path and align it with the user; clarify any material uncertainty first. Then pursue the user's goal through the clearest, most effective path.
|
|
46
46
|
- Keep only the essential logic and core actions. Don't explain or test what was removed or why something wasn't done, especially when writing documentation or communicating. Convey enough valuable information with as few words as possible.
|
|
47
47
|
- Solve problems by thinking from first principles and at a higher level.
|
|
48
48
|
`;
|
|
49
|
+
/** Default deployment Persona template used by the Codex preset. */
|
|
50
|
+
const DEFAULT_CODEX_PERSONA = String.raw`You are Codex, a coding agent based on the {{model}} model. Your working directory is {{cwd}}.`;
|
|
51
|
+
/** Default DSH Core source-checkout guidance template. */
|
|
52
|
+
const DEFAULT_DSH_CORE_SOURCE_PROMPT = String.raw`The DeepSeek Harness implementation checkout is at {{sourceRoot}}. The checkout location and current working directory are separate values and may differ; never infer the working directory from this path. Use pwd to determine the current working directory. Use this checkout only to inspect or extend DSH itself.`;
|
|
53
|
+
/** Default DSH Web runtime guidance template. */
|
|
54
|
+
const DEFAULT_DSH_CORE_WEB_PROMPT = [
|
|
55
|
+
"You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}.",
|
|
56
|
+
"When the user refers to \"this page\", \"this GUI\", or \"this app\" without naming another target, they mean this GUI.",
|
|
57
|
+
"The browser provides no implicit DOM, route, or screenshot context.",
|
|
58
|
+
"The client-plugin HMR receiver is active, but client-plugin changes reload without a refresh only while `pnpm run dev:web` is also running from this same checkout to rebuild their bundles; verify that watcher before promising automatic updates.",
|
|
59
|
+
"Every other change - the apps/web shell and plain packages - requires rebuilding the affected Web artifacts and verifying this existing URL after a page refresh.",
|
|
60
|
+
"Starting another server does not update this GUI.",
|
|
61
|
+
"The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__.",
|
|
62
|
+
"Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL."
|
|
63
|
+
].join(" ");
|
|
49
64
|
//#endregion
|
|
50
65
|
//#region lib/types/settings.js
|
|
51
66
|
/** Shared host-side Codex settings contract. */
|
|
@@ -54,6 +69,10 @@ const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
|
|
|
54
69
|
/** Default settings exposed even before a Codex session is opened. */
|
|
55
70
|
const CODEX_SETTINGS_ENTRY = {
|
|
56
71
|
fast: false,
|
|
72
|
+
fastModeControlEnabled: true,
|
|
73
|
+
persona: DEFAULT_CODEX_PERSONA,
|
|
74
|
+
harnessSourcePrompt: DEFAULT_DSH_CORE_SOURCE_PROMPT,
|
|
75
|
+
webSurfacePrompt: DEFAULT_DSH_CORE_WEB_PROMPT,
|
|
57
76
|
systemPrompt: DEFAULT_CODEX_SYSTEM_PROMPT,
|
|
58
77
|
promptEnabled: true,
|
|
59
78
|
terminalToolsEnabled: true,
|
|
@@ -65,7 +84,11 @@ const CODEX_SETTINGS_ENTRY = {
|
|
|
65
84
|
};
|
|
66
85
|
const CODEX_SETTINGS_SCHEMA = z.object({
|
|
67
86
|
fast: z.boolean().default(false),
|
|
87
|
+
fastModeControlEnabled: z.boolean().default(true),
|
|
68
88
|
contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX),
|
|
89
|
+
persona: z.string().default(DEFAULT_CODEX_PERSONA),
|
|
90
|
+
harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
|
|
91
|
+
webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),
|
|
69
92
|
systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
|
|
70
93
|
promptEnabled: z.boolean().default(true),
|
|
71
94
|
terminalToolsEnabled: z.boolean().default(true),
|
|
@@ -7,7 +7,11 @@ import { modelActivity } from './activity.ts';
|
|
|
7
7
|
declare const LEGACY_OVERLAY_SLOT: "conversation.input.overlay";
|
|
8
8
|
interface CodexSettings {
|
|
9
9
|
fast: boolean;
|
|
10
|
+
fastModeControlEnabled: boolean;
|
|
10
11
|
contextWindow?: number;
|
|
12
|
+
persona?: string;
|
|
13
|
+
harnessSourcePrompt?: string;
|
|
14
|
+
webSurfacePrompt?: string;
|
|
11
15
|
systemPrompt?: string;
|
|
12
16
|
promptEnabled: boolean;
|
|
13
17
|
terminalToolsEnabled: boolean;
|
|
@@ -29,25 +33,38 @@ declare const en: {
|
|
|
29
33
|
readonly contextRestore: "Restore model default";
|
|
30
34
|
readonly promptCardTitle: "Codex Harness";
|
|
31
35
|
readonly promptCardDescription: "Choose Codex capabilities and customize the operating prompt.";
|
|
32
|
-
readonly
|
|
36
|
+
readonly codexOnlyCapabilitiesLabel: "Codex mode only";
|
|
37
|
+
readonly otherCapabilitiesLabel: "Additional capabilities";
|
|
33
38
|
readonly capabilityPrompt: "Codex operating prompt";
|
|
34
|
-
readonly capabilityPromptHint: "Inject the editable instructions and persona-first prompt layout
|
|
39
|
+
readonly capabilityPromptHint: "Inject the editable instructions and persona-first prompt layout.";
|
|
40
|
+
readonly capabilityFast: "Fast mode control";
|
|
41
|
+
readonly capabilityFastHint: "Show the Fast mode switch beside the conversation composer.";
|
|
42
|
+
readonly compactRemote: "Remote compaction";
|
|
43
|
+
readonly compactRemoteHint: "Use the provider remote compaction endpoint first.";
|
|
44
|
+
readonly compactLocal: "Local compaction";
|
|
45
|
+
readonly compactLocalHint: "Use the DSH text-summary compaction engine directly.";
|
|
35
46
|
readonly capabilityTerminal: "Terminal tools";
|
|
36
|
-
readonly capabilityTerminalHint: "Expose exec_command and write_stdin
|
|
47
|
+
readonly capabilityTerminalHint: "Expose exec_command and write_stdin.";
|
|
37
48
|
readonly capabilityPatch: "Patch tool";
|
|
38
|
-
readonly capabilityPatchHint: "Expose apply_patch
|
|
49
|
+
readonly capabilityPatchHint: "Expose apply_patch, using the native Responses grammar when supported.";
|
|
39
50
|
readonly capabilityPlan: "Plan tool";
|
|
40
|
-
readonly capabilityPlanHint: "Expose update_plan for implementation task tracking
|
|
51
|
+
readonly capabilityPlanHint: "Expose update_plan for implementation task tracking.";
|
|
41
52
|
readonly capabilityWebSearch: "Hosted web search";
|
|
42
53
|
readonly capabilityWebSearchHint: "Use the provider-native Responses web_search tool when available.";
|
|
43
54
|
readonly capabilityCompaction: "Remote compaction";
|
|
44
55
|
readonly capabilityCompactionHint: "Prefer the provider Responses compact endpoint before local compaction.";
|
|
45
56
|
readonly capabilityActivity: "Activity indicator";
|
|
46
57
|
readonly capabilityActivityHint: "Show request, reply, and compaction status beside the conversation.";
|
|
47
|
-
readonly
|
|
48
|
-
readonly
|
|
49
|
-
readonly
|
|
50
|
-
readonly
|
|
58
|
+
readonly promptCustomizationLabel: "Prompt customization";
|
|
59
|
+
readonly personaLabel: "Persona";
|
|
60
|
+
readonly personaHint: "Deployment identity and role. Supports {{model}} and {{cwd}}.";
|
|
61
|
+
readonly sourcePromptLabel: "DSH Core source instructions";
|
|
62
|
+
readonly sourcePromptHint: "Guidance about the DSH checkout and working directory. Supports {{sourceRoot}}.";
|
|
63
|
+
readonly webPromptLabel: "DSH Core Web instructions";
|
|
64
|
+
readonly webPromptHint: "Guidance about this Web GUI, HMR, builds, and verification. Supports {{webUrl}}.";
|
|
65
|
+
readonly promptRestoreAll: "Restore all prompt defaults";
|
|
66
|
+
readonly promptLabel: "Codex operating prompt";
|
|
67
|
+
readonly promptHint: "This is the Codex operating prompt. Persona and DSH Core instructions are edited separately above.";
|
|
51
68
|
readonly promptUnsaved: "Unsaved";
|
|
52
69
|
readonly promptDiscard: "Discard";
|
|
53
70
|
readonly promptSave: "Save";
|