@dinoxx/dinox-cli 3.4.0 → 3.5.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.
@@ -736,7 +736,7 @@ var forwardDependencies = {
736
736
  return Boolean(info && matchesRuntimeTokenBinding(info, version, config));
737
737
  },
738
738
  ensureDaemonRunning: async () => {
739
- await (await import("./ensure-MCRPOLJB.js")).ensureDaemonRunning();
739
+ await (await import("./ensure-PW3HZZSJ.js")).ensureDaemonRunning();
740
740
  },
741
741
  sendDaemonRequest,
742
742
  envTokenOverridesLogin,
@@ -2,7 +2,7 @@ import { createRequire as __dinoxCreateRequire } from 'node:module';
2
2
  const require = __dinoxCreateRequire(import.meta.url);
3
3
  import {
4
4
  ensureDaemonRunning
5
- } from "./chunk-SD3ZE2DK.js";
5
+ } from "./chunk-K3VX75DA.js";
6
6
  import {
7
7
  WRITE_DURABILITY_OPTION,
8
8
  buildBatchWriteReceiptFields,
@@ -33,7 +33,7 @@ import {
33
33
  withCommandRuntime,
34
34
  withExclusivePowerSync,
35
35
  withNoteDatabase
36
- } from "./chunk-62T3W35C.js";
36
+ } from "./chunk-YERBRBQV.js";
37
37
  import {
38
38
  reportProgress
39
39
  } from "./chunk-52XLDO77.js";
@@ -240,10 +240,10 @@ import {
240
240
  waitForUploadQueueEmpty,
241
241
  withNestedWriteTransaction,
242
242
  withPowerSyncWriteTransaction
243
- } from "./chunk-VIWFJRN7.js";
243
+ } from "./chunk-ZPE53YBS.js";
244
244
  import {
245
245
  executeCommandLine
246
- } from "./chunk-OOYOA25J.js";
246
+ } from "./chunk-QOKO7V6A.js";
247
247
  import {
248
248
  AI_SERVICE_URL,
249
249
  FORMAT_OPTIONS,
@@ -269,7 +269,7 @@ import {
269
269
  updateConfig,
270
270
  validateRequestId,
271
271
  withAsyncRelease
272
- } from "./chunk-T7FAMGXX.js";
272
+ } from "./chunk-D7QTW6N6.js";
273
273
  import {
274
274
  TASK_STATUS_VALUES,
275
275
  isTaskStatus
@@ -3332,7 +3332,7 @@ var gatewayCommandGroup = {
3332
3332
  examples: ["dino gateway mcp"]
3333
3333
  },
3334
3334
  action: async () => {
3335
- const { serveDinoxMcpOverStdio } = await import("./mcpServer-63HXCNLX.js");
3335
+ const { serveDinoxMcpOverStdio } = await import("./mcpServer-WURTU2CQ.js");
3336
3336
  await serveDinoxMcpOverStdio();
3337
3337
  }
3338
3338
  },
@@ -3414,7 +3414,7 @@ var editorCommandGroup = {
3414
3414
  examples: ["dino editor mcp", "dino editor mcp --session codex"]
3415
3415
  },
3416
3416
  action: async (context) => {
3417
- const { serveEditorMcpOverStdio } = await import("./mcp-G54XTPLN.js");
3417
+ const { serveEditorMcpOverStdio } = await import("./mcp-OF7C72WL.js");
3418
3418
  await serveEditorMcpOverStdio({ session: String(context.options.session ?? "mcp") });
3419
3419
  }
3420
3420
  },
@@ -11340,7 +11340,7 @@ var clipCommandGroup = {
11340
11340
  examples: ["dino clip inspect https://example.com/article --format json"]
11341
11341
  },
11342
11342
  action: async (context) => {
11343
- const { runClipInspect } = await import("./run-QGJNZSF4.js");
11343
+ const { runClipInspect } = await import("./run-FUEARSZ2.js");
11344
11344
  await runClipInspect(context);
11345
11345
  }
11346
11346
  },
@@ -11398,7 +11398,7 @@ var clipCommandGroup = {
11398
11398
  ]
11399
11399
  },
11400
11400
  action: async (context) => {
11401
- const { runClipAdd } = await import("./run-QGJNZSF4.js");
11401
+ const { runClipAdd } = await import("./run-FUEARSZ2.js");
11402
11402
  await runClipAdd(context);
11403
11403
  }
11404
11404
  },
@@ -11419,7 +11419,7 @@ var clipCommandGroup = {
11419
11419
  examples: ["dino clip process 01a1e3bb-3827-790d-b850-52b187c12b53 --format json"]
11420
11420
  },
11421
11421
  action: async (context) => {
11422
- const { runClipProcess } = await import("./run-QGJNZSF4.js");
11422
+ const { runClipProcess } = await import("./run-FUEARSZ2.js");
11423
11423
  await runClipProcess(context);
11424
11424
  }
11425
11425
  },
@@ -13968,7 +13968,7 @@ function parseMcpGroups(raw) {
13968
13968
  }
13969
13969
  async function runMcp(context) {
13970
13970
  const groups = parseMcpGroups(context.options.groups);
13971
- const { serveStandaloneMcpOverStdio } = await import("./mcpServer-63HXCNLX.js");
13971
+ const { serveStandaloneMcpOverStdio } = await import("./mcpServer-WURTU2CQ.js");
13972
13972
  await serveStandaloneMcpOverStdio({ readOnly: context.options.readOnly === true, groups });
13973
13973
  }
13974
13974
  var mcpCommandDescriptor = {
@@ -4,7 +4,7 @@ import {
4
4
  hydrateResolvedAuthIdentity,
5
5
  restartDaemonLocked,
6
6
  stopDaemonLocked
7
- } from "./chunk-VIWFJRN7.js";
7
+ } from "./chunk-ZPE53YBS.js";
8
8
  import {
9
9
  daemonServiceSpec,
10
10
  fingerprintDaemonRuntimeConfig,
@@ -16,7 +16,7 @@ import {
16
16
  resolveConfig,
17
17
  usableDaemonService,
18
18
  withAsyncRelease
19
- } from "./chunk-T7FAMGXX.js";
19
+ } from "./chunk-D7QTW6N6.js";
20
20
  import {
21
21
  DEFAULT_DAEMON_PORT,
22
22
  acquireDaemonStartLock,
@@ -4,7 +4,7 @@ import {
4
4
  requestIdFromArgv,
5
5
  runWithRequestId,
6
6
  tryForwardToDaemon
7
- } from "./chunk-T7FAMGXX.js";
7
+ } from "./chunk-D7QTW6N6.js";
8
8
  import {
9
9
  localCommandExecution,
10
10
  requestContext
@@ -12,7 +12,7 @@ import {
12
12
 
13
13
  // src/requests/execute.ts
14
14
  async function runCapturedInProcess(argv, onFatalError) {
15
- const { runCli } = await import("./runCli-G4OGL7FZ.js");
15
+ const { runCli } = await import("./runCli-NSGPBNXJ.js");
16
16
  const context = {
17
17
  stdout: [],
18
18
  stderr: [],
@@ -13,13 +13,13 @@ import {
13
13
  waitForDownloadIdle,
14
14
  waitForLastSyncedAfter,
15
15
  waitForUploadQueueEmpty
16
- } from "./chunk-VIWFJRN7.js";
16
+ } from "./chunk-ZPE53YBS.js";
17
17
  import {
18
18
  fingerprintDaemonRuntimeConfig,
19
19
  loadConfig,
20
20
  parseSyncTimeoutMs,
21
21
  resolveConfig
22
- } from "./chunk-T7FAMGXX.js";
22
+ } from "./chunk-D7QTW6N6.js";
23
23
  import {
24
24
  DEFAULT_DAEMON_PORT,
25
25
  acquireDaemonExclusiveIntentLock,
@@ -24,7 +24,7 @@ import {
24
24
  toAuthorizationHeaderValue,
25
25
  withAsyncRelease,
26
26
  writeDaemonLogLine
27
- } from "./chunk-T7FAMGXX.js";
27
+ } from "./chunk-D7QTW6N6.js";
28
28
  import {
29
29
  DEFAULT_TODO_FILTER,
30
30
  TASK_STATUS_MARKDOWN_MARKER,
@@ -8122,24 +8122,69 @@ function upgradeDiagram(node, type) {
8122
8122
  ...source ? { content: [{ type: "text", text: source }] } : {}
8123
8123
  };
8124
8124
  }
8125
- function upgradeLegacyNoteNodes(value) {
8126
- if (Array.isArray(value)) {
8127
- let changed = false;
8128
- const next = value.map((item) => {
8129
- const upgraded = upgradeLegacyNoteNodes(item);
8130
- if (upgraded !== item) changed = true;
8131
- return upgraded;
8132
- });
8133
- return changed ? next : value;
8125
+ function blockId(attrs) {
8126
+ return typeof attrs.id === "string" && attrs.id ? { id: attrs.id } : {};
8127
+ }
8128
+ function nodeText(node) {
8129
+ if (typeof node.text === "string") return node.text;
8130
+ return Array.isArray(node.content) ? node.content.map((child) => nodeText(child)).join("") : "";
8131
+ }
8132
+ function firstStringAttr(attrs, keys) {
8133
+ for (const key of keys) {
8134
+ if (typeof attrs[key] === "string") return attrs[key];
8134
8135
  }
8136
+ return null;
8137
+ }
8138
+ function stripFrontmatterDelimiters(raw) {
8139
+ const text = raw.replace(/\r\n?/g, "\n").replace(/^\uFEFF/, "");
8140
+ const fenced = /^---[ \t]*\n([\s\S]*?)\n---[ \t]*$/.exec(text);
8141
+ return (fenced ? fenced[1] : text).replace(/^\n+|\n+$/g, "");
8142
+ }
8143
+ function upgradeFrontmatter(node) {
8144
+ const attrs = node.attrs ?? {};
8145
+ const source = stripFrontmatterDelimiters(firstStringAttr(attrs, ["raw"]) ?? nodeText(node));
8146
+ return {
8147
+ type: "codeBlock",
8148
+ attrs: { ...blockId(attrs), language: "yaml" },
8149
+ ...source ? { content: [{ type: "text", text: source }] } : {}
8150
+ };
8151
+ }
8152
+ var LEGACY_MATH_NODES = /* @__PURE__ */ new Set(["math", "mathBlock", "mathInline"]);
8153
+ function upgradeMath(node, type, inline) {
8154
+ const attrs = node.attrs ?? {};
8155
+ const latex = firstStringAttr(attrs, ["latex", "content"]) ?? nodeText(node);
8156
+ const isInline = type === "mathInline" || type === "math" && inline;
8157
+ return isInline ? { type: "inlineMath", attrs: { latex } } : { type: "blockMath", attrs: { ...blockId(attrs), latex } };
8158
+ }
8159
+ function upgradeNode(value, inline) {
8160
+ if (Array.isArray(value)) return upgradeChildren(value, false);
8135
8161
  if (!value || typeof value !== "object") return value;
8136
8162
  const node = value;
8137
8163
  const type = typeof node.type === "string" ? node.type : "";
8138
8164
  if (type in LEGACY_NOTE_DIAGRAM_NODES) return upgradeDiagram(node, type);
8165
+ if (type === "frontmatter") return upgradeFrontmatter(node);
8166
+ if (LEGACY_MATH_NODES.has(type)) return upgradeMath(node, type, inline);
8139
8167
  if (!Array.isArray(node.content)) return value;
8140
- const content = upgradeLegacyNoteNodes(node.content);
8168
+ const content = upgradeChildren(node.content, TEXTBLOCK_TYPES.has(type));
8141
8169
  return content === node.content ? value : { ...node, content };
8142
8170
  }
8171
+ var TEXTBLOCK_TYPES = /* @__PURE__ */ new Set(["paragraph", "heading"]);
8172
+ function upgradeChildren(children, inTextblock) {
8173
+ const inline = inTextblock || children.some((child) => {
8174
+ const type = child?.type;
8175
+ return type === "text" || type === "hardBreak" || type === "mathInline";
8176
+ });
8177
+ let changed = false;
8178
+ const next = children.map((child) => {
8179
+ const upgraded = upgradeNode(child, inline);
8180
+ if (upgraded !== child) changed = true;
8181
+ return upgraded;
8182
+ });
8183
+ return changed ? next : children;
8184
+ }
8185
+ function upgradeLegacyNoteNodes(value) {
8186
+ return upgradeNode(value, false);
8187
+ }
8143
8188
 
8144
8189
  // ../../packages/note-schema/src/spec/index.ts
8145
8190
  var nul = { default: null };
@@ -24154,6 +24199,90 @@ function isPublicFlag(value) {
24154
24199
  return Number(value) === 1;
24155
24200
  }
24156
24201
 
24202
+ // src/editor/tree.ts
24203
+ var TREE_INBOX = "inbox";
24204
+ var ACTIVE_TOP_LEVEL = `(n.is_del IS NULL OR n.is_del = 0) AND (n.parent_id IS NULL OR TRIM(n.parent_id) = '')`;
24205
+ var BOX_ITEMS = `json_each(CASE WHEN json_valid(COALESCE(n.zettel_boxes, '')) THEN n.zettel_boxes ELSE '[]' END)`;
24206
+ var NO_BOX = `NOT EXISTS (SELECT 1 FROM ${BOX_ITEMS} b WHERE TRIM(CAST(b.value AS TEXT)) <> '')`;
24207
+ function createTreeSource(db) {
24208
+ async function level(parent, offset, limit) {
24209
+ if (parent === TREE_INBOX) return { folders: [], ...await notesIn(null, offset, limit) };
24210
+ const boxes = await listBoxes(db);
24211
+ const known = new Set(boxes.map((box) => box.id));
24212
+ const counts = new Map(
24213
+ (await db.getAll(
24214
+ `SELECT TRIM(CAST(b.value AS TEXT)) AS id, COUNT(DISTINCT n.id) AS n FROM c_note n, ${BOX_ITEMS} b WHERE ${ACTIVE_TOP_LEVEL} GROUP BY 1`
24215
+ )).map((row) => [row.id, Number(row.n) || 0])
24216
+ );
24217
+ const subfolders = /* @__PURE__ */ new Map();
24218
+ for (const box of boxes) {
24219
+ const at = box.parentId && known.has(box.parentId) ? box.parentId : "";
24220
+ subfolders.set(at, (subfolders.get(at) ?? 0) + 1);
24221
+ }
24222
+ const folders = boxes.filter((box) => (box.parentId && known.has(box.parentId) ? box.parentId : null) === parent).sort((a, b) => a.name.localeCompare(b.name, "zh-Hans-CN", { numeric: true })).map((box) => ({
24223
+ id: box.id,
24224
+ name: box.name,
24225
+ path: box.path,
24226
+ color: box.color,
24227
+ folders: subfolders.get(box.id) ?? 0,
24228
+ notes: counts.get(box.id) ?? 0
24229
+ }));
24230
+ if (parent === null) {
24231
+ const inbox = await db.getOptional(`SELECT COUNT(*) AS n FROM c_note n WHERE ${ACTIVE_TOP_LEVEL} AND ${NO_BOX}`);
24232
+ return { folders, notes: [], more: 0, inbox: Number(inbox?.n) || 0 };
24233
+ }
24234
+ return { folders, ...await notesIn(parent, offset, limit) };
24235
+ }
24236
+ async function notesIn(boxId, offset, limit) {
24237
+ const where = boxId === null ? `${ACTIVE_TOP_LEVEL} AND ${NO_BOX}` : `${ACTIVE_TOP_LEVEL} AND EXISTS (SELECT 1 FROM ${BOX_ITEMS} b WHERE TRIM(CAST(b.value AS TEXT)) = ?)`;
24238
+ const params = boxId === null ? [] : [boxId];
24239
+ const total = Number((await db.getOptional(`SELECT COUNT(*) AS n FROM c_note n WHERE ${where}`, params))?.n) || 0;
24240
+ const rows = await db.getAll(
24241
+ `SELECT n.id, n.title, n.updated_at, n.created_at, n.is_top, n.type FROM c_note n WHERE ${where}
24242
+ ORDER BY CAST(COALESCE(n.is_top, 0) AS INTEGER) DESC, COALESCE(n.updated_at, n.created_at) DESC, n.id DESC
24243
+ LIMIT ? OFFSET ?`,
24244
+ [...params, limit, offset]
24245
+ );
24246
+ return {
24247
+ notes: rows.map((row) => ({
24248
+ id: row.id,
24249
+ title: row.title?.trim() ?? "",
24250
+ updatedAt: row.updated_at ?? row.created_at ?? null,
24251
+ pinned: Number(row.is_top ?? 0) > 0,
24252
+ type: row.type === "crawl" ? "crawl" : "note"
24253
+ })),
24254
+ more: Math.max(0, total - offset - rows.length)
24255
+ };
24256
+ }
24257
+ async function expandTags(names) {
24258
+ if (!names.length) return [];
24259
+ const all = await listTags(db);
24260
+ return names.map((name) => {
24261
+ const wanted = name.toLowerCase();
24262
+ const matches = all.filter((tag) => {
24263
+ const lower = tag.toLowerCase();
24264
+ return lower === wanted || lower.startsWith(`${wanted}/`);
24265
+ });
24266
+ return matches.length ? matches : [name];
24267
+ });
24268
+ }
24269
+ return { level, expandTags };
24270
+ }
24271
+ function parseTreeQuery(query) {
24272
+ const tags = [];
24273
+ const text = query.split(/\s+/).filter((term) => {
24274
+ const match = /^[##](.+)$/.exec(term);
24275
+ if (!match) return true;
24276
+ tags.push(match[1].replace(/[##]+$/, ""));
24277
+ return false;
24278
+ }).join(" ").trim();
24279
+ return { text, tags: [...new Set(tags.filter(Boolean))] };
24280
+ }
24281
+ function tagExpression(groups) {
24282
+ const parts = groups.map((group) => group.filter((tag) => !tag.includes('"')).map((tag) => `"${tag}"`)).filter((group) => group.length).map((group) => group.length > 1 ? `(${group.join(" OR ")})` : group[0]);
24283
+ return parts.length ? parts.join(" AND ") : void 0;
24284
+ }
24285
+
24157
24286
  // src/commands/savedViews/fields.ts
24158
24287
  var SYSTEM_FIELD_META = {
24159
24288
  "sys.title": { name: "Title", propertyType: "text", type: "text" },
@@ -24975,11 +25104,13 @@ function createEditorStore(db, options2) {
24975
25104
  return row;
24976
25105
  };
24977
25106
  const meta = createMetaStore(db, options2.userId);
25107
+ const tree = createTreeSource(db);
24978
25108
  return {
24979
25109
  meta: meta.meta,
24980
25110
  catalog: meta.catalog,
24981
25111
  updateMeta: meta.update,
24982
25112
  trash: meta.trash,
25113
+ tree: tree.level,
24983
25114
  views: () => listEditorViews(db, options2.userId),
24984
25115
  viewEmbed: (request) => fetchEditorViewEmbed(db, options2.userId, request),
24985
25116
  async load(noteId) {
@@ -24993,8 +25124,10 @@ function createEditorStore(db, options2) {
24993
25124
  return { status: result.status, hash: result.hash, version: result.version, updatedAt: result.updatedAt };
24994
25125
  },
24995
25126
  async search(query, limit) {
24996
- if (query.trim()) await syncNoteTokenIndex(db);
24997
- const { rows } = await searchNotesPage(db, query, { includeDeleted: false, limit, offset: 0 });
25127
+ const { text, tags } = parseTreeQuery(query);
25128
+ if (text) await syncNoteTokenIndex(db);
25129
+ const tagsExpression = tagExpression(await tree.expandTags(tags));
25130
+ const { rows } = await searchNotesPage(db, text, { includeDeleted: false, limit, offset: 0, tagsExpression });
24998
25131
  if (!rows.length) return [];
24999
25132
  const dates = await db.getAll(
25000
25133
  `SELECT id, updated_at FROM c_note WHERE id IN (${rows.map(() => "?").join(",")})`,
@@ -25588,6 +25721,7 @@ function parseEditorUpload(input) {
25588
25721
 
25589
25722
  // src/editor/service.ts
25590
25723
  var MAX_TODO_SUGGESTIONS = 10;
25724
+ var TREE_PAGE = 100;
25591
25725
  var MAX_KEY_LENGTH = 200;
25592
25726
  var MAX_ACTIVITY = 80;
25593
25727
  var MAX_SUGGESTIONS = 50;
@@ -25883,19 +26017,19 @@ var EditorService = class {
25883
26017
  const edit = raw;
25884
26018
  const reason = str2(edit.reason, "reason", { optional: true, max: 2e3 }) ?? "";
25885
26019
  const base = { id: `s${randomUUID2().slice(0, 8)}`, reason, status: "pending", createdAt: new Date(this.now()).toISOString() };
25886
- const blockId = typeof edit.block === "string" ? blockRef(session.blocks, edit.block.trim()) : void 0;
26020
+ const blockId2 = typeof edit.block === "string" ? blockRef(session.blocks, edit.block.trim()) : void 0;
25887
26021
  if (edit.comment !== void 0 || edit.kind === "comment") {
25888
26022
  const comment = str2(edit.comment, "comment", { max: 4e3 }).trim();
25889
26023
  if (!comment) throw usage2("comment must not be empty");
25890
26024
  const find2 = edit.find === void 0 || edit.find === "" ? void 0 : str2(edit.find, "find", { max: 2e4 });
25891
- if (blockId) {
25892
- const block = session.blocks[this.blockIndex(session, blockId)];
26025
+ if (blockId2) {
26026
+ const block = session.blocks[this.blockIndex(session, blockId2)];
25893
26027
  if (find2 === void 0) {
25894
- if (!block.text) throw usage2(`${blockId} is empty; there is nothing to comment on`);
25895
- return { ...base, kind: "comment", block: blockId, find: block.text, comment, anchor: block.text, at: block.start };
26028
+ if (!block.text) throw usage2(`${blockId2} is empty; there is nothing to comment on`);
26029
+ return { ...base, kind: "comment", block: blockId2, find: block.text, comment, anchor: block.text, at: block.start };
25896
26030
  }
25897
- const located3 = this.locate(block.text, find2, "find", blockId);
25898
- return { ...base, kind: "comment", block: blockId, find: find2, comment, anchor: located3.anchor, at: block.start + located3.start };
26031
+ const located3 = this.locate(block.text, find2, "find", blockId2);
26032
+ return { ...base, kind: "comment", block: blockId2, find: find2, comment, anchor: located3.anchor, at: block.start + located3.start };
25899
26033
  }
25900
26034
  if (find2 === void 0) throw usage2("a comment needs block (and optionally find), or find");
25901
26035
  const located2 = this.locate(session.plainText, find2, "find");
@@ -25904,7 +26038,7 @@ var EditorService = class {
25904
26038
  if (edit.markdown !== void 0 || edit.kind === "insert") {
25905
26039
  const markdown = str2(edit.markdown, "markdown", { max: 5e4 });
25906
26040
  if (!markdown.trim()) throw usage2("markdown must not be empty");
25907
- const after = blockRef(session.blocks, (str2(edit.after ?? blockId, "after", { max: 2e4 }) ?? "").trim());
26041
+ const after = blockRef(session.blocks, (str2(edit.after ?? blockId2, "after", { max: 2e4 }) ?? "").trim());
25908
26042
  if (!after) throw usage2('an insert needs after: a block id, "start" or "end"');
25909
26043
  if (after === "end" || after === "<end>") return { ...base, kind: "insert", after: "<end>", markdown, anchor: "<end>" };
25910
26044
  if (after === "start" || after === "<start>") return { ...base, kind: "insert", after: "<start>", markdown, anchor: "<start>" };
@@ -25920,22 +26054,22 @@ var EditorService = class {
25920
26054
  if (edit.replace === void 0) throw usage2("each edit needs {block, replace}, {block, find, replace}, {after, markdown} or {block, find?, comment}");
25921
26055
  const replace = str2(edit.replace, "replace", { max: 5e4 });
25922
26056
  const find = edit.find === void 0 || edit.find === "" ? void 0 : str2(edit.find, "find", { max: 2e4 });
25923
- if (blockId) {
25924
- const block = session.blocks[this.blockIndex(session, blockId)];
26057
+ if (blockId2) {
26058
+ const block = session.blocks[this.blockIndex(session, blockId2)];
25925
26059
  if (find !== void 0) {
25926
- const located2 = this.locate(block.text, find, "find", blockId);
25927
- return { ...base, kind: "replace", block: blockId, find, replace, anchor: located2.anchor, at: block.start + located2.start };
26060
+ const located2 = this.locate(block.text, find, "find", blockId2);
26061
+ return { ...base, kind: "replace", block: blockId2, find, replace, anchor: located2.anchor, at: block.start + located2.start };
25928
26062
  }
25929
- if (!block.text) throw usage2(`${blockId} is empty; add content with {after: "${blockId}", markdown} instead`);
25930
- return { ...base, kind: "replace", block: blockId, find: block.text, replace: withoutLinePrefix(block.md, replace), anchor: block.text, at: block.start };
26063
+ if (!block.text) throw usage2(`${blockId2} is empty; add content with {after: "${blockId2}", markdown} instead`);
26064
+ return { ...base, kind: "replace", block: blockId2, find: block.text, replace: withoutLinePrefix(block.md, replace), anchor: block.text, at: block.start };
25931
26065
  }
25932
26066
  if (find === void 0) throw usage2("a replace needs block (and optionally find), or find");
25933
26067
  const located = this.locate(session.plainText, find, "find");
25934
26068
  return { ...base, kind: "replace", find, replace, anchor: located.anchor, at: located.start, block: this.blockAt(session, located.start)?.id };
25935
26069
  }
25936
- locate(text, find, name, blockId) {
26070
+ locate(text, find, name, blockId2) {
25937
26071
  const located = locateAnchor(text, find);
25938
- const where = blockId ? ` in ${blockId}` : " in the note";
26072
+ const where = blockId2 ? ` in ${blockId2}` : " in the note";
25939
26073
  if (located.status === "missing") {
25940
26074
  throw new DinoxError(`${name} "${clip2(find, 60)}" does not occur${where}; read the note again and quote it exactly.`, {
25941
26075
  code: "EDITOR_ANCHOR_MISSING",
@@ -25943,7 +26077,7 @@ var EditorService = class {
25943
26077
  });
25944
26078
  }
25945
26079
  if (located.status === "ambiguous") {
25946
- throw new DinoxError(`${name} "${clip2(find, 60)}" occurs ${located.count} times${where}; ${blockId ? "quote more of the block" : "name the block, or quote more text"} so it is unique.`, {
26080
+ throw new DinoxError(`${name} "${clip2(find, 60)}" occurs ${located.count} times${where}; ${blockId2 ? "quote more of the block" : "name the block, or quote more text"} so it is unique.`, {
25947
26081
  code: "EDITOR_ANCHOR_AMBIGUOUS",
25948
26082
  recoverable: true,
25949
26083
  details: { count: located.count }
@@ -26026,9 +26160,16 @@ var EditorService = class {
26026
26160
  }
26027
26161
  async search(input) {
26028
26162
  const query = str2(input.query ?? "", "query", { max: 500 });
26029
- const limit = Math.max(1, Math.min(20, Number(input.limit) || 10));
26163
+ const limit = Math.max(1, Math.min(50, Number(input.limit) || 10));
26030
26164
  return this.options.store.search(query, limit);
26031
26165
  }
26166
+ /** One level of the sidebar's file tree: `parent` null is the root, `'inbox'` the unfiled notes. */
26167
+ async tree(input) {
26168
+ if (!this.options.store.tree) throw new DinoxError("This editor has no note tree.", { code: "COMMAND_FAILED", recoverable: false });
26169
+ const parent = input.parent == null || input.parent === "" ? null : str2(input.parent, "parent", { max: 200 });
26170
+ const offset = Math.max(0, Math.min(1e6, Math.trunc(Number(input.offset) || 0)));
26171
+ return this.options.store.tree(parent, offset, TREE_PAGE);
26172
+ }
26032
26173
  /** The todo list for the panel; a `filter` it sends becomes the session's, so a reopened panel keeps it. */
26033
26174
  async todos(key, input) {
26034
26175
  const session = this.session(key);
@@ -26827,6 +26968,7 @@ var EDITOR_METHODS = /* @__PURE__ */ new Set([
26827
26968
  "editor.updateMeta",
26828
26969
  "editor.trash",
26829
26970
  "editor.share",
26971
+ "editor.tree",
26830
26972
  "editor.watchOpens",
26831
26973
  "editor.showTodos",
26832
26974
  "editor.todos",
@@ -26875,6 +27017,8 @@ async function handleEditorRequest(service, method, params, signal) {
26875
27017
  return service.trash(session, input);
26876
27018
  case "editor.share":
26877
27019
  return service.share(session, input);
27020
+ case "editor.tree":
27021
+ return service.tree(input);
26878
27022
  case "editor.watchOpens":
26879
27023
  return service.watchOpens(input, signal);
26880
27024
  case "editor.showTodos":
@@ -27068,7 +27212,7 @@ var DaemonServer = class {
27068
27212
  }
27069
27213
  };
27070
27214
  const execute = async () => {
27071
- const { runCli } = await import("./runCli-G4OGL7FZ.js");
27215
+ const { runCli } = await import("./runCli-NSGPBNXJ.js");
27072
27216
  const exitCode = await requestContext.run(context, () => runCli(input.argv));
27073
27217
  return { stdout: context.stdout.join(""), stderr: context.stderr.join(""), exitCode };
27074
27218
  };
@@ -2,9 +2,9 @@ import { createRequire as __dinoxCreateRequire } from 'node:module';
2
2
  const require = __dinoxCreateRequire(import.meta.url);
3
3
  import {
4
4
  ensureDaemonRunning
5
- } from "./chunk-SD3ZE2DK.js";
6
- import "./chunk-VIWFJRN7.js";
7
- import "./chunk-T7FAMGXX.js";
5
+ } from "./chunk-K3VX75DA.js";
6
+ import "./chunk-ZPE53YBS.js";
7
+ import "./chunk-D7QTW6N6.js";
8
8
  import "./chunk-JNRA4TTH.js";
9
9
  import "./chunk-YFGDTC2F.js";
10
10
  import "./chunk-7ODU7LXP.js";
@@ -3,8 +3,8 @@ const require = __dinoxCreateRequire(import.meta.url);
3
3
  import {
4
4
  executeCommandLine,
5
5
  runCapturedInProcess
6
- } from "./chunk-OOYOA25J.js";
7
- import "./chunk-T7FAMGXX.js";
6
+ } from "./chunk-QOKO7V6A.js";
7
+ import "./chunk-D7QTW6N6.js";
8
8
  import "./chunk-YFGDTC2F.js";
9
9
  import "./chunk-WMJXAF3X.js";
10
10
  import "./chunk-TOGYWN3D.js";
@@ -27,7 +27,7 @@ import { z } from "zod";
27
27
  var EDITOR_RESOURCE_URI = "ui://dinox/editor";
28
28
  var EDITOR_SESSION_META_KEY = "dinox.ai/editorSession";
29
29
  var IMAGE_DOMAINS = ["https://bitiful.chatgo.pro", "https://*.chatgo.pro", "https://*.dinox.info"];
30
- var UI_METHODS = ["sync", "save", "resolve", "search", "excerpt", "open", "log", "catalog", "updateMeta", "trash", "share", "watchOpens", "todos", "todoUpdate", "todoAppend", "todoRestore", "todoSuggestion", "upload", "linkPreview", "views", "viewEmbed"];
30
+ var UI_METHODS = ["sync", "save", "resolve", "search", "excerpt", "open", "log", "catalog", "updateMeta", "trash", "share", "tree", "watchOpens", "todos", "todoUpdate", "todoAppend", "todoRestore", "todoSuggestion", "upload", "linkPreview", "views", "viewEmbed"];
31
31
  var SYNC_TIMEOUT_GRACE_MS = 1e4;
32
32
  var DEFAULT_TIMEOUT_MS = 3e4;
33
33
  var UPLOAD_TIMEOUT_MS = 15 * 6e4;
@@ -271,7 +271,7 @@ function createEditorMcpServer(options = {}) {
271
271
  return server;
272
272
  }
273
273
  async function serveEditorMcpOverStdio(options = {}) {
274
- const { ensureDaemonRunning } = await import("./ensure-MCRPOLJB.js");
274
+ const { ensureDaemonRunning } = await import("./ensure-PW3HZZSJ.js");
275
275
  let ensured = null;
276
276
  const ensure = () => ensured ??= ensureDaemonRunning().finally(() => {
277
277
  ensured = null;
@@ -3,9 +3,9 @@ const require = __dinoxCreateRequire(import.meta.url);
3
3
  import {
4
4
  MCP_COMMAND_GROUPS,
5
5
  listCommandSchemas
6
- } from "./chunk-MDRD6FX5.js";
7
- import "./chunk-SD3ZE2DK.js";
8
- import "./chunk-62T3W35C.js";
6
+ } from "./chunk-EPY4F7CC.js";
7
+ import "./chunk-K3VX75DA.js";
8
+ import "./chunk-YERBRBQV.js";
9
9
  import "./chunk-52XLDO77.js";
10
10
  import {
11
11
  DINOX_MCP_SERVER_NAME,
@@ -14,11 +14,11 @@ import {
14
14
  GATEWAY_SESSION_CWD_ENV,
15
15
  GATEWAY_SESSION_TOKEN_ENV,
16
16
  READ_CONVERSATION_MAX_LIMIT
17
- } from "./chunk-VIWFJRN7.js";
18
- import "./chunk-OOYOA25J.js";
17
+ } from "./chunk-ZPE53YBS.js";
18
+ import "./chunk-QOKO7V6A.js";
19
19
  import {
20
20
  tryForwardToDaemon
21
- } from "./chunk-T7FAMGXX.js";
21
+ } from "./chunk-D7QTW6N6.js";
22
22
  import {
23
23
  TASK_STATUS_VALUES
24
24
  } from "./chunk-JNRA4TTH.js";
@@ -64,7 +64,7 @@ function createCliCommandRunner(overrides = {}) {
64
64
  noticeProvider: null,
65
65
  cwd: process.cwd()
66
66
  };
67
- const { printCliError } = await import("./runCli-G4OGL7FZ.js");
67
+ const { printCliError } = await import("./runCli-NSGPBNXJ.js");
68
68
  const code = requestContext.run(context, () => printCliError(error, argv));
69
69
  throw Object.assign(new Error(`Command failed with exit code ${code}`), {
70
70
  code,
@@ -25,7 +25,7 @@ import {
25
25
  syncBeforeNoteCommand,
26
26
  waitForMutationUpload,
27
27
  withNoteDatabase
28
- } from "./chunk-62T3W35C.js";
28
+ } from "./chunk-YERBRBQV.js";
29
29
  import {
30
30
  reportProgress
31
31
  } from "./chunk-52XLDO77.js";
@@ -36,7 +36,7 @@ import {
36
36
  resolveZettelBoxIdsForCreate,
37
37
  uploadToOfficialStorage,
38
38
  validateTagsForCreate
39
- } from "./chunk-VIWFJRN7.js";
39
+ } from "./chunk-ZPE53YBS.js";
40
40
  import {
41
41
  isWorkbuddyUrl,
42
42
  normalizeWorkbuddyUrl
@@ -140,7 +140,7 @@ import {
140
140
  AI_SERVICE_URL,
141
141
  generateId,
142
142
  toAuthorizationHeaderValue
143
- } from "./chunk-T7FAMGXX.js";
143
+ } from "./chunk-D7QTW6N6.js";
144
144
  import "./chunk-JNRA4TTH.js";
145
145
  import "./chunk-YFGDTC2F.js";
146
146
  import "./chunk-7ODU7LXP.js";
@@ -27,21 +27,21 @@ import {
27
27
  registerTodoCommands,
28
28
  registerUpdateCommand,
29
29
  schemaCommandMetadata
30
- } from "./chunk-MDRD6FX5.js";
31
- import "./chunk-SD3ZE2DK.js";
32
- import "./chunk-62T3W35C.js";
30
+ } from "./chunk-EPY4F7CC.js";
31
+ import "./chunk-K3VX75DA.js";
32
+ import "./chunk-YERBRBQV.js";
33
33
  import {
34
34
  setProgressReporting
35
35
  } from "./chunk-52XLDO77.js";
36
36
  import {
37
37
  registerDaemonCommands,
38
38
  registerStandaloneCommand
39
- } from "./chunk-VIWFJRN7.js";
40
- import "./chunk-OOYOA25J.js";
39
+ } from "./chunk-ZPE53YBS.js";
40
+ import "./chunk-QOKO7V6A.js";
41
41
  import {
42
42
  GLOBAL_VALUE_OPTIONS,
43
43
  validateRequestId
44
- } from "./chunk-T7FAMGXX.js";
44
+ } from "./chunk-D7QTW6N6.js";
45
45
  import "./chunk-JNRA4TTH.js";
46
46
  import "./chunk-YFGDTC2F.js";
47
47
  import "./chunk-7ODU7LXP.js";
package/dist/dinox.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  requestIdFromArgv,
7
7
  runWithRequestId,
8
8
  tryForwardToDaemon
9
- } from "./chunks/chunk-T7FAMGXX.js";
9
+ } from "./chunks/chunk-D7QTW6N6.js";
10
10
  import "./chunks/chunk-YFGDTC2F.js";
11
11
  import {
12
12
  getPackageVersion
@@ -121,10 +121,10 @@ try {
121
121
  process.stderr.write(forwarded.stderr);
122
122
  process.exitCode = forwarded.exitCode;
123
123
  } else {
124
- const { runCli } = await import("./chunks/runCli-G4OGL7FZ.js");
124
+ const { runCli } = await import("./chunks/runCli-NSGPBNXJ.js");
125
125
  const key = requestIdFromArgv(argv);
126
126
  if (key && commandExecutionTarget(argv) === "daemon") {
127
- const { runCapturedInProcess } = await import("./chunks/execute-4OIOIVML.js");
127
+ const { runCapturedInProcess } = await import("./chunks/execute-DSHVATUX.js");
128
128
  const result = await runWithRequestId(key, argv, () => runCapturedInProcess(argv, (error) => {
129
129
  fatalError = error;
130
130
  }));
@@ -138,7 +138,7 @@ try {
138
138
  }
139
139
  }
140
140
  } catch (error) {
141
- const { printCliError } = await import("./chunks/runCli-G4OGL7FZ.js");
141
+ const { printCliError } = await import("./chunks/runCli-NSGPBNXJ.js");
142
142
  process.exitCode = printCliError(error, argv);
143
143
  }
144
144
  if (isDinoxError(fatalError) && fatalError.requiresProcessExit) {