@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,252 @@
1
+ const REQUEST_HEADER_REASONS = new Set(["initial", "resume", "change", "series"]);
2
+ const TODO_STATUSES = new Set(["pending", "in_progress", "completed"]);
3
+ const GOAL_OPERATIONS = new Set(["create", "edit", "pause", "resume", "complete", "block"]);
4
+ const GOAL_PHASES = new Set(["active", "paused", "blocked", "complete"]);
5
+ const LOWER_KEBAB_CODE = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
6
+ const SNAPSHOT_EVENT_KEYS = ["createdAt", "goal", "kind", "operation", "roundsStarted", "updatedAt", "version"];
7
+ const CLEAR_EVENT_KEYS = ["cleared", "clearedAt", "kind", "operation", "version"];
8
+ const BLOCKED_GOAL_KEYS = ["blockedReason", "id", "maxGoalRounds", "objective", "phase", "revision"];
9
+ const UNBLOCKED_GOAL_KEYS = ["id", "maxGoalRounds", "objective", "phase", "revision"];
10
+ const CLEAR_REF_KEYS = ["id", "revision"];
11
+ const BLOCKED_REASON_KEYS = ["code", "message"];
12
+ export function classifyRecoveryFailure(failure, settings) {
13
+ if (!isRecord(failure))
14
+ return { kind: "ignored" };
15
+ const status = failure.status;
16
+ if (typeof status === "number" && Number.isInteger(status) && settings.retryOnStatusCodes.includes(status)) {
17
+ return { kind: "retryable", matchedBy: "status" };
18
+ }
19
+ // Payment failures require an explicit status policy, not a generic transport code.
20
+ if (status === 402)
21
+ return { kind: "ignored" };
22
+ const code = failure.code;
23
+ if (typeof code === "string" && settings.retryOnCodes.includes(code.toLowerCase())) {
24
+ return { kind: "retryable", matchedBy: "code" };
25
+ }
26
+ return { kind: "ignored" };
27
+ }
28
+ export function isCurrentRecoveryStep(events, turn, step) {
29
+ for (let index = events.length - 1; index >= 0; index -= 1) {
30
+ const event = events[index];
31
+ if (event.type === "step/start" || event.type === "step/end") {
32
+ const coordinates = readStepCoordinates(event.data);
33
+ if (coordinates !== undefined)
34
+ return event.type === "step/start" && coordinates.turn === turn && coordinates.step === step;
35
+ }
36
+ if (event.type === "turn/start" || event.type === "turn/end") {
37
+ const data = eventData(event);
38
+ if (isRecord(data) && isPositiveSafeInteger(data.turn))
39
+ return false;
40
+ }
41
+ }
42
+ return false;
43
+ }
44
+ export function foldAttemptedRecoveryRoutes(events, turn, step) {
45
+ const routes = [];
46
+ let inheritedRoute;
47
+ let targetStarted = false;
48
+ for (const event of events) {
49
+ if (!targetStarted) {
50
+ if (isTargetStepStart(event, turn, step)) {
51
+ targetStarted = true;
52
+ if (inheritedRoute !== undefined)
53
+ appendUniqueRoute(routes, inheritedRoute);
54
+ continue;
55
+ }
56
+ const route = readHeaderRoute(event);
57
+ if (route !== undefined)
58
+ inheritedRoute = route;
59
+ continue;
60
+ }
61
+ if (endsTargetScope(event))
62
+ break;
63
+ const route = readHeaderRoute(event);
64
+ if (route !== undefined)
65
+ appendUniqueRoute(routes, route);
66
+ }
67
+ return routes;
68
+ }
69
+ export function foldDurableRecoveryWork(events) {
70
+ let latestTurnStart = -1;
71
+ for (let index = 0; index < events.length; index += 1) {
72
+ if (isTurnStart(events[index]))
73
+ latestTurnStart = index;
74
+ }
75
+ let incompleteTodo = false;
76
+ if (latestTurnStart >= 0) {
77
+ for (let index = latestTurnStart + 1; index < events.length; index += 1) {
78
+ const todos = readTodos(events[index]);
79
+ if (todos !== undefined)
80
+ incompleteTodo = todos.some((todo) => todo.status === "pending" || todo.status === "in_progress");
81
+ }
82
+ }
83
+ let activeGoal = false;
84
+ for (const event of events) {
85
+ const nextActiveGoal = readGoalActivity(event);
86
+ if (nextActiveGoal !== undefined)
87
+ activeGoal = nextActiveGoal;
88
+ }
89
+ return { incompleteTodo, activeGoal };
90
+ }
91
+ export function selectFallbackRoute({ failedRoute, attemptedRoutes, fallbackRoutes, maxFallbackAttempts }) {
92
+ const cap = Number.isFinite(maxFallbackAttempts) ? Math.floor(maxFallbackAttempts) : 0;
93
+ if (cap <= 0)
94
+ return undefined;
95
+ const attempts = uniqueRoutes(attemptedRoutes);
96
+ if (attempts.slice(1).length >= cap)
97
+ return undefined;
98
+ for (const fallbackRoute of fallbackRoutes) {
99
+ const route = readRoute(fallbackRoute);
100
+ if (route === undefined || sameRoute(route, failedRoute) || attempts.some((attempt) => sameRoute(attempt, route)))
101
+ continue;
102
+ return { ...route };
103
+ }
104
+ return undefined;
105
+ }
106
+ function isRecord(value) {
107
+ return typeof value === "object" && value !== null && !Array.isArray(value);
108
+ }
109
+ function isNonEmptyString(value) {
110
+ return typeof value === "string" && value.trim() !== "";
111
+ }
112
+ function isNormalizedNonEmptyString(value) {
113
+ return typeof value === "string" && value !== "" && value === value.trim();
114
+ }
115
+ function isPositiveSafeInteger(value) {
116
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
117
+ }
118
+ function isNonnegativeSafeInteger(value) {
119
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
120
+ }
121
+ function hasExactKeys(value, expectedKeys) {
122
+ const keys = Object.keys(value);
123
+ return keys.length === expectedKeys.length && keys.every((key) => expectedKeys.includes(key));
124
+ }
125
+ function readRoute(value) {
126
+ if (!isRecord(value) || !isNonEmptyString(value.provider) || !isNonEmptyString(value.model))
127
+ return undefined;
128
+ return { provider: value.provider, model: value.model };
129
+ }
130
+ function sameRoute(left, right) {
131
+ return left.provider === right.provider && left.model === right.model;
132
+ }
133
+ function appendUniqueRoute(routes, route) {
134
+ if (!routes.some((candidate) => sameRoute(candidate, route)))
135
+ routes.push({ ...route });
136
+ }
137
+ function uniqueRoutes(routes) {
138
+ const unique = [];
139
+ for (const candidate of routes) {
140
+ const route = readRoute(candidate);
141
+ if (route !== undefined)
142
+ appendUniqueRoute(unique, route);
143
+ }
144
+ return unique;
145
+ }
146
+ function eventType(event) {
147
+ return isRecord(event) && typeof event.type === "string" ? event.type : undefined;
148
+ }
149
+ function eventData(event) {
150
+ return isRecord(event) ? event.data : undefined;
151
+ }
152
+ function readStepCoordinates(value) {
153
+ if (!isRecord(value) || !isPositiveSafeInteger(value.turn) || !isPositiveSafeInteger(value.step))
154
+ return undefined;
155
+ return { turn: value.turn, step: value.step };
156
+ }
157
+ function isTargetStepStart(event, turn, step) {
158
+ if (eventType(event) !== "step/start")
159
+ return false;
160
+ const coordinates = readStepCoordinates(eventData(event));
161
+ return coordinates?.turn === turn && coordinates.step === step;
162
+ }
163
+ function readHeaderRoute(event) {
164
+ if (eventType(event) !== "request/header")
165
+ return undefined;
166
+ const data = eventData(event);
167
+ if (!isRecord(data) || typeof data.reason !== "string" || !REQUEST_HEADER_REASONS.has(data.reason))
168
+ return undefined;
169
+ if (!isRecord(data.header) || !isRecord(data.header.config))
170
+ return undefined;
171
+ return readRoute(data.header.config);
172
+ }
173
+ function endsTargetScope(event) {
174
+ const type = eventType(event);
175
+ if (type === "step/start" || type === "step/end") {
176
+ const coordinates = readStepCoordinates(eventData(event));
177
+ if (coordinates === undefined)
178
+ return false;
179
+ return true;
180
+ }
181
+ if (type !== "turn/start" && type !== "turn/end")
182
+ return false;
183
+ const data = eventData(event);
184
+ return isRecord(data) && isPositiveSafeInteger(data.turn);
185
+ }
186
+ function isTurnStart(event) {
187
+ if (eventType(event) !== "turn/start")
188
+ return false;
189
+ const data = eventData(event);
190
+ return isRecord(data) && isPositiveSafeInteger(data.turn);
191
+ }
192
+ function readTodos(event) {
193
+ if (eventType(event) !== "todo/write")
194
+ return undefined;
195
+ const data = eventData(event);
196
+ if (!isRecord(data) || !Array.isArray(data.todos))
197
+ return undefined;
198
+ const todos = [];
199
+ for (const todo of data.todos) {
200
+ if (!isRecord(todo) || typeof todo.content !== "string" || typeof todo.status !== "string" || !TODO_STATUSES.has(todo.status))
201
+ return undefined;
202
+ todos.push({ status: todo.status });
203
+ }
204
+ return todos;
205
+ }
206
+ function readGoalActivity(event) {
207
+ if (eventType(event) !== "goal/change")
208
+ return undefined;
209
+ const data = eventData(event);
210
+ if (!isRecord(data) || data.kind !== "goal/change" || data.version !== 1)
211
+ return undefined;
212
+ if (data.operation === "clear") {
213
+ return hasExactKeys(data, CLEAR_EVENT_KEYS) && isValidGoalClear(data) ? false : undefined;
214
+ }
215
+ if (typeof data.operation !== "string" || !hasExactKeys(data, SNAPSHOT_EVENT_KEYS) || !GOAL_OPERATIONS.has(data.operation) || !isValidGoalSnapshot(data))
216
+ return undefined;
217
+ return data.goal.phase === "active";
218
+ }
219
+ function isValidGoalClear(data) {
220
+ return isRecord(data.cleared)
221
+ && hasExactKeys(data.cleared, CLEAR_REF_KEYS)
222
+ && typeof data.cleared.id === "string"
223
+ && data.cleared.id !== ""
224
+ && isPositiveSafeInteger(data.cleared.revision)
225
+ && isNonnegativeSafeInteger(data.clearedAt);
226
+ }
227
+ function isValidGoalSnapshot(data) {
228
+ if (!isRecord(data.goal) || typeof data.goal.phase !== "string" || !GOAL_PHASES.has(data.goal.phase))
229
+ return false;
230
+ const expectedGoalKeys = data.goal.phase === "blocked" ? BLOCKED_GOAL_KEYS : UNBLOCKED_GOAL_KEYS;
231
+ if (!hasExactKeys(data.goal, expectedGoalKeys) || typeof data.goal.id !== "string" || data.goal.id === "")
232
+ return false;
233
+ if (!isPositiveSafeInteger(data.goal.revision) || !isNormalizedNonEmptyString(data.goal.objective) || !isPositiveSafeInteger(data.goal.maxGoalRounds))
234
+ return false;
235
+ if (data.goal.phase === "blocked" && !isValidBlockedReason(data.goal.blockedReason))
236
+ return false;
237
+ const roundsStarted = data.roundsStarted;
238
+ const createdAt = data.createdAt;
239
+ const updatedAt = data.updatedAt;
240
+ return isNonnegativeSafeInteger(roundsStarted)
241
+ && isNonnegativeSafeInteger(createdAt)
242
+ && isNonnegativeSafeInteger(updatedAt)
243
+ && updatedAt >= createdAt;
244
+ }
245
+ function isValidBlockedReason(value) {
246
+ return isRecord(value)
247
+ && hasExactKeys(value, BLOCKED_REASON_KEYS)
248
+ && typeof value.code === "string"
249
+ && LOWER_KEBAB_CODE.test(value.code)
250
+ && isNormalizedNonEmptyString(value.message);
251
+ }
252
+ //# sourceMappingURL=recovery-policy.js.map
@@ -0,0 +1,6 @@
1
+ import type { DshContext } from "./dsh-types.js";
2
+ import type { DsmmSettings } from "./settings.js";
3
+ import type { DeepworkModeController } from "./state.js";
4
+ /** The DSH headless runner never mounts Agent presets; give it role-specific native tools. */
5
+ export declare function registerHeadlessRoleTools(ctx: DshContext, controller: DeepworkModeController, getSettings: () => DsmmSettings): void;
6
+ //# sourceMappingURL=role-subagents.d.ts.map
@@ -0,0 +1,54 @@
1
+ import * as nativeSubagentTool from "@deepseek-ai/dsh-tool-subagent";
2
+ import { DSMM_ROLES, roleSubagentConfig } from "./roles.js";
3
+ import { isDsmmRoleId } from "./roles.js";
4
+ import { resolveSelectedAgentPreset } from "./session-scope.js";
5
+ /** The DSH headless runner never mounts Agent presets; give it role-specific native tools. */
6
+ export function registerHeadlessRoleTools(ctx, controller, getSettings) {
7
+ const installed = new WeakSet();
8
+ const onCreated = async ({ agent }) => {
9
+ const profile = agent.ctx.get?.("profileContext")
10
+ ?? ctx.get?.("profileContext")
11
+ ?? ctx.profileContext;
12
+ if (!profile?.startedBundles.includes("@deepseek-ai/dsh-headless"))
13
+ return;
14
+ if (agent.session.header?.origin === "subagent")
15
+ return;
16
+ const agentCtx = agent.ctx;
17
+ if (installed.has(agentCtx))
18
+ return;
19
+ if (agentCtx.plugin === undefined || agentCtx.tools?.guard === undefined)
20
+ throw new Error("dsmm headless role tools require Agent-scoped Cordis plugin and tool guard services");
21
+ installed.add(agentCtx);
22
+ try {
23
+ const settings = getSettings();
24
+ const roles = DSMM_ROLES.filter((role) => role.id !== "dsmm-orchestrator" && settings.roles[role.id]);
25
+ const names = new Set(roles.map((role) => role.id.replace(/-/gu, "_")));
26
+ const guard = agentCtx.tools.guard((execution) => {
27
+ if (!names.has(execution.name))
28
+ return undefined;
29
+ const current = getSettings();
30
+ if (controller.active(execution.agent, current.defaultActive) || isDsmmRoleId(resolveSelectedAgentPreset(execution.agent?.session)))
31
+ return undefined;
32
+ return "dsmm role tools require an active deepwork session or DSMM-selected preset";
33
+ });
34
+ agentCtx.effect?.(() => guard);
35
+ const catalog = agentCtx.tools;
36
+ const availableTools = catalog.get?.("read_image") === undefined ? [] : ["read_image"];
37
+ for (const role of roles) {
38
+ // Agent creation is awaited before first prompt assembly. Mounting here
39
+ // sees the Agent-isolated systemPrompt/tools and avoids leaking tools to
40
+ // its sibling sessions or the read-only child being delegated.
41
+ await agentCtx.plugin(nativeSubagentTool, roleSubagentConfig(role, availableTools));
42
+ }
43
+ agentCtx.effect?.(() => () => installed.delete(agentCtx));
44
+ }
45
+ catch (error) {
46
+ installed.delete(agentCtx);
47
+ throw error;
48
+ }
49
+ };
50
+ // Agent-created is emitted in the new Agent scope; DSMM's bundle scope is
51
+ // a sibling, so a global listener is required to observe that publication.
52
+ ctx.on?.("agent/created", onCreated, { global: true });
53
+ }
54
+ //# sourceMappingURL=role-subagents.js.map
package/lib/roles.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import type { DsmmSkillName } from "./skills.js";
2
+ export declare const DSMM_ROLE_IDS: readonly ["dsmm-orchestrator", "dsmm-planner", "dsmm-plan-critic", "dsmm-builder", "dsmm-reviewer", "dsmm-oracle", "dsmm-oracle-2nd", "dsmm-creative", "dsmm-code-search", "dsmm-doc-search", "dsmm-clarifier", "dsmm-media-reader"];
3
+ export type DsmmRoleId = (typeof DSMM_ROLE_IDS)[number];
4
+ export interface DsmmRoleDefinition {
5
+ id: DsmmRoleId;
6
+ name: string;
7
+ description: string;
8
+ order: number;
9
+ enabledByDefault: boolean;
10
+ access?: "read-only" | "write";
11
+ persona: string;
12
+ }
13
+ export declare const DSMM_ROLES: readonly DsmmRoleDefinition[];
14
+ export declare function isDsmmRoleId(value: unknown): value is DsmmRoleId;
15
+ export declare function renderAgentCordis(role: DsmmRoleDefinition, skills?: readonly DsmmSkillName[], enabledRoles?: readonly DsmmRoleId[]): string;
16
+ export interface RolePluginRow {
17
+ id: string;
18
+ name: string;
19
+ config?: Record<string, unknown>;
20
+ disabled?: boolean;
21
+ }
22
+ /** The native PresetDefinition and the static YAML mirror use this same inventory. */
23
+ export declare function rolePluginRows(role: DsmmRoleDefinition, skills?: readonly DsmmSkillName[], enabledRoles?: readonly DsmmRoleId[]): RolePluginRow[];
24
+ /** DSH's spawn provider joins the parent's preset; persona/filter give each child its own role. */
25
+ export declare function roleSubagentPluginRows(enabledRoles?: readonly DsmmRoleId[]): RolePluginRow[];
26
+ export declare function roleSubagentConfig(role: DsmmRoleDefinition, availableTools?: readonly string[]): Record<string, unknown>;
27
+ export declare function renderPresetMetadata(role: DsmmRoleDefinition): string;
28
+ //# sourceMappingURL=roles.d.ts.map
package/lib/roles.js ADDED
@@ -0,0 +1,239 @@
1
+ import { DSMM_SKILL_NAMES } from "./skills.js";
2
+ export const DSMM_ROLE_IDS = [
3
+ "dsmm-orchestrator",
4
+ "dsmm-planner",
5
+ "dsmm-plan-critic",
6
+ "dsmm-builder",
7
+ "dsmm-reviewer",
8
+ "dsmm-oracle",
9
+ "dsmm-oracle-2nd",
10
+ "dsmm-creative",
11
+ "dsmm-code-search",
12
+ "dsmm-doc-search",
13
+ "dsmm-clarifier",
14
+ "dsmm-media-reader"
15
+ ];
16
+ export const DSMM_ROLES = [
17
+ {
18
+ id: "dsmm-orchestrator",
19
+ name: "DSMM Orchestrator",
20
+ description: "Coordinates deepwork sessions and routes work to focused dsmm role presets.",
21
+ order: 10,
22
+ enabledByDefault: true,
23
+ persona: `You are dsmm-orchestrator, a dsh-native coordinator for deepwork sessions.
24
+ For complex behavior implementation, default to planner → plan-critic → implementation; for simple bounded low-risk work, proceed directly. A clear implementation request authorizes its stated scope without repeated design approval.
25
+ Delegate bounded work only through callable role-specific DSH tools: dsmm-planner, dsmm-plan-critic, dsmm-builder, dsmm-reviewer, dsmm-oracle, dsmm-oracle-2nd, dsmm-creative, dsmm-code-search, dsmm-doc-search, dsmm-clarifier and dsmm-media-reader.
26
+ Reviewer is primary-lane self-review; use Oracle only for a useful external cross-check when a different model was explicitly selected. Review when risk warrants it, not in a fixed loop.
27
+ Keep scope explicit, preserve user constraints, and do not claim a preset is active unless the host selected it. Implementing does not authorize Git writes.`
28
+ },
29
+ {
30
+ id: "dsmm-planner",
31
+ name: "DSMM Planner",
32
+ description: "Turns approved scope into ordered implementation steps with verification gates.",
33
+ order: 20,
34
+ enabledByDefault: true,
35
+ access: "read-only",
36
+ persona: `You are dsmm-planner, a dsh-native planning specialist.
37
+ Inspect evidence and convert approved complex work into an outcome-oriented plan with dependencies, interfaces, risks and verification. Do not implement or modify files. Flag decisions that change scope, safety or public APIs. Git writes need specific authorization.`
38
+ },
39
+ {
40
+ id: "dsmm-plan-critic",
41
+ name: "DSMM Plan Critic",
42
+ description: "Checks implementation plans for ambiguity, missing evidence, and unsafe sequencing.",
43
+ order: 30,
44
+ enabledByDefault: true,
45
+ access: "read-only",
46
+ persona: `You are dsmm-plan-critic, a dsh-native plan review specialist.
47
+ Inspect the plan and evidence for material blockers in outcome coverage, dependencies, tests, safety and scope. Return concrete blockers or a concise pass with residual risks; do not require a fixed format or repeated reviews after editorial changes. Read only; do not implement or perform Git writes.`
48
+ },
49
+ {
50
+ id: "dsmm-builder",
51
+ name: "DSMM Builder",
52
+ description: "Implements one bounded approved outcome and verifies the changed surface.",
53
+ order: 35,
54
+ enabledByDefault: true,
55
+ access: "write",
56
+ persona: `You are dsmm-builder, a bounded implementation worker. Respect assigned file ownership and other workers' changes. Implement only the approved outcome, verify the affected surface, and report changes, evidence and risks. Escalate changes to public APIs, permissions, safety, data guarantees or irreversible behavior. Never stage, commit, push, tag, rebase or release without specific authorization.`
57
+ },
58
+ {
59
+ id: "dsmm-reviewer",
60
+ name: "DSMM Reviewer",
61
+ description: "Reviews completed changes against requirements, tests, and regression risk.",
62
+ order: 40,
63
+ enabledByDefault: true,
64
+ access: "read-only",
65
+ persona: `You are dsmm-reviewer, a dsh-native implementation reviewer.
66
+ Read the current implementation diff and new files against requirements, conventions and verification. Prioritize actionable correctness and regression findings. This is primary-model or primary-lane self-review, not external Oracle review. Do not modify files or perform Git writes.`
67
+ },
68
+ {
69
+ id: "dsmm-oracle",
70
+ name: "DSMM Oracle",
71
+ description: "First-priority external-model implementation cross-check when explicitly configured.",
72
+ order: 42,
73
+ enabledByDefault: true,
74
+ access: "read-only",
75
+ persona: `You are dsmm-oracle, first-priority implementation cross-check. Read only; inspect the current diff, evidence and requirements for concrete defects. Your role is externally heterogeneous only when the caller selects a different available model; do not claim model independence when inheriting the parent's route. Do not implement or perform Git writes.`
76
+ },
77
+ {
78
+ id: "dsmm-oracle-2nd",
79
+ name: "DSMM Oracle 2nd",
80
+ description: "Second-priority external-model implementation cross-check for an additional evidence need.",
81
+ order: 44,
82
+ enabledByDefault: true,
83
+ access: "read-only",
84
+ persona: `You are dsmm-oracle-2nd, second-priority implementation cross-check, not a higher-capability rank. Read only; report concrete defects in the current diff and evidence. An external model must be explicitly selected; the role label alone is no proof of independence. Do not implement or perform Git writes.`
85
+ },
86
+ {
87
+ id: "dsmm-creative",
88
+ name: "DSMM Creative",
89
+ description: "Explores unconventional but coherent approaches and explicit trade-offs.",
90
+ order: 46,
91
+ enabledByDefault: true,
92
+ access: "read-only",
93
+ persona: `You are dsmm-creative. Explore distinct coherent approaches, state trade-offs, constraints and a grounded recommendation. Remain read-only unless a separate implementation assignment authorizes changes. Do not perform Git writes.`
94
+ },
95
+ {
96
+ id: "dsmm-code-search",
97
+ name: "DSMM Code Search",
98
+ description: "Finds local codebase facts, symbols, patterns, and relevant implementation context.",
99
+ order: 50,
100
+ enabledByDefault: true,
101
+ access: "read-only",
102
+ persona: `You are dsmm-code-search, a dsh-native codebase research specialist.
103
+ Search local project context for exact files, symbols, references, and conventions needed by the caller.
104
+ Summarize findings with paths and evidence; do not modify files.`
105
+ },
106
+ {
107
+ id: "dsmm-doc-search",
108
+ name: "DSMM Doc Search",
109
+ description: "Finds current external documentation and examples for library or API questions.",
110
+ order: 60,
111
+ enabledByDefault: true,
112
+ access: "read-only",
113
+ persona: `You are dsmm-doc-search, a dsh-native documentation research specialist.
114
+ Find current documentation and real examples for libraries, APIs, CLIs, and services relevant to the task.
115
+ Cite source locations, separate facts from assumptions, and avoid guessing when documentation is unavailable.`
116
+ },
117
+ {
118
+ id: "dsmm-clarifier",
119
+ name: "DSMM Clarifier",
120
+ description: "Reduces ambiguous requests to the few decisions needed before planning or implementation.",
121
+ order: 70,
122
+ enabledByDefault: true,
123
+ access: "read-only",
124
+ persona: `You are dsmm-clarifier, a dsh-native requirements clarification specialist.
125
+ Identify ambiguity in purpose, constraints, success criteria, and scope boundaries.
126
+ Ask at most three material questions, prefer concrete choices, and propose safe defaults when evidence is strong.`
127
+ },
128
+ {
129
+ id: "dsmm-media-reader",
130
+ name: "DSMM Media Reader",
131
+ description: "Extracts implementation-relevant information from images, PDFs, and visual artifacts.",
132
+ order: 80,
133
+ enabledByDefault: true,
134
+ access: "read-only",
135
+ persona: `You are dsmm-media-reader, a dsh-native visual and document analysis specialist.
136
+ Extract text, structure, UI details, diagrams, and implementation-relevant facts from provided media.
137
+ Report uncertainty clearly and avoid inventing details that are not visible.`
138
+ }
139
+ ];
140
+ export function isDsmmRoleId(value) {
141
+ return typeof value === "string" && DSMM_ROLE_IDS.includes(value);
142
+ }
143
+ export function renderAgentCordis(role, skills = DSMM_SKILL_NAMES, enabledRoles = DSMM_ROLE_IDS) {
144
+ return rolePluginRows(role, skills, enabledRoles).map(renderPluginRow).join("");
145
+ }
146
+ /** The native PresetDefinition and the static YAML mirror use this same inventory. */
147
+ export function rolePluginRows(role, skills = DSMM_SKILL_NAMES, enabledRoles = DSMM_ROLE_IDS) {
148
+ const rows = [
149
+ { id: "persona", name: "@deepseek-ai/dsh-persona", config: { text: role.persona } },
150
+ { id: "agent-instructions", name: "@deepseek-ai/dsh-agent-instructions" },
151
+ { id: "tool-fs", name: "@deepseek-ai/dsh-tool-fs" },
152
+ { id: "tool-fs-search", name: "@deepseek-ai/dsh-tool-fs-search", config: { sampleOverCapGlobResults: false } },
153
+ { id: "tool-web", name: "@deepseek-ai/dsh-tool-web", config: { fetch: true } },
154
+ { id: "skill-filesystem", name: "@deepseek-ai/dsh-skill-filesystem" },
155
+ { id: "tool-skill", name: "@deepseek-ai/dsh-tool-skill" },
156
+ { id: "dsmm-preset-skills", name: "@dsmm/dsmm/preset-skills", config: { skills: DSMM_SKILL_NAMES.filter((name) => skills.includes(name)) } }
157
+ ];
158
+ if (role.access !== "read-only") {
159
+ rows.push({ id: "tool-bash", name: "@deepseek-ai/dsh-tool-bash", disabled: process.platform === "win32" });
160
+ rows.push({ id: "tool-pwsh", name: "@deepseek-ai/dsh-tool-pwsh", disabled: process.platform !== "win32" });
161
+ rows.push({ id: "tool-jobs", name: "@deepseek-ai/dsh-tool-jobs" });
162
+ }
163
+ if (role.id === "dsmm-orchestrator" || role.id === "dsmm-builder")
164
+ rows.push(...roleSubagentPluginRows(enabledRoles));
165
+ return rows;
166
+ }
167
+ /** DSH's spawn provider joins the parent's preset; persona/filter give each child its own role. */
168
+ export function roleSubagentPluginRows(enabledRoles = DSMM_ROLE_IDS) {
169
+ return DSMM_ROLES.filter((role) => role.id !== "dsmm-orchestrator" && enabledRoles.includes(role.id)).map((role) => ({
170
+ id: `subagent-${role.id}`,
171
+ name: "@deepseek-ai/dsh-tool-subagent",
172
+ config: roleSubagentConfig(role)
173
+ }));
174
+ }
175
+ export function roleSubagentConfig(role, availableTools = []) {
176
+ const readOnlyTools = ["read", "glob", "grep"];
177
+ if (role.id === "dsmm-doc-search" || role.id === "dsmm-media-reader") {
178
+ readOnlyTools.push("web_search", "web_fetch");
179
+ }
180
+ // read_image is conditional on the DSH attachment store; an unknown name
181
+ // would make DSH's native toolFilter reject the child at startup.
182
+ if (role.id === "dsmm-media-reader" && availableTools.includes("read_image"))
183
+ readOnlyTools.push("read_image");
184
+ return {
185
+ provider: "spawn",
186
+ toolName: role.id.replace(/-/gu, "_"),
187
+ // A standing preset with modelSelectionSettings=true re-registers tools in
188
+ // each child Agent's own scope. DSH restrictions filter inherited tools,
189
+ // not same-scope registrations, so that would bypass readonly filters.
190
+ modelSelectionSettings: false,
191
+ backgroundMode: "one-shot",
192
+ enableRunInBackground: false,
193
+ persona: role.persona,
194
+ ...(role.access === "read-only" ? { toolFilter: { allow: readOnlyTools } } : {})
195
+ };
196
+ }
197
+ export function renderPresetMetadata(role) {
198
+ return `id: ${role.id}
199
+ name: ${quoteYamlString(role.name)}
200
+ description: ${quoteYamlString(role.description)}
201
+ `;
202
+ }
203
+ function indentBlock(value, spaces) {
204
+ const prefix = " ".repeat(spaces);
205
+ return value.split(/\r?\n/u).map((line) => `${prefix}${line}`).join("\n");
206
+ }
207
+ function renderPluginRow(row) {
208
+ let output = `- id: ${row.id}\n name: ${quoteYamlString(row.name)}\n`;
209
+ if (row.disabled !== undefined) {
210
+ output += ` disabled: !!js process.platform ${row.id === "tool-bash" ? "===" : "!=="} 'win32'\n`;
211
+ }
212
+ if (row.config === undefined)
213
+ return output;
214
+ output += " config:\n";
215
+ for (const [key, value] of Object.entries(row.config)) {
216
+ if (typeof value === "string" && value.includes("\n"))
217
+ output += ` ${key}: |-\n${indentBlock(value, 6)}\n`;
218
+ else if (typeof value === "string")
219
+ output += ` ${key}: ${quoteYamlString(value)}\n`;
220
+ else if (Array.isArray(value))
221
+ output += value.length === 0 ? ` ${key}: []\n` : ` ${key}:\n${value.map((item) => ` - ${quoteYamlString(String(item))}\n`).join("")}`;
222
+ else if (typeof value === "object" && value !== null) {
223
+ output += ` ${key}:\n`;
224
+ for (const [nestedKey, nestedValue] of Object.entries(value)) {
225
+ if (Array.isArray(nestedValue))
226
+ output += nestedValue.length === 0 ? ` ${nestedKey}: []\n` : ` ${nestedKey}:\n${nestedValue.map((item) => ` - ${quoteYamlString(String(item))}\n`).join("")}`;
227
+ else
228
+ output += ` ${nestedKey}: ${String(nestedValue)}\n`;
229
+ }
230
+ }
231
+ else
232
+ output += ` ${key}: ${String(value)}\n`;
233
+ }
234
+ return output;
235
+ }
236
+ function quoteYamlString(value) {
237
+ return `'${value.replace(/'/gu, "''")}'`;
238
+ }
239
+ //# sourceMappingURL=roles.js.map
@@ -0,0 +1,5 @@
1
+ import type { DshContext } from "./dsh-types.js";
2
+ import type { DsmmSettings } from "./settings.js";
3
+ import type { DeepworkModeController } from "./state.js";
4
+ export declare function registerRuntimeRecovery(ctx: DshContext, controller: DeepworkModeController, getSettings: () => DsmmSettings): void;
5
+ //# sourceMappingURL=runtime-recovery.d.ts.map