@shuind/dsh-codex-harness 0.1.36 → 0.1.38

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
@@ -21,7 +21,7 @@
21
21
  ## 安装
22
22
 
23
23
  ```sh
24
- dsh plugin --profile web add @shuind/dsh-codex-harness@0.1.36
24
+ dsh plugin --profile web add @shuind/dsh-codex-harness@0.1.38
25
25
  ```
26
26
 
27
27
  重启 Web,创建新会话,在模式菜单中选择 **Codex 模式**。
@@ -124,9 +124,10 @@ order: 10
124
124
  开启后,Codex preset 会在系统提示词中注入以下协作要求:
125
125
 
126
126
  ```text
127
+ ## Working principles
128
+
127
129
  Ask, align, and clarify first. Gather enough context from the user, then align the approach to achieve the user's goal through the clearest, most effective path.
128
- 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.
129
- Convey enough valuable information with as few words as possible. Stay focused on the end goal.
130
+ 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, especially when writing documentation or communicating. Convey enough valuable information with as few words as possible.
130
131
  Solve problems by thinking from first principles and at a higher level.
131
132
  ```
132
133
 
package/lib/index.js CHANGED
@@ -1227,16 +1227,22 @@ function syncCodexContextWindow(session, contextWindow) {
1227
1227
  }
1228
1228
  /** Keep the official context meter synchronized with a live Codex override. */
1229
1229
  function installCodexContextProjection(ctx, current) {
1230
- const sync = (session) => {
1231
- syncCodexContextWindow(session, current().contextWindow);
1230
+ const sync = (session, contextWindow = current().contextWindow) => {
1231
+ syncCodexContextWindow(session, contextWindow);
1232
1232
  };
1233
- const syncAll = () => {
1233
+ const syncAll = (contextWindow = current().contextWindow) => {
1234
1234
  const sessions = ctx.get("sessions");
1235
- for (const session of sessions?.list?.() ?? []) sync(session);
1235
+ for (const session of sessions?.list?.() ?? []) sync(session, contextWindow);
1236
1236
  };
1237
1237
  ctx.on("session/event", (session, event) => {
1238
1238
  if (event.type === "request/header" || event.type === "request/context") sync(session);
1239
1239
  });
1240
+ ctx.on("session/created", (session) => {
1241
+ sync(session);
1242
+ });
1243
+ ctx.on("settings/updated", (ns, next) => {
1244
+ if (ns === CODEX_SETTINGS_NAMESPACE) syncAll(next.contextWindow);
1245
+ });
1240
1246
  ctx.on("settings/document-updated", (ns) => {
1241
1247
  if (ns === CODEX_SETTINGS_NAMESPACE) syncAll();
1242
1248
  });
@@ -1282,11 +1288,10 @@ const CODEX_BASE_PROMPT = String.raw`## General
1282
1288
  - Do not dump large files into the conversation; refer to their paths.
1283
1289
  - Use plain text with short sections only when they improve scanability.
1284
1290
  `;
1285
- const CODEX_COLLABORATION_PROMPT = String.raw`## Collaboration
1291
+ const CODEX_COLLABORATION_PROMPT = String.raw`## Working principles
1286
1292
 
1287
1293
  - Ask, align, and clarify first. Gather enough context from the user, then align the approach to achieve the user's goal through the clearest, most effective path.
1288
- - 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.
1289
- - Convey enough valuable information with as few words as possible. Stay focused on the end goal.
1294
+ - 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, especially when writing documentation or communicating. Convey enough valuable information with as few words as possible.
1290
1295
  - Solve problems by thinking from first principles and at a higher level.
1291
1296
  `;
1292
1297
  /** Put the agent persona first and omit the generic Harness identity opener. */
@@ -165,18 +165,30 @@ export function syncCodexContextWindow(session, contextWindow) {
165
165
  }
166
166
  /** Keep the official context meter synchronized with a live Codex override. */
167
167
  function installCodexContextProjection(ctx, current) {
168
- const sync = (session) => {
169
- syncCodexContextWindow(session, current().contextWindow);
168
+ const sync = (session, contextWindow = current().contextWindow) => {
169
+ syncCodexContextWindow(session, contextWindow);
170
170
  };
171
- const syncAll = () => {
171
+ const syncAll = (contextWindow = current().contextWindow) => {
172
172
  const sessions = ctx.get('sessions');
173
173
  for (const session of sessions?.list?.() ?? [])
174
- sync(session);
174
+ sync(session, contextWindow);
175
175
  };
176
176
  ctx.on('session/event', (session, event) => {
177
177
  if (event.type === 'request/header' || event.type === 'request/context')
178
178
  sync(session);
179
179
  });
180
+ // Restored sessions may already contain their request/header seed, so no
181
+ // session/event is emitted for the initial capacity. Catch them at the
182
+ // store publication boundary as well.
183
+ ctx.on('session/created', (session) => { sync(session); });
184
+ // Use the resolved value carried by the consumer-facing event. This avoids
185
+ // waiting for the settings source closure to refresh before synchronizing
186
+ // already-open sessions.
187
+ ctx.on('settings/updated', (ns, next) => {
188
+ if (ns === CODEX_SETTINGS_NAMESPACE) {
189
+ syncAll(next.contextWindow);
190
+ }
191
+ });
180
192
  ctx.on('settings/document-updated', ns => {
181
193
  if (ns === CODEX_SETTINGS_NAMESPACE)
182
194
  syncAll();
@@ -225,11 +237,10 @@ const CODEX_BASE_PROMPT = String.raw `## General
225
237
  - Do not dump large files into the conversation; refer to their paths.
226
238
  - Use plain text with short sections only when they improve scanability.
227
239
  `;
228
- const CODEX_COLLABORATION_PROMPT = String.raw `## Collaboration
240
+ const CODEX_COLLABORATION_PROMPT = String.raw `## Working principles
229
241
 
230
242
  - Ask, align, and clarify first. Gather enough context from the user, then align the approach to achieve the user's goal through the clearest, most effective path.
231
- - 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.
232
- - Convey enough valuable information with as few words as possible. Stay focused on the end goal.
243
+ - 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, especially when writing documentation or communicating. Convey enough valuable information with as few words as possible.
233
244
  - Solve problems by thinking from first principles and at a higher level.
234
245
  `;
235
246
  /** Put the agent persona first and omit the generic Harness identity opener. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuind/dsh-codex-harness",
3
- "version": "0.1.36",
3
+ "version": "0.1.38",
4
4
  "description": "A Codex harness with a streamlined system prompt 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",