@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.
- package/LICENSE +103 -0
- package/README.md +70 -2
- package/agent-presets/dsmm-builder/agent.cordis.yml +210 -0
- package/agent-presets/dsmm-builder/preset.yml +3 -0
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +34 -0
- package/agent-presets/dsmm-clarifier/preset.yml +3 -0
- package/agent-presets/dsmm-code-search/agent.cordis.yml +34 -0
- package/agent-presets/dsmm-code-search/preset.yml +3 -0
- package/agent-presets/dsmm-creative/agent.cordis.yml +31 -0
- package/agent-presets/dsmm-creative/preset.yml +3 -0
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +34 -0
- package/agent-presets/dsmm-doc-search/preset.yml +3 -0
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +34 -0
- package/agent-presets/dsmm-media-reader/preset.yml +3 -0
- package/agent-presets/dsmm-oracle/agent.cordis.yml +31 -0
- package/agent-presets/dsmm-oracle/preset.yml +3 -0
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +31 -0
- package/agent-presets/dsmm-oracle-2nd/preset.yml +3 -0
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +215 -0
- package/agent-presets/dsmm-orchestrator/preset.yml +3 -0
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +33 -0
- package/agent-presets/dsmm-plan-critic/preset.yml +3 -0
- package/agent-presets/dsmm-planner/agent.cordis.yml +33 -0
- package/agent-presets/dsmm-planner/preset.yml +3 -0
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +33 -0
- package/agent-presets/dsmm-reviewer/preset.yml +3 -0
- package/cordis.patch.yml +8 -0
- package/docs/agent-presets.md +19 -0
- package/docs/compatibility.md +49 -0
- package/docs/design.md +237 -0
- package/docs/lsp.md +40 -0
- package/docs/migration-from-ocmm.md +54 -0
- package/docs/model-routing.md +61 -0
- package/docs/releasing.md +52 -0
- package/docs/research/deepseek-v4-pro.md +74 -0
- package/docs/research/oh-dsh.md +96 -0
- package/docs/roadmap.md +207 -0
- package/docs/runtime-recovery.md +75 -0
- package/docs/safety-guards.md +55 -0
- package/docs/settings-status.md +55 -0
- package/docs/skill-sync.md +20 -0
- package/lib/commands.d.ts +13 -0
- package/lib/commands.js +55 -0
- package/lib/dsh-events.d.ts +21 -0
- package/lib/dsh-events.js +2 -0
- package/lib/dsh-types.d.ts +312 -0
- package/lib/dsh-types.js +2 -0
- package/lib/guards.d.ts +10 -0
- package/lib/guards.js +252 -0
- package/lib/index.d.ts +33 -0
- package/lib/index.js +58 -0
- package/lib/lsp.d.ts +30 -0
- package/lib/lsp.js +154 -0
- package/lib/mode.d.ts +6 -0
- package/lib/mode.js +62 -0
- package/lib/model-family.d.ts +6 -0
- package/lib/model-family.js +49 -0
- package/lib/model-routing.d.ts +11 -0
- package/lib/model-routing.js +128 -0
- package/lib/plan-validation.d.ts +3 -0
- package/lib/plan-validation.js +119 -0
- package/lib/preset-materializer.d.ts +36 -0
- package/lib/preset-materializer.js +258 -0
- package/lib/preset-registry.d.ts +5 -0
- package/lib/preset-registry.js +126 -0
- package/lib/preset-skills.d.ts +12 -0
- package/lib/preset-skills.js +28 -0
- package/lib/prompts.d.ts +13 -0
- package/lib/prompts.js +82 -0
- package/lib/recovery-policy.d.ts +25 -0
- package/lib/recovery-policy.js +252 -0
- package/lib/role-providers.d.ts +13 -0
- package/lib/role-providers.js +61 -0
- package/lib/role-routing.d.ts +15 -0
- package/lib/role-routing.js +144 -0
- package/lib/role-subagents.d.ts +6 -0
- package/lib/role-subagents.js +54 -0
- package/lib/roles.d.ts +29 -0
- package/lib/roles.js +241 -0
- package/lib/runtime-recovery.d.ts +5 -0
- package/lib/runtime-recovery.js +168 -0
- package/lib/session-scope.d.ts +9 -0
- package/lib/session-scope.js +40 -0
- package/lib/settings.d.ts +123 -0
- package/lib/settings.js +447 -0
- package/lib/shell-command.d.ts +18 -0
- package/lib/shell-command.js +492 -0
- package/lib/skills.d.ts +18 -0
- package/lib/skills.js +64 -0
- package/lib/state.d.ts +13 -0
- package/lib/state.js +64 -0
- package/lib/status.d.ts +55 -0
- package/lib/status.js +193 -0
- package/package.json +129 -4
- package/patches/agent-presets-root.example.cordis.patch.yml +14 -0
- package/patches/ocmm-lsp-mcp.example.cordis.patch.yml +15 -0
- package/prompts/deepseek-flash.md +11 -0
- package/prompts/deepseek-v4-pro.md +14 -0
- package/prompts/deepwork.md +32 -0
- package/skills/brainstorming/SKILL.md +15 -0
- package/skills/debugging/SKILL.md +12 -0
- package/skills/debugging/references/logging.md +91 -0
- package/skills/debugging/references/methodology/00-setup.md +108 -0
- package/skills/debugging/references/methodology/02-investigate.md +67 -0
- package/skills/debugging/references/methodology/03-flaky-triage.md +69 -0
- package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +83 -0
- package/skills/debugging/references/methodology/05-escalate.md +69 -0
- package/skills/debugging/references/methodology/06-fix.md +123 -0
- package/skills/debugging/references/methodology/08-qa.md +94 -0
- package/skills/debugging/references/methodology/09-cleanup.md +164 -0
- package/skills/debugging/references/methodology/partial-runtime-evidence.md +217 -0
- package/skills/debugging/references/runtimes/bundled-js-binary.md +415 -0
- package/skills/debugging/references/runtimes/go.md +252 -0
- package/skills/debugging/references/runtimes/native-binary.md +484 -0
- package/skills/debugging/references/runtimes/node.md +260 -0
- package/skills/debugging/references/runtimes/python.md +248 -0
- package/skills/debugging/references/runtimes/rust.md +234 -0
- package/skills/debugging/references/scripts/dap.mjs +533 -0
- package/skills/debugging/references/tools/dap.md +89 -0
- package/skills/debugging/references/tools/ghidra.md +212 -0
- package/skills/debugging/references/tools/playwright-cli.md +316 -0
- package/skills/debugging/references/tools/pwndbg.md +263 -0
- package/skills/debugging/references/tools/pwntools.md +265 -0
- package/skills/dispatching-parallel-agents/SKILL.md +14 -0
- package/skills/receiving-code-review/SKILL.md +13 -0
- package/skills/remove-ai-slops/SKILL.md +14 -0
- package/skills/requesting-code-review/SKILL.md +10 -0
- package/skills/subagent-driven-development/SKILL.md +13 -0
- package/skills/writing-plans/SKILL.md +14 -0
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
const GIT_WRITE_COMMANDS = new Set([
|
|
2
|
+
"add",
|
|
3
|
+
"am",
|
|
4
|
+
"apply",
|
|
5
|
+
"branch",
|
|
6
|
+
"checkout",
|
|
7
|
+
"cherry-pick",
|
|
8
|
+
"clean",
|
|
9
|
+
"clone",
|
|
10
|
+
"commit",
|
|
11
|
+
"fetch",
|
|
12
|
+
"init",
|
|
13
|
+
"merge",
|
|
14
|
+
"mv",
|
|
15
|
+
"pull",
|
|
16
|
+
"push",
|
|
17
|
+
"rebase",
|
|
18
|
+
"remote",
|
|
19
|
+
"reset",
|
|
20
|
+
"restore",
|
|
21
|
+
"revert",
|
|
22
|
+
"rm",
|
|
23
|
+
"stash",
|
|
24
|
+
"submodule",
|
|
25
|
+
"switch",
|
|
26
|
+
"tag",
|
|
27
|
+
"worktree"
|
|
28
|
+
]);
|
|
29
|
+
const GIT_GLOBAL_OPTIONS_WITH_VALUE = new Set([
|
|
30
|
+
"-C",
|
|
31
|
+
"-c",
|
|
32
|
+
"--config-env",
|
|
33
|
+
"--exec-path",
|
|
34
|
+
"--git-dir",
|
|
35
|
+
"--namespace",
|
|
36
|
+
"--super-prefix",
|
|
37
|
+
"--work-tree"
|
|
38
|
+
]);
|
|
39
|
+
const CONFIG_WRITE_OPTIONS = new Set([
|
|
40
|
+
"--add",
|
|
41
|
+
"--replace-all",
|
|
42
|
+
"--unset",
|
|
43
|
+
"--unset-all",
|
|
44
|
+
"--rename-section",
|
|
45
|
+
"--remove-section",
|
|
46
|
+
"--edit"
|
|
47
|
+
]);
|
|
48
|
+
const CONFIG_QUERY_OPTIONS = new Set([
|
|
49
|
+
"--get",
|
|
50
|
+
"--get-all",
|
|
51
|
+
"--get-regexp",
|
|
52
|
+
"--get-urlmatch",
|
|
53
|
+
"--list",
|
|
54
|
+
"-l",
|
|
55
|
+
"--show-origin",
|
|
56
|
+
"--show-scope",
|
|
57
|
+
"--name-only"
|
|
58
|
+
]);
|
|
59
|
+
const CONFIG_OPTIONS_WITH_VALUE = new Set(["--file", "-f", "--blob", "--type", "--default", "--comment"]);
|
|
60
|
+
const ENV_OPTIONS_WITH_VALUE = new Set(["-u", "--unset", "-C", "--chdir", "-a", "--argv0", "-f", "--file", "-S", "--split-string"]);
|
|
61
|
+
const ENV_SHORT_OPTIONS_WITH_ATTACHED_VALUE = new Set(["-C", "-u", "-a", "-f", "-S"]);
|
|
62
|
+
const ENV_LONG_OPTIONS_WITH_ATTACHED_VALUE = new Set(["--unset", "--chdir", "--argv0", "--file", "--split-string", "--default-signal", "--ignore-signal", "--block-signal"]);
|
|
63
|
+
const ENV_OPTIONS_WITHOUT_VALUE = new Set(["-i", "--ignore-environment", "-v", "--debug", "--default-signal", "--ignore-signal", "--block-signal", "--list-signal-handling"]);
|
|
64
|
+
const ENV_SHORT_FLAGS_WITHOUT_VALUE = new Set(["i", "v"]);
|
|
65
|
+
function lower(value) {
|
|
66
|
+
return value.toLowerCase();
|
|
67
|
+
}
|
|
68
|
+
function matching(value, expected, dialect) {
|
|
69
|
+
return dialect === "powershell" ? lower(value) === lower(expected) : value === expected;
|
|
70
|
+
}
|
|
71
|
+
function executableBasename(value) {
|
|
72
|
+
return value.replace(/^.*[\\/]/u, "");
|
|
73
|
+
}
|
|
74
|
+
function isNamedExecutable(value, expected, dialect) {
|
|
75
|
+
const basename = executableBasename(value);
|
|
76
|
+
return matching(basename, expected, dialect) || matching(basename, `${expected}.exe`, dialect);
|
|
77
|
+
}
|
|
78
|
+
function isPosixAssignment(value) {
|
|
79
|
+
return /^[A-Za-z_][A-Za-z0-9_]*=/u.test(value);
|
|
80
|
+
}
|
|
81
|
+
function isEnvAssignment(value, afterOptions) {
|
|
82
|
+
return value.includes("=") && (afterOptions || !value.startsWith("-"));
|
|
83
|
+
}
|
|
84
|
+
function isEnvShortOptionWithAttachedValue(value) {
|
|
85
|
+
return [...ENV_SHORT_OPTIONS_WITH_ATTACHED_VALUE].some((option) => value.startsWith(option) && value.length > option.length);
|
|
86
|
+
}
|
|
87
|
+
function envShortCluster(words, index) {
|
|
88
|
+
const option = words[index] ?? "";
|
|
89
|
+
if (!option.startsWith("-") || option.startsWith("--"))
|
|
90
|
+
return undefined;
|
|
91
|
+
let character = 1;
|
|
92
|
+
while (ENV_SHORT_FLAGS_WITHOUT_VALUE.has(option[character] ?? ""))
|
|
93
|
+
character += 1;
|
|
94
|
+
if (character === 1)
|
|
95
|
+
return undefined;
|
|
96
|
+
if (character === option.length)
|
|
97
|
+
return { nextIndex: index + 1 };
|
|
98
|
+
const valueOption = `-${option[character] ?? ""}`;
|
|
99
|
+
if (!ENV_SHORT_OPTIONS_WITH_ATTACHED_VALUE.has(valueOption))
|
|
100
|
+
return undefined;
|
|
101
|
+
if (character + 1 < option.length)
|
|
102
|
+
return { nextIndex: index + 1, splitString: valueOption === "-S" ? option.slice(character + 1) : undefined };
|
|
103
|
+
const value = words[index + 1];
|
|
104
|
+
if (value === undefined)
|
|
105
|
+
return undefined;
|
|
106
|
+
return { nextIndex: index + 2, splitString: valueOption === "-S" ? value : undefined };
|
|
107
|
+
}
|
|
108
|
+
function isPowerShellAssignmentStatement(words) {
|
|
109
|
+
return words.length >= 3 && /^\$[A-Za-z_][A-Za-z0-9_:]*$/u.test(words[0] ?? "") && words[1] === "=";
|
|
110
|
+
}
|
|
111
|
+
function unquotedWord(tokens) {
|
|
112
|
+
return tokens.find((token) => token.kind === "word" && !token.quoted);
|
|
113
|
+
}
|
|
114
|
+
function isRedirectionOperator(value) {
|
|
115
|
+
return value.includes(">");
|
|
116
|
+
}
|
|
117
|
+
export function parseShellCommand(input, dialect) {
|
|
118
|
+
const segments = [];
|
|
119
|
+
let tokens = [];
|
|
120
|
+
let words = [];
|
|
121
|
+
let word = "";
|
|
122
|
+
let quoted = false;
|
|
123
|
+
let wordStarted = false;
|
|
124
|
+
let state = "unquoted";
|
|
125
|
+
const escape = dialect === "posix" ? "\\" : "`";
|
|
126
|
+
const finishWord = () => {
|
|
127
|
+
if (!wordStarted)
|
|
128
|
+
return;
|
|
129
|
+
tokens.push({ kind: "word", value: word, quoted });
|
|
130
|
+
words.push(word);
|
|
131
|
+
word = "";
|
|
132
|
+
quoted = false;
|
|
133
|
+
wordStarted = false;
|
|
134
|
+
};
|
|
135
|
+
const appendWord = (value) => {
|
|
136
|
+
word += value;
|
|
137
|
+
wordStarted = true;
|
|
138
|
+
};
|
|
139
|
+
const appendOperator = (value) => {
|
|
140
|
+
finishWord();
|
|
141
|
+
tokens.push({ kind: "operator", value });
|
|
142
|
+
};
|
|
143
|
+
const finishSegment = () => {
|
|
144
|
+
finishWord();
|
|
145
|
+
if (tokens.length === 0)
|
|
146
|
+
return;
|
|
147
|
+
segments.push({ tokens, words });
|
|
148
|
+
tokens = [];
|
|
149
|
+
words = [];
|
|
150
|
+
};
|
|
151
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
152
|
+
const char = input[index] ?? "";
|
|
153
|
+
if (char === escape && state !== "single-quoted") {
|
|
154
|
+
const next = input[index + 1];
|
|
155
|
+
if (next === "\r" && input[index + 2] === "\n") {
|
|
156
|
+
index += 2;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (next === "\n") {
|
|
160
|
+
index += 1;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (next !== undefined) {
|
|
164
|
+
appendWord(next);
|
|
165
|
+
index += 1;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
appendWord(char);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (state === "single-quoted") {
|
|
172
|
+
if (char === "'")
|
|
173
|
+
state = "unquoted";
|
|
174
|
+
else
|
|
175
|
+
appendWord(char);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (state === "double-quoted") {
|
|
179
|
+
if (char === '"')
|
|
180
|
+
state = "unquoted";
|
|
181
|
+
else
|
|
182
|
+
appendWord(char);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (char === "'") {
|
|
186
|
+
state = "single-quoted";
|
|
187
|
+
quoted = true;
|
|
188
|
+
wordStarted = true;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (char === '"') {
|
|
192
|
+
state = "double-quoted";
|
|
193
|
+
quoted = true;
|
|
194
|
+
wordStarted = true;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (char === "\r" || char === "\n") {
|
|
198
|
+
if (char === "\r" && input[index + 1] === "\n")
|
|
199
|
+
index += 1;
|
|
200
|
+
finishSegment();
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (char === ";") {
|
|
204
|
+
finishSegment();
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
if (char === "&" && input[index + 1] === ">") {
|
|
208
|
+
let operator = "&>";
|
|
209
|
+
index += 1;
|
|
210
|
+
if (input[index + 1] === ">") {
|
|
211
|
+
operator = "&>>";
|
|
212
|
+
index += 1;
|
|
213
|
+
}
|
|
214
|
+
appendOperator(operator);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (char === "&") {
|
|
218
|
+
if (input[index + 1] === "&") {
|
|
219
|
+
index += 1;
|
|
220
|
+
finishSegment();
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (dialect === "powershell" && tokens.length === 0 && !wordStarted)
|
|
224
|
+
appendOperator(char);
|
|
225
|
+
else
|
|
226
|
+
finishSegment();
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (char === "|") {
|
|
230
|
+
if (input[index + 1] === "|")
|
|
231
|
+
index += 1;
|
|
232
|
+
finishSegment();
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
if (char === ">" || char === "<") {
|
|
236
|
+
let operator = char;
|
|
237
|
+
if (input[index + 1] === char) {
|
|
238
|
+
operator += char;
|
|
239
|
+
index += 1;
|
|
240
|
+
}
|
|
241
|
+
if (input[index + 1] === "&") {
|
|
242
|
+
operator += "&";
|
|
243
|
+
index += 1;
|
|
244
|
+
}
|
|
245
|
+
appendOperator(operator);
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
if (/\s/u.test(char)) {
|
|
249
|
+
finishWord();
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
appendWord(char);
|
|
253
|
+
}
|
|
254
|
+
finishSegment();
|
|
255
|
+
return segments;
|
|
256
|
+
}
|
|
257
|
+
function commandStart(words, dialect) {
|
|
258
|
+
if (dialect === "powershell" && isPowerShellAssignmentStatement(words))
|
|
259
|
+
return undefined;
|
|
260
|
+
let index = 0;
|
|
261
|
+
while (dialect === "posix" && isPosixAssignment(words[index] ?? ""))
|
|
262
|
+
index += 1;
|
|
263
|
+
return index < words.length ? index : undefined;
|
|
264
|
+
}
|
|
265
|
+
function envCommandWords(words, start, consumeBare) {
|
|
266
|
+
let index = start;
|
|
267
|
+
if (consumeBare && words[index] === "-")
|
|
268
|
+
index += 1;
|
|
269
|
+
while (isEnvAssignment(words[index] ?? "", true))
|
|
270
|
+
index += 1;
|
|
271
|
+
return index < words.length ? words.slice(index) : undefined;
|
|
272
|
+
}
|
|
273
|
+
function splitEnvCommand(value, trailing) {
|
|
274
|
+
const segments = parseShellCommand(value, "posix");
|
|
275
|
+
if (segments.length !== 1)
|
|
276
|
+
return undefined;
|
|
277
|
+
const segment = segments[0];
|
|
278
|
+
if (segment === undefined || segment.tokens.some((token) => token.kind !== "word") || segment.words.length === 0)
|
|
279
|
+
return undefined;
|
|
280
|
+
return [...segment.words, ...trailing];
|
|
281
|
+
}
|
|
282
|
+
function skipEnv(words, start) {
|
|
283
|
+
let index = start + 1;
|
|
284
|
+
while (index < words.length) {
|
|
285
|
+
const option = words[index] ?? "";
|
|
286
|
+
if (option === "--")
|
|
287
|
+
return envCommandWords(words, index + 1, true);
|
|
288
|
+
if (option === "-")
|
|
289
|
+
return envCommandWords(words, index + 1, false);
|
|
290
|
+
if (ENV_OPTIONS_WITHOUT_VALUE.has(option)) {
|
|
291
|
+
index += 1;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (option === "-S" || option === "--split-string") {
|
|
295
|
+
const value = words[index + 1];
|
|
296
|
+
return value === undefined ? undefined : splitEnvCommand(value, words.slice(index + 2));
|
|
297
|
+
}
|
|
298
|
+
if (option.startsWith("--split-string="))
|
|
299
|
+
return splitEnvCommand(option.slice("--split-string=".length), words.slice(index + 1));
|
|
300
|
+
if (ENV_OPTIONS_WITH_VALUE.has(option)) {
|
|
301
|
+
if (index + 1 >= words.length)
|
|
302
|
+
return undefined;
|
|
303
|
+
index += 2;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
const cluster = envShortCluster(words, index);
|
|
307
|
+
if (cluster !== undefined) {
|
|
308
|
+
if (cluster.splitString !== undefined)
|
|
309
|
+
return splitEnvCommand(cluster.splitString, words.slice(cluster.nextIndex));
|
|
310
|
+
index = cluster.nextIndex;
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
if (option.startsWith("-S") && option.length > 2)
|
|
314
|
+
return splitEnvCommand(option.slice(2), words.slice(index + 1));
|
|
315
|
+
if (isEnvShortOptionWithAttachedValue(option)) {
|
|
316
|
+
index += 1;
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
if ([...ENV_LONG_OPTIONS_WITH_ATTACHED_VALUE].some((name) => option.startsWith(`${name}=`))) {
|
|
320
|
+
index += 1;
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
if (isEnvAssignment(option, false)) {
|
|
324
|
+
index += 1;
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
return words.slice(index);
|
|
328
|
+
}
|
|
329
|
+
return undefined;
|
|
330
|
+
}
|
|
331
|
+
function gitSubcommand(words, start) {
|
|
332
|
+
let index = start + 1;
|
|
333
|
+
while (index < words.length) {
|
|
334
|
+
const option = words[index] ?? "";
|
|
335
|
+
if (option === "--") {
|
|
336
|
+
index += 1;
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (GIT_GLOBAL_OPTIONS_WITH_VALUE.has(option)) {
|
|
340
|
+
if (index + 1 >= words.length)
|
|
341
|
+
return undefined;
|
|
342
|
+
index += 2;
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
if (/^-[Cc].+/u.test(option) || [...GIT_GLOBAL_OPTIONS_WITH_VALUE].some((name) => option.startsWith(`${name}=`))) {
|
|
346
|
+
index += 1;
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
if (option.startsWith("-")) {
|
|
350
|
+
index += 1;
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
return { name: lower(option), args: words.slice(index + 1) };
|
|
354
|
+
}
|
|
355
|
+
return undefined;
|
|
356
|
+
}
|
|
357
|
+
function configWrites(args) {
|
|
358
|
+
const options = args.map(lower);
|
|
359
|
+
if (options.some((option) => CONFIG_WRITE_OPTIONS.has(option) || [...CONFIG_WRITE_OPTIONS].some((name) => option.startsWith(`${name}=`))))
|
|
360
|
+
return true;
|
|
361
|
+
if (options.some((option) => CONFIG_QUERY_OPTIONS.has(option)))
|
|
362
|
+
return false;
|
|
363
|
+
const positional = [];
|
|
364
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
365
|
+
const argument = args[index] ?? "";
|
|
366
|
+
const option = lower(argument);
|
|
367
|
+
if (argument === "--") {
|
|
368
|
+
positional.push(...args.slice(index + 1));
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
if (CONFIG_OPTIONS_WITH_VALUE.has(option)) {
|
|
372
|
+
index += 1;
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
if ([...CONFIG_OPTIONS_WITH_VALUE].some((name) => option.startsWith(`${name}=`)))
|
|
376
|
+
continue;
|
|
377
|
+
if (argument.startsWith("-"))
|
|
378
|
+
continue;
|
|
379
|
+
positional.push(argument);
|
|
380
|
+
}
|
|
381
|
+
return positional.length >= 2;
|
|
382
|
+
}
|
|
383
|
+
function firstAction(args, optionsWithValue) {
|
|
384
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
385
|
+
const argument = args[index] ?? "";
|
|
386
|
+
if (argument === "--")
|
|
387
|
+
return args[index + 1];
|
|
388
|
+
if (optionsWithValue.includes(lower(argument))) {
|
|
389
|
+
index += 1;
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
if (argument.startsWith("-"))
|
|
393
|
+
continue;
|
|
394
|
+
return argument;
|
|
395
|
+
}
|
|
396
|
+
return undefined;
|
|
397
|
+
}
|
|
398
|
+
function replaceWrites(args) {
|
|
399
|
+
const options = args.map(lower);
|
|
400
|
+
if (options.some((option) => option === "-d" || option === "--delete" || option === "-e" || option === "--edit" || option === "-g" || option === "--graft"))
|
|
401
|
+
return true;
|
|
402
|
+
if (options.some((option) => option === "-l" || option === "--list"))
|
|
403
|
+
return false;
|
|
404
|
+
return args.filter((argument) => !argument.startsWith("-")).length >= 2;
|
|
405
|
+
}
|
|
406
|
+
function symbolicRefWrites(args) {
|
|
407
|
+
const options = args.map(lower);
|
|
408
|
+
if (options.some((option) => option === "-d" || option === "--delete"))
|
|
409
|
+
return true;
|
|
410
|
+
return args.filter((argument) => !argument.startsWith("-")).length >= 2;
|
|
411
|
+
}
|
|
412
|
+
export function classifyKnownGitWrite(input, dialect) {
|
|
413
|
+
for (const segment of parseShellCommand(input, dialect)) {
|
|
414
|
+
const start = commandStart(segment.words, dialect);
|
|
415
|
+
if (start === undefined)
|
|
416
|
+
continue;
|
|
417
|
+
let commandWords = segment.words.slice(start);
|
|
418
|
+
let executable = commandWords[0] ?? "";
|
|
419
|
+
while (isNamedExecutable(executable, "env", dialect)) {
|
|
420
|
+
const unwrapped = skipEnv(commandWords, 0);
|
|
421
|
+
if (unwrapped === undefined) {
|
|
422
|
+
executable = "";
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
commandWords = unwrapped;
|
|
426
|
+
executable = commandWords[0] ?? "";
|
|
427
|
+
}
|
|
428
|
+
if (!isNamedExecutable(executable, "git", dialect))
|
|
429
|
+
continue;
|
|
430
|
+
const subcommand = gitSubcommand(commandWords, 0);
|
|
431
|
+
if (subcommand === undefined)
|
|
432
|
+
continue;
|
|
433
|
+
if (subcommand.name === "config") {
|
|
434
|
+
if (configWrites(subcommand.args))
|
|
435
|
+
return "config";
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
if (subcommand.name === "notes") {
|
|
439
|
+
const action = lower(firstAction(subcommand.args, ["--ref", "-r"]) ?? "");
|
|
440
|
+
if (["add", "append", "copy", "edit", "merge", "prune", "remove"].includes(action))
|
|
441
|
+
return `notes ${action}`;
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (subcommand.name === "replace") {
|
|
445
|
+
if (replaceWrites(subcommand.args))
|
|
446
|
+
return "replace";
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
if (subcommand.name === "update-ref")
|
|
450
|
+
return "update-ref";
|
|
451
|
+
if (subcommand.name === "symbolic-ref") {
|
|
452
|
+
if (symbolicRefWrites(subcommand.args))
|
|
453
|
+
return "symbolic-ref";
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
if (subcommand.name === "reset" && subcommand.args.some((argument) => lower(argument) === "--hard"))
|
|
457
|
+
return "reset --hard";
|
|
458
|
+
if (subcommand.name === "stash") {
|
|
459
|
+
const action = lower(subcommand.args[0] ?? "");
|
|
460
|
+
if (action === "pop" || action === "drop" || action === "clear")
|
|
461
|
+
return `stash ${action}`;
|
|
462
|
+
}
|
|
463
|
+
if (GIT_WRITE_COMMANDS.has(subcommand.name))
|
|
464
|
+
return subcommand.name;
|
|
465
|
+
}
|
|
466
|
+
return undefined;
|
|
467
|
+
}
|
|
468
|
+
export function classifyShellDialectViolation(input, dialect) {
|
|
469
|
+
for (const segment of parseShellCommand(input, dialect)) {
|
|
470
|
+
const command = unquotedWord(segment.tokens);
|
|
471
|
+
if (dialect === "powershell" && command !== undefined) {
|
|
472
|
+
const name = lower(command.value);
|
|
473
|
+
if (name === "export")
|
|
474
|
+
return "powershell-export";
|
|
475
|
+
if (name === "source")
|
|
476
|
+
return "powershell-source";
|
|
477
|
+
}
|
|
478
|
+
if (dialect === "powershell") {
|
|
479
|
+
for (let index = 0; index < segment.tokens.length - 1; index += 1) {
|
|
480
|
+
const token = segment.tokens[index];
|
|
481
|
+
const operand = segment.tokens[index + 1];
|
|
482
|
+
if (token?.kind === "operator" && isRedirectionOperator(token.value) && operand?.kind === "word" && !operand.quoted && operand.value === "/dev/null") {
|
|
483
|
+
return "powershell-dev-null";
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
if (dialect === "posix" && command !== undefined && /^\$env:/iu.test(command.value))
|
|
488
|
+
return "posix-powershell-env";
|
|
489
|
+
}
|
|
490
|
+
return undefined;
|
|
491
|
+
}
|
|
492
|
+
//# sourceMappingURL=shell-command.js.map
|
package/lib/skills.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DshSkillRegistration, DshSkillRegistry } from "./dsh-types.js";
|
|
2
|
+
import type { DsmmSettings } from "./settings.js";
|
|
3
|
+
export declare const DSMM_SKILL_NAMES: readonly ["brainstorming", "writing-plans", "requesting-code-review", "receiving-code-review", "subagent-driven-development", "dispatching-parallel-agents", "remove-ai-slops"];
|
|
4
|
+
export declare const MVP_SKILL_NAMES: readonly ["brainstorming", "writing-plans", "requesting-code-review", "receiving-code-review", "subagent-driven-development", "dispatching-parallel-agents", "remove-ai-slops"];
|
|
5
|
+
export type DsmmSkillName = (typeof DSMM_SKILL_NAMES)[number];
|
|
6
|
+
export declare const DSMM_ON_DEMAND_SKILL_NAMES: readonly ["debugging"];
|
|
7
|
+
export type DsmmAvailableSkillName = DsmmSkillName | (typeof DSMM_ON_DEMAND_SKILL_NAMES)[number];
|
|
8
|
+
export type MvpSkillName = DsmmSkillName;
|
|
9
|
+
export declare function parseSkillMarkdown(markdown: string): {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
content: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function enabledSkillNames(settings: DsmmSettings): readonly DsmmSkillName[];
|
|
15
|
+
export declare function loadBundledSkill(name: DsmmAvailableSkillName): DshSkillRegistration;
|
|
16
|
+
export declare function registerBundledSkills(skills: DshSkillRegistry | undefined, names: readonly DsmmAvailableSkillName[]): void;
|
|
17
|
+
export declare function renderBundledSkillPrompt(names: readonly DsmmSkillName[]): string;
|
|
18
|
+
//# sourceMappingURL=skills.d.ts.map
|
package/lib/skills.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
export const DSMM_SKILL_NAMES = [
|
|
5
|
+
"brainstorming",
|
|
6
|
+
"writing-plans",
|
|
7
|
+
"requesting-code-review",
|
|
8
|
+
"receiving-code-review",
|
|
9
|
+
"subagent-driven-development",
|
|
10
|
+
"dispatching-parallel-agents",
|
|
11
|
+
"remove-ai-slops"
|
|
12
|
+
];
|
|
13
|
+
export const MVP_SKILL_NAMES = DSMM_SKILL_NAMES;
|
|
14
|
+
export const DSMM_ON_DEMAND_SKILL_NAMES = ["debugging"];
|
|
15
|
+
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
16
|
+
export function parseSkillMarkdown(markdown) {
|
|
17
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/u.exec(markdown);
|
|
18
|
+
if (match === null)
|
|
19
|
+
throw new Error("skill markdown must start with YAML frontmatter");
|
|
20
|
+
const frontmatter = match[1];
|
|
21
|
+
const name = /^name:\s*(.+)$/mu.exec(frontmatter)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
|
|
22
|
+
const description = /^description:\s*(.+)$/mu.exec(frontmatter)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
|
|
23
|
+
if (name === undefined || description === undefined)
|
|
24
|
+
throw new Error("skill frontmatter needs name and description");
|
|
25
|
+
return { name, description, content: match[2].replace(/^\r?\n/u, "") };
|
|
26
|
+
}
|
|
27
|
+
export function enabledSkillNames(settings) {
|
|
28
|
+
return DSMM_SKILL_NAMES.filter((name) => settings.skills[name]);
|
|
29
|
+
}
|
|
30
|
+
export function loadBundledSkill(name) {
|
|
31
|
+
const directory = join(packageRoot, "skills", name);
|
|
32
|
+
const parsed = parseSkillMarkdown(readFileSync(join(directory, "SKILL.md"), "utf8"));
|
|
33
|
+
return {
|
|
34
|
+
name: parsed.name,
|
|
35
|
+
description: parsed.description,
|
|
36
|
+
content: parsed.content,
|
|
37
|
+
source: "bundled",
|
|
38
|
+
provider: "dsmm",
|
|
39
|
+
resourceBase: { kind: "directory", path: directory },
|
|
40
|
+
invocation: { modelInvocable: true, userInvocable: true }
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function registerBundledSkills(skills, names) {
|
|
44
|
+
if (skills === undefined)
|
|
45
|
+
return;
|
|
46
|
+
for (const name of DSMM_SKILL_NAMES) {
|
|
47
|
+
if (names.includes(name))
|
|
48
|
+
skills.register(loadBundledSkill(name));
|
|
49
|
+
}
|
|
50
|
+
for (const name of DSMM_ON_DEMAND_SKILL_NAMES) {
|
|
51
|
+
if (names.includes(name))
|
|
52
|
+
skills.register(loadBundledSkill(name));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function renderBundledSkillPrompt(names) {
|
|
56
|
+
return DSMM_SKILL_NAMES
|
|
57
|
+
.filter((name) => names.includes(name))
|
|
58
|
+
.map((name) => {
|
|
59
|
+
const body = loadBundledSkill(name).content.replace(/\r?\n$/u, "");
|
|
60
|
+
return `<dsmm-skill name="${name}">\n${body}\n</dsmm-skill>`;
|
|
61
|
+
})
|
|
62
|
+
.join("\n\n");
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=skills.js.map
|
package/lib/state.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DshAgent, DshContext, DshSessionEvent } from "./dsh-types.js";
|
|
2
|
+
export declare const DEEPWORK_MODE_EVENT = "deepwork/mode";
|
|
3
|
+
export type DeepworkSelectionOutcome = "committed" | "pending" | "unchanged";
|
|
4
|
+
export declare function isDeepworkActive(events?: readonly DshSessionEvent[], defaultActive?: boolean): boolean;
|
|
5
|
+
export declare function hasOpenTurn(events?: readonly DshSessionEvent[]): boolean;
|
|
6
|
+
export declare class DeepworkModeController {
|
|
7
|
+
private readonly pending;
|
|
8
|
+
constructor(ctx: DshContext);
|
|
9
|
+
active(agent: DshAgent | undefined, defaultActive: boolean): boolean;
|
|
10
|
+
select(agent: DshAgent, active: boolean, defaultActive?: boolean): Promise<DeepworkSelectionOutcome>;
|
|
11
|
+
private commit;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=state.d.ts.map
|
package/lib/state.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { sessionEvents } from "./session-scope.js";
|
|
2
|
+
export const DEEPWORK_MODE_EVENT = "deepwork/mode";
|
|
3
|
+
function activeFromEvent(event) {
|
|
4
|
+
if (event.type !== DEEPWORK_MODE_EVENT)
|
|
5
|
+
return undefined;
|
|
6
|
+
const data = event.data;
|
|
7
|
+
return typeof data === "object" && data !== null && "active" in data && typeof data.active === "boolean"
|
|
8
|
+
? data.active
|
|
9
|
+
: undefined;
|
|
10
|
+
}
|
|
11
|
+
export function isDeepworkActive(events = [], defaultActive = false) {
|
|
12
|
+
let active = defaultActive;
|
|
13
|
+
for (const event of events)
|
|
14
|
+
active = activeFromEvent(event) ?? active;
|
|
15
|
+
return active;
|
|
16
|
+
}
|
|
17
|
+
export function hasOpenTurn(events = []) {
|
|
18
|
+
let open = false;
|
|
19
|
+
for (const event of events) {
|
|
20
|
+
if (event.type === "turn/start")
|
|
21
|
+
open = true;
|
|
22
|
+
else if (event.type === "turn/end")
|
|
23
|
+
open = false;
|
|
24
|
+
}
|
|
25
|
+
return open;
|
|
26
|
+
}
|
|
27
|
+
export class DeepworkModeController {
|
|
28
|
+
pending = new WeakMap();
|
|
29
|
+
constructor(ctx) {
|
|
30
|
+
ctx.on?.("agent/pre-step", async (frame, next) => {
|
|
31
|
+
const decision = await next();
|
|
32
|
+
const intent = this.pending.get(frame.agent.session);
|
|
33
|
+
if (decision.kind === "reject" || frame.signal.aborted || intent === undefined)
|
|
34
|
+
return decision;
|
|
35
|
+
try {
|
|
36
|
+
await this.commit(frame.agent.session, intent.active);
|
|
37
|
+
}
|
|
38
|
+
catch (cause) {
|
|
39
|
+
ctx.logger?.warn("dsmm failed to append deepwork mode event; pending intent will retry", cause);
|
|
40
|
+
}
|
|
41
|
+
return decision;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
active(agent, defaultActive) {
|
|
45
|
+
if (agent === undefined)
|
|
46
|
+
return false;
|
|
47
|
+
return this.pending.get(agent.session)?.active ?? isDeepworkActive(sessionEvents(agent.session), defaultActive);
|
|
48
|
+
}
|
|
49
|
+
async select(agent, active, defaultActive = false) {
|
|
50
|
+
const current = this.active(agent, defaultActive);
|
|
51
|
+
if (current === active && !this.pending.has(agent.session))
|
|
52
|
+
return "unchanged";
|
|
53
|
+
this.pending.set(agent.session, { active });
|
|
54
|
+
if (hasOpenTurn(sessionEvents(agent.session)))
|
|
55
|
+
return "pending";
|
|
56
|
+
await this.commit(agent.session, active);
|
|
57
|
+
return "committed";
|
|
58
|
+
}
|
|
59
|
+
async commit(session, active) {
|
|
60
|
+
await session.append(DEEPWORK_MODE_EVENT, { active });
|
|
61
|
+
this.pending.delete(session);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=state.js.map
|