@shuind/dsh-codex-harness 0.2.32-dsh-v0.2.2-rc.1 → 0.3.0

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.
Files changed (220) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +37 -59
  3. package/RELEASE.md +1 -1
  4. package/cordis.patch.yml +42 -11
  5. package/docs/preset-library.md +6 -12
  6. package/docs/tool-policy-benchmark.json +89 -89
  7. package/docs/tool-policy.md +11 -7
  8. package/lib/client.js +3780 -2950
  9. package/lib/compact-command.js +416 -0
  10. package/lib/compaction.js +129 -15
  11. package/lib/hybrid-executor.js +1196 -0
  12. package/lib/index.js +3554 -2841
  13. package/lib/preferences.js +17 -11
  14. package/lib/tool-policy.js +1930 -1743
  15. package/lib/typert.js +49 -89
  16. package/lib/types/client/activity.js +4 -3
  17. package/lib/types/client/desktop.d.ts +26 -2
  18. package/lib/types/client/desktop.js +143 -35
  19. package/lib/types/client/index.d.ts +136 -129
  20. package/lib/types/client/index.js +92 -466
  21. package/lib/types/client/policy-drafts.d.ts +1 -1
  22. package/lib/types/client/policy-locale.d.ts +260 -0
  23. package/lib/types/client/policy-locale.js +357 -0
  24. package/lib/types/client/preset-manager.d.ts +33 -15
  25. package/lib/types/client/preset-manager.js +220 -215
  26. package/lib/types/client/preset-requests.d.ts +2 -2
  27. package/lib/types/client/tool-policy.d.ts +6 -93
  28. package/lib/types/client/tool-policy.js +85 -143
  29. package/lib/types/contracts/preset-editor-schema.d.ts +78 -0
  30. package/lib/types/contracts/preset-editor-schema.js +95 -0
  31. package/lib/types/{prompt.js → contracts/prompt.js} +9 -5
  32. package/lib/types/{settings.d.ts → contracts/settings.d.ts} +8 -1
  33. package/lib/types/{settings.js → contracts/settings.js} +19 -3
  34. package/lib/types/{tool-policy-contract.d.ts → contracts/tool-policy-contract.d.ts} +9 -6
  35. package/lib/types/{tool-policy-contract.js → contracts/tool-policy-contract.js} +9 -2
  36. package/lib/types/contracts/ui-contracts.d.ts +92 -0
  37. package/lib/types/contracts/ui-contracts.js +83 -0
  38. package/lib/types/{client/entry.d.ts → entries/client.d.ts} +2 -2
  39. package/lib/types/{client/entry.js → entries/client.js} +2 -4
  40. package/lib/types/{compact-command.d.ts → entries/compact-command.d.ts} +2 -0
  41. package/lib/types/entries/compact-command.js +176 -0
  42. package/lib/types/{compaction.d.ts → entries/compaction.d.ts} +12 -0
  43. package/lib/types/{compaction.js → entries/compaction.js} +43 -11
  44. package/lib/types/entries/hybrid-executor.d.ts +19 -0
  45. package/lib/types/entries/hybrid-executor.js +57 -0
  46. package/lib/types/entries/index.d.ts +66 -0
  47. package/lib/types/entries/index.js +192 -0
  48. package/lib/types/{preferences.d.ts → entries/preferences.d.ts} +1 -1
  49. package/lib/types/{preferences.js → entries/preferences.js} +1 -1
  50. package/lib/types/entries/tool-policy.d.ts +97 -0
  51. package/lib/types/entries/tool-policy.js +158 -0
  52. package/lib/types/entries/typert.host.d.ts +23 -0
  53. package/lib/types/entries/typert.host.js +24 -0
  54. package/lib/types/hybrid/codex-hybrid-executor.d.ts +44 -0
  55. package/lib/types/hybrid/codex-hybrid-executor.js +257 -0
  56. package/lib/types/hybrid/hybrid-sdk.d.ts +13 -0
  57. package/lib/types/hybrid/hybrid-sdk.js +196 -0
  58. package/lib/types/hybrid/program-calls.d.ts +28 -0
  59. package/lib/types/hybrid/program-calls.js +193 -0
  60. package/lib/types/hybrid/subcall-scheduler.d.ts +90 -0
  61. package/lib/types/hybrid/subcall-scheduler.js +343 -0
  62. package/lib/types/policy/deferred-tools.d.ts +42 -0
  63. package/lib/types/policy/deferred-tools.js +264 -0
  64. package/lib/types/policy/overlay-installer.d.ts +12 -0
  65. package/lib/types/policy/overlay-installer.js +179 -0
  66. package/lib/types/policy/rule-resolver.d.ts +94 -0
  67. package/lib/types/policy/rule-resolver.js +114 -0
  68. package/lib/types/{tool-capabilities.d.ts → policy/tool-capabilities.d.ts} +3 -2
  69. package/lib/types/{tool-capabilities.js → policy/tool-capabilities.js} +6 -2
  70. package/lib/types/{activity.d.ts → presets/activity.d.ts} +2 -4
  71. package/lib/types/{activity.js → presets/activity.js} +2 -14
  72. package/lib/types/{desktop-preset.d.ts → presets/desktop-preset.d.ts} +3 -1
  73. package/lib/types/{desktop-preset.js → presets/desktop-preset.js} +6 -2
  74. package/lib/types/presets/preset-editor.d.ts +47 -0
  75. package/lib/types/presets/preset-editor.js +81 -0
  76. package/lib/types/{preset-prompt-catalog.d.ts → presets/preset-prompt-catalog.d.ts} +3 -1
  77. package/lib/types/{preset-prompt-catalog.js → presets/preset-prompt-catalog.js} +27 -4
  78. package/lib/types/{preset-tool-catalog.d.ts → presets/preset-tool-catalog.d.ts} +1 -1
  79. package/lib/types/{preset-tool-catalog.js → presets/preset-tool-catalog.js} +11 -4
  80. package/lib/types/presets/runtime-enhancements.d.ts +45 -0
  81. package/lib/types/presets/runtime-enhancements.js +349 -0
  82. package/lib/types/presets/small-window-compaction.d.ts +15 -0
  83. package/lib/types/presets/small-window-compaction.js +121 -0
  84. package/lib/types/responses/compact-checkpoint.d.ts +27 -0
  85. package/lib/types/responses/compact-checkpoint.js +257 -0
  86. package/lib/types/responses/fetch-transport.d.ts +16 -0
  87. package/lib/types/responses/fetch-transport.js +257 -0
  88. package/lib/types/responses/remote-compact.d.ts +13 -0
  89. package/lib/types/responses/remote-compact.js +319 -0
  90. package/lib/types/responses/sse-diagnostics.d.ts +9 -0
  91. package/lib/types/responses/sse-diagnostics.js +157 -0
  92. package/lib/types/responses/wire-rewrite.d.ts +35 -0
  93. package/lib/types/responses/wire-rewrite.js +237 -0
  94. package/lib/types/tools/exec-output.d.ts +58 -0
  95. package/lib/types/tools/exec-output.js +173 -0
  96. package/lib/types/tools/exec-plan-tools.d.ts +37 -0
  97. package/lib/types/tools/exec-plan-tools.js +265 -0
  98. package/lib/types/tools/exec-runner.d.ts +21 -0
  99. package/lib/types/tools/exec-runner.js +385 -0
  100. package/lib/types/tools/patch-tool.d.ts +16 -0
  101. package/lib/types/tools/patch-tool.js +258 -0
  102. package/lib/types/{patch.d.ts → tools/patch.d.ts} +1 -1
  103. package/lib/types/{patch.js → tools/patch.js} +96 -21
  104. package/locale/hybrid-executor/en.json +6 -0
  105. package/locale/hybrid-executor/zh.json +6 -0
  106. package/package.json +211 -289
  107. package/presets/{codex-collaboration → codex-hybrid}/agent.cordis.yml +45 -48
  108. package/presets/codex-hybrid/preset.yml +3 -0
  109. package/scripts/benchmark-tool-policy.mjs +3 -3
  110. package/scripts/build-preset.mjs +5 -5
  111. package/src/client/activity.ts +4 -3
  112. package/src/client/desktop.tsx +165 -51
  113. package/src/client/index.tsx +128 -709
  114. package/src/client/policy-drafts.ts +1 -1
  115. package/src/client/policy-locale.ts +362 -0
  116. package/src/client/preset-manager.tsx +331 -236
  117. package/src/client/preset-requests.ts +2 -2
  118. package/src/client/tool-policy.tsx +225 -203
  119. package/src/contracts/preset-editor-schema.ts +110 -0
  120. package/src/{prompt.ts → contracts/prompt.ts} +9 -5
  121. package/src/{settings.ts → contracts/settings.ts} +27 -3
  122. package/src/{tool-policy-contract.ts → contracts/tool-policy-contract.ts} +24 -7
  123. package/src/contracts/ui-contracts.ts +173 -0
  124. package/src/{client/entry.tsx → entries/client.tsx} +2 -4
  125. package/src/entries/compact-command.ts +256 -0
  126. package/src/{compaction.ts → entries/compaction.ts} +47 -19
  127. package/src/entries/hybrid-executor.ts +76 -0
  128. package/src/entries/index.ts +298 -0
  129. package/src/{preferences.ts → entries/preferences.ts} +1 -1
  130. package/src/entries/tool-policy.ts +162 -0
  131. package/src/entries/typert.host.ts +29 -0
  132. package/src/hybrid/codex-hybrid-executor.ts +310 -0
  133. package/src/hybrid/hybrid-sdk.ts +217 -0
  134. package/src/hybrid/program-calls.ts +202 -0
  135. package/src/hybrid/subcall-scheduler.ts +446 -0
  136. package/src/policy/deferred-tools.ts +331 -0
  137. package/src/policy/overlay-installer.ts +191 -0
  138. package/src/policy/rule-resolver.ts +128 -0
  139. package/src/{tool-capabilities.ts → policy/tool-capabilities.ts} +16 -4
  140. package/src/{activity.ts → presets/activity.ts} +4 -16
  141. package/src/{desktop-preset.ts → presets/desktop-preset.ts} +7 -2
  142. package/src/presets/preset-editor.ts +101 -0
  143. package/src/{preset-prompt-catalog.ts → presets/preset-prompt-catalog.ts} +35 -5
  144. package/src/{preset-tool-catalog.ts → presets/preset-tool-catalog.ts} +12 -5
  145. package/src/presets/runtime-enhancements.ts +415 -0
  146. package/src/presets/small-window-compaction.ts +166 -0
  147. package/src/responses/compact-checkpoint.ts +264 -0
  148. package/src/responses/fetch-transport.ts +290 -0
  149. package/src/responses/remote-compact.ts +393 -0
  150. package/src/responses/sse-diagnostics.ts +156 -0
  151. package/src/responses/wire-rewrite.ts +261 -0
  152. package/src/tools/exec-output.ts +211 -0
  153. package/src/tools/exec-plan-tools.ts +307 -0
  154. package/src/tools/exec-runner.ts +445 -0
  155. package/src/tools/patch-tool.ts +331 -0
  156. package/src/{patch.ts → tools/patch.ts} +90 -20
  157. package/tsdown.config.ts +8 -8
  158. package/lib/installer.js +0 -281
  159. package/lib/invariant.js +0 -23
  160. package/lib/types/activity-types.d.ts +0 -6
  161. package/lib/types/activity-types.js +0 -3
  162. package/lib/types/client/preset-copy.d.ts +0 -43
  163. package/lib/types/client/preset-copy.js +0 -83
  164. package/lib/types/client/session.d.ts +0 -6
  165. package/lib/types/client/session.js +0 -9
  166. package/lib/types/compact-command.js +0 -79
  167. package/lib/types/context.d.ts +0 -8
  168. package/lib/types/context.js +0 -14
  169. package/lib/types/exec.d.ts +0 -50
  170. package/lib/types/exec.js +0 -491
  171. package/lib/types/host-settings.d.ts +0 -4
  172. package/lib/types/host-settings.js +0 -13
  173. package/lib/types/index.d.ts +0 -113
  174. package/lib/types/index.js +0 -851
  175. package/lib/types/installer.d.ts +0 -27
  176. package/lib/types/installer.js +0 -155
  177. package/lib/types/invariant.d.ts +0 -16
  178. package/lib/types/invariant.js +0 -22
  179. package/lib/types/preset-contract.d.ts +0 -69
  180. package/lib/types/preset-contract.js +0 -22
  181. package/lib/types/preset-editor-remote.d.ts +0 -32
  182. package/lib/types/preset-editor-remote.js +0 -41
  183. package/lib/types/preset-editor.d.ts +0 -74
  184. package/lib/types/preset-editor.js +0 -587
  185. package/lib/types/preset-prompt-catalog-schema.d.ts +0 -16
  186. package/lib/types/preset-prompt-catalog-schema.js +0 -11
  187. package/lib/types/preset-prompt-contract.d.ts +0 -22
  188. package/lib/types/preset-prompt-contract.js +0 -3
  189. package/lib/types/preset-tool-catalog-schema.d.ts +0 -38
  190. package/lib/types/preset-tool-catalog-schema.js +0 -28
  191. package/lib/types/prompt-sections.d.ts +0 -15
  192. package/lib/types/prompt-sections.js +0 -29
  193. package/lib/types/remote.d.ts +0 -40
  194. package/lib/types/remote.js +0 -698
  195. package/lib/types/tool-policy.d.ts +0 -171
  196. package/lib/types/tool-policy.js +0 -367
  197. package/lib/types/typert.host.d.ts +0 -47
  198. package/lib/types/typert.host.js +0 -109
  199. package/presets/codex-collaboration/preset.yml +0 -3
  200. package/src/activity-types.ts +0 -7
  201. package/src/client/preset-copy.ts +0 -83
  202. package/src/client/session.ts +0 -11
  203. package/src/compact-command.ts +0 -112
  204. package/src/context.ts +0 -15
  205. package/src/exec.ts +0 -570
  206. package/src/host-settings.ts +0 -17
  207. package/src/index.ts +0 -1097
  208. package/src/installer.ts +0 -172
  209. package/src/invariant.ts +0 -34
  210. package/src/preset-contract.ts +0 -85
  211. package/src/preset-editor-remote.ts +0 -41
  212. package/src/preset-editor.ts +0 -502
  213. package/src/preset-prompt-catalog-schema.ts +0 -10
  214. package/src/preset-prompt-contract.ts +0 -21
  215. package/src/preset-tool-catalog-schema.ts +0 -28
  216. package/src/prompt-sections.ts +0 -33
  217. package/src/remote.ts +0 -748
  218. package/src/tool-policy.ts +0 -388
  219. package/src/typert.host.ts +0 -119
  220. /package/lib/types/{prompt.d.ts → contracts/prompt.d.ts} +0 -0
@@ -1,9 +1,9 @@
1
1
  import { Service } from "@deepseek-ai/cordis";
2
2
  import z from "@deepseek-ai/schemastery";
3
- //#region lib/types/context.js
3
+ //#region lib/types/contracts/ui-contracts.js
4
4
  const CODEX_CONTEXT_MAX = 1e6;
5
5
  //#endregion
6
- //#region lib/types/prompt.js
6
+ //#region lib/types/contracts/prompt.js
7
7
  /** Default plugin-owned Codex operating prompt. */
8
8
  const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
9
9
 
@@ -12,8 +12,9 @@ const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
12
12
  ## Editing constraints
13
13
 
14
14
  - 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.
15
+ - Prefer apply_patch (or dedicated file tools when present) over shell heredocs or redirection for file edits; do not re-read a file immediately after apply_patch succeeds unless checking external changes.
15
16
  - Add succinct code comments that explain non-obvious code. Do not add comments that merely narrate assignments or control flow.
16
- - 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.
17
+ - You may be in a dirty git worktree. Never revert existing changes you did not make unless the user explicitly requests it, never amend commits unless asked, and avoid interactive git commands such as git rebase -i or git add -p. If unrelated files are changed, leave them alone.
17
18
 
18
19
  ## Planning
19
20
 
@@ -28,23 +29,26 @@ const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
28
29
 
29
30
  ## Task execution
30
31
 
31
- - Keep the user informed with concise progress updates and lead with the result.
32
+ - Parallelize independent read, search, and check calls. Do not sleep-poll background jobs or subagents; they wake on completion.
33
+ - When delegating parallel edits, assign disjoint write scopes. Record key paths and facts as you go since older large tool outputs may be pruned.
34
+ - Never claim unrun checks passed, and keep the user informed with concise progress updates.
32
35
 
33
36
  ## Presenting your work
34
37
 
35
- - Be concise, direct, friendly, and actionable.
38
+ - Be concise, direct, friendly, and actionable, and lead with the result.
36
39
  - For substantial work, explain what changed and why, then briefly note how the work was verified and what comes next.
40
+ - For code reviews, lead with concrete findings ordered by severity with file and line references before any brief summary, or state explicitly if no issues were found.
37
41
  - Do not dump large files into the conversation; refer to their paths.
38
42
  - Use plain text with short sections only when they improve scanability.
39
43
 
40
44
  ## Working principles
41
45
 
42
- - 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
+ - Actively establish the user's current context from the repository rather than relying on stale assumptions. Execute tasks directly through implementation and verification using the clearest, most effective path; ask the user only when a user-owned choice or external/destructive action cannot be resolved by inspection.
43
47
  - 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.
44
48
  - Solve problems by thinking from first principles and at a higher level.
45
49
  `;
46
50
  /** Default deployment Persona template used by the Codex preset. */
47
- const DEFAULT_CODEX_PERSONA = String.raw`You are Codex, a coding agent based on the {{model}} model. Your working directory is {{cwd}}.`;
51
+ const DEFAULT_CODEX_PERSONA = String.raw`You are Codex, a coding agent based on the {{model}} model.`;
48
52
  /** Default DSH Core source-checkout guidance template. */
49
53
  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. If the supplied path is inside app.asar, treat it as a packaged runtime rather than a source checkout. Discover the installed packageDir via Inspect and read its README and package.json exports; do not assume src or individual lib/types filenames exist. Use Host file-read tools for app.asar; native shell search and glob cannot traverse it.`;
50
54
  /** Default DSH Web runtime guidance template. */
@@ -59,12 +63,13 @@ const DEFAULT_DSH_CORE_WEB_PROMPT = [
59
63
  "Do not start a replacement server unless the user asks; if one is needed, use a managed background job and verify its exact URL."
60
64
  ].join(" ");
61
65
  //#endregion
62
- //#region lib/types/settings.js
63
- /** Shared host-side Codex settings contract. */
66
+ //#region lib/types/contracts/settings.js
67
+ /** Shared host-side Codex settings contract, Host reader, and GPT route matcher. */
64
68
  /** Default settings exposed even before a Codex session is opened. */
65
69
  const CODEX_SETTINGS_ENTRY = {
66
70
  fast: false,
67
71
  fastModeControlEnabled: true,
72
+ contextWindowControlEnabled: true,
68
73
  persona: DEFAULT_CODEX_PERSONA,
69
74
  harnessSourcePrompt: DEFAULT_DSH_CORE_SOURCE_PROMPT,
70
75
  webSurfacePrompt: DEFAULT_DSH_CORE_WEB_PROMPT,
@@ -78,12 +83,13 @@ const CODEX_SETTINGS_ENTRY = {
78
83
  activityIndicatorEnabled: true
79
84
  };
80
85
  //#endregion
81
- //#region lib/types/preferences.js
86
+ //#region lib/types/entries/preferences.js
82
87
  /** Profile-backed live preferences on DSH 0.2; legacy hosts keep settings.yaml. */
83
88
  const Config = z.object({
84
89
  fast: z.boolean().default(false),
85
90
  fastModeControlEnabled: z.boolean().default(true),
86
- contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX),
91
+ contextWindowControlEnabled: z.boolean().default(true),
92
+ contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX).hidden(),
87
93
  persona: z.string().default(DEFAULT_CODEX_PERSONA),
88
94
  harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
89
95
  webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),