@dinoxx/dinox-cli 2.16.1 → 2.18.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 (73) hide show
  1. package/dist/cli.js +2 -0
  2. package/dist/commands/editor/index.d.ts +4 -0
  3. package/dist/commands/editor/index.js +155 -0
  4. package/dist/commands/notes/contentPatch.d.ts +23 -0
  5. package/dist/commands/notes/contentPatch.js +37 -0
  6. package/dist/commands/schema/renderSkills.js +1 -0
  7. package/dist/commands/schema/spec.js +2 -0
  8. package/dist/daemon/server.d.ts +2 -1
  9. package/dist/daemon/server.js +22 -2
  10. package/dist/dsh-plugin/cordis.patch.yml +3 -0
  11. package/dist/dsh-plugin/lib/client.js +2145 -0
  12. package/dist/dsh-plugin/lib/index.js +369 -0
  13. package/dist/dsh-plugin/package.json +32 -0
  14. package/dist/dsh-plugin/runtime.json +5 -0
  15. package/dist/editor/anchor.d.ts +46 -0
  16. package/dist/editor/anchor.js +129 -0
  17. package/dist/editor/blockIds.d.ts +21 -0
  18. package/dist/editor/blockIds.js +51 -0
  19. package/dist/editor/blocks.d.ts +47 -0
  20. package/dist/editor/blocks.js +236 -0
  21. package/dist/editor/compat.d.ts +32 -0
  22. package/dist/editor/compat.js +392 -0
  23. package/dist/editor/daemon.d.ts +10 -0
  24. package/dist/editor/daemon.js +56 -0
  25. package/dist/editor/document.d.ts +74 -0
  26. package/dist/editor/document.js +88 -0
  27. package/dist/editor/i18n.d.ts +23 -0
  28. package/dist/editor/i18n.js +61 -0
  29. package/dist/editor/install.d.ts +72 -0
  30. package/dist/editor/install.js +239 -0
  31. package/dist/editor/mcp.d.ts +22 -0
  32. package/dist/editor/mcp.js +222 -0
  33. package/dist/editor/meta.d.ts +70 -0
  34. package/dist/editor/meta.js +163 -0
  35. package/dist/editor/paths.d.ts +2 -0
  36. package/dist/editor/paths.js +13 -0
  37. package/dist/editor/persistence.d.ts +4 -0
  38. package/dist/editor/persistence.js +35 -0
  39. package/dist/editor/saveGuard.d.ts +9 -0
  40. package/dist/editor/saveGuard.js +38 -0
  41. package/dist/editor/schema.d.ts +14 -0
  42. package/dist/editor/schema.js +38 -0
  43. package/dist/editor/service.d.ts +326 -0
  44. package/dist/editor/service.js +1007 -0
  45. package/dist/editor-ui/mcp-app.html +765 -0
  46. package/dist/gateway/adapters/acp.d.ts +8 -0
  47. package/dist/gateway/adapters/acp.js +38 -2
  48. package/dist/gateway/agentTaskHost.d.ts +135 -0
  49. package/dist/gateway/agentTaskHost.js +410 -0
  50. package/dist/gateway/config.js +2 -2
  51. package/dist/gateway/deviceHost.d.ts +6 -1
  52. package/dist/gateway/deviceHost.js +22 -4
  53. package/dist/gateway/mcpCommandTools.d.ts +1 -1
  54. package/dist/gateway/mcpCommandTools.js +2 -2
  55. package/dist/gateway/processTree.d.ts +15 -0
  56. package/dist/gateway/processTree.js +60 -0
  57. package/dist/gateway/protocol.js +2 -1
  58. package/dist/gateway/service.d.ts +1 -1
  59. package/dist/gateway/service.js +3 -1
  60. package/dist/gateway/taskJournal.d.ts +14 -0
  61. package/dist/gateway/taskJournal.js +47 -0
  62. package/dist/gateway/threadStore.d.ts +7 -1
  63. package/dist/gateway/threadStore.js +14 -3
  64. package/dist/gateway/types.d.ts +7 -3
  65. package/dist/gateway/types.js +3 -1
  66. package/dist/integrations/dsh/host.d.ts +53 -0
  67. package/dist/integrations/dsh/host.js +237 -0
  68. package/dist/integrations/dsh/mcpClient.d.ts +66 -0
  69. package/dist/integrations/dsh/mcpClient.js +192 -0
  70. package/dist/utils/errorCodes.d.ts +28 -0
  71. package/dist/utils/errorCodes.js +7 -0
  72. package/dist/vendor/electron/shared/remote-device-agent.d.ts +2 -0
  73. package/package.json +9 -2
package/dist/cli.js CHANGED
@@ -3,6 +3,7 @@ import { registerAuthCommands } from './commands/auth/index.js';
3
3
  import { parseCommanderUsageError } from './utils/usageError.js';
4
4
  import { registerBatchCommand } from './commands/batch.js';
5
5
  import { registerMcpCommand } from './commands/mcp.js';
6
+ import { registerEditorCommands } from './commands/editor/index.js';
6
7
  import { registerBoxesCommand } from './commands/boxes/index.js';
7
8
  import { registerConfigCommands } from './commands/config/index.js';
8
9
  import { registerDaemonCommands } from './daemon/index.js';
@@ -111,6 +112,7 @@ export function createCli() {
111
112
  registerGraphCommands(program);
112
113
  registerInfoCommand(program);
113
114
  registerMcpCommand(program);
115
+ registerEditorCommands(program);
114
116
  registerMetaCommands(program);
115
117
  registerSyncCommand(program);
116
118
  registerUpdateCommand(program);
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'commander';
2
+ import type { CommandGroupDescriptor } from '../descriptor/types.js';
3
+ export declare const editorCommandGroup: CommandGroupDescriptor;
4
+ export declare function registerEditorCommands(program: Command): void;
@@ -0,0 +1,155 @@
1
+ import { DinoxError } from '../../utils/errors.js';
2
+ import { getRequestedStructuredOutputFormat, printHumanReadableLine, printSuccess } from '../../utils/output.js';
3
+ import { registerCommandGroup } from '../descriptor/register.js';
4
+ import { FORMAT_OPTIONS } from '../schema/globalOptions.js';
5
+ const HOST_ARGUMENT = { syntax: '<host>', description: 'AI app to set the editor up in: dsh (DeepSeek Harness Desktop)' };
6
+ const PROFILE_OPTION = { flags: '--profile <name>', description: 'dsh profile to use', type: 'string', defaultValue: 'desktop' };
7
+ const DSH_OPTION = { flags: '--dsh <path>', description: 'Path to the dsh CLI (default: the one inside DeepSeek Harness.app, then PATH)', type: 'string' };
8
+ const DRY_RUN_OPTION = { flags: '--dry-run', description: 'Show the planned changes without making them', type: 'boolean' };
9
+ function hostOf(context) {
10
+ const host = String(context.args.host ?? '').toLowerCase();
11
+ if (host !== 'dsh') {
12
+ throw new DinoxError(`Unsupported editor host: ${host || '(none)'}`, {
13
+ code: 'INVALID_ARGUMENT',
14
+ suggestion: 'Use dsh. Codex runs `dino editor mcp` from its own MCP server config.',
15
+ });
16
+ }
17
+ return host;
18
+ }
19
+ function installOptions(context) {
20
+ return {
21
+ profile: typeof context.options.profile === 'string' ? context.options.profile : undefined,
22
+ dsh: typeof context.options.dsh === 'string' ? context.options.dsh : undefined,
23
+ dryRun: Boolean(context.options.dryRun),
24
+ };
25
+ }
26
+ function report(result, done, next) {
27
+ if (getRequestedStructuredOutputFormat()) {
28
+ printSuccess(result);
29
+ return;
30
+ }
31
+ if (!result.actions.length) {
32
+ printHumanReadableLine('Nothing to change.');
33
+ return;
34
+ }
35
+ printHumanReadableLine(result.dryRun ? 'Planned changes:' : done);
36
+ for (const action of result.actions)
37
+ printHumanReadableLine(` - ${action}`);
38
+ if (!result.dryRun && result.restartRequired && next)
39
+ printHumanReadableLine(next);
40
+ }
41
+ export const editorCommandGroup = {
42
+ name: 'editor',
43
+ description: 'Co-edit Dinox notes with an AI in the side panel of AI apps (Codex, DeepSeek Harness)',
44
+ commands: [
45
+ {
46
+ name: 'mcp',
47
+ description: 'Serve the Dinox note editor as an MCP App over stdio (add it to an MCP Apps client such as Codex)',
48
+ options: [
49
+ {
50
+ flags: '--session <name>',
51
+ description: 'Editor session this client shares; clients with the same name see the same open note',
52
+ type: 'string',
53
+ defaultValue: 'mcp',
54
+ },
55
+ ],
56
+ schema: {
57
+ path: 'editor.mcp',
58
+ risk: 'write',
59
+ auth: 'required',
60
+ globalOptions: [],
61
+ output: { type: 'structured', summary: 'MCP JSON-RPC over stdio until stdin closes', fields: [] },
62
+ examples: ['dino editor mcp', 'dino editor mcp --session codex'],
63
+ },
64
+ action: async (context) => {
65
+ const { serveEditorMcpOverStdio } = await import('../../editor/mcp.js');
66
+ await serveEditorMcpOverStdio({ session: String(context.options.session ?? 'mcp') });
67
+ },
68
+ },
69
+ {
70
+ name: 'install',
71
+ description: 'Add the Dinox editor to an AI app (dsh: link the editor plugin into a DeepSeek Harness Desktop profile)',
72
+ arguments: [HOST_ARGUMENT],
73
+ options: [PROFILE_OPTION, DSH_OPTION, DRY_RUN_OPTION],
74
+ schema: {
75
+ path: 'editor.install',
76
+ risk: 'write',
77
+ auth: 'none',
78
+ globalOptions: FORMAT_OPTIONS,
79
+ output: {
80
+ type: 'structured',
81
+ summary: 'What was (or would be) changed in the host app',
82
+ fields: ['host', 'profile', 'profilePath', 'plugin', 'dsh', 'dryRun', 'actions', 'changed', 'restartRequired', 'next'],
83
+ },
84
+ examples: ['dino editor install dsh --dry-run', 'dino editor install dsh --format json'],
85
+ },
86
+ action: async (context) => {
87
+ hostOf(context);
88
+ const { installDsh } = await import('../../editor/install.js');
89
+ const result = await installDsh(installOptions(context));
90
+ report(result, 'Installed the Dinox editor in DeepSeek Harness:', result.next);
91
+ },
92
+ },
93
+ {
94
+ name: 'uninstall',
95
+ description: 'Remove the Dinox editor from an AI app (dsh: take the plugin out of the profile)',
96
+ arguments: [HOST_ARGUMENT],
97
+ options: [PROFILE_OPTION, DSH_OPTION, DRY_RUN_OPTION],
98
+ schema: {
99
+ path: 'editor.uninstall',
100
+ risk: 'write',
101
+ auth: 'none',
102
+ globalOptions: FORMAT_OPTIONS,
103
+ output: {
104
+ type: 'structured',
105
+ summary: 'What was (or would be) removed from the host app',
106
+ fields: ['host', 'profile', 'profilePath', 'dryRun', 'actions', 'changed', 'restartRequired'],
107
+ },
108
+ examples: ['dino editor uninstall dsh --dry-run', 'dino editor uninstall dsh'],
109
+ },
110
+ action: async (context) => {
111
+ hostOf(context);
112
+ const { uninstallDsh } = await import('../../editor/install.js');
113
+ report(await uninstallDsh(installOptions(context)), 'Removed the Dinox editor from DeepSeek Harness:', 'Restart DeepSeek Harness Desktop.');
114
+ },
115
+ },
116
+ {
117
+ name: 'status',
118
+ description: 'Show where the Dinox editor is installed (dsh, Codex) and whether it matches this CLI',
119
+ options: [PROFILE_OPTION],
120
+ schema: {
121
+ path: 'editor.status',
122
+ risk: 'read',
123
+ auth: 'none',
124
+ globalOptions: FORMAT_OPTIONS,
125
+ output: {
126
+ type: 'structured',
127
+ summary: 'This CLI, whether the editor UI is built, and each host app\'s installation',
128
+ fields: ['cli', 'ui', 'hosts'],
129
+ },
130
+ examples: ['dino editor status', 'dino editor status --format json'],
131
+ },
132
+ action: async (context) => {
133
+ const { editorStatus } = await import('../../editor/install.js');
134
+ const status = editorStatus(installOptions(context));
135
+ if (getRequestedStructuredOutputFormat()) {
136
+ printSuccess(status);
137
+ return;
138
+ }
139
+ const [dsh, codex] = status.hosts;
140
+ printHumanReadableLine(`dino ${status.cli.version} · editor UI ${status.ui.built ? 'built' : 'not built (run pnpm build)'}`);
141
+ const dshState = !dsh.installed
142
+ ? (dsh.found ? 'not installed (dino editor install dsh)' : 'DeepSeek Harness not found')
143
+ : `installed in profile ${dsh.profile}` +
144
+ (dsh.bundled ? '' : ', but missing from its bundles (rerun dino editor install dsh)') +
145
+ (dsh.linkedToThisCli ? '' : ', points at another dino') +
146
+ (dsh.upToDate ? '' : `, plugin ${dsh.pluginVersion ?? 'unknown'} (rerun dino editor install dsh)`);
147
+ printHumanReadableLine(`dsh: ${dshState}`);
148
+ printHumanReadableLine(`codex: ${codex.configured ? `configured (${codex.servers.join(', ')})` : 'not configured'}`);
149
+ },
150
+ },
151
+ ],
152
+ };
153
+ export function registerEditorCommands(program) {
154
+ registerCommandGroup(program, editorCommandGroup);
155
+ }
@@ -89,3 +89,26 @@ export declare function applyNoteContentPatch(db: AbstractPowerSyncDatabase, inp
89
89
  readToken: string;
90
90
  operation: NoteContentPatchOperation;
91
91
  }): Promise<NoteContentPatchResult>;
92
+ /** Atomically replace a reviewed editor document, preserving derived note metadata. */
93
+ export declare function replaceNoteDocument(db: AbstractPowerSyncDatabase, input: {
94
+ id: string;
95
+ userId: string;
96
+ baseHash: string;
97
+ baseVersion: number | null;
98
+ document: unknown;
99
+ }): Promise<{
100
+ status: 'saved' | 'unchanged';
101
+ noteId: string;
102
+ title: string;
103
+ hash: string;
104
+ version: number | null;
105
+ updatedAt: string | null;
106
+ } | {
107
+ status: 'conflict';
108
+ noteId: string;
109
+ current: {
110
+ hash: string;
111
+ version: number | null;
112
+ updatedAt: string | null;
113
+ };
114
+ }>;
@@ -411,3 +411,40 @@ export async function applyNoteContentPatch(db, input) {
411
411
  saved: result.changed,
412
412
  };
413
413
  }
414
+ /** Atomically replace a reviewed editor document, preserving derived note metadata. */
415
+ export async function replaceNoteDocument(db, input) {
416
+ return withPowerSyncWriteTransaction(db, async (transaction) => {
417
+ const tx = transaction;
418
+ const row = await readNoteContentRow(tx, input.id);
419
+ const before = parseStoredNoteDocument({ contentJson: row.content_json, contentMd: row.content_md });
420
+ const current = { hash: getNoteContentHash(before), version: normalizeVersion(row.version), updatedAt: row.updated_at ?? null };
421
+ if (current.hash !== input.baseHash || current.version !== input.baseVersion) {
422
+ return { status: 'conflict', noteId: row.id, current };
423
+ }
424
+ if (!input.document || typeof input.document !== 'object' || Array.isArray(input.document)
425
+ || !('type' in input.document) || input.document.type !== 'doc'
426
+ || !('content' in input.document) || !Array.isArray(input.document.content)) {
427
+ throw new DinoxError('Invalid note document: expected an object with type doc and array content', { code: 'USAGE_ERROR' });
428
+ }
429
+ // projectNoteContent applies contentEngine's private normalizeDocument, then resolves hashtags.
430
+ const tagLookup = await loadTagReferenceLookup(tx, input.userId);
431
+ const options = { resolveHashtagReference: createHashtagReferenceResolver(tagLookup, { strictMissingPaths: false }) };
432
+ const projection = projectNoteContent(input.document, options);
433
+ const hash = getNoteContentHash(projection.document);
434
+ if (hash === current.hash) {
435
+ return { status: 'unchanged', noteId: row.id, title: row.title?.trim() ?? '', ...current };
436
+ }
437
+ await updateNoteContentProjection(tx, {
438
+ rowId: row.id,
439
+ contentMd: projection.contentMd, contentJson: projection.contentJson, contentText: projection.contentText,
440
+ tags: mergeProjectedTags(parseStoredTags(row.tags), projectNoteContent(before, options).hashtags, projection.hashtags),
441
+ images: projection.images, bidLinks: projection.bidLinks,
442
+ imageDetail: deriveImageDetailFromContentJson(projection.document, row.id),
443
+ expectedVersion: current.version ?? 0,
444
+ });
445
+ const saved = await readNoteContentRow(tx, row.id);
446
+ return { status: 'saved', noteId: row.id, title: saved.title?.trim() ?? '',
447
+ hash: getNoteContentHash(parseStoredNoteDocument({ contentJson: saved.content_json, contentMd: saved.content_md })),
448
+ version: normalizeVersion(saved.version), updatedAt: saved.updated_at ?? null };
449
+ });
450
+ }
@@ -14,6 +14,7 @@ const SECTION_ORDER = [
14
14
  { title: 'Schema', paths: ['schema'] },
15
15
  { title: 'Batch', paths: ['batch'] },
16
16
  { title: 'MCP Server', paths: ['mcp'] },
17
+ { title: 'Note Co-editing', paths: ['editor.mcp', 'editor.install', 'editor.uninstall', 'editor.status'] },
17
18
  { title: 'Update CLI', paths: ['update'] },
18
19
  { title: 'Agent Skills', paths: ['skills.doctor', 'skills.migrate'] },
19
20
  { title: 'Notes', paths: ['note.search', 'note.semantic', 'note.similar', 'note.context', 'note.get', 'note.preview', 'note.detail', 'note.export', 'note.content-read', 'note.create', 'note.update', 'note.tag', 'note.move', 'note.patch', 'note.bulk', 'note.star', 'note.unstar', 'note.delete'] },
@@ -7,6 +7,7 @@ import { commandSchemasFromGroupDescriptor } from '../descriptor/register.js';
7
7
  import { standaloneCommandSchemaFromDescriptor } from '../descriptor/register.js';
8
8
  import { configCommandGroup } from '../config/index.js';
9
9
  import { gatewayCommandGroup } from '../gateway/index.js';
10
+ import { editorCommandGroup } from '../editor/index.js';
10
11
  import { daemonCommandGroup } from '../../daemon/index.js';
11
12
  import { doctorCommandDescriptor } from '../doctor.js';
12
13
  import { graphCommandGroup } from '../graph/index.js';
@@ -47,6 +48,7 @@ export const COMMAND_SCHEMAS = [
47
48
  standaloneCommandSchemaFromDescriptor(syncCommandDescriptor),
48
49
  standaloneCommandSchemaFromDescriptor(batchCommandDescriptor),
49
50
  standaloneCommandSchemaFromDescriptor(mcpCommandDescriptor),
51
+ ...commandSchemasFromGroupDescriptor(editorCommandGroup),
50
52
  standaloneCommandSchemaFromDescriptor({ ...schemaCommandMetadata, action: async () => undefined }),
51
53
  standaloneCommandSchemaFromDescriptor(infoCommandDescriptor),
52
54
  standaloneCommandSchemaFromDescriptor(updateCommandDescriptor),
@@ -27,6 +27,7 @@ export declare class DaemonServer {
27
27
  private reconnecting;
28
28
  private syncUnconfirmedSince;
29
29
  private gateways;
30
+ private editor;
30
31
  constructor(options?: {
31
32
  runtime?: {
32
33
  db: AbstractPowerSyncDatabase;
@@ -37,7 +38,7 @@ export declare class DaemonServer {
37
38
  onStopRequested?: (reason: string, details?: Record<string, unknown>) => void | Promise<void>;
38
39
  });
39
40
  initialize(): Promise<void>;
40
- handleRequest(req: DaemonRequest, onProgress?: (text: string) => void): Promise<DaemonResponse>;
41
+ handleRequest(req: DaemonRequest, onProgress?: (text: string) => void, signal?: AbortSignal): Promise<DaemonResponse>;
41
42
  private isCacheStale;
42
43
  start(port: number): Promise<void>;
43
44
  stop(): Promise<void>;
@@ -22,6 +22,7 @@ import { requestContext } from '../utils/requestContext.js';
22
22
  import { runWithRequestId } from '../requests/store.js';
23
23
  import { getDaemonInfo } from './client.js';
24
24
  import { GatewayService } from '../gateway/service.js';
25
+ import { createDaemonEditorService, EDITOR_METHODS, handleEditorRequest } from '../editor/daemon.js';
25
26
  import { readConversation } from '../gateway/conversationContext.js';
26
27
  const MAX_DAEMON_REQUEST_BYTES = 1 * 1024 * 1024;
27
28
  const DAEMON_HEALTH_CHECK_INTERVAL_MS = 60_000;
@@ -98,6 +99,7 @@ export class DaemonServer {
98
99
  reconnecting = false;
99
100
  syncUnconfirmedSince = null;
100
101
  gateways = null;
102
+ editor = null;
101
103
  constructor(options = {}) {
102
104
  this.options = options;
103
105
  if (options.runtime) {
@@ -144,15 +146,27 @@ export class DaemonServer {
144
146
  writeDaemonLogLine('dinox-gateway', 'start failed', { error: String(error) });
145
147
  });
146
148
  }
149
+ if (config.auth.userId) {
150
+ this.editor = await createDaemonEditorService(db, {
151
+ userId: config.auth.userId,
152
+ log: (message, details) => writeDaemonLogLine('dinox-editor', message, details),
153
+ }).catch((error) => {
154
+ writeDaemonLogLine('dinox-editor', 'start failed', { error: String(error) });
155
+ return null;
156
+ });
157
+ }
147
158
  // PowerSync keeps the local cache in sync continuously while connected,
148
159
  // so no background polling loop is needed here.
149
160
  }
150
- async handleRequest(req, onProgress) {
161
+ async handleRequest(req, onProgress, signal) {
151
162
  try {
152
163
  if (!this.db) {
153
164
  throw new Error('Database not initialized');
154
165
  }
155
166
  const { method, params } = req;
167
+ if (EDITOR_METHODS.has(method)) {
168
+ return { id: req.id, ok: true, result: await handleEditorRequest(this.editor, method, params, signal) };
169
+ }
156
170
  switch (method) {
157
171
  case 'command.execute': {
158
172
  const input = params;
@@ -328,7 +342,10 @@ export class DaemonServer {
328
342
  res.end(JSON.stringify(daemonRes));
329
343
  return;
330
344
  }
331
- const daemonRes = await this.handleRequest(daemonReq);
345
+ // Long-polling editor requests end early when their client goes away.
346
+ const aborted = new AbortController();
347
+ res.once('close', () => aborted.abort());
348
+ const daemonRes = await this.handleRequest(daemonReq, undefined, aborted.signal);
332
349
  res.writeHead(200, { 'Content-Type': 'application/json' });
333
350
  res.end(JSON.stringify(daemonRes));
334
351
  }
@@ -487,6 +504,9 @@ export class DaemonServer {
487
504
  const gateways = this.gateways;
488
505
  this.gateways = null;
489
506
  await gateways?.stop().catch(() => undefined);
507
+ const editor = this.editor;
508
+ this.editor = null;
509
+ await editor?.close().catch(() => undefined);
490
510
  const db = this.db;
491
511
  const releaseOwner = this.releaseOwner;
492
512
  if (db) {
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: dinox-editor
3
+ name: 'dinox-editor-dsh'