@dsmm/dsmm 0.0.0-stage → 0.1.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 (125) hide show
  1. package/LICENSE +103 -0
  2. package/README.md +67 -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 +17 -0
  29. package/docs/compatibility.md +46 -0
  30. package/docs/design.md +237 -0
  31. package/docs/lsp.md +40 -0
  32. package/docs/migration-from-ocmm.md +48 -0
  33. package/docs/model-routing.md +16 -0
  34. package/docs/releasing.md +50 -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 +67 -0
  39. package/docs/safety-guards.md +55 -0
  40. package/docs/settings-status.md +51 -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 +13 -0
  45. package/lib/dsh-events.js +2 -0
  46. package/lib/dsh-types.d.ts +308 -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 +31 -0
  51. package/lib/index.js +54 -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 +103 -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-subagents.d.ts +6 -0
  73. package/lib/role-subagents.js +54 -0
  74. package/lib/roles.d.ts +28 -0
  75. package/lib/roles.js +239 -0
  76. package/lib/runtime-recovery.d.ts +5 -0
  77. package/lib/runtime-recovery.js +149 -0
  78. package/lib/session-scope.d.ts +4 -0
  79. package/lib/session-scope.js +17 -0
  80. package/lib/settings.d.ts +112 -0
  81. package/lib/settings.js +363 -0
  82. package/lib/shell-command.d.ts +18 -0
  83. package/lib/shell-command.js +492 -0
  84. package/lib/skills.d.ts +18 -0
  85. package/lib/skills.js +64 -0
  86. package/lib/state.d.ts +13 -0
  87. package/lib/state.js +64 -0
  88. package/lib/status.d.ts +46 -0
  89. package/lib/status.js +155 -0
  90. package/package.json +124 -4
  91. package/patches/agent-presets-root.example.cordis.patch.yml +14 -0
  92. package/patches/ocmm-lsp-mcp.example.cordis.patch.yml +15 -0
  93. package/prompts/deepseek-flash.md +11 -0
  94. package/prompts/deepseek-v4-pro.md +14 -0
  95. package/prompts/deepwork.md +32 -0
  96. package/skills/brainstorming/SKILL.md +15 -0
  97. package/skills/debugging/SKILL.md +12 -0
  98. package/skills/debugging/references/logging.md +91 -0
  99. package/skills/debugging/references/methodology/00-setup.md +108 -0
  100. package/skills/debugging/references/methodology/02-investigate.md +67 -0
  101. package/skills/debugging/references/methodology/03-flaky-triage.md +69 -0
  102. package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +83 -0
  103. package/skills/debugging/references/methodology/05-escalate.md +69 -0
  104. package/skills/debugging/references/methodology/06-fix.md +123 -0
  105. package/skills/debugging/references/methodology/08-qa.md +94 -0
  106. package/skills/debugging/references/methodology/09-cleanup.md +164 -0
  107. package/skills/debugging/references/methodology/partial-runtime-evidence.md +217 -0
  108. package/skills/debugging/references/runtimes/bundled-js-binary.md +415 -0
  109. package/skills/debugging/references/runtimes/go.md +252 -0
  110. package/skills/debugging/references/runtimes/native-binary.md +484 -0
  111. package/skills/debugging/references/runtimes/node.md +260 -0
  112. package/skills/debugging/references/runtimes/python.md +248 -0
  113. package/skills/debugging/references/runtimes/rust.md +234 -0
  114. package/skills/debugging/references/scripts/dap.mjs +533 -0
  115. package/skills/debugging/references/tools/dap.md +89 -0
  116. package/skills/debugging/references/tools/ghidra.md +212 -0
  117. package/skills/debugging/references/tools/playwright-cli.md +316 -0
  118. package/skills/debugging/references/tools/pwndbg.md +263 -0
  119. package/skills/debugging/references/tools/pwntools.md +265 -0
  120. package/skills/dispatching-parallel-agents/SKILL.md +14 -0
  121. package/skills/receiving-code-review/SKILL.md +13 -0
  122. package/skills/remove-ai-slops/SKILL.md +14 -0
  123. package/skills/requesting-code-review/SKILL.md +10 -0
  124. package/skills/subagent-driven-development/SKILL.md +13 -0
  125. package/skills/writing-plans/SKILL.md +14 -0
@@ -0,0 +1,149 @@
1
+ import { createUserMessage } from "@deepseek-ai/dsh-llm";
2
+ import { classifyRecoveryFailure, foldAttemptedRecoveryRoutes, foldDurableRecoveryWork, isCurrentRecoveryStep, selectFallbackRoute } from "./recovery-policy.js";
3
+ import { isDsmmRoleId } from "./roles.js";
4
+ import { resolveSelectedAgentPreset, sessionEvents } from "./session-scope.js";
5
+ const installedContexts = new WeakSet();
6
+ const RECOVERY_WARNING = "dsmm runtime recovery could not evaluate fallback; preserving the host request-error decision";
7
+ const CONTINUATION_WARNING = "dsmm runtime recovery continuation steering failed for turn";
8
+ function warnSafely(ctx, message) {
9
+ try {
10
+ ctx.logger?.warn(message);
11
+ }
12
+ catch { }
13
+ }
14
+ export function registerRuntimeRecovery(ctx, controller, getSettings) {
15
+ if (installedContexts.has(ctx) || ctx.on === undefined)
16
+ return;
17
+ installedContexts.add(ctx);
18
+ let pendingByAgent = new WeakMap();
19
+ let reservedByAgent = new WeakMap();
20
+ let continuationsByAgent = new WeakMap();
21
+ let disposeRequest;
22
+ let disposeRequestError;
23
+ let disposeTurnStopping;
24
+ const reset = () => {
25
+ const request = disposeRequest;
26
+ const requestError = disposeRequestError;
27
+ const turnStopping = disposeTurnStopping;
28
+ disposeRequest = undefined;
29
+ disposeRequestError = undefined;
30
+ disposeTurnStopping = undefined;
31
+ pendingByAgent = new WeakMap();
32
+ reservedByAgent = new WeakMap();
33
+ continuationsByAgent = new WeakMap();
34
+ installedContexts.delete(ctx);
35
+ if (typeof turnStopping === "function")
36
+ turnStopping();
37
+ if (typeof requestError === "function")
38
+ requestError();
39
+ if (typeof request === "function")
40
+ request();
41
+ };
42
+ try {
43
+ disposeRequest = ctx.on("agent/request", async (frame, next) => {
44
+ const downstream = await next();
45
+ const pending = pendingByAgent.get(frame.agent);
46
+ if (pending === undefined)
47
+ return downstream;
48
+ if (frame.signal.aborted || !isCurrentRecoveryStep(sessionEvents(frame.agent.session), pending.turn, pending.step)) {
49
+ pendingByAgent.delete(frame.agent);
50
+ return downstream;
51
+ }
52
+ if (pending.turn !== frame.turn || pending.step !== frame.step)
53
+ return downstream;
54
+ pendingByAgent.delete(frame.agent);
55
+ const { reasoningEffort: _reasoningEffort, ...preserved } = downstream;
56
+ return {
57
+ ...preserved,
58
+ provider: pending.route.provider,
59
+ model: pending.route.model
60
+ };
61
+ });
62
+ disposeRequestError = ctx.on("agent/request-error", async (frame, next) => {
63
+ const downstream = await next();
64
+ if (downstream?.kind === "retry") {
65
+ pendingByAgent.delete(frame.agent);
66
+ return downstream;
67
+ }
68
+ try {
69
+ const settings = getSettings();
70
+ if (!settings.runtimeRecovery.enabled || frame.signal.aborted
71
+ || !isCurrentRecoveryStep(sessionEvents(frame.agent.session), frame.turn, frame.step))
72
+ return downstream;
73
+ const preset = resolveSelectedAgentPreset(frame.agent.session);
74
+ const inScope = controller.active(frame.agent, settings.defaultActive) || isDsmmRoleId(preset);
75
+ if (!inScope || classifyRecoveryFailure(frame.failure, settings.runtimeRecovery).kind !== "retryable")
76
+ return downstream;
77
+ const header = frame.agent.session.requestHeader?.();
78
+ if (header === undefined || header.config.provider !== frame.provider)
79
+ return downstream;
80
+ const reserved = reservedByAgent.get(frame.agent);
81
+ if (reserved?.turn === frame.turn && reserved.step === frame.step
82
+ && reserved.route.provider === header.config.provider && reserved.route.model === header.config.model)
83
+ return downstream;
84
+ const attemptedRoutes = foldAttemptedRecoveryRoutes(sessionEvents(frame.agent.session), frame.turn, frame.step);
85
+ const lastAttemptedRoute = attemptedRoutes.at(-1);
86
+ if (lastAttemptedRoute === undefined
87
+ || lastAttemptedRoute.provider !== header.config.provider
88
+ || lastAttemptedRoute.model !== header.config.model)
89
+ return downstream;
90
+ const route = selectFallbackRoute({
91
+ failedRoute: { provider: header.config.provider, model: header.config.model },
92
+ attemptedRoutes,
93
+ fallbackRoutes: settings.runtimeRecovery.fallbackRoutes,
94
+ maxFallbackAttempts: settings.runtimeRecovery.maxFallbackAttempts
95
+ });
96
+ if (route === undefined)
97
+ return downstream;
98
+ reservedByAgent.set(frame.agent, {
99
+ turn: frame.turn, step: frame.step,
100
+ route: { provider: header.config.provider, model: header.config.model }
101
+ });
102
+ pendingByAgent.set(frame.agent, { turn: frame.turn, step: frame.step, route });
103
+ return { kind: "retry" };
104
+ }
105
+ catch {
106
+ warnSafely(ctx, RECOVERY_WARNING);
107
+ return downstream;
108
+ }
109
+ }, { prepend: true });
110
+ disposeTurnStopping = ctx.on("agent/turn-stopping", async (frame) => {
111
+ try {
112
+ const settings = getSettings();
113
+ const continuation = settings.runtimeRecovery.idleContinuation;
114
+ if (!settings.runtimeRecovery.enabled || !continuation.enabled || frame.signal.aborted)
115
+ return;
116
+ const preset = resolveSelectedAgentPreset(frame.agent.session);
117
+ const inScope = controller.active(frame.agent, settings.defaultActive) || isDsmmRoleId(preset);
118
+ if (!inScope || typeof frame.agent.steer !== "function")
119
+ return;
120
+ const work = foldDurableRecoveryWork(sessionEvents(frame.agent.session));
121
+ if (!work.incompleteTodo && !work.activeGoal)
122
+ return;
123
+ const cap = continuation.maxContinuations;
124
+ if (cap <= 0)
125
+ return;
126
+ const previous = continuationsByAgent.get(frame.agent);
127
+ const count = previous?.turn === frame.turn ? previous.count : 0;
128
+ if (count >= cap)
129
+ return;
130
+ continuationsByAgent.set(frame.agent, { turn: frame.turn, count: count + 1 });
131
+ await frame.agent.steer(createUserMessage({
132
+ content: [{ type: "text", text: continuation.prompt }],
133
+ source: { kind: "user" }
134
+ }));
135
+ }
136
+ catch {
137
+ warnSafely(ctx, `${CONTINUATION_WARNING} ${frame.turn}`);
138
+ }
139
+ });
140
+ ctx.effect?.(() => () => {
141
+ reset();
142
+ });
143
+ }
144
+ catch (error) {
145
+ reset();
146
+ throw error;
147
+ }
148
+ }
149
+ //# sourceMappingURL=runtime-recovery.js.map
@@ -0,0 +1,4 @@
1
+ import type { DshSession, DshSessionEvent } from "./dsh-types.js";
2
+ export declare function sessionEvents(session: DshSession | undefined): readonly DshSessionEvent[];
3
+ export declare function resolveSelectedAgentPreset(session: DshSession | undefined): string | undefined;
4
+ //# sourceMappingURL=session-scope.d.ts.map
@@ -0,0 +1,17 @@
1
+ export function sessionEvents(session) {
2
+ return session?.snapshotEvents?.() ?? session?.events ?? [];
3
+ }
4
+ export function resolveSelectedAgentPreset(session) {
5
+ const events = sessionEvents(session);
6
+ for (let index = events.length - 1; index >= 0; index -= 1) {
7
+ const event = events[index];
8
+ if (event?.type !== "agent-preset/selected")
9
+ continue;
10
+ const data = event.data;
11
+ if (typeof data === "object" && data !== null && "agentPreset" in data && typeof data.agentPreset === "string") {
12
+ return data.agentPreset;
13
+ }
14
+ }
15
+ return typeof session?.header?.agentPreset === "string" ? session.header.agentPreset : undefined;
16
+ }
17
+ //# sourceMappingURL=session-scope.js.map
@@ -0,0 +1,112 @@
1
+ import Schema from "@deepseek-ai/schemastery";
2
+ import type { DshContext } from "./dsh-types.js";
3
+ import type { DsmmLspSettings } from "./lsp.js";
4
+ import type { DsmmRoleId } from "./roles.js";
5
+ import type { DsmmSkillName } from "./skills.js";
6
+ export { DSMM_SKILL_NAMES, MVP_SKILL_NAMES } from "./skills.js";
7
+ export type { DsmmSkillName, MvpSkillName } from "./skills.js";
8
+ export type DeepseekCalibration = "off" | "auto" | "strict";
9
+ export type DeepseekDefaultReasoningEffort = "off" | "low" | "high";
10
+ export type DsmmFinalReviewPolicy = "simple-oracle-complex-reviewer" | "reviewer-only" | "off";
11
+ export type DsmmGuardScope = "deepwork-or-dsmm-agent" | "always" | "off";
12
+ export type DsmmGitWritePolicy = "ask" | "deny" | "off";
13
+ export interface DsmmWorkflowSettings {
14
+ policy: "risk-based" | "legacy";
15
+ strictGates: boolean;
16
+ reviewCap: number;
17
+ finalReviewPolicy: DsmmFinalReviewPolicy;
18
+ }
19
+ export interface DsmmPresetSettings {
20
+ materialize: boolean;
21
+ root?: string;
22
+ }
23
+ export interface DsmmGuardSettings {
24
+ scope: DsmmGuardScope;
25
+ shellCommandSafety: boolean;
26
+ gitWriteGuard: DsmmGitWritePolicy;
27
+ toolOutputTruncation: {
28
+ enabled: boolean;
29
+ maxInlineBytes: number;
30
+ };
31
+ planFormatValidation: boolean;
32
+ questionLabelHelper: {
33
+ enabled: boolean;
34
+ maxLabelChars: number;
35
+ };
36
+ todoDisciplineHelper: boolean;
37
+ }
38
+ export interface DsmmRecoveryRoute {
39
+ provider: string;
40
+ model: string;
41
+ }
42
+ export interface DsmmRuntimeRecoverySettings {
43
+ enabled: boolean;
44
+ retryOnStatusCodes: number[];
45
+ retryOnCodes: string[];
46
+ fallbackRoutes: DsmmRecoveryRoute[];
47
+ maxFallbackAttempts: number;
48
+ idleContinuation: {
49
+ enabled: boolean;
50
+ maxContinuations: number;
51
+ prompt: string;
52
+ };
53
+ }
54
+ type DsmmGuardConfig = Partial<Omit<DsmmGuardSettings, "toolOutputTruncation" | "questionLabelHelper">> & {
55
+ toolOutputTruncation?: Partial<DsmmGuardSettings["toolOutputTruncation"]>;
56
+ questionLabelHelper?: Partial<DsmmGuardSettings["questionLabelHelper"]>;
57
+ };
58
+ type DsmmRuntimeRecoveryConfig = Partial<Omit<DsmmRuntimeRecoverySettings, "fallbackRoutes" | "idleContinuation">> & {
59
+ fallbackRoutes?: Array<Partial<DsmmRecoveryRoute>>;
60
+ idleContinuation?: Partial<DsmmRuntimeRecoverySettings["idleContinuation"]>;
61
+ };
62
+ export interface DsmmPluginConfig {
63
+ modeName?: string;
64
+ section?: string;
65
+ deepseekV4ProCalibration?: DeepseekCalibration;
66
+ deepseekV4ProDefaultReasoningEffort?: DeepseekDefaultReasoningEffort;
67
+ deepseekV4ProMaxReasoningPresets?: DsmmRoleId[];
68
+ deepseekFlashCalibration?: DeepseekCalibration;
69
+ deepseekFlashDefaultReasoningEffort?: DeepseekDefaultReasoningEffort;
70
+ deepseekFlashMaxReasoningPresets?: DsmmRoleId[];
71
+ defaultActive?: boolean;
72
+ promptOrder?: number;
73
+ skills?: Partial<Record<DsmmSkillName, boolean>>;
74
+ roles?: Partial<Record<DsmmRoleId, boolean>>;
75
+ presets?: Partial<DsmmPresetSettings>;
76
+ workflow?: Partial<DsmmWorkflowSettings>;
77
+ guards?: DsmmGuardConfig;
78
+ runtimeRecovery?: DsmmRuntimeRecoveryConfig;
79
+ lsp?: Partial<DsmmLspSettings>;
80
+ }
81
+ export interface DsmmSettings {
82
+ modeName: string;
83
+ defaultActive: boolean;
84
+ promptOrder: number;
85
+ deepseekV4ProCalibration: DeepseekCalibration;
86
+ deepseekV4ProDefaultReasoningEffort: DeepseekDefaultReasoningEffort;
87
+ deepseekV4ProMaxReasoningPresets: DsmmRoleId[];
88
+ deepseekFlashCalibration: DeepseekCalibration;
89
+ deepseekFlashDefaultReasoningEffort: DeepseekDefaultReasoningEffort;
90
+ deepseekFlashMaxReasoningPresets: DsmmRoleId[];
91
+ skills: Record<DsmmSkillName, boolean>;
92
+ roles: Record<DsmmRoleId, boolean>;
93
+ presets: DsmmPresetSettings;
94
+ workflow: DsmmWorkflowSettings;
95
+ guards: DsmmGuardSettings;
96
+ runtimeRecovery: DsmmRuntimeRecoverySettings;
97
+ lsp: DsmmLspSettings;
98
+ }
99
+ export declare const DSMM_SETTINGS_NAMESPACE = "dsmm";
100
+ export declare const DSMM_STATUS_COMMAND = "dsmm-status";
101
+ export interface RegisterSettingsOptions {
102
+ onChange?: (settings: DsmmSettings) => void;
103
+ install?: (readyCtx: DshContext, getSettings: () => DsmmSettings) => void;
104
+ }
105
+ export declare const DEFAULT_DSMM_SETTINGS: DsmmSettings;
106
+ export declare const DSMM_CONFIG_SCHEMA: Schema<DsmmPluginConfig>;
107
+ export declare const DSMM_SETTINGS_SCHEMA: Schema<DsmmSettings>;
108
+ export declare function resolveConfig(config?: DsmmPluginConfig): DsmmSettings;
109
+ export declare function isRoleEnabled(settings: DsmmSettings, role: DsmmRoleId): boolean;
110
+ export declare function resolveGuardSettings(config: DsmmPluginConfig["guards"]): DsmmGuardSettings;
111
+ export declare function registerSettings(ctx: DshContext, config?: DsmmPluginConfig, options?: RegisterSettingsOptions): () => DsmmSettings;
112
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1,363 @@
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
+ presets: {
21
+ materialize: false
22
+ },
23
+ workflow: {
24
+ policy: "risk-based",
25
+ strictGates: true,
26
+ reviewCap: 5,
27
+ finalReviewPolicy: "simple-oracle-complex-reviewer"
28
+ },
29
+ guards: {
30
+ scope: "deepwork-or-dsmm-agent",
31
+ shellCommandSafety: true,
32
+ gitWriteGuard: "ask",
33
+ toolOutputTruncation: {
34
+ enabled: true,
35
+ maxInlineBytes: 12000
36
+ },
37
+ planFormatValidation: true,
38
+ questionLabelHelper: {
39
+ enabled: true,
40
+ maxLabelChars: 30
41
+ },
42
+ todoDisciplineHelper: true
43
+ },
44
+ runtimeRecovery: {
45
+ enabled: false,
46
+ retryOnStatusCodes: [429, 500, 502, 503, 504],
47
+ retryOnCodes: [],
48
+ fallbackRoutes: [],
49
+ maxFallbackAttempts: 2,
50
+ idleContinuation: {
51
+ enabled: false,
52
+ maxContinuations: 3,
53
+ prompt: "Continue the current task from the durable goal or unfinished todo list. Do not repeat completed work."
54
+ }
55
+ },
56
+ lsp: DEFAULT_DSMM_LSP_SETTINGS
57
+ };
58
+ function normalizeModeName(modeName) {
59
+ return modeName === DSMM_STATUS_COMMAND ? DEFAULT_DSMM_SETTINGS.modeName : modeName ?? DEFAULT_DSMM_SETTINGS.modeName;
60
+ }
61
+ function createDefaultSkillSettings() {
62
+ return Object.fromEntries(DSMM_SKILL_NAMES.map((id) => [id, true]));
63
+ }
64
+ function createDefaultRoleSettings() {
65
+ return Object.fromEntries(DSMM_ROLE_IDS.map((id) => [id, true]));
66
+ }
67
+ const SKILLS_SCHEMA = Schema.object({
68
+ brainstorming: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills.brainstorming),
69
+ "writing-plans": Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills["writing-plans"]),
70
+ "requesting-code-review": Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills["requesting-code-review"]),
71
+ "receiving-code-review": Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills["receiving-code-review"]),
72
+ "subagent-driven-development": Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills["subagent-driven-development"]),
73
+ "dispatching-parallel-agents": Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills["dispatching-parallel-agents"]),
74
+ "remove-ai-slops": Schema.boolean().default(DEFAULT_DSMM_SETTINGS.skills["remove-ai-slops"])
75
+ });
76
+ const ROLES_SCHEMA = Schema.object(Object.fromEntries(DSMM_ROLE_IDS.map((id) => [id, Schema.boolean().default(DEFAULT_DSMM_SETTINGS.roles[id])])));
77
+ const PRESETS_SCHEMA = Schema.object({
78
+ materialize: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.presets.materialize),
79
+ root: Schema.string()
80
+ });
81
+ const FINAL_REVIEW_POLICY_SCHEMA = Schema.union([
82
+ Schema.const("simple-oracle-complex-reviewer"),
83
+ Schema.const("reviewer-only"),
84
+ Schema.const("off")
85
+ ]).default(DEFAULT_DSMM_SETTINGS.workflow.finalReviewPolicy);
86
+ const WORKFLOW_SCHEMA = Schema.object({
87
+ policy: Schema.union([Schema.const("risk-based"), Schema.const("legacy")]).default(DEFAULT_DSMM_SETTINGS.workflow.policy),
88
+ strictGates: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.workflow.strictGates),
89
+ reviewCap: Schema.number().default(DEFAULT_DSMM_SETTINGS.workflow.reviewCap),
90
+ finalReviewPolicy: FINAL_REVIEW_POLICY_SCHEMA
91
+ });
92
+ const WORKFLOW_CONFIG_SCHEMA = Schema.object({
93
+ policy: Schema.union([Schema.const("risk-based"), Schema.const("legacy")]),
94
+ strictGates: Schema.boolean(),
95
+ reviewCap: Schema.number(),
96
+ finalReviewPolicy: Schema.union([
97
+ Schema.const("simple-oracle-complex-reviewer"), Schema.const("reviewer-only"), Schema.const("off")
98
+ ])
99
+ });
100
+ const GUARD_SCOPE_SCHEMA = Schema.union([
101
+ Schema.const("deepwork-or-dsmm-agent"),
102
+ Schema.const("always"),
103
+ Schema.const("off")
104
+ ]).default(DEFAULT_DSMM_SETTINGS.guards.scope);
105
+ const GIT_WRITE_POLICY_SCHEMA = Schema.union([
106
+ Schema.const("ask"),
107
+ Schema.const("deny"),
108
+ Schema.const("off")
109
+ ]).default(DEFAULT_DSMM_SETTINGS.guards.gitWriteGuard);
110
+ const TOOL_OUTPUT_TRUNCATION_SCHEMA = Schema.object({
111
+ enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.toolOutputTruncation.enabled),
112
+ maxInlineBytes: Schema.number().default(DEFAULT_DSMM_SETTINGS.guards.toolOutputTruncation.maxInlineBytes)
113
+ });
114
+ const QUESTION_LABEL_HELPER_SCHEMA = Schema.object({
115
+ enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.questionLabelHelper.enabled),
116
+ maxLabelChars: Schema.number().default(DEFAULT_DSMM_SETTINGS.guards.questionLabelHelper.maxLabelChars)
117
+ });
118
+ const GUARDS_SCHEMA = Schema.object({
119
+ scope: GUARD_SCOPE_SCHEMA,
120
+ shellCommandSafety: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.shellCommandSafety),
121
+ gitWriteGuard: GIT_WRITE_POLICY_SCHEMA,
122
+ toolOutputTruncation: TOOL_OUTPUT_TRUNCATION_SCHEMA,
123
+ planFormatValidation: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.planFormatValidation),
124
+ questionLabelHelper: QUESTION_LABEL_HELPER_SCHEMA,
125
+ todoDisciplineHelper: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.guards.todoDisciplineHelper)
126
+ });
127
+ const RUNTIME_RECOVERY_IDLE_CONTINUATION_SCHEMA = Schema.object({
128
+ enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.idleContinuation.enabled),
129
+ maxContinuations: Schema.number().default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.idleContinuation.maxContinuations),
130
+ prompt: Schema.string().default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.idleContinuation.prompt)
131
+ });
132
+ const RUNTIME_RECOVERY_SCHEMA = Schema.object({
133
+ enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.enabled),
134
+ retryOnStatusCodes: Schema.array(Number).default([...DEFAULT_DSMM_SETTINGS.runtimeRecovery.retryOnStatusCodes]),
135
+ retryOnCodes: Schema.array(String).default([...DEFAULT_DSMM_SETTINGS.runtimeRecovery.retryOnCodes]),
136
+ fallbackRoutes: Schema.array(Schema.object({
137
+ provider: Schema.string(),
138
+ model: Schema.string()
139
+ })).default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.fallbackRoutes.map((route) => ({ ...route }))),
140
+ maxFallbackAttempts: Schema.number().default(DEFAULT_DSMM_SETTINGS.runtimeRecovery.maxFallbackAttempts),
141
+ idleContinuation: RUNTIME_RECOVERY_IDLE_CONTINUATION_SCHEMA
142
+ });
143
+ const DEEPSEEK_CALIBRATION_SCHEMA = Schema.union([
144
+ Schema.const("off"),
145
+ Schema.const("auto"),
146
+ Schema.const("strict")
147
+ ]).default(DEFAULT_DSMM_SETTINGS.deepseekV4ProCalibration);
148
+ const DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA = Schema.union([
149
+ Schema.const("off"),
150
+ Schema.const("low"),
151
+ Schema.const("high")
152
+ ]).default(DEFAULT_DSMM_SETTINGS.deepseekV4ProDefaultReasoningEffort);
153
+ const DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA = Schema.array(String)
154
+ .default([...DEFAULT_DSMM_SETTINGS.deepseekV4ProMaxReasoningPresets]);
155
+ const LSP_SCHEMA = Schema.object({
156
+ enabled: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.lsp.enabled),
157
+ serverName: Schema.string().default(DEFAULT_DSMM_SETTINGS.lsp.serverName),
158
+ command: Schema.string().default(DEFAULT_DSMM_SETTINGS.lsp.command),
159
+ args: Schema.array(String).default([...DEFAULT_DSMM_SETTINGS.lsp.args]),
160
+ cwd: Schema.string().default(DEFAULT_DSMM_SETTINGS.lsp.cwd),
161
+ env: Schema.dict(String).default({ ...DEFAULT_DSMM_SETTINGS.lsp.env }),
162
+ toolCallTimeoutMs: Schema.number().default(DEFAULT_DSMM_SETTINGS.lsp.toolCallTimeoutMs),
163
+ failOnStartupError: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.lsp.failOnStartupError)
164
+ });
165
+ export const DSMM_CONFIG_SCHEMA = Schema.object({
166
+ modeName: Schema.string().default(DEFAULT_DSMM_SETTINGS.modeName),
167
+ section: Schema.string(),
168
+ defaultActive: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.defaultActive),
169
+ promptOrder: Schema.number().default(DEFAULT_DSMM_SETTINGS.promptOrder),
170
+ deepseekV4ProCalibration: DEEPSEEK_CALIBRATION_SCHEMA,
171
+ deepseekV4ProDefaultReasoningEffort: DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA,
172
+ deepseekV4ProMaxReasoningPresets: DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA,
173
+ deepseekFlashCalibration: DEEPSEEK_CALIBRATION_SCHEMA,
174
+ deepseekFlashDefaultReasoningEffort: DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA,
175
+ deepseekFlashMaxReasoningPresets: DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA,
176
+ skills: SKILLS_SCHEMA,
177
+ roles: ROLES_SCHEMA,
178
+ presets: PRESETS_SCHEMA,
179
+ workflow: WORKFLOW_CONFIG_SCHEMA,
180
+ guards: GUARDS_SCHEMA,
181
+ runtimeRecovery: RUNTIME_RECOVERY_SCHEMA,
182
+ lsp: LSP_SCHEMA
183
+ });
184
+ export const DSMM_SETTINGS_SCHEMA = Schema.object({
185
+ modeName: Schema.string().default(DEFAULT_DSMM_SETTINGS.modeName),
186
+ defaultActive: Schema.boolean().default(DEFAULT_DSMM_SETTINGS.defaultActive),
187
+ promptOrder: Schema.number().default(DEFAULT_DSMM_SETTINGS.promptOrder),
188
+ deepseekV4ProCalibration: DEEPSEEK_CALIBRATION_SCHEMA,
189
+ deepseekV4ProDefaultReasoningEffort: DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA,
190
+ deepseekV4ProMaxReasoningPresets: DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA,
191
+ deepseekFlashCalibration: DEEPSEEK_CALIBRATION_SCHEMA,
192
+ deepseekFlashDefaultReasoningEffort: DEEPSEEK_DEFAULT_REASONING_EFFORT_SCHEMA,
193
+ deepseekFlashMaxReasoningPresets: DEEPSEEK_MAX_REASONING_PRESETS_SCHEMA,
194
+ skills: SKILLS_SCHEMA,
195
+ roles: ROLES_SCHEMA,
196
+ presets: PRESETS_SCHEMA,
197
+ workflow: WORKFLOW_SCHEMA,
198
+ guards: GUARDS_SCHEMA,
199
+ runtimeRecovery: RUNTIME_RECOVERY_SCHEMA,
200
+ lsp: LSP_SCHEMA
201
+ });
202
+ export function resolveConfig(config = {}) {
203
+ return {
204
+ modeName: normalizeModeName(config.modeName),
205
+ defaultActive: config.defaultActive ?? DEFAULT_DSMM_SETTINGS.defaultActive,
206
+ promptOrder: config.promptOrder ?? DEFAULT_DSMM_SETTINGS.promptOrder,
207
+ deepseekV4ProCalibration: config.deepseekV4ProCalibration ?? DEFAULT_DSMM_SETTINGS.deepseekV4ProCalibration,
208
+ deepseekV4ProDefaultReasoningEffort: config.deepseekV4ProDefaultReasoningEffort ?? DEFAULT_DSMM_SETTINGS.deepseekV4ProDefaultReasoningEffort,
209
+ deepseekV4ProMaxReasoningPresets: resolveMaxReasoningPresets(config.deepseekV4ProMaxReasoningPresets, DEFAULT_DSMM_SETTINGS.deepseekV4ProMaxReasoningPresets),
210
+ deepseekFlashCalibration: config.deepseekFlashCalibration ?? DEFAULT_DSMM_SETTINGS.deepseekFlashCalibration,
211
+ deepseekFlashDefaultReasoningEffort: config.deepseekFlashDefaultReasoningEffort ?? DEFAULT_DSMM_SETTINGS.deepseekFlashDefaultReasoningEffort,
212
+ deepseekFlashMaxReasoningPresets: resolveMaxReasoningPresets(config.deepseekFlashMaxReasoningPresets, DEFAULT_DSMM_SETTINGS.deepseekFlashMaxReasoningPresets),
213
+ skills: { ...DEFAULT_DSMM_SETTINGS.skills, ...config.skills },
214
+ roles: { ...DEFAULT_DSMM_SETTINGS.roles, ...config.roles },
215
+ presets: resolvePresetSettings(config.presets),
216
+ workflow: resolveWorkflowSettings(config.workflow),
217
+ guards: resolveGuardSettings(config.guards),
218
+ runtimeRecovery: resolveRuntimeRecoverySettings(config.runtimeRecovery),
219
+ lsp: resolveLspSettings(config.lsp)
220
+ };
221
+ }
222
+ function resolveMaxReasoningPresets(input, defaults) {
223
+ const requested = new Set(input ?? defaults);
224
+ return DSMM_ROLE_IDS.filter((id) => requested.has(id));
225
+ }
226
+ export function isRoleEnabled(settings, role) {
227
+ return settings.roles[role];
228
+ }
229
+ function resolvePresetSettings(config) {
230
+ return {
231
+ materialize: config?.materialize ?? DEFAULT_DSMM_SETTINGS.presets.materialize,
232
+ ...(config?.root === undefined ? {} : { root: config.root })
233
+ };
234
+ }
235
+ function resolveWorkflowSettings(config) {
236
+ const legacy = config !== undefined && (config.strictGates !== undefined || config.reviewCap !== undefined || config.finalReviewPolicy !== undefined);
237
+ return {
238
+ ...DEFAULT_DSMM_SETTINGS.workflow,
239
+ ...config,
240
+ policy: config?.policy ?? (legacy ? "legacy" : "risk-based")
241
+ };
242
+ }
243
+ export function resolveGuardSettings(config) {
244
+ const defaults = DEFAULT_DSMM_SETTINGS.guards;
245
+ return {
246
+ ...defaults,
247
+ ...config,
248
+ toolOutputTruncation: {
249
+ ...defaults.toolOutputTruncation,
250
+ ...config?.toolOutputTruncation,
251
+ maxInlineBytes: normalizePositiveInteger(config?.toolOutputTruncation?.maxInlineBytes, defaults.toolOutputTruncation.maxInlineBytes)
252
+ },
253
+ questionLabelHelper: {
254
+ ...defaults.questionLabelHelper,
255
+ ...config?.questionLabelHelper,
256
+ maxLabelChars: normalizePositiveInteger(config?.questionLabelHelper?.maxLabelChars, defaults.questionLabelHelper.maxLabelChars)
257
+ }
258
+ };
259
+ }
260
+ function resolveRuntimeRecoverySettings(config) {
261
+ const defaults = DEFAULT_DSMM_SETTINGS.runtimeRecovery;
262
+ return {
263
+ enabled: config?.enabled ?? defaults.enabled,
264
+ retryOnStatusCodes: normalizeStatusCodes(config?.retryOnStatusCodes, defaults.retryOnStatusCodes),
265
+ retryOnCodes: normalizeRetryCodes(config?.retryOnCodes, defaults.retryOnCodes),
266
+ fallbackRoutes: normalizeRecoveryRoutes(config?.fallbackRoutes, defaults.fallbackRoutes),
267
+ maxFallbackAttempts: normalizeBoundedInteger(config?.maxFallbackAttempts, defaults.maxFallbackAttempts),
268
+ idleContinuation: {
269
+ enabled: config?.idleContinuation?.enabled ?? defaults.idleContinuation.enabled,
270
+ maxContinuations: normalizeBoundedInteger(config?.idleContinuation?.maxContinuations, defaults.idleContinuation.maxContinuations),
271
+ prompt: config?.idleContinuation?.prompt ?? defaults.idleContinuation.prompt
272
+ }
273
+ };
274
+ }
275
+ function normalizeStatusCodes(input, defaults) {
276
+ const normalized = [];
277
+ for (const status of input ?? defaults) {
278
+ if (Number.isInteger(status) && status >= 100 && status <= 599 && !normalized.includes(status))
279
+ normalized.push(status);
280
+ }
281
+ return normalized;
282
+ }
283
+ function normalizeRetryCodes(input, defaults) {
284
+ const normalized = [];
285
+ for (const code of input ?? defaults) {
286
+ const normalizedCode = code.trim().toLowerCase();
287
+ if (normalizedCode !== "" && !normalized.includes(normalizedCode))
288
+ normalized.push(normalizedCode);
289
+ }
290
+ return normalized;
291
+ }
292
+ function normalizeRecoveryRoutes(input, defaults) {
293
+ const normalized = [];
294
+ for (const route of input ?? defaults) {
295
+ const provider = route.provider?.trim() ?? "";
296
+ const model = route.model?.trim() ?? "";
297
+ if (provider === "" || model === "" || normalized.some((candidate) => candidate.provider === provider && candidate.model === model))
298
+ continue;
299
+ normalized.push({ provider, model });
300
+ }
301
+ return normalized;
302
+ }
303
+ function normalizeBoundedInteger(value, defaultValue) {
304
+ if (value === undefined || !Number.isFinite(value))
305
+ return defaultValue;
306
+ return Math.min(10, Math.max(0, Math.floor(value)));
307
+ }
308
+ function normalizePositiveInteger(value, defaultValue) {
309
+ if (value === undefined || !Number.isFinite(value) || value <= 0)
310
+ return defaultValue;
311
+ return Math.floor(value);
312
+ }
313
+ export function registerSettings(ctx, config = {}, options = {}) {
314
+ const base = resolveConfig(config);
315
+ // Current Cordis loads restart-scoped Config itself; SettingsForms has no register().
316
+ if (ctx.get !== undefined) {
317
+ const getSettings = () => base;
318
+ options.onChange?.(base);
319
+ options.install?.(ctx, getSettings);
320
+ return getSettings;
321
+ }
322
+ let getSettings = () => base;
323
+ let attached = false;
324
+ const installedSettingsByReadyContext = new WeakMap();
325
+ const ready = (readyCtx, settings) => {
326
+ if (settings === undefined || installedSettingsByReadyContext.get(readyCtx) === settings)
327
+ return;
328
+ const scope = settings.register(DSMM_SETTINGS_NAMESPACE, DSMM_SETTINGS_SCHEMA, { base, applies: "restart" });
329
+ const previousGetSettings = getSettings;
330
+ const previousAttached = attached;
331
+ getSettings = () => resolveConfig(scope.get());
332
+ try {
333
+ options.onChange?.(getSettings());
334
+ options.install?.(readyCtx, () => getSettings());
335
+ installedSettingsByReadyContext.set(readyCtx, settings);
336
+ readyCtx.effect?.(() => () => {
337
+ if (installedSettingsByReadyContext.get(readyCtx) === settings)
338
+ installedSettingsByReadyContext.delete(readyCtx);
339
+ });
340
+ attached = true;
341
+ }
342
+ catch (error) {
343
+ if (installedSettingsByReadyContext.get(readyCtx) === settings)
344
+ installedSettingsByReadyContext.delete(readyCtx);
345
+ getSettings = previousGetSettings;
346
+ attached = previousAttached;
347
+ throw error;
348
+ }
349
+ };
350
+ if (ctx.inject !== undefined) {
351
+ ctx.inject(["settings", "systemPrompt"], (readyCtx) => ready(readyCtx, readyCtx.settings));
352
+ return () => getSettings();
353
+ }
354
+ if (Object.prototype.hasOwnProperty.call(ctx, "settings")) {
355
+ ready(ctx, Object.getOwnPropertyDescriptor(ctx, "settings")?.value);
356
+ }
357
+ if (!attached) {
358
+ options.onChange?.(getSettings());
359
+ options.install?.(ctx, () => getSettings());
360
+ }
361
+ return () => getSettings();
362
+ }
363
+ //# 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