@dinoxx/dinox-cli 2.17.0 → 2.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +39 -11
  2. package/dist/cli.js +2 -0
  3. package/dist/commands/editor/index.d.ts +4 -0
  4. package/dist/commands/editor/index.js +155 -0
  5. package/dist/commands/notes/contentPatch.d.ts +23 -0
  6. package/dist/commands/notes/contentPatch.js +37 -0
  7. package/dist/commands/schema/renderSkills.js +1 -0
  8. package/dist/commands/schema/spec.js +2 -0
  9. package/dist/commands/update.d.ts +3 -0
  10. package/dist/commands/update.js +45 -2
  11. package/dist/daemon/server.d.ts +2 -1
  12. package/dist/daemon/server.js +22 -2
  13. package/dist/dinox.js +12 -1
  14. package/dist/dsh-plugin/cordis.patch.yml +3 -0
  15. package/dist/dsh-plugin/lib/client.js +2145 -0
  16. package/dist/dsh-plugin/lib/index.js +369 -0
  17. package/dist/dsh-plugin/package.json +32 -0
  18. package/dist/dsh-plugin/runtime.json +5 -0
  19. package/dist/editor/anchor.d.ts +46 -0
  20. package/dist/editor/anchor.js +129 -0
  21. package/dist/editor/blockIds.d.ts +21 -0
  22. package/dist/editor/blockIds.js +51 -0
  23. package/dist/editor/blocks.d.ts +47 -0
  24. package/dist/editor/blocks.js +236 -0
  25. package/dist/editor/compat.d.ts +32 -0
  26. package/dist/editor/compat.js +392 -0
  27. package/dist/editor/daemon.d.ts +10 -0
  28. package/dist/editor/daemon.js +56 -0
  29. package/dist/editor/document.d.ts +74 -0
  30. package/dist/editor/document.js +88 -0
  31. package/dist/editor/i18n.d.ts +23 -0
  32. package/dist/editor/i18n.js +61 -0
  33. package/dist/editor/install.d.ts +72 -0
  34. package/dist/editor/install.js +239 -0
  35. package/dist/editor/mcp.d.ts +22 -0
  36. package/dist/editor/mcp.js +222 -0
  37. package/dist/editor/meta.d.ts +70 -0
  38. package/dist/editor/meta.js +163 -0
  39. package/dist/editor/paths.d.ts +2 -0
  40. package/dist/editor/paths.js +13 -0
  41. package/dist/editor/persistence.d.ts +4 -0
  42. package/dist/editor/persistence.js +35 -0
  43. package/dist/editor/saveGuard.d.ts +9 -0
  44. package/dist/editor/saveGuard.js +38 -0
  45. package/dist/editor/schema.d.ts +14 -0
  46. package/dist/editor/schema.js +38 -0
  47. package/dist/editor/service.d.ts +326 -0
  48. package/dist/editor/service.js +1007 -0
  49. package/dist/editor-ui/mcp-app.html +765 -0
  50. package/dist/gateway/adapters/acp.d.ts +8 -0
  51. package/dist/gateway/adapters/acp.js +38 -2
  52. package/dist/gateway/agentTaskHost.d.ts +9 -3
  53. package/dist/gateway/agentTaskHost.js +45 -25
  54. package/dist/gateway/config.js +2 -2
  55. package/dist/gateway/deviceHost.d.ts +1 -1
  56. package/dist/gateway/deviceHost.js +8 -4
  57. package/dist/gateway/mcpCommandTools.d.ts +1 -1
  58. package/dist/gateway/mcpCommandTools.js +2 -2
  59. package/dist/gateway/processTree.d.ts +15 -0
  60. package/dist/gateway/processTree.js +60 -0
  61. package/dist/gateway/protocol.js +2 -1
  62. package/dist/gateway/service.d.ts +1 -1
  63. package/dist/gateway/service.js +2 -1
  64. package/dist/gateway/taskJournal.d.ts +14 -0
  65. package/dist/gateway/taskJournal.js +47 -0
  66. package/dist/gateway/threadStore.d.ts +7 -1
  67. package/dist/gateway/threadStore.js +14 -3
  68. package/dist/gateway/types.d.ts +7 -3
  69. package/dist/gateway/types.js +3 -1
  70. package/dist/integrations/dsh/host.d.ts +53 -0
  71. package/dist/integrations/dsh/host.js +237 -0
  72. package/dist/integrations/dsh/mcpClient.d.ts +66 -0
  73. package/dist/integrations/dsh/mcpClient.js +192 -0
  74. package/dist/utils/errorCodes.d.ts +28 -0
  75. package/dist/utils/errorCodes.js +7 -0
  76. package/dist/utils/nodeRuntime.d.ts +4 -0
  77. package/dist/utils/nodeRuntime.js +12 -0
  78. package/dist/vendor/electron/shared/remote-device-agent.d.ts +2 -0
  79. package/package.json +9 -2
@@ -0,0 +1,47 @@
1
+ import type { JSONContent } from '@tiptap/core';
2
+ /**
3
+ * The note as a list of addressable blocks: every textblock (paragraph,
4
+ * heading, list item line, code block, ...) in document order, with the
5
+ * Markdown it reads as and its range in the shared text projection
6
+ * (`buildTextIndex`). The model reads and targets blocks by id instead of
7
+ * quoting text back, and reads only the blocks that changed since it last
8
+ * looked.
9
+ */
10
+ export type Segment = {
11
+ /** One line of Markdown, prefixed the way it renders: `## `, `- [ ] `, `> `, ... */
12
+ md: string;
13
+ /** The block's plain text, exactly as it appears in `text`. */
14
+ text: string;
15
+ start: number;
16
+ end: number;
17
+ /**
18
+ * The block's own id in the note (`attrs.id`; a list line without one falls
19
+ * back to its item's). Absent when the block has none, or when an earlier
20
+ * block already has the same one.
21
+ */
22
+ nodeId?: string;
23
+ };
24
+ export type SegmentedDocument = {
25
+ text: string;
26
+ segments: Segment[];
27
+ };
28
+ export declare function segmentDocument(document: JSONContent): SegmentedDocument;
29
+ export type BlockChange = {
30
+ id: string;
31
+ op: 'added' | 'changed' | 'removed';
32
+ };
33
+ /** Dice similarity of character bigrams; empty blocks pair with whatever was typed into them. */
34
+ export declare function similarity(a: string, b: string): number;
35
+ /**
36
+ * Carries block ids from one version of a note to the next. Unchanged blocks
37
+ * keep their id; a block edited in place keeps it too (paired with the most
38
+ * similar block between unchanged neighbours); anything else is added or
39
+ * removed.
40
+ */
41
+ export declare function reconcileBlocks(previous: Array<{
42
+ id: string;
43
+ md: string;
44
+ }>, next: string[], newId: (index: number) => string): {
45
+ ids: string[];
46
+ changes: BlockChange[];
47
+ };
@@ -0,0 +1,236 @@
1
+ import { serializeNoteContentMarkdown } from '../commands/notes/contentEngine.js';
2
+ import { buildTextIndex } from './anchor.js';
3
+ import { blockIdOf } from './blockIds.js';
4
+ import { unwrapOpaque } from './compat.js';
5
+ import { parseEditorDocument } from './schema.js';
6
+ const ITEM_TYPES = new Set(['listItem', 'taskItem']);
7
+ const inlineCache = new Map();
8
+ const INLINE_CACHE_LIMIT = 4000;
9
+ /**
10
+ * The serializer escapes every punctuation mark that could ever start syntax.
11
+ * Inside a single line most of that is noise to a reader (`a\\, b\\.`); keep
12
+ * only escapes that still change meaning: emphasis, code, links, HTML, and a
13
+ * list or heading marker at the start of the line.
14
+ */
15
+ function readableMarkdown(md) {
16
+ return md
17
+ .replace(/\\([,.;:!?'"()/%&@$^=|{}])/g, (match, char, offset) => (char === '.' && /^\d+$/.test(md.slice(0, offset)) ? match : char));
18
+ }
19
+ function inlineMarkdown(node) {
20
+ const content = node.toJSON().content;
21
+ if (!content?.length)
22
+ return '';
23
+ const key = JSON.stringify(content);
24
+ const cached = inlineCache.get(key);
25
+ if (cached !== undefined)
26
+ return cached;
27
+ let md = '';
28
+ try {
29
+ const doc = unwrapOpaque({ type: 'doc', content: [{ type: 'paragraph', content }] });
30
+ md = readableMarkdown(serializeNoteContentMarkdown(doc));
31
+ }
32
+ catch {
33
+ md = '';
34
+ }
35
+ if (inlineCache.size >= INLINE_CACHE_LIMIT)
36
+ inlineCache.clear();
37
+ inlineCache.set(key, md);
38
+ return md;
39
+ }
40
+ function linePrefix($pos) {
41
+ let quote = '';
42
+ const items = [];
43
+ for (let depth = 1; depth <= $pos.depth; depth++) {
44
+ const type = $pos.node(depth).type.name;
45
+ if (type === 'blockquote')
46
+ quote += '> ';
47
+ if (type === 'listItem' || type === 'taskItem')
48
+ items.push(depth);
49
+ }
50
+ if (!items.length)
51
+ return quote;
52
+ const innermost = items[items.length - 1];
53
+ const indent = ' '.repeat(items.length - 1);
54
+ // Only an item's first line carries its marker; later paragraphs are continuation lines.
55
+ if ($pos.index(innermost) !== 0)
56
+ return `${quote}${indent} `;
57
+ const item = $pos.node(innermost);
58
+ const list = $pos.node(innermost - 1);
59
+ if (list.type.name === 'orderedList')
60
+ return `${quote}${indent}${Number(list.attrs.start ?? 1) + $pos.index(innermost - 1)}. `;
61
+ if (item.type.name === 'taskItem')
62
+ return `${quote}${indent}- [${item.attrs.checked ? 'x' : ' '}] `;
63
+ return `${quote}${indent}- `;
64
+ }
65
+ function blockMarkdown(node, $pos, text) {
66
+ const prefix = linePrefix($pos);
67
+ if (node.type.name === 'codeBlock') {
68
+ const language = String(node.attrs.language ?? '');
69
+ return `${prefix}\`\`\`${language}\n${node.textContent}\n\`\`\``;
70
+ }
71
+ const inline = inlineMarkdown(node) || text;
72
+ if (node.type.name === 'heading')
73
+ return `${prefix}${'#'.repeat(Number(node.attrs.level) || 1)} ${inline}`;
74
+ return `${prefix}${inline}`;
75
+ }
76
+ /** Stored notes can carry empty text nodes, which ProseMirror refuses; they render as nothing. */
77
+ function withoutEmptyText(node) {
78
+ if (!node.content)
79
+ return node;
80
+ return { ...node, content: node.content.filter(child => child.type !== 'text' || child.text).map(withoutEmptyText) };
81
+ }
82
+ export function segmentDocument(document) {
83
+ const { node: doc } = parseEditorDocument(withoutEmptyText(document));
84
+ const index = buildTextIndex(doc);
85
+ const seen = new Set();
86
+ const segments = index.blocks.map(({ pos, start, end }) => {
87
+ const node = doc.nodeAt(pos);
88
+ const $pos = doc.resolve(pos);
89
+ const text = index.text.slice(start, end);
90
+ const item = $pos.depth > 0 && $pos.index() === 0 && ITEM_TYPES.has($pos.parent.type.name) ? $pos.parent : null;
91
+ const candidate = blockIdOf(node.attrs.id) ?? blockIdOf(item?.attrs.id);
92
+ const nodeId = candidate && !seen.has(candidate) ? candidate : undefined;
93
+ if (nodeId)
94
+ seen.add(nodeId);
95
+ return { md: blockMarkdown(node, $pos, text), text, start, end, ...(nodeId ? { nodeId } : {}) };
96
+ });
97
+ return { text: index.text, segments };
98
+ }
99
+ const PAIR_THRESHOLD = 0.3;
100
+ const LCS_LIMIT = 250_000;
101
+ const ALIGN_LIMIT = 400;
102
+ function bigrams(value) {
103
+ const grams = new Map();
104
+ for (let i = 0; i < value.length - 1; i++) {
105
+ const gram = value.slice(i, i + 2);
106
+ grams.set(gram, (grams.get(gram) ?? 0) + 1);
107
+ }
108
+ return grams;
109
+ }
110
+ /** Dice similarity of character bigrams; empty blocks pair with whatever was typed into them. */
111
+ export function similarity(a, b) {
112
+ if (a === b)
113
+ return 1;
114
+ if (!a.trim() || !b.trim())
115
+ return PAIR_THRESHOLD;
116
+ if (a.length < 2 || b.length < 2)
117
+ return a.includes(b) || b.includes(a) ? 0.5 : 0;
118
+ const left = bigrams(a);
119
+ const right = bigrams(b);
120
+ let shared = 0;
121
+ for (const [gram, count] of left)
122
+ shared += Math.min(count, right.get(gram) ?? 0);
123
+ const dice = (2 * shared) / (a.length - 1 + b.length - 1);
124
+ // A block the user kept typing into still contains most of what it was.
125
+ const contained = shared / (Math.min(a.length, b.length) - 1);
126
+ return Math.max(dice, 0.8 * contained);
127
+ }
128
+ /** Index pairs of a longest common subsequence of equal strings. */
129
+ function lcsPairs(a, b) {
130
+ const n = a.length;
131
+ const m = b.length;
132
+ if (!n || !m || n * m > LCS_LIMIT)
133
+ return [];
134
+ const table = Array.from({ length: n + 1 }, () => new Uint32Array(m + 1));
135
+ for (let i = n - 1; i >= 0; i--) {
136
+ for (let j = m - 1; j >= 0; j--) {
137
+ table[i][j] = a[i] === b[j] ? table[i + 1][j + 1] + 1 : Math.max(table[i + 1][j], table[i][j + 1]);
138
+ }
139
+ }
140
+ const pairs = [];
141
+ for (let i = 0, j = 0; i < n && j < m;) {
142
+ if (a[i] === b[j]) {
143
+ pairs.push([i, j]);
144
+ i++;
145
+ j++;
146
+ }
147
+ else if (table[i + 1][j] >= table[i][j + 1])
148
+ i++;
149
+ else
150
+ j++;
151
+ }
152
+ return pairs;
153
+ }
154
+ /** Pairs edited blocks inside a gap of unmatched ones, keeping order and preferring similar text. */
155
+ function alignGap(a, b) {
156
+ if (!a.length || !b.length)
157
+ return [];
158
+ if (a.length * b.length > ALIGN_LIMIT) {
159
+ return Array.from({ length: Math.min(a.length, b.length) }, (_, i) => [i, i]);
160
+ }
161
+ const n = a.length;
162
+ const m = b.length;
163
+ const score = Array.from({ length: n + 1 }, () => new Float64Array(m + 1));
164
+ const sim = (i, j) => similarity(a[i], b[j]);
165
+ for (let i = 1; i <= n; i++) {
166
+ for (let j = 1; j <= m; j++) {
167
+ const s = sim(i - 1, j - 1);
168
+ const pair = s >= PAIR_THRESHOLD ? score[i - 1][j - 1] + s : -Infinity;
169
+ score[i][j] = Math.max(score[i - 1][j], score[i][j - 1], pair);
170
+ }
171
+ }
172
+ const pairs = [];
173
+ for (let i = n, j = m; i > 0 && j > 0;) {
174
+ if (score[i][j] === score[i - 1][j])
175
+ i--;
176
+ else if (score[i][j] === score[i][j - 1])
177
+ j--;
178
+ else {
179
+ pairs.unshift([i - 1, j - 1]);
180
+ i--;
181
+ j--;
182
+ }
183
+ }
184
+ return pairs;
185
+ }
186
+ /**
187
+ * Carries block ids from one version of a note to the next. Unchanged blocks
188
+ * keep their id; a block edited in place keeps it too (paired with the most
189
+ * similar block between unchanged neighbours); anything else is added or
190
+ * removed.
191
+ */
192
+ export function reconcileBlocks(previous, next, newId) {
193
+ const ids = Array.from({ length: next.length }, () => undefined);
194
+ const changes = [];
195
+ const used = new Set();
196
+ const keep = (i, j) => {
197
+ ids[j] = previous[i].id;
198
+ used.add(i);
199
+ if (previous[i].md !== next[j])
200
+ changes.push({ id: previous[i].id, op: 'changed' });
201
+ };
202
+ let head = 0;
203
+ while (head < previous.length && head < next.length && previous[head].md === next[head])
204
+ keep(head, head++);
205
+ let tail = 0;
206
+ while (tail < previous.length - head && tail < next.length - head
207
+ && previous[previous.length - 1 - tail].md === next[next.length - 1 - tail]) {
208
+ keep(previous.length - 1 - tail, next.length - 1 - tail);
209
+ tail++;
210
+ }
211
+ const oldMid = previous.slice(head, previous.length - tail).map(block => block.md);
212
+ const newMid = next.slice(head, next.length - tail);
213
+ const anchors = [...lcsPairs(oldMid, newMid), [oldMid.length, newMid.length]];
214
+ let i0 = 0;
215
+ let j0 = 0;
216
+ for (const [i1, j1] of anchors) {
217
+ for (const [gi, gj] of alignGap(oldMid.slice(i0, i1), newMid.slice(j0, j1)))
218
+ keep(head + i0 + gi, head + j0 + gj);
219
+ if (i1 < oldMid.length)
220
+ keep(head + i1, head + j1);
221
+ i0 = i1 + 1;
222
+ j0 = j1 + 1;
223
+ }
224
+ previous.forEach((block, i) => {
225
+ if (!used.has(i))
226
+ changes.push({ id: block.id, op: 'removed' });
227
+ });
228
+ const result = ids.map((id, index) => {
229
+ if (id)
230
+ return id;
231
+ const fresh = newId(index);
232
+ changes.push({ id: fresh, op: 'added' });
233
+ return fresh;
234
+ });
235
+ return { ids: result, changes };
236
+ }
@@ -0,0 +1,32 @@
1
+ import { Extension, Mark, Node, type JSONContent } from '@tiptap/core';
2
+ import { type Schema } from '@tiptap/pm/model';
3
+ export interface Analysis {
4
+ extraAttrs: Record<string, string[]>;
5
+ unknownNodes?: string[];
6
+ unknownMarks: Record<string, string[]>;
7
+ }
8
+ export declare function analyze(doc: JSONContent, baseSchema: Schema): Analysis;
9
+ export declare function setEmojiLookup(lookup: (name: string) => string | undefined): void;
10
+ export declare function opaqueLabel(node: any): string;
11
+ /**
12
+ * How a desktop presentation attribute shows in the panel. Block backgrounds
13
+ * apply only from the desktop palette: other values are mostly white or
14
+ * near-black page colors pasted from the web, which would fight the theme.
15
+ */
16
+ export declare function presentationOf(type: string, key: string, value: unknown): Record<string, string>;
17
+ export declare function compatExtensions(analysis: Analysis): (Node<any, any> | Mark<any, any> | Extension<any, any>)[];
18
+ export declare function setLabelTranslator(translate: (text: string) => string): void;
19
+ /**
20
+ * Prepares a stored document for the editor schema. Unknown nodes become
21
+ * opaque atoms (restored verbatim on save). With the full editor schema
22
+ * (one that has the opaque types), nodes the desktop tolerates but the schema
23
+ * forbids in their position (an image inside a paragraph, a note link at the
24
+ * top level, an empty list item) are wrapped the same way, escalating to the
25
+ * nearest ancestor that can hold an opaque atom, so the rest of the note
26
+ * stays editable. Empty text nodes and repeated marks, which carry nothing,
27
+ * are dropped.
28
+ */
29
+ export declare function wrapUnknown(doc: JSONContent, schema: Schema): JSONContent;
30
+ export declare function unwrapOpaque(doc: JSONContent): JSONContent;
31
+ export declare function losslessCompare(storedInput: any, roundTripped: JSONContent, schema: Schema): string[];
32
+ export declare function cleanForSave(doc: JSONContent, _schema?: Schema): JSONContent;