@shuind/dsh-codex-harness 0.1.39 → 0.1.40

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.39
24
+ dsh plugin --profile web add @shuind/dsh-codex-harness@0.1.40
25
25
  ```
26
26
 
27
27
  重启 Web,创建新会话,在模式菜单中选择 **Codex 模式**。
package/lib/index.js CHANGED
@@ -1230,12 +1230,24 @@ function installCodexContextProjection(ctx, current) {
1230
1230
  const sync = (session, contextWindow = current().contextWindow) => {
1231
1231
  syncCodexContextWindow(session, contextWindow);
1232
1232
  };
1233
+ const pending = /* @__PURE__ */ new WeakSet();
1234
+ const syncAfterPublication = (session) => {
1235
+ if (pending.has(session)) return;
1236
+ pending.add(session);
1237
+ queueMicrotask(() => {
1238
+ try {
1239
+ sync(session);
1240
+ } finally {
1241
+ pending.delete(session);
1242
+ }
1243
+ });
1244
+ };
1233
1245
  const syncAll = (contextWindow = current().contextWindow) => {
1234
1246
  const sessions = ctx.get("sessions");
1235
1247
  for (const session of sessions?.list?.() ?? []) sync(session, contextWindow);
1236
1248
  };
1237
1249
  ctx.on("session/event", (session, event) => {
1238
- if (event.type === "request/header" || event.type === "request/context") sync(session);
1250
+ if (event.type === "request/header" || event.type === "request/context") syncAfterPublication(session);
1239
1251
  });
1240
1252
  ctx.on("session/created", (session) => {
1241
1253
  sync(session);
@@ -168,14 +168,29 @@ function installCodexContextProjection(ctx, current) {
168
168
  const sync = (session, contextWindow = current().contextWindow) => {
169
169
  syncCodexContextWindow(session, contextWindow);
170
170
  };
171
+ const pending = new WeakSet();
172
+ const syncAfterPublication = (session) => {
173
+ if (pending.has(session))
174
+ return;
175
+ pending.add(session);
176
+ queueMicrotask(() => {
177
+ try {
178
+ sync(session);
179
+ }
180
+ finally {
181
+ pending.delete(session);
182
+ }
183
+ });
184
+ };
171
185
  const syncAll = (contextWindow = current().contextWindow) => {
172
186
  const sessions = ctx.get('sessions');
173
187
  for (const session of sessions?.list?.() ?? [])
174
188
  sync(session, contextWindow);
175
189
  };
176
190
  ctx.on('session/event', (session, event) => {
191
+ // Session.append() rejects nested appends until every observer returns.
177
192
  if (event.type === 'request/header' || event.type === 'request/context')
178
- sync(session);
193
+ syncAfterPublication(session);
179
194
  });
180
195
  // Restored sessions may already contain their request/header seed, so no
181
196
  // session/event is emitted for the initial capacity. Catch them at the
@@ -207,41 +222,41 @@ export function applyCodexRequestSettings(request, settings) {
207
222
  };
208
223
  }
209
224
  // The shipped persona owns the single Codex identity line, model, and working directory.
210
- const CODEX_BASE_PROMPT = String.raw `## General
211
-
212
- - 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.
213
-
214
- ## Editing constraints
215
-
216
- - 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.
217
- - Add succinct code comments that explain non-obvious code. Do not add comments that merely narrate assignments or control flow.
218
- - 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.
219
-
220
- ## Planning
221
-
222
- - Use update_plan for work with multiple meaningful steps. Keep the plan current as the task progresses.
223
- - Do not use a plan for a trivial one-step request.
224
-
225
- ## dsh session
226
-
227
- - The user and you share one workspace. Inspect the repository and every applicable AGENTS.md before editing.
228
-
229
- ## Task execution
230
-
231
- - Keep the user informed with concise progress updates and lead with the result.
232
-
233
- ## Presenting your work
234
-
235
- - Be concise, direct, friendly, and actionable.
236
- - For substantial work, explain what changed and why, then briefly note how the work was verified and what comes next.
237
- - Do not dump large files into the conversation; refer to their paths.
238
- - Use plain text with short sections only when they improve scanability.
225
+ const CODEX_BASE_PROMPT = String.raw `## General
226
+
227
+ - 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.
228
+
229
+ ## Editing constraints
230
+
231
+ - 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.
232
+ - Add succinct code comments that explain non-obvious code. Do not add comments that merely narrate assignments or control flow.
233
+ - 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.
234
+
235
+ ## Planning
236
+
237
+ - Use update_plan for work with multiple meaningful steps. Keep the plan current as the task progresses.
238
+ - Do not use a plan for a trivial one-step request.
239
+
240
+ ## dsh session
241
+
242
+ - The user and you share one workspace. Inspect the repository and every applicable AGENTS.md before editing.
243
+
244
+ ## Task execution
245
+
246
+ - Keep the user informed with concise progress updates and lead with the result.
247
+
248
+ ## Presenting your work
249
+
250
+ - Be concise, direct, friendly, and actionable.
251
+ - For substantial work, explain what changed and why, then briefly note how the work was verified and what comes next.
252
+ - Do not dump large files into the conversation; refer to their paths.
253
+ - Use plain text with short sections only when they improve scanability.
239
254
  `;
240
- const CODEX_COLLABORATION_PROMPT = String.raw `## Working principles
241
-
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.
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.
244
- - Solve problems by thinking from first principles and at a higher level.
255
+ const CODEX_COLLABORATION_PROMPT = String.raw `## Working principles
256
+
257
+ - 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.
258
+ - 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.
259
+ - Solve problems by thinking from first principles and at a higher level.
245
260
  `;
246
261
  /** Put the agent persona first and omit the generic Harness identity opener. */
247
262
  export function normalizeCodexPromptAssembly(assembly) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuind/dsh-codex-harness",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
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",