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

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 (128) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/README.md +48 -38
  3. package/RELEASE.md +61 -0
  4. package/assets/codex.svg +5 -0
  5. package/cordis.patch.yml +150 -6
  6. package/docs/preset-library.md +39 -23
  7. package/docs/tool-policy-benchmark.json +310 -0
  8. package/docs/tool-policy.md +144 -0
  9. package/lib/client.js +1639 -111
  10. package/lib/compaction.js +17 -2
  11. package/lib/index.js +799 -188
  12. package/lib/installer.js +50 -6
  13. package/lib/preferences.js +111 -0
  14. package/lib/tool-policy.js +2235 -0
  15. package/lib/typert.js +57 -10
  16. package/lib/types/activity.d.ts +1 -1
  17. package/lib/types/activity.js +50 -14
  18. package/lib/types/client/activity.d.ts +33 -9
  19. package/lib/types/client/desktop.d.ts +43 -0
  20. package/lib/types/client/desktop.js +121 -0
  21. package/lib/types/client/entry.d.ts +10 -0
  22. package/lib/types/client/entry.js +12 -0
  23. package/lib/types/client/index.d.ts +109 -19
  24. package/lib/types/client/index.js +21 -40
  25. package/lib/types/client/policy-drafts.d.ts +25 -0
  26. package/lib/types/client/policy-drafts.js +47 -0
  27. package/lib/types/client/preset-copy.d.ts +1 -0
  28. package/lib/types/client/preset-copy.js +2 -0
  29. package/lib/types/client/preset-manager.d.ts +12 -2
  30. package/lib/types/client/preset-manager.js +70 -25
  31. package/lib/types/client/preset-requests.d.ts +12 -0
  32. package/lib/types/client/preset-requests.js +101 -0
  33. package/lib/types/client/session.d.ts +6 -0
  34. package/lib/types/client/session.js +9 -0
  35. package/lib/types/client/tool-policy.d.ts +120 -0
  36. package/lib/types/client/tool-policy.js +394 -0
  37. package/lib/types/compaction.d.ts +3 -3
  38. package/lib/types/compaction.js +6 -2
  39. package/lib/types/desktop-preset.d.ts +20 -0
  40. package/lib/types/desktop-preset.js +39 -0
  41. package/lib/types/exec.d.ts +4 -0
  42. package/lib/types/exec.js +192 -66
  43. package/lib/types/host-settings.d.ts +4 -0
  44. package/lib/types/host-settings.js +13 -0
  45. package/lib/types/index.d.ts +20 -2
  46. package/lib/types/index.js +181 -68
  47. package/lib/types/installer.js +11 -2
  48. package/lib/types/preferences.d.ts +11 -0
  49. package/lib/types/preferences.js +16 -0
  50. package/lib/types/preset-editor-remote.d.ts +2 -0
  51. package/lib/types/preset-editor-remote.js +6 -2
  52. package/lib/types/preset-editor.d.ts +12 -7
  53. package/lib/types/preset-editor.js +43 -13
  54. package/lib/types/preset-prompt-catalog-schema.d.ts +16 -0
  55. package/lib/types/preset-prompt-catalog-schema.js +11 -0
  56. package/lib/types/preset-prompt-catalog.d.ts +21 -0
  57. package/lib/types/preset-prompt-catalog.js +192 -0
  58. package/lib/types/preset-prompt-contract.d.ts +22 -0
  59. package/lib/types/preset-prompt-contract.js +3 -0
  60. package/lib/types/preset-tool-catalog-schema.d.ts +38 -0
  61. package/lib/types/preset-tool-catalog-schema.js +28 -0
  62. package/lib/types/preset-tool-catalog.d.ts +5 -0
  63. package/lib/types/preset-tool-catalog.js +51 -0
  64. package/lib/types/prompt-sections.d.ts +1 -1
  65. package/lib/types/prompt-sections.js +9 -3
  66. package/lib/types/prompt.js +4 -2
  67. package/lib/types/remote.js +23 -8
  68. package/lib/types/settings.d.ts +3 -3
  69. package/lib/types/settings.js +3 -3
  70. package/lib/types/tool-capabilities.d.ts +32 -0
  71. package/lib/types/tool-capabilities.js +42 -0
  72. package/lib/types/tool-policy-contract.d.ts +60 -0
  73. package/lib/types/tool-policy-contract.js +26 -0
  74. package/lib/types/tool-policy.d.ts +171 -0
  75. package/lib/types/tool-policy.js +367 -0
  76. package/lib/types/typert.host.d.ts +2 -2
  77. package/lib/types/typert.host.js +12 -2
  78. package/locale/en.json +6 -0
  79. package/locale/tool-policy/en.json +6 -0
  80. package/locale/tool-policy/zh.json +6 -0
  81. package/locale/zh.json +6 -0
  82. package/package.json +375 -299
  83. package/scripts/benchmark-tool-policy.mjs +186 -0
  84. package/scripts/build-preset.mjs +19 -0
  85. package/scripts/clean-build.mjs +11 -0
  86. package/src/activity-types.ts +7 -0
  87. package/src/activity.ts +158 -0
  88. package/src/client/activity.ts +82 -0
  89. package/src/client/desktop.tsx +162 -0
  90. package/src/client/entry.tsx +16 -0
  91. package/src/client/index.tsx +972 -0
  92. package/src/client/policy-drafts.ts +56 -0
  93. package/src/client/preset-copy.ts +83 -0
  94. package/src/client/preset-manager.tsx +281 -0
  95. package/src/client/preset-requests.ts +113 -0
  96. package/src/client/session.ts +11 -0
  97. package/src/client/tool-policy.tsx +380 -0
  98. package/src/compact-command.ts +112 -0
  99. package/src/compaction.ts +190 -0
  100. package/src/context.ts +15 -0
  101. package/src/desktop-preset.ts +55 -0
  102. package/src/exec.ts +570 -0
  103. package/src/host-settings.ts +17 -0
  104. package/src/index.ts +1097 -0
  105. package/src/installer.ts +172 -0
  106. package/src/invariant.ts +34 -0
  107. package/src/patch.ts +258 -0
  108. package/src/preferences.ts +17 -0
  109. package/src/preset-contract.ts +85 -0
  110. package/src/preset-editor-remote.ts +41 -0
  111. package/src/preset-editor.ts +502 -0
  112. package/src/preset-prompt-catalog-schema.ts +10 -0
  113. package/src/preset-prompt-catalog.ts +191 -0
  114. package/src/preset-prompt-contract.ts +21 -0
  115. package/src/preset-tool-catalog-schema.ts +28 -0
  116. package/src/preset-tool-catalog.ts +51 -0
  117. package/src/prompt-sections.ts +33 -0
  118. package/src/prompt.ts +62 -0
  119. package/src/remote.ts +748 -0
  120. package/src/settings.ts +79 -0
  121. package/src/tool-capabilities.ts +76 -0
  122. package/src/tool-policy-contract.ts +76 -0
  123. package/src/tool-policy.ts +388 -0
  124. package/src/typert.host.ts +119 -0
  125. package/tsconfig.json +29 -0
  126. package/tsdown.config.ts +110 -0
  127. package/lib/types/preset-templates.d.ts +0 -36
  128. package/lib/types/preset-templates.js +0 -12
package/lib/installer.js CHANGED
@@ -4,6 +4,7 @@ import { homedir } from "node:os";
4
4
  import { dirname, join, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import z from "@deepseek-ai/schemastery";
7
+ import { parseDocument } from "yaml";
7
8
  //#region lib/types/context.js
8
9
  const CODEX_CONTEXT_MAX = 1e6;
9
10
  //#endregion
@@ -11,7 +12,7 @@ const CODEX_CONTEXT_MAX = 1e6;
11
12
  /** Default plugin-owned Codex operating prompt. */
12
13
  const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
13
14
 
14
- - 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.
15
+ - Follow the current tool catalog, not assumptions from another Codex client. For unknown paths, use the available list/search tools instead of guessing and reuse the returned paths. If only shell search is available, prefer rg or rg --files.
15
16
 
16
17
  ## Editing constraints
17
18
 
@@ -27,6 +28,8 @@ const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
27
28
  ## dsh session
28
29
 
29
30
  - The user and you share one workspace. Inspect the repository and every applicable AGENTS.md before editing.
31
+ - For Harness APIs, first load the relevant Harness skill. When Inspect tools are available, start with cordis_inspect_list, then query the provider's directory before an exact Service contract. Reuse returned names; Inspect is read-only.
32
+ - A not-found path or unknown Service is a discovery error: check the file list or Service directory before retrying. Preserve actual failures; do not hide them or bypass permission denials.
30
33
 
31
34
  ## Task execution
32
35
 
@@ -48,7 +51,7 @@ const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
48
51
  /** Default deployment Persona template used by the Codex preset. */
49
52
  const DEFAULT_CODEX_PERSONA = String.raw`You are Codex, a coding agent based on the {{model}} model. Your working directory is {{cwd}}.`;
50
53
  /** Default DSH Core source-checkout guidance template. */
51
- 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.`;
54
+ 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.`;
52
55
  /** Default DSH Web runtime guidance template. */
53
56
  const DEFAULT_DSH_CORE_WEB_PROMPT = [
54
57
  "You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}.",
@@ -90,14 +93,50 @@ const CODEX_SETTINGS_SCHEMA = z.object({
90
93
  webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),
91
94
  systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
92
95
  promptEnabled: z.boolean().default(true),
93
- terminalToolsEnabled: z.boolean().default(true),
94
- patchToolEnabled: z.boolean().default(true),
95
- planToolEnabled: z.boolean().default(true),
96
+ terminalToolsEnabled: z.boolean().default(true).hidden(),
97
+ patchToolEnabled: z.boolean().default(true).hidden(),
98
+ planToolEnabled: z.boolean().default(true).hidden(),
96
99
  hostedWebSearchEnabled: z.boolean().default(true),
97
100
  remoteCompactionEnabled: z.boolean().default(true),
98
101
  activityIndicatorEnabled: z.boolean().default(true)
99
102
  });
100
103
  //#endregion
104
+ //#region lib/types/desktop-preset.js
105
+ /** Keep expressions literal for the Desktop Loader, not YAML strings or eager eval. */
106
+ function readYaml(path) {
107
+ const document = parseDocument(readFileSync(path, "utf8"), { customTags: [{
108
+ tag: "tag:yaml.org,2002:js",
109
+ resolve: (expression) => ({ __jsExpr: expression })
110
+ }] });
111
+ if (document.errors.length) throw document.errors[0];
112
+ return document.toJS();
113
+ }
114
+ /** Convert the legacy file composition to Harness 0.2.2's declarative preset APIs. */
115
+ function desktopCodexPreset(sourceDirectory) {
116
+ const metadata = readYaml(join(sourceDirectory, "preset.yml"));
117
+ const plugins = readYaml(join(sourceDirectory, "agent.cordis.yml"));
118
+ function adapt(rows) {
119
+ return rows.filter((row) => row.name !== "@deepseek-ai/dsh-tool-subagent-control/list-agents").map((row) => {
120
+ if (row.name === "@deepseek-ai/dsh-workflow-worker-thread") row.name = "@deepseek-ai/dsh-workflow-ptc";
121
+ if (row.name === "@deepseek-ai/dsh-tool-subagent" && row.config && !Array.isArray(row.config)) {
122
+ const { modelSelectionSettings, backgroundMode: _backgroundMode, ...config } = row.config;
123
+ row.config = modelSelectionSettings === void 0 ? config : {
124
+ ...config,
125
+ modelSelection: modelSelectionSettings,
126
+ modelDiscovery: modelSelectionSettings
127
+ };
128
+ }
129
+ if (row.group && Array.isArray(row.config)) row.config = adapt(row.config);
130
+ return row;
131
+ });
132
+ }
133
+ return {
134
+ ...metadata,
135
+ id: "codex-collaboration",
136
+ plugins: adapt(plugins)
137
+ };
138
+ }
139
+ //#endregion
101
140
  //#region lib/types/installer.js
102
141
  /** Install the user-visible Codex agent preset supplied by this bundle. */
103
142
  const PRESET_FILES = ["agent.cordis.yml", "preset.yml"];
@@ -129,7 +168,7 @@ function dshHomePath(...segments) {
129
168
  }
130
169
  /** Bundle plugin name for the preset installer. */
131
170
  const name = "codex-preset-installer";
132
- const inject = ["settings"];
171
+ const inject = ["settings", "agentPresets"];
133
172
  function presetSignature(directory) {
134
173
  if (PRESET_FILES.some((file) => !existsSync(join(directory, file)))) return void 0;
135
174
  const hash = createHash("sha256");
@@ -220,6 +259,11 @@ function retireLegacyCodexPreset(targetDir = dshHomePath(".agent-presets", LEGAC
220
259
  }
221
260
  /** Install the preset during profile boot without changing the host tool catalog. */
222
261
  function apply(ctx) {
262
+ const registry = ctx.agentPresets;
263
+ if (typeof registry?.register === "function") {
264
+ ctx.effect(() => registry.register(desktopCodexPreset(SOURCE_PRESET_DIR)), "codex.preset");
265
+ return;
266
+ }
223
267
  try {
224
268
  ctx.settings.register(CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, { base: CODEX_SETTINGS_ENTRY });
225
269
  installCodexPreset();
@@ -0,0 +1,111 @@
1
+ import { Service } from "@deepseek-ai/cordis";
2
+ import z from "@deepseek-ai/schemastery";
3
+ //#region lib/types/context.js
4
+ const CODEX_CONTEXT_MAX = 1e6;
5
+ //#endregion
6
+ //#region lib/types/prompt.js
7
+ /** Default plugin-owned Codex operating prompt. */
8
+ const DEFAULT_CODEX_SYSTEM_PROMPT = String.raw`## General
9
+
10
+ - Follow the current tool catalog, not assumptions from another Codex client. For unknown paths, use the available list/search tools instead of guessing and reuse the returned paths. If only shell search is available, prefer rg or rg --files.
11
+
12
+ ## Editing constraints
13
+
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
+ - 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
+
18
+ ## Planning
19
+
20
+ - Use update_plan for work with multiple meaningful steps. Keep the plan current as the task progresses.
21
+ - Do not use a plan for a trivial one-step request.
22
+
23
+ ## dsh session
24
+
25
+ - The user and you share one workspace. Inspect the repository and every applicable AGENTS.md before editing.
26
+ - For Harness APIs, first load the relevant Harness skill. When Inspect tools are available, start with cordis_inspect_list, then query the provider's directory before an exact Service contract. Reuse returned names; Inspect is read-only.
27
+ - A not-found path or unknown Service is a discovery error: check the file list or Service directory before retrying. Preserve actual failures; do not hide them or bypass permission denials.
28
+
29
+ ## Task execution
30
+
31
+ - Keep the user informed with concise progress updates and lead with the result.
32
+
33
+ ## Presenting your work
34
+
35
+ - Be concise, direct, friendly, and actionable.
36
+ - For substantial work, explain what changed and why, then briefly note how the work was verified and what comes next.
37
+ - Do not dump large files into the conversation; refer to their paths.
38
+ - Use plain text with short sections only when they improve scanability.
39
+
40
+ ## Working principles
41
+
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.
43
+ - 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
+ - Solve problems by thinking from first principles and at a higher level.
45
+ `;
46
+ /** 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}}.`;
48
+ /** Default DSH Core source-checkout guidance template. */
49
+ 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
+ /** Default DSH Web runtime guidance template. */
51
+ const DEFAULT_DSH_CORE_WEB_PROMPT = [
52
+ "You are interacting with the user through the DeepSeek Harness Web GUI at {{webUrl}}.",
53
+ "When the user refers to \"this page\", \"this GUI\", or \"this app\" without naming another target, they mean this GUI.",
54
+ "The browser provides no implicit DOM, route, or screenshot context.",
55
+ "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.",
56
+ "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.",
57
+ "Starting another server does not update this GUI.",
58
+ "The apps/web Vite entry builds the shell but is not a standalone application because only dsh web injects window.__DSH_BOOT__.",
59
+ "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
+ ].join(" ");
61
+ //#endregion
62
+ //#region lib/types/settings.js
63
+ /** Shared host-side Codex settings contract. */
64
+ /** Default settings exposed even before a Codex session is opened. */
65
+ const CODEX_SETTINGS_ENTRY = {
66
+ fast: false,
67
+ fastModeControlEnabled: true,
68
+ persona: DEFAULT_CODEX_PERSONA,
69
+ harnessSourcePrompt: DEFAULT_DSH_CORE_SOURCE_PROMPT,
70
+ webSurfacePrompt: DEFAULT_DSH_CORE_WEB_PROMPT,
71
+ systemPrompt: DEFAULT_CODEX_SYSTEM_PROMPT,
72
+ promptEnabled: true,
73
+ terminalToolsEnabled: true,
74
+ patchToolEnabled: true,
75
+ planToolEnabled: true,
76
+ hostedWebSearchEnabled: true,
77
+ remoteCompactionEnabled: true,
78
+ activityIndicatorEnabled: true
79
+ };
80
+ //#endregion
81
+ //#region lib/types/preferences.js
82
+ /** Profile-backed live preferences on DSH 0.2; legacy hosts keep settings.yaml. */
83
+ const Config = z.object({
84
+ fast: z.boolean().default(false),
85
+ fastModeControlEnabled: z.boolean().default(true),
86
+ contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX),
87
+ persona: z.string().default(DEFAULT_CODEX_PERSONA),
88
+ harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
89
+ webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),
90
+ systemPrompt: z.string().default(DEFAULT_CODEX_SYSTEM_PROMPT),
91
+ promptEnabled: z.boolean().default(true),
92
+ terminalToolsEnabled: z.boolean().default(true).hidden(),
93
+ patchToolEnabled: z.boolean().default(true).hidden(),
94
+ planToolEnabled: z.boolean().default(true).hidden(),
95
+ hostedWebSearchEnabled: z.boolean().default(true),
96
+ remoteCompactionEnabled: z.boolean().default(true),
97
+ activityIndicatorEnabled: z.boolean().default(true)
98
+ }).default(CODEX_SETTINGS_ENTRY).volatile();
99
+ var CodexPreferences = class extends Service {
100
+ value;
101
+ static Config = Config;
102
+ constructor(ctx, value) {
103
+ super(ctx, "codexPreferences");
104
+ this.value = value;
105
+ }
106
+ current() {
107
+ return this.value.get() ?? CODEX_SETTINGS_ENTRY;
108
+ }
109
+ };
110
+ //#endregion
111
+ export { Config, CodexPreferences as default };