@shuind/dsh-codex-harness 0.1.14 → 0.1.15

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 CHANGED
@@ -11,10 +11,31 @@
11
11
  - **远程搜索与压缩**:OpenAI Responses 请求默认优先使用 hosted `web_search` 和 `/responses/compact`;失败时回退到 DSH 的本地实现。
12
12
  - **上下文容量**:在 Web 中设置 `1K`–`1000K` tokens,设置值作用于下一次请求。
13
13
 
14
+ ## 可选协作提示词(私货)
15
+
16
+ 这段提示词默认关闭,不会注入系统提示词。需要时,在自定义 `agent.cordis.yml` 中开启:
17
+
18
+ ```yaml
19
+ - id: codex-tools
20
+ name: '@shuind/dsh-codex-harness'
21
+ config:
22
+ collaborationPrompt: true
23
+ ```
24
+
25
+ 开启后,Codex preset 会在系统提示词中注入以下协作要求:
26
+
27
+ ```text
28
+ Ask, align, and clarify whenever uncertainty, assumptions, tradeoffs, or decisions could materially affect the outcome.
29
+ Understand the user's full picture, align it with your own, and leave no hidden assumptions or gaps.
30
+ Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done.
31
+ Convey enough valuable information with as few words as possible. Stay focused on the end goal.
32
+ Solve problems by thinking from first principles and at a higher level.
33
+ Make things as effortless as possible for the user.
34
+ ```
14
35
  ## 安装
15
36
 
16
37
  ```sh
17
- dsh plugin --profile web add @shuind/dsh-codex-harness@0.1.14
38
+ dsh plugin --profile web add @shuind/dsh-codex-harness@0.1.15
18
39
  ```
19
40
 
20
41
  重启 Web,创建新会话,在模式菜单中选择 **Codex 模式**。
package/lib/index.js CHANGED
@@ -726,7 +726,8 @@ const Config = z.object({
726
726
  writeYieldTimeMs: z.number().step(1).min(0).default(250),
727
727
  maxOutputBytes: z.number().step(1).min(1).default(64e3),
728
728
  hostedWebSearch: z.boolean().default(true),
729
- remoteCompact: z.boolean().default(true)
729
+ remoteCompact: z.boolean().default(true),
730
+ collaborationPrompt: z.boolean().default(false)
730
731
  });
731
732
  const LLM_PI_AI_SETTINGS = settingsNamespace("llm-pi-ai");
732
733
  /** Live Codex-only request controls shared by the Web controls and agent layer. */
@@ -846,15 +847,6 @@ const CODEX_BASE_PROMPT = String.raw`You are Codex, based on {{model}}. You are
846
847
 
847
848
  - 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.
848
849
 
849
- ## Collaboration
850
-
851
- - Ask, align, and clarify whenever uncertainty, assumptions, tradeoffs, or decisions could materially affect the outcome.
852
- - Understand the user's full picture, align it with your own, and leave no hidden assumptions or gaps.
853
- - Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done.
854
- - Convey enough valuable information with as few words as possible. Stay focused on the end goal.
855
- - Solve problems by thinking from first principles and at a higher level.
856
- - Make things as effortless as possible for the user.
857
-
858
850
  ## Editing constraints
859
851
 
860
852
  - 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.
@@ -888,6 +880,19 @@ const CODEX_BASE_PROMPT = String.raw`You are Codex, based on {{model}}. You are
888
880
  - Do not dump large files into the conversation; refer to their paths.
889
881
  - Use plain text with short sections only when they improve scanability.
890
882
  `;
883
+ const CODEX_COLLABORATION_PROMPT = String.raw`## Collaboration
884
+
885
+ - Ask, align, and clarify whenever uncertainty, assumptions, tradeoffs, or decisions could materially affect the outcome.
886
+ - Understand the user's full picture, align it with your own, and leave no hidden assumptions or gaps.
887
+ - Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done.
888
+ - Convey enough valuable information with as few words as possible. Stay focused on the end goal.
889
+ - Solve problems by thinking from first principles and at a higher level.
890
+ - Make things as effortless as possible for the user.
891
+ `;
892
+ /** Build the Codex system prompt with optional, user-enabled collaboration guidance. */
893
+ function buildCodexSystemPrompt(config = {}) {
894
+ return config.collaborationPrompt === true ? `${CODEX_BASE_PROMPT}\n\n${CODEX_COLLABORATION_PROMPT}` : CODEX_BASE_PROMPT;
895
+ }
891
896
  const EXEC_COMMAND_DESCRIPTION = "Runs a command in a PTY, returning output or a session ID for ongoing interaction.";
892
897
  const WRITE_STDIN_DESCRIPTION = "Writes characters to an existing unified exec session and returns recent output.";
893
898
  const APPLY_PATCH_DESCRIPTION = "The `apply_patch` tool can be used to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.";
@@ -1257,7 +1262,8 @@ function apply(ctx, config = {}) {
1257
1262
  writeYieldTimeMs: config.writeYieldTimeMs ?? 250,
1258
1263
  maxOutputBytes: config.maxOutputBytes ?? 64e3,
1259
1264
  hostedWebSearch: config.hostedWebSearch ?? true,
1260
- remoteCompact: config.remoteCompact ?? true
1265
+ remoteCompact: config.remoteCompact ?? true,
1266
+ collaborationPrompt: config.collaborationPrompt ?? false
1261
1267
  };
1262
1268
  if (ctx.fs.sandboxMode !== void 0 && ctx.get("sandboxPolicy") === void 0) throw new Error("codex: a sandboxing filesystem requires ctx.sandboxPolicy");
1263
1269
  watchConfiguredGptModels(ctx);
@@ -1277,7 +1283,7 @@ function apply(ctx, config = {}) {
1277
1283
  ctx.systemPrompt.section({
1278
1284
  name: "codex:base",
1279
1285
  order: 10,
1280
- text: CODEX_BASE_PROMPT
1286
+ text: buildCodexSystemPrompt(resolved)
1281
1287
  });
1282
1288
  registerExecTools(ctx, resolved);
1283
1289
  registerPatchTool(ctx);
@@ -1290,4 +1296,4 @@ var types_default = {
1290
1296
  apply
1291
1297
  };
1292
1298
  //#endregion
1293
- export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, Config, apply, applyCodexRequestSettings, types_default as default, enrichCodexModel, inject, name };
1299
+ export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, Config, apply, applyCodexRequestSettings, buildCodexSystemPrompt, types_default as default, enrichCodexModel, inject, name };
@@ -26,6 +26,8 @@ export interface Config {
26
26
  hostedWebSearch?: boolean;
27
27
  /** Use the provider's /responses/compact endpoint before local compaction. */
28
28
  remoteCompact?: boolean;
29
+ /** Inject the optional collaboration guidance into the model system prompt. */
30
+ collaborationPrompt?: boolean;
29
31
  }
30
32
  /** Runtime configuration schema for the Codex tool bridge. */
31
33
  export declare const Config: z<Config>;
@@ -48,6 +50,8 @@ export interface CodexModelProfile {
48
50
  export declare function enrichCodexModel(model: CodexModelProfile): CodexModelProfile;
49
51
  /** Apply the live Codex controls to one agent request without leaking them to other routes. */
50
52
  export declare function applyCodexRequestSettings(request: LlmCallConfig, settings: CodexSettings): LlmCallConfig;
53
+ /** Build the Codex system prompt with optional, user-enabled collaboration guidance. */
54
+ export declare function buildCodexSystemPrompt(config?: Pick<Config, 'collaborationPrompt'>): string;
51
55
  /** Mount the Codex prompt/tool layer inside one fixed agent preset. */
52
56
  export declare function apply(ctx: Context, config?: Config): void;
53
57
  declare const _default: {
@@ -16,6 +16,7 @@ export const Config = z.object({
16
16
  maxOutputBytes: z.number().step(1).min(1).default(64_000),
17
17
  hostedWebSearch: z.boolean().default(true),
18
18
  remoteCompact: z.boolean().default(true),
19
+ collaborationPrompt: z.boolean().default(false),
19
20
  });
20
21
  const LLM_PI_AI_SETTINGS = settingsNamespace('llm-pi-ai');
21
22
  /** Live Codex-only request controls shared by the Web controls and agent layer. */
@@ -142,15 +143,6 @@ const CODEX_BASE_PROMPT = String.raw `You are Codex, based on {{model}}. You are
142
143
 
143
144
  - 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.
144
145
 
145
- ## Collaboration
146
-
147
- - Ask, align, and clarify whenever uncertainty, assumptions, tradeoffs, or decisions could materially affect the outcome.
148
- - Understand the user's full picture, align it with your own, and leave no hidden assumptions or gaps.
149
- - Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done.
150
- - Convey enough valuable information with as few words as possible. Stay focused on the end goal.
151
- - Solve problems by thinking from first principles and at a higher level.
152
- - Make things as effortless as possible for the user.
153
-
154
146
  ## Editing constraints
155
147
 
156
148
  - 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.
@@ -184,6 +176,21 @@ const CODEX_BASE_PROMPT = String.raw `You are Codex, based on {{model}}. You are
184
176
  - Do not dump large files into the conversation; refer to their paths.
185
177
  - Use plain text with short sections only when they improve scanability.
186
178
  `;
179
+ const CODEX_COLLABORATION_PROMPT = String.raw `## Collaboration
180
+
181
+ - Ask, align, and clarify whenever uncertainty, assumptions, tradeoffs, or decisions could materially affect the outcome.
182
+ - Understand the user's full picture, align it with your own, and leave no hidden assumptions or gaps.
183
+ - Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done.
184
+ - Convey enough valuable information with as few words as possible. Stay focused on the end goal.
185
+ - Solve problems by thinking from first principles and at a higher level.
186
+ - Make things as effortless as possible for the user.
187
+ `;
188
+ /** Build the Codex system prompt with optional, user-enabled collaboration guidance. */
189
+ export function buildCodexSystemPrompt(config = {}) {
190
+ return config.collaborationPrompt === true
191
+ ? `${CODEX_BASE_PROMPT}\n\n${CODEX_COLLABORATION_PROMPT}`
192
+ : CODEX_BASE_PROMPT;
193
+ }
187
194
  const EXEC_COMMAND_DESCRIPTION = 'Runs a command in a PTY, returning output or a session ID for ongoing interaction.';
188
195
  const WRITE_STDIN_DESCRIPTION = 'Writes characters to an existing unified exec session and returns recent output.';
189
196
  const APPLY_PATCH_DESCRIPTION = 'The `apply_patch` tool can be used to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.';
@@ -443,6 +450,7 @@ export function apply(ctx, config = {}) {
443
450
  maxOutputBytes: config.maxOutputBytes ?? 64_000,
444
451
  hostedWebSearch: config.hostedWebSearch ?? true,
445
452
  remoteCompact: config.remoteCompact ?? true,
453
+ collaborationPrompt: config.collaborationPrompt ?? false,
446
454
  };
447
455
  if (ctx.fs.sandboxMode !== undefined && ctx.get('sandboxPolicy') === undefined) {
448
456
  throw new Error('codex: a sandboxing filesystem requires ctx.sandboxPolicy');
@@ -476,7 +484,7 @@ export function apply(ctx, config = {}) {
476
484
  return next();
477
485
  }));
478
486
  }
479
- ctx.systemPrompt.section({ name: 'codex:base', order: 10, text: CODEX_BASE_PROMPT });
487
+ ctx.systemPrompt.section({ name: 'codex:base', order: 10, text: buildCodexSystemPrompt(resolved) });
480
488
  registerExecTools(ctx, resolved);
481
489
  registerPatchTool(ctx);
482
490
  registerPlanTool(ctx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuind/dsh-codex-harness",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "A minimal Codex harness for GPT models that do not fit DSH's native interface, while remaining compatible with the DSH plugin ecosystem.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -17,6 +17,8 @@
17
17
  # and the four Codex core tool names; execution remains delegated to dsh.
18
18
  - id: codex-tools
19
19
  name: '@shuind/dsh-codex-harness'
20
+ config:
21
+ collaborationPrompt: false
20
22
 
21
23
  # The generic DSH pi-ai adapter still owns the user's configured provider,
22
24
  # endpoint, API key, and model. Codex's remote-first transport wrapper is