@dinoxx/dinox-cli 2.18.4 → 2.19.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 (35) hide show
  1. package/dist/commands/notes/contentEngine.js +8 -4
  2. package/dist/commands/schema/renderSkills.js +3 -1
  3. package/dist/commands/todo/contentModel.d.ts +5 -3
  4. package/dist/commands/todo/contentModel.js +7 -5
  5. package/dist/commands/todo/dryRun.d.ts +9 -7
  6. package/dist/commands/todo/dryRun.js +99 -86
  7. package/dist/commands/todo/index.js +279 -93
  8. package/dist/commands/todo/repo.d.ts +128 -7
  9. package/dist/commands/todo/repo.js +474 -130
  10. package/dist/commands/todo/taskModel.d.ts +20 -1
  11. package/dist/commands/todo/taskModel.js +153 -20
  12. package/dist/commands/todo/taskPatch.d.ts +119 -0
  13. package/dist/commands/todo/taskPatch.js +502 -0
  14. package/dist/commands/todo/taskText.d.ts +26 -0
  15. package/dist/commands/todo/taskText.js +221 -0
  16. package/dist/daemon/supervisor.d.ts +0 -6
  17. package/dist/daemon/supervisor.js +10 -2
  18. package/dist/dsh-plugin/lib/client.js +713 -289
  19. package/dist/dsh-plugin/lib/index.js +7 -2
  20. package/dist/dsh-plugin/package.json +1 -1
  21. package/dist/dsh-plugin/runtime.json +1 -1
  22. package/dist/editor/compat.d.ts +6 -0
  23. package/dist/editor/compat.js +18 -0
  24. package/dist/editor/daemon.js +27 -0
  25. package/dist/editor/mcp.js +99 -2
  26. package/dist/editor/service.d.ts +57 -1
  27. package/dist/editor/service.js +174 -7
  28. package/dist/editor/todos.d.ts +67 -0
  29. package/dist/editor/todos.js +293 -0
  30. package/dist/editor-ui/mcp-app.html +262 -253
  31. package/dist/integrations/dsh/host.js +10 -2
  32. package/dist/utils/tiptapMarkdown.js +15 -1
  33. package/dist/vendor/electron/shared/task-priority.d.ts +42 -0
  34. package/dist/vendor/electron/shared/task-priority.js +186 -0
  35. package/package.json +1 -1
@@ -0,0 +1,221 @@
1
+ import { parseHashtagPath } from '../../utils/tiptapMarkdownSchemaUtils.js';
2
+ function isNode(value) {
3
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
4
+ }
5
+ /** The task's own first paragraph (nested task lists belong to subtasks). */
6
+ export function taskParagraph(taskItem) {
7
+ if (!Array.isArray(taskItem.content))
8
+ return null;
9
+ return taskItem.content.find(child => isNode(child) && child.type === 'paragraph') ?? null;
10
+ }
11
+ function tagText(node) {
12
+ return `#${String(node.attrs?.label ?? node.attrs?.id ?? '').trim()}`;
13
+ }
14
+ function segments(paragraph) {
15
+ const parts = [];
16
+ let full = '';
17
+ for (const child of Array.isArray(paragraph?.content) ? paragraph.content : []) {
18
+ if (!isNode(child))
19
+ continue;
20
+ let text = '';
21
+ let kind = 'atom';
22
+ if (child.type === 'text' && typeof child.text === 'string') {
23
+ text = child.text;
24
+ kind = 'text';
25
+ }
26
+ else if (child.type === 'hashtag') {
27
+ text = tagText(child);
28
+ kind = 'tag';
29
+ }
30
+ else if (child.type === 'hardBreak')
31
+ text = ' ';
32
+ parts.push({ node: child, start: full.length, end: full.length + text.length, kind });
33
+ full += text;
34
+ }
35
+ return { full, parts };
36
+ }
37
+ /** What the inline editor shows (and what an edit is compared against). */
38
+ export function taskEditText(taskItem) {
39
+ return segments(taskParagraph(taskItem)).full.replace(/\s+/g, ' ').trim();
40
+ }
41
+ /** Plain text with `#tags` as hashtag nodes. */
42
+ function inlineNodes(text, marks) {
43
+ const out = [];
44
+ let plain = '';
45
+ const flush = () => {
46
+ if (plain)
47
+ out.push({ type: 'text', text: plain, ...(marks?.length ? { marks } : {}) });
48
+ plain = '';
49
+ };
50
+ for (let index = 0; index < text.length;) {
51
+ const tag = text[index] === '#' ? parseHashtagPath(text, index) : null;
52
+ if (tag) {
53
+ flush();
54
+ out.push({ type: 'hashtag', attrs: { id: tag.label, label: tag.label } });
55
+ index += tag.raw.length;
56
+ }
57
+ else {
58
+ plain += text[index];
59
+ index += 1;
60
+ }
61
+ }
62
+ flush();
63
+ return out;
64
+ }
65
+ function sameMarks(a, b) {
66
+ return JSON.stringify(a ?? []) === JSON.stringify(b ?? []);
67
+ }
68
+ /** Text without a link mark: typing at the end of a link should not extend it. */
69
+ function typingMarks(marks) {
70
+ const kept = (marks ?? []).filter(mark => !(isNode(mark) && mark.type === 'link'));
71
+ return kept.length ? kept : undefined;
72
+ }
73
+ /**
74
+ * Character diff of `a` → `b` as replaced spans of `a` (LCS; long rewrites fall
75
+ * back to one span). Spans closer than two characters are joined so a word
76
+ * changes as a word.
77
+ */
78
+ function diffHunks(a, b) {
79
+ let prefix = 0;
80
+ while (prefix < a.length && prefix < b.length && a[prefix] === b[prefix])
81
+ prefix += 1;
82
+ let suffix = 0;
83
+ while (suffix < a.length - prefix && suffix < b.length - prefix && a[a.length - 1 - suffix] === b[b.length - 1 - suffix])
84
+ suffix += 1;
85
+ const x = a.slice(prefix, a.length - suffix);
86
+ const y = b.slice(prefix, b.length - suffix);
87
+ if (!x.length && !y.length)
88
+ return [];
89
+ if (!x.length || !y.length || x.length * y.length > 250_000)
90
+ return [{ start: prefix, end: prefix + x.length, insert: y }];
91
+ const width = y.length + 1;
92
+ const table = new Uint16Array((x.length + 1) * width);
93
+ for (let i = x.length - 1; i >= 0; i -= 1) {
94
+ for (let j = y.length - 1; j >= 0; j -= 1) {
95
+ table[i * width + j] = x[i] === y[j] ? table[(i + 1) * width + j + 1] + 1 : Math.max(table[(i + 1) * width + j], table[i * width + j + 1]);
96
+ }
97
+ }
98
+ const hunks = [];
99
+ let open = null;
100
+ let i = 0;
101
+ let j = 0;
102
+ const close = () => { if (open)
103
+ hunks.push(open); open = null; };
104
+ while (i < x.length || j < y.length) {
105
+ if (i < x.length && j < y.length && x[i] === y[j]) {
106
+ close();
107
+ i += 1;
108
+ j += 1;
109
+ continue;
110
+ }
111
+ open ??= { start: prefix + i, end: prefix + i, insert: '' };
112
+ if (j < y.length && (i >= x.length || table[i * width + j + 1] >= table[(i + 1) * width + j])) {
113
+ open.insert += y[j];
114
+ j += 1;
115
+ }
116
+ else {
117
+ i += 1;
118
+ open.end = prefix + i;
119
+ }
120
+ }
121
+ close();
122
+ const joined = [];
123
+ for (const hunk of hunks) {
124
+ const last = joined[joined.length - 1];
125
+ if (last && hunk.start - last.end < 2) {
126
+ last.insert += a.slice(last.end, hunk.start) + hunk.insert;
127
+ last.end = hunk.end;
128
+ }
129
+ else {
130
+ joined.push({ ...hunk });
131
+ }
132
+ }
133
+ return joined;
134
+ }
135
+ /**
136
+ * Sets the task's words, editing only what changed. Returns false when the
137
+ * words are already `next`. Whitespace runs collapse; `next` must not be empty.
138
+ */
139
+ export function setTaskEditText(taskItem, next) {
140
+ const wanted = next.replace(/\s+/g, ' ').trim();
141
+ let paragraph = taskParagraph(taskItem);
142
+ if (!paragraph) {
143
+ paragraph = { type: 'paragraph', content: [] };
144
+ taskItem.content = [paragraph, ...(Array.isArray(taskItem.content) ? taskItem.content : [])];
145
+ }
146
+ const { full } = segments(paragraph);
147
+ const lead = full.length - full.trimStart().length;
148
+ const core = full.trim();
149
+ if (core.replace(/\s+/g, ' ') === wanted)
150
+ return false;
151
+ // Right to left, so the earlier spans keep their offsets.
152
+ for (const hunk of diffHunks(core, wanted).reverse())
153
+ splice(paragraph, lead + hunk.start, lead + hunk.end, hunk.insert);
154
+ return true;
155
+ }
156
+ /** Replaces [start, end) of the paragraph's words with `insert`, keeping every node outside it. */
157
+ function splice(paragraph, start, end, insert) {
158
+ const { full, parts } = segments(paragraph);
159
+ // Hashtags are atoms: an edit touching one rewrites the whole tag, and typing
160
+ // right after a tag (#work → #works) continues it.
161
+ for (const part of parts) {
162
+ if (part.kind !== 'tag')
163
+ continue;
164
+ const touches = (part.start < end && start < part.end) || (start === end && start > part.start && start < part.end)
165
+ || (start === part.end && /^[^\s#]/.test(insert));
166
+ if (!touches)
167
+ continue;
168
+ if (part.start < start) {
169
+ insert = full.slice(part.start, start) + insert;
170
+ start = part.start;
171
+ }
172
+ if (part.end > end) {
173
+ insert += full.slice(end, part.end);
174
+ end = part.end;
175
+ }
176
+ }
177
+ const before = [];
178
+ const kept = [];
179
+ const after = [];
180
+ let marks;
181
+ for (const part of parts) {
182
+ const { node } = part;
183
+ if (part.start === part.end) {
184
+ // Time nodes and other atoms without text are never removed by an edit.
185
+ (part.start <= start ? before : part.start >= end ? after : kept).push(node);
186
+ }
187
+ else if (part.end <= start) {
188
+ if (part.end === start && part.kind === 'text')
189
+ marks = typingMarks(node.marks);
190
+ before.push(node);
191
+ }
192
+ else if (part.start >= end) {
193
+ after.push(node);
194
+ }
195
+ else if (part.kind === 'text') {
196
+ const text = String(node.text);
197
+ if (part.start < start) {
198
+ before.push({ ...node, text: text.slice(0, start - part.start) });
199
+ marks = node.marks;
200
+ }
201
+ if (part.end > end)
202
+ after.push({ ...node, text: text.slice(end - part.start) });
203
+ }
204
+ // Tags and text-bearing atoms inside the span give way to `insert`.
205
+ }
206
+ const ordered = [...before, ...inlineNodes(insert, marks), ...kept, ...after];
207
+ // Merge neighbouring text with equal marks; drop empty text.
208
+ const content = [];
209
+ for (const node of ordered) {
210
+ if (node.type === 'text' && !String(node.text ?? ''))
211
+ continue;
212
+ const last = content[content.length - 1];
213
+ if (last && last.type === 'text' && node.type === 'text' && sameMarks(last.marks, node.marks)) {
214
+ content[content.length - 1] = { ...last, text: String(last.text) + String(node.text) };
215
+ }
216
+ else {
217
+ content.push(node);
218
+ }
219
+ }
220
+ paragraph.content = content;
221
+ }
@@ -68,12 +68,6 @@ export declare function quoteWindowsArg(value: string): string;
68
68
  export declare function splitWindowsCommandLine(commandLine: string): string[];
69
69
  /** The command line of a launcher written by renderWindowsLauncher. */
70
70
  export declare function parseWindowsLauncherCommand(launcher: string): string[] | null;
71
- /**
72
- * Task Scheduler runs console programs in a visible window, so the task runs
73
- * this script with wscript, which sets the daemon environment and starts the
74
- * supervisor with a hidden window (the launcher pattern pm2-windows-startup
75
- * uses). The supervisor then outlives the script.
76
- */
77
71
  export declare function renderWindowsLauncher(spec: DaemonServiceSpec): string;
78
72
  export declare function renderWindowsTaskXml(userId: string, wscriptPath: string, launcherPath: string): string;
79
73
  export type DaemonServiceOptions = {
@@ -372,6 +372,12 @@ function vbsString(value) {
372
372
  * supervisor with a hidden window (the launcher pattern pm2-windows-startup
373
373
  * uses). The supervisor then outlives the script.
374
374
  */
375
+ /**
376
+ * `//E:vbscript` names the engine, so the launcher runs even when the `.vbs`
377
+ * file association is broken (wscript then fails silently under //B with
378
+ * "There is no script engine for file extension .vbs").
379
+ */
380
+ const WSCRIPT_ARGS = ['//B', '//Nologo', '//E:vbscript'];
375
381
  export function renderWindowsLauncher(spec) {
376
382
  const commandLine = [spec.program, ...spec.args].map(quoteWindowsArg).join(' ');
377
383
  const env = Object.keys(spec.env)
@@ -380,6 +386,8 @@ export function renderWindowsLauncher(spec) {
380
386
  .join('\r\n');
381
387
  return [
382
388
  "' Generated by `dino daemon install`; rewritten when the CLI changes.",
389
+ // Run with //E:vbscript; the line changes the file so older registrations are rewritten.
390
+ "' Started as: wscript //B //Nologo //E:vbscript <this file>",
383
391
  'Set shell = CreateObject("WScript.Shell")',
384
392
  'Set env = shell.Environment("Process")',
385
393
  env,
@@ -427,7 +435,7 @@ export function renderWindowsTaskXml(userId, wscriptPath, launcherPath) {
427
435
  <Actions Context="Author">
428
436
  <Exec>
429
437
  <Command>${xmlEscape(wscriptPath)}</Command>
430
- <Arguments>${xmlEscape(`//B //Nologo ${quoteWindowsArg(launcherPath)}`)}</Arguments>
438
+ <Arguments>${xmlEscape(`${WSCRIPT_ARGS.join(' ')} ${quoteWindowsArg(launcherPath)}`)}</Arguments>
431
439
  </Exec>
432
440
  </Actions>
433
441
  </Task>
@@ -481,7 +489,7 @@ class WindowsTaskService {
481
489
  return launcher === null ? null : parseWindowsLauncherCommand(launcher);
482
490
  }
483
491
  launcherArgs() {
484
- return ['//B', '//Nologo', this.definitionPath];
492
+ return [...WSCRIPT_ARGS, this.definitionPath];
485
493
  }
486
494
  async isTaskRegistered() {
487
495
  return (await this.run('schtasks', ['/Query', '/TN', this.taskName])).code === 0;