@dsmm/dsmm 0.0.0-stage → 0.1.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 (129) hide show
  1. package/LICENSE +103 -0
  2. package/README.md +70 -2
  3. package/agent-presets/dsmm-builder/agent.cordis.yml +210 -0
  4. package/agent-presets/dsmm-builder/preset.yml +3 -0
  5. package/agent-presets/dsmm-clarifier/agent.cordis.yml +34 -0
  6. package/agent-presets/dsmm-clarifier/preset.yml +3 -0
  7. package/agent-presets/dsmm-code-search/agent.cordis.yml +34 -0
  8. package/agent-presets/dsmm-code-search/preset.yml +3 -0
  9. package/agent-presets/dsmm-creative/agent.cordis.yml +31 -0
  10. package/agent-presets/dsmm-creative/preset.yml +3 -0
  11. package/agent-presets/dsmm-doc-search/agent.cordis.yml +34 -0
  12. package/agent-presets/dsmm-doc-search/preset.yml +3 -0
  13. package/agent-presets/dsmm-media-reader/agent.cordis.yml +34 -0
  14. package/agent-presets/dsmm-media-reader/preset.yml +3 -0
  15. package/agent-presets/dsmm-oracle/agent.cordis.yml +31 -0
  16. package/agent-presets/dsmm-oracle/preset.yml +3 -0
  17. package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +31 -0
  18. package/agent-presets/dsmm-oracle-2nd/preset.yml +3 -0
  19. package/agent-presets/dsmm-orchestrator/agent.cordis.yml +215 -0
  20. package/agent-presets/dsmm-orchestrator/preset.yml +3 -0
  21. package/agent-presets/dsmm-plan-critic/agent.cordis.yml +33 -0
  22. package/agent-presets/dsmm-plan-critic/preset.yml +3 -0
  23. package/agent-presets/dsmm-planner/agent.cordis.yml +33 -0
  24. package/agent-presets/dsmm-planner/preset.yml +3 -0
  25. package/agent-presets/dsmm-reviewer/agent.cordis.yml +33 -0
  26. package/agent-presets/dsmm-reviewer/preset.yml +3 -0
  27. package/cordis.patch.yml +8 -0
  28. package/docs/agent-presets.md +19 -0
  29. package/docs/compatibility.md +49 -0
  30. package/docs/design.md +237 -0
  31. package/docs/lsp.md +40 -0
  32. package/docs/migration-from-ocmm.md +54 -0
  33. package/docs/model-routing.md +61 -0
  34. package/docs/releasing.md +52 -0
  35. package/docs/research/deepseek-v4-pro.md +74 -0
  36. package/docs/research/oh-dsh.md +96 -0
  37. package/docs/roadmap.md +207 -0
  38. package/docs/runtime-recovery.md +75 -0
  39. package/docs/safety-guards.md +55 -0
  40. package/docs/settings-status.md +55 -0
  41. package/docs/skill-sync.md +20 -0
  42. package/lib/commands.d.ts +13 -0
  43. package/lib/commands.js +55 -0
  44. package/lib/dsh-events.d.ts +21 -0
  45. package/lib/dsh-events.js +2 -0
  46. package/lib/dsh-types.d.ts +312 -0
  47. package/lib/dsh-types.js +2 -0
  48. package/lib/guards.d.ts +10 -0
  49. package/lib/guards.js +252 -0
  50. package/lib/index.d.ts +33 -0
  51. package/lib/index.js +58 -0
  52. package/lib/lsp.d.ts +30 -0
  53. package/lib/lsp.js +154 -0
  54. package/lib/mode.d.ts +6 -0
  55. package/lib/mode.js +62 -0
  56. package/lib/model-family.d.ts +6 -0
  57. package/lib/model-family.js +49 -0
  58. package/lib/model-routing.d.ts +11 -0
  59. package/lib/model-routing.js +128 -0
  60. package/lib/plan-validation.d.ts +3 -0
  61. package/lib/plan-validation.js +119 -0
  62. package/lib/preset-materializer.d.ts +36 -0
  63. package/lib/preset-materializer.js +258 -0
  64. package/lib/preset-registry.d.ts +5 -0
  65. package/lib/preset-registry.js +126 -0
  66. package/lib/preset-skills.d.ts +12 -0
  67. package/lib/preset-skills.js +28 -0
  68. package/lib/prompts.d.ts +13 -0
  69. package/lib/prompts.js +82 -0
  70. package/lib/recovery-policy.d.ts +25 -0
  71. package/lib/recovery-policy.js +252 -0
  72. package/lib/role-providers.d.ts +13 -0
  73. package/lib/role-providers.js +61 -0
  74. package/lib/role-routing.d.ts +15 -0
  75. package/lib/role-routing.js +144 -0
  76. package/lib/role-subagents.d.ts +6 -0
  77. package/lib/role-subagents.js +54 -0
  78. package/lib/roles.d.ts +29 -0
  79. package/lib/roles.js +241 -0
  80. package/lib/runtime-recovery.d.ts +5 -0
  81. package/lib/runtime-recovery.js +168 -0
  82. package/lib/session-scope.d.ts +9 -0
  83. package/lib/session-scope.js +40 -0
  84. package/lib/settings.d.ts +123 -0
  85. package/lib/settings.js +447 -0
  86. package/lib/shell-command.d.ts +18 -0
  87. package/lib/shell-command.js +492 -0
  88. package/lib/skills.d.ts +18 -0
  89. package/lib/skills.js +64 -0
  90. package/lib/state.d.ts +13 -0
  91. package/lib/state.js +64 -0
  92. package/lib/status.d.ts +55 -0
  93. package/lib/status.js +193 -0
  94. package/package.json +129 -4
  95. package/patches/agent-presets-root.example.cordis.patch.yml +14 -0
  96. package/patches/ocmm-lsp-mcp.example.cordis.patch.yml +15 -0
  97. package/prompts/deepseek-flash.md +11 -0
  98. package/prompts/deepseek-v4-pro.md +14 -0
  99. package/prompts/deepwork.md +32 -0
  100. package/skills/brainstorming/SKILL.md +15 -0
  101. package/skills/debugging/SKILL.md +12 -0
  102. package/skills/debugging/references/logging.md +91 -0
  103. package/skills/debugging/references/methodology/00-setup.md +108 -0
  104. package/skills/debugging/references/methodology/02-investigate.md +67 -0
  105. package/skills/debugging/references/methodology/03-flaky-triage.md +69 -0
  106. package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +83 -0
  107. package/skills/debugging/references/methodology/05-escalate.md +69 -0
  108. package/skills/debugging/references/methodology/06-fix.md +123 -0
  109. package/skills/debugging/references/methodology/08-qa.md +94 -0
  110. package/skills/debugging/references/methodology/09-cleanup.md +164 -0
  111. package/skills/debugging/references/methodology/partial-runtime-evidence.md +217 -0
  112. package/skills/debugging/references/runtimes/bundled-js-binary.md +415 -0
  113. package/skills/debugging/references/runtimes/go.md +252 -0
  114. package/skills/debugging/references/runtimes/native-binary.md +484 -0
  115. package/skills/debugging/references/runtimes/node.md +260 -0
  116. package/skills/debugging/references/runtimes/python.md +248 -0
  117. package/skills/debugging/references/runtimes/rust.md +234 -0
  118. package/skills/debugging/references/scripts/dap.mjs +533 -0
  119. package/skills/debugging/references/tools/dap.md +89 -0
  120. package/skills/debugging/references/tools/ghidra.md +212 -0
  121. package/skills/debugging/references/tools/playwright-cli.md +316 -0
  122. package/skills/debugging/references/tools/pwndbg.md +263 -0
  123. package/skills/debugging/references/tools/pwntools.md +265 -0
  124. package/skills/dispatching-parallel-agents/SKILL.md +14 -0
  125. package/skills/receiving-code-review/SKILL.md +13 -0
  126. package/skills/remove-ai-slops/SKILL.md +14 -0
  127. package/skills/requesting-code-review/SKILL.md +10 -0
  128. package/skills/subagent-driven-development/SKILL.md +13 -0
  129. package/skills/writing-plans/SKILL.md +14 -0
@@ -0,0 +1,447 @@
1
+ import Schema from "@deepseek-ai/schemastery";
2
+ import { DEFAULT_DSMM_LSP_SETTINGS, resolveLspSettings } from "./lsp.js";
3
+ import { DSMM_ROLE_IDS } from "./roles.js";
4
+ import { DSMM_SKILL_NAMES } from "./skills.js";
5
+ export { DSMM_SKILL_NAMES, MVP_SKILL_NAMES } from "./skills.js";
6
+ export const DSMM_SETTINGS_NAMESPACE = "dsmm";
7
+ export const DSMM_STATUS_COMMAND = "dsmm-status";
8
+ export const DEFAULT_DSMM_SETTINGS = {
9
+ modeName: "deepwork",
10
+ defaultActive: false,
11
+ promptOrder: 50,
12
+ deepseekV4ProCalibration: "auto",
13
+ deepseekV4ProDefaultReasoningEffort: "high",
14
+ deepseekV4ProMaxReasoningPresets: ["dsmm-plan-critic", "dsmm-reviewer"],
15
+ deepseekFlashCalibration: "auto",
16
+ deepseekFlashDefaultReasoningEffort: "high",
17
+ deepseekFlashMaxReasoningPresets: ["dsmm-plan-critic", "dsmm-reviewer"],
18
+ skills: createDefaultSkillSettings(),
19
+ roles: createDefaultRoleSettings(),
20
+ roleRouting: {},
21
+ presets: {
22
+ materialize: false
23
+ },
24
+ workflow: {
25
+ policy: "risk-based",
26
+ strictGates: true,
27
+ reviewCap: 5,
28
+ finalReviewPolicy: "simple-oracle-complex-reviewer"
29
+ },
30
+ guards: {
31
+ scope: "deepwork-or-dsmm-agent",
32
+ shellCommandSafety: true,
33
+ gitWriteGuard: "ask",
34
+ toolOutputTruncation: {
35
+ enabled: true,
36
+ maxInlineBytes: 12000
37
+ },
38
+ planFormatValidation: true,
39
+ questionLabelHelper: {
40
+ enabled: true,
41
+ maxLabelChars: 30
42
+ },
43
+ todoDisciplineHelper: true
44
+ },
45
+ runtimeRecovery: {
46
+ enabled: false,
47
+ retryOnStatusCodes: [429, 500, 502, 503, 504],
48
+ retryOnCodes: [],
49
+ fallbackRoutes: [],
50
+ maxFallbackAttempts: 2,
51
+ idleContinuation: {
52
+ enabled: false,
53
+ maxContinuations: 3,
54
+ prompt: "Continue the current task from the durable goal or unfinished todo list. Do not repeat completed work."
55
+ }
56
+ },
57
+ lsp: DEFAULT_DSMM_LSP_SETTINGS
58
+ };
59
+ function normalizeModeName(modeName) {
60
+ return modeName === DSMM_STATUS_COMMAND ? DEFAULT_DSMM_SETTINGS.modeName : modeName ?? DEFAULT_DSMM_SETTINGS.modeName;
61
+ }
62
+ function createDefaultSkillSettings() {
63
+ return Object.fromEntries(DSMM_SKILL_NAMES.map((id) => [id, true]));
64
+ }
65
+ function createDefaultRoleSettings() {
66
+ return Object.fromEntries(DSMM_ROLE_IDS.map((id) => [id, true]));
67
+ }
68
+ const SKILLS_SCHEMA = Schema.object({
69
+ brainstorming: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills.brainstorming),
70
+ "writing-plans": Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills["writing-plans"]),
71
+ "requesting-code-review": Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills["requesting-code-review"]),
72
+ "receiving-code-review": Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills["receiving-code-review"]),
73
+ "subagent-driven-development": Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills["subagent-driven-development"]),
74
+ "dispatching-parallel-agents": Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills["dispatching-parallel-agents"]),
75
+ "remove-ai-slops": Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills["remove-ai-slops"])
76
+ });
77
+ const ROLES_SCHEMA = Schema.object(Object.fromEntries(DSMM_ROLE_IDS.map((id) => [id, Schema.boolean().default(DEFAULT_DSMM_SETTINGS.roles[id])])));
78
+ const MODEL_ROUTE_SCHEMA = Schema.object({
79
+ provider: Schema.string().required(),
80
+ model: Schema.string().required(),
81
+ reasoningEffort: Schema.string()
82
+ });
83
+ // A dictionary retains unknown keys for fail-closed validation by the resolver.
84
+ const ROLE_ROUTING_SCHEMA = Schema.dict(Schema.object({
85
+ primary: Schema.union([Schema.const(undefined), MODEL_ROUTE_SCHEMA]),
86
+ fallbackRoutes: Schema.union([Schema.const(undefined), Schema.array(MODEL_ROUTE_SCHEMA)])
87
+ }).required()).default({});
88
+ // Schemastery treats null like an omitted default. Validate the untouched map
89
+ // before object defaults can erase an explicitly malformed routing policy.
90
+ const ROLE_ROUTING_VALIDATION_SCHEMA = Schema.transform(Schema.any(), (input) => {
91
+ if (!isRoutingRecord(input))
92
+ return input;
93
+ if (isRoutingRecord(input.runtimeRecovery) && Array.isArray(input.runtimeRecovery.fallbackRoutes)) {
94
+ for (const route of input.runtimeRecovery.fallbackRoutes) {
95
+ if (isRoutingRecord(route))
96
+ normalizeRecoveryEffort(route);
97
+ }
98
+ }
99
+ return { roleRouting: resolveRoleRouting(input.roleRouting) };
100
+ });
101
+ const PRESETS_SCHEMA = Schema.object({
102
+ materialize: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.presets.materialize),
103
+ root: Schema.string()
104
+ });
105
+ const FINAL_REVIEW_POLICY_SCHEMA = Schema.union([
106
+ Schema.const("simple-oracle-complex-reviewer"),
107
+ Schema.const("reviewer-only"),
108
+ Schema.const("off")
109
+ ]).default(DEFAULT_DSMM_SETTINGS.workflow.finalReviewPolicy);
110
+ const WORKFLOW_SCHEMA = Schema.object({
111
+ policy: Schema.union([Schema.const("risk-based"), Schema.const("legacy")]).default(DEFAULT_DSMM_SETTINGS.workflow.policy),
112
+ strictGates: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.workflow.strictGates),
113
+ reviewCap: Schema.number().default(DEFAULT_DSMM_SETTINGS.workflow.reviewCap),
114
+ finalReviewPolicy: FINAL_REVIEW_POLICY_SCHEMA
115
+ });
116
+ const WORKFLOW_CONFIG_SCHEMA = Schema.object({
117
+ policy: Schema.union([Schema.const("risk-based"), Schema.const("legacy")]),
118
+ strictGates: Schema.boolean(),
119
+ reviewCap: Schema.number(),
120
+ finalReviewPolicy: Schema.union([
121
+ Schema.const("simple-oracle-complex-reviewer"), Schema.const("reviewer-only"), Schema.const("off")
122
+ ])
123
+ });
124
+ const GUARD_SCOPE_SCHEMA = Schema.union([
125
+ Schema.const("deepwork-or-dsmm-agent"),
126
+ Schema.const("always"),
127
+ Schema.const("off")
128
+ ]).default(DEFAULT_DSMM_SETTINGS.guards.scope);
129
+ const GIT_WRITE_POLICY_SCHEMA = Schema.union([
130
+ Schema.const("ask"),
131
+ Schema.const("deny"),
132
+ Schema.const("off")
133
+ ]).default(DEFAULT_DSMM_SETTINGS.guards.gitWriteGuard);
134
+ const TOOL_OUTPUT_TRUNCATION_SCHEMA = Schema.object({
135
+ enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.toolOutputTruncation.enabled),
136
+ maxInlineBytes: Schema.number().default(DEFAULT_DSMM_SETTINGS.guards.toolOutputTruncation.maxInlineBytes)
137
+ });
138
+ const QUESTION_LABEL_HELPER_SCHEMA = Schema.object({
139
+ enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.questionLabelHelper.enabled),
140
+ maxLabelChars: Schema.number().default(DEFAULT_DSMM_SETTINGS.guards.questionLabelHelper.maxLabelChars)
141
+ });
142
+ const GUARDS_SCHEMA = Schema.object({
143
+ scope: GUARD_SCOPE_SCHEMA,
144
+ shellCommandSafety: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.shellCommandSafety),
145
+ gitWriteGuard: GIT_WRITE_POLICY_SCHEMA,
146
+ toolOutputTruncation: TOOL_OUTPUT_TRUNCATION_SCHEMA,
147
+ planFormatValidation: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.planFormatValidation),
148
+ questionLabelHelper: QUESTION_LABEL_HELPER_SCHEMA,
149
+ todoDisciplineHelper: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.todoDisciplineHelper)
150
+ });
151
+ const RUNTIME_RECOVERY_IDLE_CONTINUATION_SCHEMA = Schema.object({
152
+ enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.idleContinuation.enabled),
153
+ maxContinuations: Schema.number().default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.idleContinuation.maxContinuations),
154
+ prompt: Schema.string().default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.idleContinuation.prompt)
155
+ });
156
+ const RUNTIME_RECOVERY_SCHEMA = Schema.object({
157
+ enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.enabled),
158
+ retryOnStatusCodes: Schema.array(Number).default([...DEFAULT_DSMM_SETTINGS.runtimeRecovery.retryOnStatusCodes]),
159
+ retryOnCodes: Schema.array(String).default([...DEFAULT_DSMM_SETTINGS.runtimeRecovery.retryOnCodes]),
160
+ fallbackRoutes: Schema.array(Schema.object({
161
+ provider: Schema.string(),
162
+ model: Schema.string(),
163
+ reasoningEffort: Schema.string()
164
+ })).default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.fallbackRoutes.map((route) => ({ ...route }))),
165
+ maxFallbackAttempts: Schema.number().default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.maxFallbackAttempts),
166
+ idleContinuation: RUNTIME_RECOVERY_IDLE_CONTINUATION_SCHEMA
167
+ });
168
+ const DEEPSEEK_CALIBRATION_SCHEMA = Schema.union([
169
+ Schema.const("off"),
170
+ Schema.const("auto"),
171
+ Schema.const("strict")
172
+ ]).default(DEFAULT_DSMM_SETTINGS.deepseekV4ProCalibration);
173
+ const DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA = Schema.union([
174
+ Schema.const("off"),
175
+ Schema.const("low"),
176
+ Schema.const("high")
177
+ ]).default(DEFAULT_DSMM_SETTINGS.deepseekV4ProDefaultReasoningEffort);
178
+ const DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA = Schema.array(String)
179
+ .default([...DEFAULT_DSMM_SETTINGS.deepseekV4ProMaxReasoningPresets]);
180
+ const LSP_SCHEMA = Schema.object({
181
+ enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.lsp.enabled),
182
+ serverName: Schema.string().default(DEFAULT_DSMM_SETTINGS.lsp.serverName),
183
+ command: Schema.string().default(DEFAULT_DSMM_SETTINGS.lsp.command),
184
+ args: Schema.array(String).default([...DEFAULT_DSMM_SETTINGS.lsp.args]),
185
+ cwd: Schema.string().default(DEFAULT_DSMM_SETTINGS.lsp.cwd),
186
+ env: Schema.dict(String).default({ ...DEFAULT_DSMM_SETTINGS.lsp.env }),
187
+ toolCallTimeoutMs: Schema.number().default(DEFAULT_DSMM_SETTINGS.lsp.toolCallTimeoutMs),
188
+ failOnStartupError: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.lsp.failOnStartupError)
189
+ });
190
+ export const DSMM_CONFIG_SCHEMA = Schema.intersect([ROLE_ROUTING_VALIDATION_SCHEMA, Schema.object({
191
+ modeName: Schema.string().default(DEFAULT_DSMM_SETTINGS.modeName),
192
+ section: Schema.string(),
193
+ defaultActive: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.defaultActive),
194
+ promptOrder: Schema.number().default(DEFAULT_DSMM_SETTINGS.promptOrder),
195
+ deepseekV4ProCalibration: DEEPSEEK_CALIBRATION_SCHEMA,
196
+ deepseekV4ProDefaultReasoningEffort: DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA,
197
+ deepseekV4ProMaxReasoningPresets: DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA,
198
+ deepseekFlashCalibration: DEEPSEEK_CALIBRATION_SCHEMA,
199
+ deepseekFlashDefaultReasoningEffort: DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA,
200
+ deepseekFlashMaxReasoningPresets: DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA,
201
+ skills: SKILLS_SCHEMA,
202
+ roles: ROLES_SCHEMA,
203
+ roleRouting: ROLE_ROUTING_SCHEMA,
204
+ presets: PRESETS_SCHEMA,
205
+ workflow: WORKFLOW_CONFIG_SCHEMA,
206
+ guards: GUARDS_SCHEMA,
207
+ runtimeRecovery: RUNTIME_RECOVERY_SCHEMA,
208
+ lsp: LSP_SCHEMA
209
+ })]).default({});
210
+ export const DSMM_SETTINGS_SCHEMA = Schema.intersect([ROLE_ROUTING_VALIDATION_SCHEMA, Schema.object({
211
+ modeName: Schema.string().default(DEFAULT_DSMM_SETTINGS.modeName),
212
+ defaultActive: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.defaultActive),
213
+ promptOrder: Schema.number().default(DEFAULT_DSMM_SETTINGS.promptOrder),
214
+ deepseekV4ProCalibration: DEEPSEEK_CALIBRATION_SCHEMA,
215
+ deepseekV4ProDefaultReasoningEffort: DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA,
216
+ deepseekV4ProMaxReasoningPresets: DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA,
217
+ deepseekFlashCalibration: DEEPSEEK_CALIBRATION_SCHEMA,
218
+ deepseekFlashDefaultReasoningEffort: DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA,
219
+ deepseekFlashMaxReasoningPresets: DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA,
220
+ skills: SKILLS_SCHEMA,
221
+ roles: ROLES_SCHEMA,
222
+ roleRouting: ROLE_ROUTING_SCHEMA,
223
+ presets: PRESETS_SCHEMA,
224
+ workflow: WORKFLOW_SCHEMA,
225
+ guards: GUARDS_SCHEMA,
226
+ runtimeRecovery: RUNTIME_RECOVERY_SCHEMA,
227
+ lsp: LSP_SCHEMA
228
+ })]).default({});
229
+ export function resolveConfig(config = {}) {
230
+ return {
231
+ modeName: normalizeModeName(config.modeName),
232
+ defaultActive: config.defaultActive ?? DEFAULT_DSMM_SETTINGS.defaultActive,
233
+ promptOrder: config.promptOrder ?? DEFAULT_DSMM_SETTINGS.promptOrder,
234
+ deepseekV4ProCalibration: config.deepseekV4ProCalibration ?? DEFAULT_DSMM_SETTINGS.deepseekV4ProCalibration,
235
+ deepseekV4ProDefaultReasoningEffort: config.deepseekV4ProDefaultReasoningEffort ?? DEFAULT_DSMM_SETTINGS.deepseekV4ProDefaultReasoningEffort,
236
+ deepseekV4ProMaxReasoningPresets: resolveMaxReasoningPresets(config.deepseekV4ProMaxReasoningPresets, DEFAULT_DSMM_SETTINGS.deepseekV4ProMaxReasoningPresets),
237
+ deepseekFlashCalibration: config.deepseekFlashCalibration ?? DEFAULT_DSMM_SETTINGS.deepseekFlashCalibration,
238
+ deepseekFlashDefaultReasoningEffort: config.deepseekFlashDefaultReasoningEffort ?? DEFAULT_DSMM_SETTINGS.deepseekFlashDefaultReasoningEffort,
239
+ deepseekFlashMaxReasoningPresets: resolveMaxReasoningPresets(config.deepseekFlashMaxReasoningPresets, DEFAULT_DSMM_SETTINGS.deepseekFlashMaxReasoningPresets),
240
+ skills: { ...DEFAULT_DSMM_SETTINGS.skills, ...config.skills },
241
+ roles: { ...DEFAULT_DSMM_SETTINGS.roles, ...config.roles },
242
+ roleRouting: resolveRoleRouting(config.roleRouting),
243
+ presets: resolvePresetSettings(config.presets),
244
+ workflow: resolveWorkflowSettings(config.workflow),
245
+ guards: resolveGuardSettings(config.guards),
246
+ runtimeRecovery: resolveRuntimeRecoverySettings(config.runtimeRecovery),
247
+ lsp: resolveLspSettings(config.lsp)
248
+ };
249
+ }
250
+ function resolveMaxReasoningPresets(input, defaults) {
251
+ const requested = new Set(input ?? defaults);
252
+ return DSMM_ROLE_IDS.filter((id) => requested.has(id));
253
+ }
254
+ export function resolveRoleRouting(input) {
255
+ if (input === undefined)
256
+ return {};
257
+ if (!isRoutingRecord(input))
258
+ throw new TypeError("dsmm roleRouting must be an object");
259
+ const result = {};
260
+ for (const [key, value] of Object.entries(input)) {
261
+ if (!DSMM_ROLE_IDS.includes(key))
262
+ throw new TypeError("dsmm roleRouting contains an unknown role");
263
+ if (!isRoutingRecord(value) || Object.keys(value).some((field) => field !== "primary" && field !== "fallbackRoutes")) {
264
+ throw new TypeError("dsmm roleRouting role policy must contain only primary and fallbackRoutes");
265
+ }
266
+ const policy = {};
267
+ if (Object.hasOwn(value, "primary"))
268
+ policy.primary = normalizeExplicitRoute(value.primary);
269
+ if (Object.hasOwn(value, "fallbackRoutes")) {
270
+ if (!Array.isArray(value.fallbackRoutes))
271
+ throw new TypeError("dsmm roleRouting fallbackRoutes must be an array");
272
+ policy.fallbackRoutes = [];
273
+ for (const entry of value.fallbackRoutes) {
274
+ const route = normalizeExplicitRoute(entry);
275
+ if (!policy.fallbackRoutes.some((existing) => existing.provider === route.provider && existing.model === route.model))
276
+ policy.fallbackRoutes.push(route);
277
+ }
278
+ }
279
+ result[key] = policy;
280
+ }
281
+ return result;
282
+ }
283
+ function isRoutingRecord(value) {
284
+ return typeof value === "object" && value !== null && !Array.isArray(value);
285
+ }
286
+ function normalizeExplicitRoute(value) {
287
+ if (!isRoutingRecord(value) || Object.keys(value).some((field) => !["provider", "model", "reasoningEffort"].includes(field))) {
288
+ throw new TypeError("dsmm explicit model route must contain provider, model and optional reasoningEffort");
289
+ }
290
+ if (typeof value.provider !== "string" || value.provider.trim() === "" || typeof value.model !== "string" || value.model.trim() === "") {
291
+ throw new TypeError("dsmm explicit model route requires nonempty provider and model");
292
+ }
293
+ if (Object.hasOwn(value, "reasoningEffort") && (typeof value.reasoningEffort !== "string" || value.reasoningEffort.trim() === "")) {
294
+ throw new TypeError("dsmm explicit model route reasoningEffort must be nonempty");
295
+ }
296
+ return {
297
+ provider: value.provider.trim(), model: value.model.trim(),
298
+ ...(typeof value.reasoningEffort === "string" ? { reasoningEffort: value.reasoningEffort.trim() } : {})
299
+ };
300
+ }
301
+ export function isRoleEnabled(settings, role) {
302
+ return settings.roles[role];
303
+ }
304
+ function resolvePresetSettings(config) {
305
+ return {
306
+ materialize: config?.materialize ?? DEFAULT_DSMM_SETTINGS.presets.materialize,
307
+ ...(config?.root === undefined ? {} : { root: config.root })
308
+ };
309
+ }
310
+ function resolveWorkflowSettings(config) {
311
+ const legacy = config !== undefined && (config.strictGates !== undefined || config.reviewCap !== undefined || config.finalReviewPolicy !== undefined);
312
+ return {
313
+ ...DEFAULT_DSMM_SETTINGS.workflow,
314
+ ...config,
315
+ policy: config?.policy ?? (legacy ? "legacy" : "risk-based")
316
+ };
317
+ }
318
+ export function resolveGuardSettings(config) {
319
+ const defaults = DEFAULT_DSMM_SETTINGS.guards;
320
+ return {
321
+ ...defaults,
322
+ ...config,
323
+ toolOutputTruncation: {
324
+ ...defaults.toolOutputTruncation,
325
+ ...config?.toolOutputTruncation,
326
+ maxInlineBytes: normalizePositiveInteger(config?.toolOutputTruncation?.maxInlineBytes, defaults.toolOutputTruncation.maxInlineBytes)
327
+ },
328
+ questionLabelHelper: {
329
+ ...defaults.questionLabelHelper,
330
+ ...config?.questionLabelHelper,
331
+ maxLabelChars: normalizePositiveInteger(config?.questionLabelHelper?.maxLabelChars, defaults.questionLabelHelper.maxLabelChars)
332
+ }
333
+ };
334
+ }
335
+ function resolveRuntimeRecoverySettings(config) {
336
+ const defaults = DEFAULT_DSMM_SETTINGS.runtimeRecovery;
337
+ return {
338
+ enabled: config?.enabled ?? defaults.enabled,
339
+ retryOnStatusCodes: normalizeStatusCodes(config?.retryOnStatusCodes, defaults.retryOnStatusCodes),
340
+ retryOnCodes: normalizeRetryCodes(config?.retryOnCodes, defaults.retryOnCodes),
341
+ fallbackRoutes: normalizeRecoveryRoutes(config?.fallbackRoutes, defaults.fallbackRoutes),
342
+ maxFallbackAttempts: normalizeBoundedInteger(config?.maxFallbackAttempts, defaults.maxFallbackAttempts),
343
+ idleContinuation: {
344
+ enabled: config?.idleContinuation?.enabled ?? defaults.idleContinuation.enabled,
345
+ maxContinuations: normalizeBoundedInteger(config?.idleContinuation?.maxContinuations, defaults.idleContinuation.maxContinuations),
346
+ prompt: config?.idleContinuation?.prompt ?? defaults.idleContinuation.prompt
347
+ }
348
+ };
349
+ }
350
+ function normalizeStatusCodes(input, defaults) {
351
+ const normalized = [];
352
+ for (const status of input ?? defaults) {
353
+ if (Number.isInteger(status) && status >= 100 && status <= 599 && !normalized.includes(status))
354
+ normalized.push(status);
355
+ }
356
+ return normalized;
357
+ }
358
+ function normalizeRetryCodes(input, defaults) {
359
+ const normalized = [];
360
+ for (const code of input ?? defaults) {
361
+ const normalizedCode = code.trim().toLowerCase();
362
+ if (normalizedCode !== "" && !normalized.includes(normalizedCode))
363
+ normalized.push(normalizedCode);
364
+ }
365
+ return normalized;
366
+ }
367
+ function normalizeRecoveryRoutes(input, defaults) {
368
+ const normalized = [];
369
+ for (const route of input ?? defaults) {
370
+ const reasoningEffort = normalizeRecoveryEffort(route);
371
+ const provider = route.provider?.trim() ?? "";
372
+ const model = route.model?.trim() ?? "";
373
+ if (provider === "" || model === "" || normalized.some((candidate) => candidate.provider === provider && candidate.model === model))
374
+ continue;
375
+ normalized.push({ provider, model, ...(reasoningEffort ? { reasoningEffort } : {}) });
376
+ }
377
+ return normalized;
378
+ }
379
+ function normalizeRecoveryEffort(route) {
380
+ if (!Object.hasOwn(route, "reasoningEffort"))
381
+ return undefined;
382
+ const value = route.reasoningEffort;
383
+ if (typeof value !== "string" || value.trim() === "")
384
+ throw new TypeError("dsmm recovery route reasoningEffort must be nonempty");
385
+ return value.trim();
386
+ }
387
+ function normalizeBoundedInteger(value, defaultValue) {
388
+ if (value === undefined || !Number.isFinite(value))
389
+ return defaultValue;
390
+ return Math.min(10, Math.max(0, Math.floor(value)));
391
+ }
392
+ function normalizePositiveInteger(value, defaultValue) {
393
+ if (value === undefined || !Number.isFinite(value) || value <= 0)
394
+ return defaultValue;
395
+ return Math.floor(value);
396
+ }
397
+ export function registerSettings(ctx, config = {}, options = {}) {
398
+ const base = resolveConfig(config);
399
+ // Current Cordis loads restart-scoped Config itself; SettingsForms has no register().
400
+ if (ctx.get !== undefined) {
401
+ const getSettings = () => base;
402
+ options.onChange?.(base);
403
+ options.install?.(ctx, getSettings);
404
+ return getSettings;
405
+ }
406
+ let getSettings = () => base;
407
+ let attached = false;
408
+ const installedSettingsByReadyContext = new WeakMap();
409
+ const ready = (readyCtx, settings) => {
410
+ if (settings === undefined || installedSettingsByReadyContext.get(readyCtx) === settings)
411
+ return;
412
+ const scope = settings.register(DSMM_SETTINGS_NAMESPACE, DSMM_SETTINGS_SCHEMA, { base, applies: "restart" });
413
+ const previousGetSettings = getSettings;
414
+ const previousAttached = attached;
415
+ getSettings = () => resolveConfig(scope.get());
416
+ try {
417
+ options.onChange?.(getSettings());
418
+ options.install?.(readyCtx, () => getSettings());
419
+ installedSettingsByReadyContext.set(readyCtx, settings);
420
+ readyCtx.effect?.(() => () => {
421
+ if (installedSettingsByReadyContext.get(readyCtx) === settings)
422
+ installedSettingsByReadyContext.delete(readyCtx);
423
+ });
424
+ attached = true;
425
+ }
426
+ catch (error) {
427
+ if (installedSettingsByReadyContext.get(readyCtx) === settings)
428
+ installedSettingsByReadyContext.delete(readyCtx);
429
+ getSettings = previousGetSettings;
430
+ attached = previousAttached;
431
+ throw error;
432
+ }
433
+ };
434
+ if (ctx.inject !== undefined) {
435
+ ctx.inject(["settings", "systemPrompt"], (readyCtx) => ready(readyCtx, readyCtx.settings));
436
+ return () => getSettings();
437
+ }
438
+ if (Object.prototype.hasOwnProperty.call(ctx, "settings")) {
439
+ ready(ctx, Object.getOwnPropertyDescriptor(ctx, "settings")?.value);
440
+ }
441
+ if (!attached) {
442
+ options.onChange?.(getSettings());
443
+ options.install?.(ctx, () => getSettings());
444
+ }
445
+ return () => getSettings();
446
+ }
447
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1,18 @@
1
+ export type ShellDialect = "posix" | "powershell";
2
+ export type ShellToken = {
3
+ kind: "word";
4
+ value: string;
5
+ quoted: boolean;
6
+ } | {
7
+ kind: "operator";
8
+ value: string;
9
+ };
10
+ export interface ParsedShellSegment {
11
+ tokens: readonly ShellToken[];
12
+ words: readonly string[];
13
+ }
14
+ export declare function parseShellCommand(input: string, dialect: ShellDialect): readonly ParsedShellSegment[];
15
+ export declare function classifyKnownGitWrite(input: string, dialect: ShellDialect): string | undefined;
16
+ export type ShellDialectViolation = "powershell-export" | "powershell-source" | "powershell-dev-null" | "posix-powershell-env";
17
+ export declare function classifyShellDialectViolation(input: string, dialect: ShellDialect): ShellDialectViolation | undefined;
18
+ //# sourceMappingURL=shell-command.d.ts.map