@dinoxx/dinox-cli 2.20.1 → 3.0.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 (58) hide show
  1. package/README.md +17 -16
  2. package/dist/chunks/{applePodcast-V4FSJOC5.js → applePodcast-YDYM4JYQ.js} +3 -3
  3. package/dist/chunks/{bbc-NTMRPYRF.js → bbc-N3BM2EGG.js} +3 -3
  4. package/dist/chunks/{bilibili-UA3MBSPH.js → bilibili-V4XVW33T.js} +63 -9
  5. package/dist/chunks/{bohaishibei-B7UVXH4Y.js → bohaishibei-IQO5CZTN.js} +3 -3
  6. package/dist/chunks/{chunk-BKCNERPB.js → chunk-2DREJFKB.js} +98 -17
  7. package/dist/chunks/{chunk-X7JXCHLI.js → chunk-ARBWJ3ZA.js} +4176 -2821
  8. package/dist/chunks/{chunk-XMMTGPZ6.js → chunk-AZ43P73A.js} +56 -2
  9. package/dist/chunks/{chunk-PGR7R2HI.js → chunk-HG3RZFDX.js} +3 -3
  10. package/dist/chunks/{chunk-VI7C4BBS.js → chunk-KJBN7TD7.js} +3 -3
  11. package/dist/chunks/{chunk-FIQYJ6KZ.js → chunk-LLAXR5EG.js} +1 -1
  12. package/dist/chunks/{chunk-TILRKKRN.js → chunk-MKEL2KNU.js} +893 -468
  13. package/dist/chunks/{chunk-FGQRYB7F.js → chunk-MZMOE3RX.js} +13 -1
  14. package/dist/chunks/{chunk-53CT7DJ3.js → chunk-N2VYTZWU.js} +2 -2
  15. package/dist/chunks/{chunk-XEPDFQYD.js → chunk-N5YDNM3P.js} +26 -26
  16. package/dist/chunks/{chunk-YDIE7QBM.js → chunk-NVKSI4BD.js} +671 -159
  17. package/dist/chunks/{chunk-QFUD3I7W.js → chunk-QPVGA46P.js} +0 -1
  18. package/dist/chunks/{chunk-6AZT4ARG.js → chunk-R2CGNGOT.js} +3 -3
  19. package/dist/chunks/{chunk-GTDX2LIJ.js → chunk-RSSEVU2F.js} +58 -10
  20. package/dist/chunks/{chunk-G6JSWE66.js → chunk-WABL3OUP.js} +2 -2
  21. package/dist/chunks/{cookies-6QQHSM26.js → cookies-ORQ3RLAH.js} +1 -3
  22. package/dist/chunks/{doubanGroup-HR4K2KMY.js → doubanGroup-MADXDGDI.js} +4 -4
  23. package/dist/chunks/{doubao-MXUHPLUB.js → doubao-DKZERP6Y.js} +2 -2
  24. package/dist/chunks/{douyin-UU2FSQPS.js → douyin-PIWFZHK7.js} +91 -5
  25. package/dist/chunks/{ensure-CHJ5YTBX.js → ensure-MPOQ244L.js} +5 -5
  26. package/dist/chunks/{execute-RXJ4AO2Z.js → execute-KMNZ5EFR.js} +3 -3
  27. package/dist/chunks/{facebook-SZFOVE7R.js → facebook-TI2CF5UY.js} +2 -2
  28. package/dist/chunks/{feishu-ISWRJ7HI.js → feishu-XSSEBWQD.js} +2 -2
  29. package/dist/chunks/{ima-D7CX5WR4.js → ima-SKE2C64C.js} +2 -2
  30. package/dist/chunks/{instagram-HNDPO37H.js → instagram-4W4HCWJN.js} +2 -2
  31. package/dist/chunks/{install-IIMVFNAT.js → install-35YBLHXE.js} +0 -2
  32. package/dist/chunks/{jike-H7L4LJTN.js → jike-GS64MEEO.js} +4 -4
  33. package/dist/chunks/{mcp-NMKVOSVN.js → mcp-H667ML2O.js} +9 -9
  34. package/dist/chunks/{mcpServer-NYJAKMVH.js → mcpServer-G2WEAD2O.js} +13 -11
  35. package/dist/chunks/{metaso-ZVZW5UBB.js → metaso-RRYEUXIL.js} +2 -2
  36. package/dist/chunks/{run-ETPFUFB6.js → run-7D6ATULD.js} +7 -7
  37. package/dist/chunks/{runCli-GJRY73UA.js → runCli-QEWWUIZN.js} +8 -8
  38. package/dist/chunks/{setup-EEU6GSWX.js → setup-DSTOF3BZ.js} +2 -2
  39. package/dist/chunks/{threads-ADW6IANQ.js → threads-JKMT3E73.js} +3 -3
  40. package/dist/chunks/{twitter-NAGCB3NI.js → twitter-WNBOJELM.js} +2 -2
  41. package/dist/chunks/{web-QFKZCM4F.js → web-LJESVHHV.js} +4 -4
  42. package/dist/chunks/{wechat-OXNNLT4J.js → wechat-N7O77CB4.js} +40 -1
  43. package/dist/chunks/{weibo-PMVGDNQU.js → weibo-XPEV5CLQ.js} +4 -4
  44. package/dist/chunks/{workbuddy-NNAXIIIZ.js → workbuddy-ZXNDX7O7.js} +5 -5
  45. package/dist/chunks/{xiaoheihe-WFQJRBAD.js → xiaoheihe-WXFAORLQ.js} +3 -3
  46. package/dist/chunks/{xiaohongshu-5CXBELGW.js → xiaohongshu-3N3ZVSXJ.js} +2 -2
  47. package/dist/chunks/{xiaoyuzhou-6L6IB46Y.js → xiaoyuzhou-OGIWFABL.js} +3 -3
  48. package/dist/chunks/{youtube-52NGBTQC.js → youtube-YRSK7CWC.js} +3 -3
  49. package/dist/chunks/{zcool-HDSWK4KD.js → zcool-K5KJ2KDG.js} +2 -2
  50. package/dist/chunks/{zhihu-EX2VRJYY.js → zhihu-X6XSPD6B.js} +2 -2
  51. package/dist/dinox.js +5 -5
  52. package/dist/dsh-plugin/lib/client.js +309 -567
  53. package/dist/dsh-plugin/lib/index.js +1 -1
  54. package/dist/dsh-plugin/package.json +1 -1
  55. package/dist/dsh-plugin/runtime.json +2 -2
  56. package/dist/editor-ui/mcp-app.html +356 -592
  57. package/package.json +22 -12
  58. /package/dist/chunks/{chunk-QFSMFANX.js → chunk-SM2QOO45.js} +0 -0
@@ -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-VI7C4BBS.js";
5
+ } from "./chunk-KJBN7TD7.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-PGR7R2HI.js";
36
+ } from "./chunk-HG3RZFDX.js";
37
37
  import {
38
38
  reportProgress
39
39
  } from "./chunk-BZQYECIH.js";
@@ -42,7 +42,9 @@ import {
42
42
  DEFAULT_DAEMON_PORT,
43
43
  MAX_BOX_NAME_LENGTH,
44
44
  MAX_TAG_SEGMENT_LENGTH,
45
+ NOTE_PROPERTY_LIMITS,
45
46
  PROPERTY_OPTION_COLORS,
47
+ PROPERTY_OPTION_LABEL_MAX_LENGTH,
46
48
  REQUIRED_NOTE_BOX_COLUMNS,
47
49
  REQUIRED_NOTE_TAG_COLUMNS,
48
50
  REQUIRED_TAG_NODE_COLUMNS,
@@ -81,6 +83,7 @@ import {
81
83
  canonicalizeBoxPath,
82
84
  canonicalizeTagPath,
83
85
  closePowerSyncAndReleaseOwner,
86
+ coercePropertyValue,
84
87
  commandSchemasFromGroupDescriptor,
85
88
  configureProperty,
86
89
  connectPowerSync,
@@ -106,6 +109,7 @@ import {
106
109
  ensureNoTagPathConflict,
107
110
  executeNoteSearch,
108
111
  executeTodoSearch,
112
+ extractMarkdownFrontmatter,
109
113
  fetchCredentialsWithAuthorization,
110
114
  fetchDomainReadModel,
111
115
  fetchSavedViewScopedPage,
@@ -161,6 +165,7 @@ import {
161
165
  migrateLegacyOptions,
162
166
  migrationAffectedCount,
163
167
  normalizeBoxLookupKey,
168
+ normalizeDatePropertyValue,
164
169
  normalizePropertyDefConfig,
165
170
  normalizeTagLookupKey,
166
171
  normalizeTaskTexts,
@@ -168,6 +173,7 @@ import {
168
173
  nowIsoUtc,
169
174
  parentIdForPath,
170
175
  parentPathOf,
176
+ parseRawNoteProperties,
171
177
  parseSavedViewZettelBoxDetails,
172
178
  parseStorageUploadCategory,
173
179
  parseStoredBoxIds,
@@ -226,6 +232,7 @@ import {
226
232
  updateNotePropertySlots,
227
233
  updateTodoTaskStatus,
228
234
  updateTodoTasks,
235
+ upgradeLegacyNoteNodes,
229
236
  validateTagsForBulk,
230
237
  validateTagsForCreate,
231
238
  validateTagsForUpdate,
@@ -235,10 +242,10 @@ import {
235
242
  withNestedWriteTransaction,
236
243
  withPowerSyncWriteTransaction,
237
244
  withReadTransaction
238
- } from "./chunk-X7JXCHLI.js";
245
+ } from "./chunk-ARBWJ3ZA.js";
239
246
  import {
240
247
  executeCommandLine
241
- } from "./chunk-53CT7DJ3.js";
248
+ } from "./chunk-N2VYTZWU.js";
242
249
  import {
243
250
  AI_SERVICE_URL,
244
251
  FORMAT_OPTIONS,
@@ -264,7 +271,11 @@ import {
264
271
  updateConfig,
265
272
  validateRequestId,
266
273
  withAsyncRelease
267
- } from "./chunk-G6JSWE66.js";
274
+ } from "./chunk-WABL3OUP.js";
275
+ import {
276
+ TASK_STATUS_VALUES,
277
+ isTaskStatus
278
+ } from "./chunk-2DREJFKB.js";
268
279
  import {
269
280
  acquireDaemonExclusiveIntentLock,
270
281
  acquireDaemonStartLock,
@@ -277,7 +288,7 @@ import {
277
288
  readPid,
278
289
  sendDaemonRequest,
279
290
  shutdownDaemonForExclusiveAccess
280
- } from "./chunk-QFSMFANX.js";
291
+ } from "./chunk-SM2QOO45.js";
281
292
  import {
282
293
  agentLaunch
283
294
  } from "./chunk-7ODU7LXP.js";
@@ -1480,7 +1491,7 @@ var batchCommandDescriptor = {
1480
1491
  fields: ["ok", "summary", "results"]
1481
1492
  },
1482
1493
  examples: [
1483
- `echo '[["note","search","AI","--limit","5"],["todo","search","--status","uncompleted"]]' | dino batch --format json`,
1494
+ `echo '[["note","search","AI","--limit","5"],["todo","search","--status","todo,in_progress"]]' | dino batch --format json`,
1484
1495
  "dino batch --input ops.json --stop-on-error --format json"
1485
1496
  ]
1486
1497
  },
@@ -1842,8 +1853,8 @@ function buildSubtreeChanges(args) {
1842
1853
  };
1843
1854
  });
1844
1855
  }
1845
- function parentPathOf2(path5) {
1846
- const segments = path5.split("/");
1856
+ function parentPathOf2(path6) {
1857
+ const segments = path6.split("/");
1847
1858
  if (segments.length <= 1) {
1848
1859
  return null;
1849
1860
  }
@@ -1883,32 +1894,32 @@ async function applySubtreePathChanges(args) {
1883
1894
  }
1884
1895
  }
1885
1896
  function parseRenameInput(input) {
1886
- const path5 = canonicalizeBoxPath(input.path);
1897
+ const path6 = canonicalizeBoxPath(input.path);
1887
1898
  const newName = canonicalizeBoxPath(input.newName);
1888
1899
  const userId = trimString(input.userId);
1889
- if (!path5) {
1900
+ if (!path6) {
1890
1901
  throw new DinoxError("Box path is required");
1891
1902
  }
1892
1903
  if (!newName || newName.includes("/")) {
1893
1904
  throw new DinoxError("New box name must be a single path segment");
1894
1905
  }
1895
- assertBoxPathLimits(path5);
1906
+ assertBoxPathLimits(path6);
1896
1907
  assertTextLimits("Box name", newName, MAX_BOX_NAME_LENGTH);
1897
- return { path: path5, newName, userId };
1908
+ return { path: path6, newName, userId };
1898
1909
  }
1899
1910
  function parseMoveInput(input) {
1900
- const path5 = canonicalizeBoxPath(input.path);
1911
+ const path6 = canonicalizeBoxPath(input.path);
1901
1912
  const to = canonicalizeBoxPath(input.to);
1902
1913
  const userId = trimString(input.userId);
1903
- if (!path5) {
1914
+ if (!path6) {
1904
1915
  throw new DinoxError("Box path is required");
1905
1916
  }
1906
1917
  if (!to) {
1907
1918
  throw new DinoxError("Target parent path is required");
1908
1919
  }
1909
- assertBoxPathLimits(path5);
1920
+ assertBoxPathLimits(path6);
1910
1921
  assertBoxPathLimits(to, "Target parent path");
1911
- return { path: path5, to, userId };
1922
+ return { path: path6, to, userId };
1912
1923
  }
1913
1924
  function parseMergeInput(input) {
1914
1925
  const from = canonicalizeBoxPath(input.from);
@@ -2376,10 +2387,10 @@ function requireArg(value, message) {
2376
2387
  return trimmed;
2377
2388
  }
2378
2389
  async function runBoxRename(context) {
2379
- const path5 = requireArg(context.args.path, "Box path is required");
2390
+ const path6 = requireArg(context.args.path, "Box path is required");
2380
2391
  const newName = requireArg(context.args.newName, "New box name is required");
2381
2392
  await withBoxWriteRuntime(context, async ({ runtime, userId, durability }) => {
2382
- const result = await renameBox(runtime.db, { path: path5, newName, userId }, { dryRun: Boolean(context.options.dryRun) });
2393
+ const result = await renameBox(runtime.db, { path: path6, newName, userId }, { dryRun: Boolean(context.options.dryRun) });
2383
2394
  if (Boolean(context.options.dryRun)) {
2384
2395
  printDryRunPreview(buildBoxMutationDryRunPreview({
2385
2396
  config: runtime.config,
@@ -2388,7 +2399,7 @@ async function runBoxRename(context) {
2388
2399
  action: "rename_box",
2389
2400
  risk: "write",
2390
2401
  summary: `Rename zettel box "${result.fromPath}" to "${result.toPath}".`,
2391
- inputs: { path: path5, new_name: newName },
2402
+ inputs: { path: path6, new_name: newName },
2392
2403
  changes: { updated_boxes: result.updatedBoxes }
2393
2404
  }), runtime);
2394
2405
  return;
@@ -2397,13 +2408,13 @@ async function runBoxRename(context) {
2397
2408
  });
2398
2409
  }
2399
2410
  async function runBoxMove(context) {
2400
- const path5 = requireArg(context.args.path, "Box path is required");
2411
+ const path6 = requireArg(context.args.path, "Box path is required");
2401
2412
  const to = typeof context.options.to === "string" ? context.options.to.trim() : "";
2402
2413
  if (!to) {
2403
2414
  throw new DinoxError("--to is required");
2404
2415
  }
2405
2416
  await withBoxWriteRuntime(context, async ({ runtime, userId, durability }) => {
2406
- const result = await moveBox(runtime.db, { path: path5, to, userId }, { dryRun: Boolean(context.options.dryRun) });
2417
+ const result = await moveBox(runtime.db, { path: path6, to, userId }, { dryRun: Boolean(context.options.dryRun) });
2407
2418
  if (Boolean(context.options.dryRun)) {
2408
2419
  printDryRunPreview(buildBoxMutationDryRunPreview({
2409
2420
  config: runtime.config,
@@ -2412,7 +2423,7 @@ async function runBoxMove(context) {
2412
2423
  action: "move_box",
2413
2424
  risk: "write",
2414
2425
  summary: `Move zettel box "${result.fromPath}" to "${result.toPath}".`,
2415
- inputs: { path: path5, to },
2426
+ inputs: { path: path6, to },
2416
2427
  changes: { updated_boxes: result.updatedBoxes }
2417
2428
  }), runtime);
2418
2429
  return;
@@ -3322,7 +3333,7 @@ var gatewayCommandGroup = {
3322
3333
  examples: ["dino gateway mcp"]
3323
3334
  },
3324
3335
  action: async () => {
3325
- const { serveDinoxMcpOverStdio } = await import("./mcpServer-NYJAKMVH.js");
3336
+ const { serveDinoxMcpOverStdio } = await import("./mcpServer-G2WEAD2O.js");
3326
3337
  await serveDinoxMcpOverStdio();
3327
3338
  }
3328
3339
  },
@@ -3404,7 +3415,7 @@ var editorCommandGroup = {
3404
3415
  examples: ["dino editor mcp", "dino editor mcp --session codex"]
3405
3416
  },
3406
3417
  action: async (context) => {
3407
- const { serveEditorMcpOverStdio } = await import("./mcp-NMKVOSVN.js");
3418
+ const { serveEditorMcpOverStdio } = await import("./mcp-H667ML2O.js");
3408
3419
  await serveEditorMcpOverStdio({ session: String(context.options.session ?? "mcp") });
3409
3420
  }
3410
3421
  },
@@ -3427,7 +3438,7 @@ var editorCommandGroup = {
3427
3438
  },
3428
3439
  action: async (context) => {
3429
3440
  hostOf(context);
3430
- const { installDsh } = await import("./install-IIMVFNAT.js");
3441
+ const { installDsh } = await import("./install-35YBLHXE.js");
3431
3442
  const result = await installDsh(installOptions(context));
3432
3443
  report(result, "Installed the Dinox editor in DeepSeek Harness:", result.next);
3433
3444
  }
@@ -3451,7 +3462,7 @@ var editorCommandGroup = {
3451
3462
  },
3452
3463
  action: async (context) => {
3453
3464
  hostOf(context);
3454
- const { uninstallDsh } = await import("./install-IIMVFNAT.js");
3465
+ const { uninstallDsh } = await import("./install-35YBLHXE.js");
3455
3466
  report(await uninstallDsh(installOptions(context)), "Removed the Dinox editor from DeepSeek Harness:", "Restart DeepSeek Harness Desktop.");
3456
3467
  }
3457
3468
  },
@@ -3472,7 +3483,7 @@ var editorCommandGroup = {
3472
3483
  examples: ["dino editor status", "dino editor status --format json"]
3473
3484
  },
3474
3485
  action: async (context) => {
3475
- const { editorStatus } = await import("./install-IIMVFNAT.js");
3486
+ const { editorStatus } = await import("./install-35YBLHXE.js");
3476
3487
  const status = editorStatus(installOptions(context));
3477
3488
  if (getRequestedStructuredOutputFormat()) {
3478
3489
  printSuccess(status);
@@ -5334,6 +5345,337 @@ function buildNoteSearchResponse(input) {
5334
5345
  };
5335
5346
  }
5336
5347
 
5348
+ // ../../packages/note-engine/src/frontmatter-properties.ts
5349
+ import { parse as parseYaml } from "yaml";
5350
+ var PROPERTY_PATH_SEPARATOR = ".";
5351
+ var SHORT_LIST_LIMIT = 20;
5352
+ var NESTED_TEXT_DEPTH = 6;
5353
+ var RESERVED_KEYS = /* @__PURE__ */ new Set([
5354
+ "title",
5355
+ "tags",
5356
+ "tag",
5357
+ "keywords",
5358
+ "created",
5359
+ "created_at",
5360
+ // Written by Dinox's own Markdown export; the note gets its own timestamps and id on import.
5361
+ "updated",
5362
+ "updated_at",
5363
+ "dinox_id",
5364
+ "cssclasses",
5365
+ "cssclass",
5366
+ "publish"
5367
+ ]);
5368
+ var TAG_KEYS = /* @__PURE__ */ new Set(["tags", "tag", "keywords"]);
5369
+ var CREATED_KEYS = /* @__PURE__ */ new Set(["created", "created_at"]);
5370
+ var LIST_TYPES = /* @__PURE__ */ new Set(["list", "multitext", "aliases"]);
5371
+ var EMPTY_DOCUMENT = {
5372
+ title: "",
5373
+ tags: [],
5374
+ createdAt: null,
5375
+ dinoxId: null,
5376
+ properties: []
5377
+ };
5378
+ function readMarkdownFrontmatter(frontmatter, propertyTypes) {
5379
+ const source = frontmatter.trim();
5380
+ if (!source) return { ...EMPTY_DOCUMENT, properties: [] };
5381
+ let parsed;
5382
+ try {
5383
+ parsed = parseYaml(source);
5384
+ } catch {
5385
+ return null;
5386
+ }
5387
+ if (!isRecord(parsed)) return { ...EMPTY_DOCUMENT, properties: [] };
5388
+ const document = {
5389
+ title: "",
5390
+ tags: [],
5391
+ createdAt: null,
5392
+ dinoxId: null,
5393
+ properties: []
5394
+ };
5395
+ for (const [rawKey, value] of Object.entries(parsed)) {
5396
+ if (rawKey === "__proto__") continue;
5397
+ const lowered = rawKey.toLowerCase();
5398
+ if (lowered === "title" && !document.title) {
5399
+ document.title = readTitle(value);
5400
+ continue;
5401
+ }
5402
+ if (TAG_KEYS.has(lowered)) {
5403
+ document.tags.push(...flattenTagValues(value));
5404
+ continue;
5405
+ }
5406
+ if (CREATED_KEYS.has(lowered) && !document.createdAt) {
5407
+ document.createdAt = readCreatedAt(value);
5408
+ continue;
5409
+ }
5410
+ if (lowered === "dinox_id" && !document.dinoxId) {
5411
+ document.dinoxId = readTitle(value) || null;
5412
+ continue;
5413
+ }
5414
+ if (RESERVED_KEYS.has(lowered)) continue;
5415
+ const segment = normalizeSegment(rawKey);
5416
+ if (!segment) continue;
5417
+ collectProperty(document.properties, [segment], value, lookupType(propertyTypes, rawKey, lowered));
5418
+ }
5419
+ return document;
5420
+ }
5421
+ function chooseMarkdownPropertyDefinitions(notes, catalog) {
5422
+ const plans = [];
5423
+ const seen = /* @__PURE__ */ new Set();
5424
+ for (const properties of notes) {
5425
+ for (const property of properties) {
5426
+ if (catalog.has(property.key) || seen.has(property.key)) continue;
5427
+ seen.add(property.key);
5428
+ plans.push({
5429
+ key: property.key,
5430
+ name: property.name,
5431
+ type: property.type,
5432
+ dateMode: property.dateMode
5433
+ });
5434
+ }
5435
+ }
5436
+ return plans;
5437
+ }
5438
+ function buildMarkdownPropertyValues(properties, resolved, currentPropertiesJson) {
5439
+ const current = parseRawNoteProperties(currentPropertiesJson);
5440
+ const patch = {};
5441
+ for (const property of properties) {
5442
+ if (Object.keys(patch).length >= NOTE_PROPERTY_LIMITS.mutationKeys) break;
5443
+ const choice = resolved.get(property.key);
5444
+ if (!choice) continue;
5445
+ if (Object.hasOwn(current, property.key) && current[property.key] !== null) continue;
5446
+ const value = coerceMarkdownPropertyValue(choice, property.value);
5447
+ if (value === null) continue;
5448
+ patch[property.key] = value;
5449
+ }
5450
+ return patch;
5451
+ }
5452
+ function collectProperty(properties, parts, value, explicitType) {
5453
+ if (properties.length >= NOTE_PROPERTY_LIMITS.mutationKeys) return;
5454
+ if (value == null) return;
5455
+ if (isRecord(value)) {
5456
+ const entries = Object.entries(value).filter(([key]) => key !== "__proto__");
5457
+ if (entries.length === 0) return;
5458
+ for (const [key, child] of entries) {
5459
+ const segment = normalizeSegment(key);
5460
+ if (!segment) continue;
5461
+ collectProperty(properties, [...parts, segment], child, void 0);
5462
+ }
5463
+ return;
5464
+ }
5465
+ if (Array.isArray(value)) {
5466
+ if (value.some((item) => isRecord(item) || Array.isArray(item))) {
5467
+ pushText(properties, parts, describeNested(value, 0));
5468
+ return;
5469
+ }
5470
+ pushList(properties, parts, value, explicitType);
5471
+ return;
5472
+ }
5473
+ pushScalar(properties, parts, value, explicitType);
5474
+ }
5475
+ function pushScalar(properties, parts, value, explicitType) {
5476
+ if (explicitType === "aliases" && typeof value === "string") {
5477
+ const items = value.split(",").map((item) => item.trim()).filter(Boolean);
5478
+ pushList(properties, parts, items, "aliases");
5479
+ return;
5480
+ }
5481
+ const typed = scalarProperty(value, explicitType);
5482
+ if (!typed) return;
5483
+ pushProperty(properties, parts, typed);
5484
+ }
5485
+ function pushList(properties, parts, values, explicitType) {
5486
+ if (explicitType === "text") {
5487
+ pushText(properties, parts, values.map(scalarToText).filter(Boolean).join("\n"));
5488
+ return;
5489
+ }
5490
+ if (explicitType === "number" || explicitType === "checkbox" || explicitType === "date" || explicitType === "datetime") {
5491
+ pushScalar(properties, parts, values.length === 1 ? values[0] : null, explicitType);
5492
+ return;
5493
+ }
5494
+ const wantsList = explicitType === void 0 || LIST_TYPES.has(explicitType);
5495
+ const options = wantsList ? readShortList(values) : null;
5496
+ if (options) {
5497
+ pushProperty(properties, parts, {
5498
+ type: "multi_select",
5499
+ value: options,
5500
+ dateMode: "date"
5501
+ });
5502
+ return;
5503
+ }
5504
+ pushText(properties, parts, values.map(scalarToText).filter(Boolean).join("\n"));
5505
+ }
5506
+ function pushText(properties, parts, text) {
5507
+ const value = clipText(text);
5508
+ if (!value) return;
5509
+ pushProperty(properties, parts, { type: "text", value, dateMode: "date" });
5510
+ }
5511
+ function pushProperty(properties, parts, property) {
5512
+ if (properties.length >= NOTE_PROPERTY_LIMITS.mutationKeys) return;
5513
+ const key = parts.join(PROPERTY_PATH_SEPARATOR);
5514
+ if (!isPropertyKeyValid(key) || properties.some((item) => item.key === key)) return;
5515
+ properties.push({
5516
+ key,
5517
+ name: key,
5518
+ type: property.type,
5519
+ value: property.value,
5520
+ dateMode: property.dateMode
5521
+ });
5522
+ }
5523
+ function scalarProperty(value, explicitType) {
5524
+ if (explicitType === "checkbox") {
5525
+ const coerced = coercePropertyValue("checkbox", value);
5526
+ return typeof coerced === "boolean" ? { type: "checkbox", value: coerced, dateMode: "date" } : null;
5527
+ }
5528
+ if (explicitType === "number") {
5529
+ const coerced = coercePropertyValue("number", value);
5530
+ return typeof coerced === "number" ? { type: "number", value: coerced, dateMode: "date" } : null;
5531
+ }
5532
+ if (explicitType === "date" || explicitType === "datetime") {
5533
+ const dateMode2 = explicitType === "datetime" ? "datetime" : "date";
5534
+ const coerced = normalizeDatePropertyValue(dateInput(value), dateMode2);
5535
+ return coerced ? { type: "date", value: coerced, dateMode: dateMode2 } : null;
5536
+ }
5537
+ if (explicitType === "text" || explicitType !== void 0 && LIST_TYPES.has(explicitType)) {
5538
+ const text2 = scalarToText(value);
5539
+ return text2 ? { type: "text", value: clipText(text2), dateMode: "date" } : null;
5540
+ }
5541
+ if (typeof value === "boolean") return { type: "checkbox", value, dateMode: "date" };
5542
+ if (typeof value === "number" && Number.isFinite(value)) {
5543
+ return { type: "number", value, dateMode: "date" };
5544
+ }
5545
+ if (value instanceof Date && !Number.isNaN(value.getTime())) {
5546
+ const coerced = normalizeDatePropertyValue(value.toISOString(), "datetime");
5547
+ return coerced ? { type: "date", value: coerced, dateMode: "datetime" } : null;
5548
+ }
5549
+ if (typeof value !== "string") return null;
5550
+ const text = value.trim();
5551
+ if (!text) return null;
5552
+ const dateMode = inferDateMode(text);
5553
+ if (dateMode) {
5554
+ const coerced = normalizeDatePropertyValue(text, dateMode);
5555
+ if (coerced) return { type: "date", value: coerced, dateMode };
5556
+ }
5557
+ return { type: "text", value: clipText(text), dateMode: "date" };
5558
+ }
5559
+ function readShortList(values) {
5560
+ if (values.length === 0 || values.length > SHORT_LIST_LIMIT) return null;
5561
+ const options = [];
5562
+ for (const value of values) {
5563
+ const option = scalarToOption(value);
5564
+ if (!option) return null;
5565
+ options.push(option);
5566
+ }
5567
+ return options;
5568
+ }
5569
+ function scalarToOption(value) {
5570
+ const text = scalarToText(value);
5571
+ if (!text || text.length > PROPERTY_OPTION_LABEL_MAX_LENGTH) return null;
5572
+ return text;
5573
+ }
5574
+ function scalarToText(value) {
5575
+ if (typeof value === "string") return value.trim();
5576
+ if (typeof value === "number" && Number.isFinite(value)) return String(value);
5577
+ if (typeof value === "boolean") return value ? "true" : "false";
5578
+ if (value instanceof Date && !Number.isNaN(value.getTime())) return value.toISOString();
5579
+ return "";
5580
+ }
5581
+ function describeNested(value, depth) {
5582
+ if (depth > NESTED_TEXT_DEPTH || value == null) return "";
5583
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
5584
+ return scalarToText(value);
5585
+ }
5586
+ if (value instanceof Date) return scalarToText(value);
5587
+ if (Array.isArray(value)) {
5588
+ return value.map((item) => describeNested(item, depth + 1)).filter(Boolean).join("\n");
5589
+ }
5590
+ if (!isRecord(value)) return "";
5591
+ return Object.entries(value).filter(([key]) => key !== "__proto__").map(([key, child]) => {
5592
+ const rendered = describeNested(child, depth + 1);
5593
+ if (!rendered) return "";
5594
+ if (!rendered.includes("\n")) return `${key}: ${rendered}`;
5595
+ const indented = rendered.split("\n").map((line) => ` ${line}`).join("\n");
5596
+ return `${key}:
5597
+ ${indented}`;
5598
+ }).filter(Boolean).join("\n");
5599
+ }
5600
+ function coerceMarkdownPropertyValue(choice, value) {
5601
+ if (choice.type === "date") {
5602
+ return normalizeDatePropertyValue(value, choice.dateMode ?? "date");
5603
+ }
5604
+ if ((choice.type === "text" || choice.type === "url" || choice.type === "email" || choice.type === "phone") && Array.isArray(value)) {
5605
+ const joined = value.filter((item) => typeof item === "string").join("\u3001");
5606
+ return coercePropertyValue("text", joined);
5607
+ }
5608
+ if ((choice.type === "select" || choice.type === "status") && Array.isArray(value)) {
5609
+ const first = value.find((item) => typeof item === "string" && item.trim());
5610
+ return typeof first === "string" ? coercePropertyValue(choice.type, first) : null;
5611
+ }
5612
+ return coercePropertyValue(choice.type, value);
5613
+ }
5614
+ function lookupType(propertyTypes, key, lowered) {
5615
+ const declared = propertyTypes?.[key];
5616
+ if (lowered === "aliases") return declared === "text" ? "text" : "aliases";
5617
+ return declared;
5618
+ }
5619
+ function readTitle(value) {
5620
+ if (typeof value === "string") return value.trim();
5621
+ if (typeof value === "number" && Number.isFinite(value)) return String(value);
5622
+ return "";
5623
+ }
5624
+ function readCreatedAt(value) {
5625
+ if (value instanceof Date && !Number.isNaN(value.getTime())) return value.toISOString();
5626
+ if (typeof value !== "string") return null;
5627
+ return parseCreatedAt(value);
5628
+ }
5629
+ function dateInput(value) {
5630
+ if (value instanceof Date && !Number.isNaN(value.getTime())) return value.toISOString();
5631
+ return value;
5632
+ }
5633
+ function inferDateMode(value) {
5634
+ if (/^\d{4}-\d{2}-\d{2}$/.test(value)) return "date";
5635
+ if (/^\d{4}-\d{2}-\d{2}[T\s]\d{2}:\d{2}/.test(value)) return "datetime";
5636
+ return null;
5637
+ }
5638
+ function parseCreatedAt(value) {
5639
+ const trimmed = value.trim();
5640
+ if (!trimmed) return null;
5641
+ const local = trimmed.match(
5642
+ /^(\d{4})[-/](\d{2})[-/](\d{2})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/
5643
+ );
5644
+ if (local) {
5645
+ const year = local[1];
5646
+ const month = local[2];
5647
+ const day = local[3];
5648
+ const hour = local[4] ?? "00";
5649
+ const minute = local[5] ?? "00";
5650
+ const second = local[6] ?? "00";
5651
+ const parsed2 = /* @__PURE__ */ new Date(`${year}-${month}-${day}T${hour}:${minute}:${second}`);
5652
+ return Number.isNaN(parsed2.getTime()) ? null : parsed2.toISOString();
5653
+ }
5654
+ const parsed = new Date(trimmed);
5655
+ return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
5656
+ }
5657
+ function flattenTagValues(value) {
5658
+ if (typeof value === "string") {
5659
+ return value.split(",").map((part) => part.trim()).filter(Boolean);
5660
+ }
5661
+ if (typeof value === "number" || typeof value === "boolean") return [String(value)];
5662
+ if (!Array.isArray(value)) return [];
5663
+ return value.flatMap((item) => flattenTagValues(item));
5664
+ }
5665
+ function normalizeSegment(value) {
5666
+ const normalized = value.normalize("NFKC").replace(/[\n\r\t]/g, " ").replace(/\s+/g, " ").trim();
5667
+ if (!normalized || normalized === "__proto__") return "";
5668
+ return normalized;
5669
+ }
5670
+ function clipText(value) {
5671
+ const trimmed = value.trim();
5672
+ if (!trimmed) return "";
5673
+ return trimmed.length > NOTE_PROPERTY_LIMITS.textLength ? trimmed.slice(0, NOTE_PROPERTY_LIMITS.textLength) : trimmed;
5674
+ }
5675
+ function isRecord(value) {
5676
+ return value !== null && typeof value === "object" && !Array.isArray(value);
5677
+ }
5678
+
5337
5679
  // src/commands/domain/options.ts
5338
5680
  function parseIntegerOption(value) {
5339
5681
  const normalized = value.trim();
@@ -5507,7 +5849,7 @@ function parseNoteTemplateContent(raw) {
5507
5849
  });
5508
5850
  }
5509
5851
  assertCanonicalTemplateDocument(parsed);
5510
- return projectNoteContent(parsed).document;
5852
+ return projectNoteContent(upgradeLegacyNoteNodes(parsed)).document;
5511
5853
  }
5512
5854
  function serializeNoteTemplateContent(document) {
5513
5855
  assertCanonicalTemplateDocument(document);
@@ -5658,6 +6000,21 @@ async function previewDeleteNoteTemplate(db, input) {
5658
6000
  }
5659
6001
 
5660
6002
  // src/commands/notes/createFromTemplate.ts
6003
+ function seedWritesProperties(seed) {
6004
+ return Boolean(seed.values) || seed.frontmatterProperties.length > 0;
6005
+ }
6006
+ function applyFrontmatterToSeed(seed, frontmatter) {
6007
+ if (!frontmatter) return [];
6008
+ const parsed = readMarkdownFrontmatter(frontmatter);
6009
+ if (!parsed) {
6010
+ throw new DinoxError("The content front matter is not valid YAML", {
6011
+ code: "USAGE_ERROR",
6012
+ suggestion: "Fix the YAML between the leading `---` lines, or remove it."
6013
+ });
6014
+ }
6015
+ seed.frontmatterProperties = parsed.properties;
6016
+ return parsed.tags;
6017
+ }
5661
6018
  async function resolveNoteCreateSeed(db, input) {
5662
6019
  const template = input.templateId ? await getNoteTemplate(db, { userId: input.userId, id: input.templateId }) : null;
5663
6020
  const projection = template?.document ? projectNoteContent(hydrateNoteTemplateDocument(template.document)) : null;
@@ -5672,19 +6029,50 @@ async function resolveNoteCreateSeed(db, input) {
5672
6029
  values = raw;
5673
6030
  if (Object.keys(values).length === 0) values = null;
5674
6031
  }
5675
- return { template, templateContent, propertiesJson: serializeRawNoteProperties(declared), values };
6032
+ return {
6033
+ template,
6034
+ templateContent,
6035
+ propertiesJson: serializeRawNoteProperties(declared),
6036
+ values,
6037
+ frontmatterProperties: []
6038
+ };
6039
+ }
6040
+ async function frontmatterValues(tx, userId, properties, updatedAt) {
6041
+ if (properties.length === 0) return {};
6042
+ const resolved = /* @__PURE__ */ new Map();
6043
+ for (const definition of await listProperties(tx, { userId, limit: 5e3 })) {
6044
+ if (!definition.key) continue;
6045
+ resolved.set(definition.key, {
6046
+ type: definition.type,
6047
+ ...definition.config?.type === "date" ? { dateMode: definition.config.mode } : {}
6048
+ });
6049
+ }
6050
+ for (const plan of chooseMarkdownPropertyDefinitions([properties], resolved)) {
6051
+ await runDomainCommand(tx, "properties.ensure", {
6052
+ key: plan.key,
6053
+ name: plan.name,
6054
+ type: plan.type,
6055
+ ...plan.type === "date" && plan.dateMode === "datetime" ? { config: { version: 1, type: "date", mode: "datetime" } } : {},
6056
+ source: "manual",
6057
+ userId,
6058
+ updatedAt
6059
+ });
6060
+ resolved.set(plan.key, { type: plan.type, ...plan.type === "date" ? { dateMode: plan.dateMode } : {} });
6061
+ }
6062
+ return buildMarkdownPropertyValues(properties, resolved, null);
5676
6063
  }
5677
6064
  async function applyValues(tx, noteId, userId, seed) {
5678
- if (!seed.values) return;
5679
- await runDomainCommand(tx, "notes.updateProperties", {
5680
- noteId,
5681
- userId,
5682
- patch: seed.values,
5683
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
5684
- });
6065
+ if (!seedWritesProperties(seed)) return;
6066
+ const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
6067
+ const patch = {
6068
+ ...await frontmatterValues(tx, userId, seed.frontmatterProperties, updatedAt),
6069
+ ...seed.values ?? {}
6070
+ };
6071
+ if (Object.keys(patch).length === 0) return;
6072
+ await runDomainCommand(tx, "notes.updateProperties", { noteId, userId, patch, updatedAt });
5685
6073
  }
5686
6074
  async function createNoteWithSeed(db, input) {
5687
- if (!input.seed.values) {
6075
+ if (!seedWritesProperties(input.seed)) {
5688
6076
  await input.insert(db);
5689
6077
  return;
5690
6078
  }
@@ -6127,8 +6515,13 @@ async function runNoteCreate({ command, options }) {
6127
6515
  const useTemplateContent = createOptions.content === void 0 && seed.templateContent !== null;
6128
6516
  const contentMd = useTemplateContent ? seed.templateContent.contentMd : createOptions.content !== void 0 ? await parseStringInput(String(createOptions.content)) : "";
6129
6517
  const canonicalContentMd = useTemplateContent ? contentMd : await canonicalizeBidlinksInMarkdown(db, contentMd, identity.userId);
6130
- const { contentJson, contentText } = useTemplateContent ? { contentJson: seed.templateContent.contentJson, contentText: seed.templateContent.contentText } : convertMarkdownToNoteContent(canonicalContentMd);
6131
- const tagsInput = typeof createOptions.tags === "string" ? await parseStringListInput(createOptions.tags, "--tags") : [];
6518
+ const { contentJson, contentText, frontmatter } = useTemplateContent ? { contentJson: seed.templateContent.contentJson, contentText: seed.templateContent.contentText, frontmatter: null } : convertMarkdownToNoteContent(canonicalContentMd, { frontmatter: "extract" });
6519
+ const frontmatterTags = applyFrontmatterToSeed(seed, frontmatter);
6520
+ const storedContentMd = frontmatter ? extractMarkdownFrontmatter(canonicalContentMd).body : canonicalContentMd;
6521
+ const tagsInput = [
6522
+ ...typeof createOptions.tags === "string" ? await parseStringListInput(createOptions.tags, "--tags") : [],
6523
+ ...frontmatterTags
6524
+ ];
6132
6525
  const boxNames = typeof createOptions.boxes === "string" ? await parseStringListInput(createOptions.boxes, "--boxes") : [];
6133
6526
  const noteType = parseNoteType(createOptions.type);
6134
6527
  const id = generateId();
@@ -6136,7 +6529,7 @@ async function runNoteCreate({ command, options }) {
6136
6529
  id,
6137
6530
  title: String(createOptions.title),
6138
6531
  noteType,
6139
- contentMd: canonicalContentMd,
6532
+ contentMd: storedContentMd,
6140
6533
  contentJson,
6141
6534
  contentText,
6142
6535
  tags: await validateTagsForCreate(tx, tagsInput, identity.userId),
@@ -6156,7 +6549,7 @@ async function runNoteCreate({ command, options }) {
6156
6549
  tagsInput,
6157
6550
  zettelBoxNames: boxNames
6158
6551
  });
6159
- if (seed.template || seed.values) {
6552
+ if (seed.template || seedWritesProperties(seed)) {
6160
6553
  const properties = await previewNoteCreateProperties(db, { noteId: id, userId: identity.userId, seed, insert });
6161
6554
  preview.inputs = { ...preview.inputs, ...seed.template ? { template: { id: seed.template.id, name: seed.template.name } } : {} };
6162
6555
  preview.changes = { ...preview.changes, properties: properties.properties };
@@ -6170,9 +6563,9 @@ async function runNoteCreate({ command, options }) {
6170
6563
  ok: true,
6171
6564
  id,
6172
6565
  ...seed.template ? { template: { id: seed.template.id, name: seed.template.name } } : {},
6173
- ...seed.template || seed.values ? { properties: (await readNoteProperties(db, { userId: identity.userId, noteId: id })).properties } : {},
6566
+ ...seed.template || seedWritesProperties(seed) ? { properties: (await readNoteProperties(db, { userId: identity.userId, noteId: id })).properties } : {},
6174
6567
  ...await readNoteWriteReceipt(db, id, {
6175
- changed: ["title", "type", "content_md", "content_json", "content_text", "tags", "boxes", ...seed.template || seed.values ? ["properties"] : []],
6568
+ changed: ["title", "type", "content_md", "content_json", "content_text", "tags", "boxes", ...seed.template || seedWritesProperties(seed) ? ["properties"] : []],
6176
6569
  upload,
6177
6570
  stale: commandStale(runtime)
6178
6571
  })
@@ -9800,9 +10193,9 @@ function registerSavedViewCommands(program) {
9800
10193
  // src/commands/skills/index.ts
9801
10194
  import { spawn as spawn2 } from "node:child_process";
9802
10195
  import { readFile } from "node:fs/promises";
9803
- import { homedir } from "node:os";
9804
- import path4 from "node:path";
9805
- import { parse as parseYaml } from "yaml";
10196
+ import { homedir as homedir2 } from "node:os";
10197
+ import path5 from "node:path";
10198
+ import { parse as parseYaml2 } from "yaml";
9806
10199
 
9807
10200
  // src/skills/registry.ts
9808
10201
  function commands(file, key) {
@@ -9870,13 +10263,78 @@ function listRegisteredSkillNames() {
9870
10263
  return SKILL_REGISTRY.map((entry) => entry.name);
9871
10264
  }
9872
10265
 
10266
+ // src/skills/leftovers.ts
10267
+ import { createHash as createHash2 } from "node:crypto";
10268
+ import fs5 from "node:fs/promises";
10269
+ import { homedir } from "node:os";
10270
+ import path4 from "node:path";
10271
+ function defaultAgentSkillDirs(home = homedir()) {
10272
+ return [
10273
+ path4.join(home, ".claude", "skills"),
10274
+ path4.join(home, ".hermes", "skills"),
10275
+ path4.join(home, ".openclaw", "skills")
10276
+ ];
10277
+ }
10278
+ function gitObjectHash(type, body) {
10279
+ return createHash2("sha1").update(`${type} ${body.byteLength}\0`).update(body).digest();
10280
+ }
10281
+ async function gitTreeHash(dir) {
10282
+ return (await treeHash(dir)).toString("hex");
10283
+ }
10284
+ async function treeHash(dir) {
10285
+ const entries = await fs5.readdir(dir, { withFileTypes: true });
10286
+ const items = [];
10287
+ for (const entry of entries) {
10288
+ if (entry.name === ".DS_Store") continue;
10289
+ const full = path4.join(dir, entry.name);
10290
+ let mode;
10291
+ let hash;
10292
+ if (entry.isDirectory()) {
10293
+ mode = "40000";
10294
+ hash = await treeHash(full);
10295
+ } else if (entry.isSymbolicLink()) {
10296
+ mode = "120000";
10297
+ hash = gitObjectHash("blob", Buffer.from(await fs5.readlink(full)));
10298
+ } else {
10299
+ const stats = await fs5.stat(full);
10300
+ mode = stats.mode & 73 ? "100755" : "100644";
10301
+ hash = gitObjectHash("blob", await fs5.readFile(full));
10302
+ }
10303
+ items.push({
10304
+ // git orders tree entries as if directory names ended with '/'.
10305
+ sortKey: entry.isDirectory() ? `${entry.name}/` : entry.name,
10306
+ bytes: Buffer.concat([Buffer.from(`${mode} ${entry.name}\0`), hash])
10307
+ });
10308
+ }
10309
+ items.sort((a, b) => Buffer.compare(Buffer.from(a.sortKey), Buffer.from(b.sortKey)));
10310
+ return gitObjectHash("tree", Buffer.concat(items.map((item) => item.bytes)));
10311
+ }
10312
+ async function findRetiredSkillLeftover(input) {
10313
+ const folder = path4.join(input.skillsRoot, input.name);
10314
+ const stats = await fs5.lstat(folder).catch(() => null);
10315
+ if (!stats?.isDirectory()) return null;
10316
+ const official = await gitTreeHash(folder).then((hash) => hash === input.skillFolderHash, () => false);
10317
+ const links = [];
10318
+ for (const agentDir of input.agentSkillDirs) {
10319
+ const link = path4.join(agentDir, input.name);
10320
+ const target = await fs5.readlink(link).catch(() => null);
10321
+ if (target !== null && path4.resolve(agentDir, target) === folder) links.push(link);
10322
+ }
10323
+ return { path: folder, official, links };
10324
+ }
10325
+ async function removeRetiredSkillLeftover(leftover) {
10326
+ if (!leftover.official) throw new Error(`refusing to delete a modified skill folder: ${leftover.path}`);
10327
+ for (const link of leftover.links) await fs5.unlink(link).catch(() => void 0);
10328
+ await fs5.rm(leftover.path, { recursive: true, force: true });
10329
+ }
10330
+
9873
10331
  // src/commands/skills/index.ts
9874
10332
  var MAX_CAPTURED_INSTALLER_OUTPUT_BYTES = 64 * 1024;
9875
- function isRecord(value) {
10333
+ function isRecord2(value) {
9876
10334
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
9877
10335
  }
9878
10336
  function defaultLockFilePath() {
9879
- return path4.join(homedir(), ".agents", ".skill-lock.json");
10337
+ return path5.join(homedir2(), ".agents", ".skill-lock.json");
9880
10338
  }
9881
10339
  async function defaultReadLockFile(lockFilePath) {
9882
10340
  return readFile(lockFilePath, "utf8");
@@ -9902,7 +10360,8 @@ function absentScan(lockFilePath) {
9902
10360
  total: skills.length,
9903
10361
  absent: skills.length,
9904
10362
  safeToRemove: 0,
9905
- conflict: 0
10363
+ conflict: 0,
10364
+ leftover: 0
9906
10365
  },
9907
10366
  skills
9908
10367
  };
@@ -9938,7 +10397,7 @@ async function readSkillsLock(lockFilePath, readLockFile) {
9938
10397
  } catch (error) {
9939
10398
  throw invalidLockError(lockFilePath, "file is not valid JSON", error);
9940
10399
  }
9941
- if (!isRecord(parsed) || !isRecord(parsed.skills)) {
10400
+ if (!isRecord2(parsed) || !isRecord2(parsed.skills)) {
9942
10401
  throw invalidLockError(lockFilePath, "expected an object with a skills map");
9943
10402
  }
9944
10403
  return {
@@ -9947,12 +10406,38 @@ async function readSkillsLock(lockFilePath, readLockFile) {
9947
10406
  entries: parsed.skills
9948
10407
  };
9949
10408
  }
9950
- async function scanRetiredSkillsLock(lockFilePath = defaultLockFilePath(), readLockFile = defaultReadLockFile) {
10409
+ async function scanRetiredSkillsLock(lockFilePath = defaultLockFilePath(), readLockFile = defaultReadLockFile, agentSkillDirs = defaultAgentSkillDirs()) {
9951
10410
  const lock = await readSkillsLock(lockFilePath, readLockFile);
9952
- if (!lock.found) {
9953
- return absentScan(lockFilePath);
10411
+ const scan = lock.found ? scanRetiredSkills(lockFilePath, lock) : absentScan(lockFilePath);
10412
+ return await withLeftovers(scan, path5.join(path5.dirname(lockFilePath), "skills"), agentSkillDirs);
10413
+ }
10414
+ async function withLeftovers(scan, skillsRoot, agentSkillDirs) {
10415
+ const skills = [];
10416
+ for (const skill of scan.skills) {
10417
+ if (skill.status !== "absent") {
10418
+ skills.push(skill);
10419
+ continue;
10420
+ }
10421
+ const leftover = await findRetiredSkillLeftover({
10422
+ name: skill.name,
10423
+ skillFolderHash: skill.expected.skillFolderHash,
10424
+ skillsRoot,
10425
+ agentSkillDirs
10426
+ });
10427
+ skills.push(leftover ? { ...skill, status: leftover.official ? "leftover" : "absent", leftover } : skill);
9954
10428
  }
9955
- return scanRetiredSkills(lockFilePath, lock);
10429
+ const count = (status) => skills.filter((skill) => skill.status === status).length;
10430
+ return {
10431
+ ...scan,
10432
+ summary: {
10433
+ total: skills.length,
10434
+ absent: count("absent"),
10435
+ safeToRemove: count("safe-to-remove"),
10436
+ conflict: count("conflict"),
10437
+ leftover: count("leftover")
10438
+ },
10439
+ skills
10440
+ };
9956
10441
  }
9957
10442
  function scanRetiredSkills(lockFilePath, lock) {
9958
10443
  const entries = lock.entries;
@@ -9972,7 +10457,7 @@ function scanRetiredSkills(lockFilePath, lock) {
9972
10457
  };
9973
10458
  }
9974
10459
  const rawEntry = entries[skill.name];
9975
- const entry = isRecord(rawEntry) ? rawEntry : {};
10460
+ const entry = isRecord2(rawEntry) ? rawEntry : {};
9976
10461
  const observed = {
9977
10462
  source: typeof entry.source === "string" ? entry.source : null,
9978
10463
  skillFolderHash: typeof entry.skillFolderHash === "string" ? entry.skillFolderHash : null
@@ -10001,7 +10486,8 @@ function scanRetiredSkills(lockFilePath, lock) {
10001
10486
  total: skills.length,
10002
10487
  absent: skills.filter((skill) => skill.status === "absent").length,
10003
10488
  safeToRemove: skills.filter((skill) => skill.status === "safe-to-remove").length,
10004
- conflict: skills.filter((skill) => skill.status === "conflict").length
10489
+ conflict: skills.filter((skill) => skill.status === "conflict").length,
10490
+ leftover: 0
10005
10491
  },
10006
10492
  skills
10007
10493
  };
@@ -10011,18 +10497,18 @@ function readSkillVersion(skillMarkdown) {
10011
10497
  if (!frontmatter) return null;
10012
10498
  let parsed;
10013
10499
  try {
10014
- parsed = parseYaml(frontmatter);
10500
+ parsed = parseYaml2(frontmatter);
10015
10501
  } catch {
10016
10502
  return null;
10017
10503
  }
10018
- if (!isRecord(parsed)) return null;
10019
- const metadataVersion = isRecord(parsed.metadata) ? parsed.metadata.version : void 0;
10504
+ if (!isRecord2(parsed)) return null;
10505
+ const metadataVersion = isRecord2(parsed.metadata) ? parsed.metadata.version : void 0;
10020
10506
  const version = metadataVersion ?? parsed.version;
10021
10507
  return typeof version === "string" && version.trim() ? version.trim() : null;
10022
10508
  }
10023
10509
  async function scanCurrentSkills(lockFilePath = defaultLockFilePath(), readLockFile = defaultReadLockFile, readInstalledSkill = defaultReadLockFile, expectedVersion = getPackageVersion()) {
10024
10510
  const lock = await readSkillsLock(lockFilePath, readLockFile);
10025
- const skillsRoot = path4.join(path4.dirname(lockFilePath), "skills");
10511
+ const skillsRoot = path5.join(path5.dirname(lockFilePath), "skills");
10026
10512
  const skills = [];
10027
10513
  for (const name of listRegisteredSkillNames()) {
10028
10514
  const rawEntry = Object.prototype.hasOwnProperty.call(lock.entries, name) ? lock.entries[name] : void 0;
@@ -10030,14 +10516,14 @@ async function scanCurrentSkills(lockFilePath = defaultLockFilePath(), readLockF
10030
10516
  skills.push({ name, status: "missing", source: null, installedVersion: null });
10031
10517
  continue;
10032
10518
  }
10033
- const source = isRecord(rawEntry) && typeof rawEntry.source === "string" ? rawEntry.source : null;
10519
+ const source = isRecord2(rawEntry) && typeof rawEntry.source === "string" ? rawEntry.source : null;
10034
10520
  if (source !== SKILLS_REPO_SLUG) {
10035
10521
  skills.push({ name, status: "foreign", source, installedVersion: null });
10036
10522
  continue;
10037
10523
  }
10038
10524
  let installedVersion = null;
10039
10525
  try {
10040
- installedVersion = readSkillVersion(await readInstalledSkill(path4.join(skillsRoot, name, "SKILL.md")));
10526
+ installedVersion = readSkillVersion(await readInstalledSkill(path5.join(skillsRoot, name, "SKILL.md")));
10041
10527
  } catch {
10042
10528
  installedVersion = null;
10043
10529
  }
@@ -10133,6 +10619,7 @@ function resolveDependencies(overrides) {
10133
10619
  return {
10134
10620
  getLockFilePath: defaultLockFilePath,
10135
10621
  readLockFile: defaultReadLockFile,
10622
+ getAgentSkillDirs: () => defaultAgentSkillDirs(),
10136
10623
  readInstalledSkill: defaultReadLockFile,
10137
10624
  getExpectedVersion: getPackageVersion,
10138
10625
  runRemoval: runSkillsRemoval,
@@ -10152,10 +10639,15 @@ function printScan(scan) {
10152
10639
  );
10153
10640
  continue;
10154
10641
  }
10155
- printHumanReadableLine(`${skill.name}: ${skill.status}; replacement: ${replacementLabel(skill)}`);
10642
+ if (skill.leftover && !skill.leftover.official) {
10643
+ printHumanReadableLine(`${skill.name}: modified folder kept at ${skill.leftover.path} (not the official skill)`);
10644
+ continue;
10645
+ }
10646
+ const where = skill.status === "leftover" ? ` (folder ${skill.leftover?.path})` : "";
10647
+ printHumanReadableLine(`${skill.name}: ${skill.status}${where}; replacement: ${replacementLabel(skill)}`);
10156
10648
  }
10157
10649
  printHumanReadableLine(
10158
- `summary: safe-to-remove=${scan.summary.safeToRemove} conflict=${scan.summary.conflict} absent=${scan.summary.absent}`
10650
+ `summary: safe-to-remove=${scan.summary.safeToRemove} leftover=${scan.summary.leftover} conflict=${scan.summary.conflict} absent=${scan.summary.absent}`
10159
10651
  );
10160
10652
  }
10161
10653
  function printCurrentScan(current) {
@@ -10181,6 +10673,29 @@ function installerPayload(skillNames) {
10181
10673
  function safeSkillNames(scan) {
10182
10674
  return scan.skills.filter((skill) => skill.status === "safe-to-remove").map((skill) => skill.name);
10183
10675
  }
10676
+ function leftoverSkillNames(scan) {
10677
+ return scan.skills.filter((skill) => skill.status === "leftover").map((skill) => skill.name);
10678
+ }
10679
+ async function removeLeftovers(dependencies, lockFilePath, scan, planned) {
10680
+ const targets = scan.skills.filter(
10681
+ (skill) => skill.status === "leftover" && skill.leftover?.official && planned.includes(skill.name)
10682
+ );
10683
+ if (targets.length === 0) return scan;
10684
+ for (const skill of targets) {
10685
+ try {
10686
+ await removeRetiredSkillLeftover(skill.leftover);
10687
+ } catch (error) {
10688
+ throw new DinoxError(`Failed to remove the leftover folder of retired skill ${skill.name}`, {
10689
+ code: "SKILLS_MIGRATION_FAILED",
10690
+ cause: error,
10691
+ details: { skill: skill.name, path: skill.leftover.path },
10692
+ suggestion: "Check the folder permissions, then rerun `dino skills migrate --dry-run --format json`.",
10693
+ recoverable: true
10694
+ });
10695
+ }
10696
+ }
10697
+ return await rescanForVerification(dependencies, lockFilePath);
10698
+ }
10184
10699
  function conflictSkillNames(scan) {
10185
10700
  return scan.skills.filter((skill) => skill.status === "conflict").map((skill) => skill.name);
10186
10701
  }
@@ -10189,7 +10704,7 @@ function scanStatus(scan, name) {
10189
10704
  }
10190
10705
  async function rescanForVerification(dependencies, lockFilePath) {
10191
10706
  try {
10192
- return await scanRetiredSkillsLock(lockFilePath, dependencies.readLockFile);
10707
+ return await scanRetiredSkillsLock(lockFilePath, dependencies.readLockFile, dependencies.getAgentSkillDirs());
10193
10708
  } catch (error) {
10194
10709
  throw new DinoxError("Failed to verify the retired skills migration", {
10195
10710
  code: "SKILLS_MIGRATION_VERIFICATION_FAILED",
@@ -10223,7 +10738,7 @@ function createSkillsCommandGroup(overrides = {}) {
10223
10738
  },
10224
10739
  action: async (_context) => {
10225
10740
  const lockFilePath = dependencies.getLockFilePath();
10226
- const scan = await scanRetiredSkillsLock(lockFilePath, dependencies.readLockFile);
10741
+ const scan = await scanRetiredSkillsLock(lockFilePath, dependencies.readLockFile, dependencies.getAgentSkillDirs());
10227
10742
  const current = await scanCurrentSkills(
10228
10743
  lockFilePath,
10229
10744
  dependencies.readLockFile,
@@ -10290,10 +10805,11 @@ function createSkillsCommandGroup(overrides = {}) {
10290
10805
  });
10291
10806
  }
10292
10807
  const lockFilePath = dependencies.getLockFilePath();
10293
- const before = await scanRetiredSkillsLock(lockFilePath, dependencies.readLockFile);
10294
- const plannedRemoval = safeSkillNames(before);
10808
+ const before = await scanRetiredSkillsLock(lockFilePath, dependencies.readLockFile, dependencies.getAgentSkillDirs());
10809
+ const lockRemoval = safeSkillNames(before);
10810
+ const plannedRemoval = [...lockRemoval, ...leftoverSkillNames(before)];
10295
10811
  const conflicts = conflictSkillNames(before);
10296
- const installer = installerPayload(plannedRemoval);
10812
+ const installer = installerPayload(lockRemoval);
10297
10813
  if (!confirmed) {
10298
10814
  const payload2 = {
10299
10815
  mode: "dry-run",
@@ -10339,9 +10855,9 @@ function createSkillsCommandGroup(overrides = {}) {
10339
10855
  printHumanReadableLine("verified: yes");
10340
10856
  return;
10341
10857
  }
10342
- const preExecution = await scanRetiredSkillsLock(lockFilePath, dependencies.readLockFile);
10858
+ const preExecution = await scanRetiredSkillsLock(lockFilePath, dependencies.readLockFile, dependencies.getAgentSkillDirs());
10343
10859
  const changedCandidates = plannedRemoval.filter(
10344
- (name) => scanStatus(preExecution, name) !== "safe-to-remove"
10860
+ (name) => scanStatus(preExecution, name) !== scanStatus(before, name)
10345
10861
  );
10346
10862
  if (changedCandidates.length > 0) {
10347
10863
  throw new DinoxError("The skills installer lock changed before migration execution", {
@@ -10357,9 +10873,9 @@ function createSkillsCommandGroup(overrides = {}) {
10357
10873
  recoverable: true
10358
10874
  });
10359
10875
  }
10360
- const execution = await dependencies.runRemoval(plannedRemoval);
10361
- const after = await rescanForVerification(dependencies, lockFilePath);
10362
- if (execution.exitCode !== 0) {
10876
+ const execution = lockRemoval.length > 0 ? await dependencies.runRemoval(lockRemoval) : null;
10877
+ const afterInstaller = await rescanForVerification(dependencies, lockFilePath);
10878
+ if (execution && execution.exitCode !== 0) {
10363
10879
  throw new DinoxError(`The skills installer exited with code ${execution.exitCode ?? "unknown"}`, {
10364
10880
  code: "SKILLS_MIGRATION_FAILED",
10365
10881
  details: {
@@ -10367,12 +10883,13 @@ function createSkillsCommandGroup(overrides = {}) {
10367
10883
  exitCode: execution.exitCode,
10368
10884
  ...execution.stdout.trim() ? { stdout: execution.stdout.trim() } : {},
10369
10885
  ...execution.stderr.trim() ? { stderr: execution.stderr.trim() } : {},
10370
- after
10886
+ after: afterInstaller
10371
10887
  },
10372
10888
  suggestion: "Run `dino skills doctor --format json` before deciding whether to retry.",
10373
10889
  recoverable: true
10374
10890
  });
10375
10891
  }
10892
+ const after = await removeLeftovers(dependencies, lockFilePath, afterInstaller, plannedRemoval);
10376
10893
  const remainingCandidates = plannedRemoval.filter(
10377
10894
  (name) => scanStatus(after, name) !== "absent"
10378
10895
  );
@@ -10383,7 +10900,7 @@ function createSkillsCommandGroup(overrides = {}) {
10383
10900
  throw new DinoxError("Retired skills migration verification failed", {
10384
10901
  code: "SKILLS_MIGRATION_VERIFICATION_FAILED",
10385
10902
  details: {
10386
- command: execution.invocation.displayCommand,
10903
+ command: execution?.invocation.displayCommand ?? null,
10387
10904
  remainingCandidates,
10388
10905
  unexpectedlyRemovedConflicts,
10389
10906
  before,
@@ -11363,7 +11880,7 @@ var clipCommandGroup = {
11363
11880
  examples: ["dino clip inspect https://example.com/article --format json"]
11364
11881
  },
11365
11882
  action: async (context) => {
11366
- const { runClipInspect } = await import("./run-ETPFUFB6.js");
11883
+ const { runClipInspect } = await import("./run-7D6ATULD.js");
11367
11884
  await runClipInspect(context);
11368
11885
  }
11369
11886
  },
@@ -11421,7 +11938,7 @@ var clipCommandGroup = {
11421
11938
  ]
11422
11939
  },
11423
11940
  action: async (context) => {
11424
- const { runClipAdd } = await import("./run-ETPFUFB6.js");
11941
+ const { runClipAdd } = await import("./run-7D6ATULD.js");
11425
11942
  await runClipAdd(context);
11426
11943
  }
11427
11944
  },
@@ -11442,7 +11959,7 @@ var clipCommandGroup = {
11442
11959
  examples: ["dino clip process 01a1e3bb-3827-790d-b850-52b187c12b53 --format json"]
11443
11960
  },
11444
11961
  action: async (context) => {
11445
- const { runClipProcess } = await import("./run-ETPFUFB6.js");
11962
+ const { runClipProcess } = await import("./run-7D6ATULD.js");
11446
11963
  await runClipProcess(context);
11447
11964
  }
11448
11965
  },
@@ -11466,7 +11983,7 @@ var clipCommandGroup = {
11466
11983
  examples: ["dino clip setup", "dino clip setup --progress --format json", "dino clip setup --check --format json"]
11467
11984
  },
11468
11985
  action: async (context) => {
11469
- const { runClipSetup } = await import("./setup-EEU6GSWX.js");
11986
+ const { runClipSetup } = await import("./setup-DSTOF3BZ.js");
11470
11987
  await runClipSetup(context);
11471
11988
  }
11472
11989
  },
@@ -11486,7 +12003,7 @@ var clipCommandGroup = {
11486
12003
  examples: ["dino clip cookies-list --format json"]
11487
12004
  },
11488
12005
  action: async () => {
11489
- const { runClipCookiesList } = await import("./cookies-6QQHSM26.js");
12006
+ const { runClipCookiesList } = await import("./cookies-ORQ3RLAH.js");
11490
12007
  await runClipCookiesList();
11491
12008
  }
11492
12009
  },
@@ -11513,7 +12030,7 @@ var clipCommandGroup = {
11513
12030
  ]
11514
12031
  },
11515
12032
  action: async (context) => {
11516
- const { runClipCookiesImport } = await import("./cookies-6QQHSM26.js");
12033
+ const { runClipCookiesImport } = await import("./cookies-ORQ3RLAH.js");
11517
12034
  await runClipCookiesImport(context);
11518
12035
  }
11519
12036
  },
@@ -11537,7 +12054,7 @@ var clipCommandGroup = {
11537
12054
  examples: ["pbpaste | dino clip cookies-set example.com - --format json"]
11538
12055
  },
11539
12056
  action: async (context) => {
11540
- const { runClipCookiesSet } = await import("./cookies-6QQHSM26.js");
12057
+ const { runClipCookiesSet } = await import("./cookies-ORQ3RLAH.js");
11541
12058
  await runClipCookiesSet(context);
11542
12059
  }
11543
12060
  },
@@ -11559,7 +12076,7 @@ var clipCommandGroup = {
11559
12076
  examples: ["dino clip cookies-remove example.com --format json", "dino clip cookies-remove --all --format json"]
11560
12077
  },
11561
12078
  action: async (context) => {
11562
- const { runClipCookiesRemove } = await import("./cookies-6QQHSM26.js");
12079
+ const { runClipCookiesRemove } = await import("./cookies-ORQ3RLAH.js");
11563
12080
  await runClipCookiesRemove(context);
11564
12081
  }
11565
12082
  }
@@ -11598,8 +12115,8 @@ function rewriteTagList(tags, oldPrefix, newPrefix, preserveSuffix) {
11598
12115
  function pathKey(value) {
11599
12116
  return canonicalizeTagPath(value).toLowerCase();
11600
12117
  }
11601
- function getPathId(path5, lookup) {
11602
- return lookup?.idByPath.get(pathKey(path5)) ?? canonicalizeTagPath(path5);
12118
+ function getPathId(path6, lookup) {
12119
+ return lookup?.idByPath.get(pathKey(path6)) ?? canonicalizeTagPath(path6);
11603
12120
  }
11604
12121
  function parseJson2(raw) {
11605
12122
  if (!raw) {
@@ -11634,9 +12151,9 @@ function rewriteHashtagsInJson(raw, oldPrefix, newPrefix, preserveSuffix, lookup
11634
12151
  let current = node;
11635
12152
  if (current.type === "hashtag") {
11636
12153
  const attrs = { ...current.attrs ?? {} };
11637
- const path5 = extractHashtagPath(attrs, lookup);
11638
- if (path5 && isTagPathWithinPrefix(path5, oldPrefix)) {
11639
- const nextPath = preserveSuffix ? renameTagPathWithPrefix(path5, oldPrefix, newPrefix) : canonicalizeTagPath(newPrefix);
12154
+ const path6 = extractHashtagPath(attrs, lookup);
12155
+ if (path6 && isTagPathWithinPrefix(path6, oldPrefix)) {
12156
+ const nextPath = preserveSuffix ? renameTagPathWithPrefix(path6, oldPrefix, newPrefix) : canonicalizeTagPath(newPrefix);
11640
12157
  const nextId = getPathId(nextPath, lookup);
11641
12158
  if (attrs.label !== nextPath || attrs.id !== nextId) {
11642
12159
  current = {
@@ -11683,9 +12200,9 @@ function collectPlainText(node, lookup) {
11683
12200
  const chunks = [];
11684
12201
  const visit = (current) => {
11685
12202
  if (current.type === "hashtag") {
11686
- const path5 = extractHashtagPath(current.attrs, lookup);
11687
- if (path5) {
11688
- chunks.push(`#${path5}`);
12203
+ const path6 = extractHashtagPath(current.attrs, lookup);
12204
+ if (path6) {
12205
+ chunks.push(`#${path6}`);
11689
12206
  }
11690
12207
  return;
11691
12208
  }
@@ -11770,9 +12287,9 @@ function rewriteHashtagsInMarkdown(raw, oldPrefix, newPrefix, preserveSuffix) {
11770
12287
  index += 1;
11771
12288
  continue;
11772
12289
  }
11773
- const path5 = canonicalizeTagPath(match.label);
11774
- if (path5 && isTagPathWithinPrefix(path5, oldPrefix)) {
11775
- const nextPath = preserveSuffix ? renameTagPathWithPrefix(path5, oldPrefix, newPrefix) : canonicalizeTagPath(newPrefix);
12290
+ const path6 = canonicalizeTagPath(match.label);
12291
+ if (path6 && isTagPathWithinPrefix(path6, oldPrefix)) {
12292
+ const nextPath = preserveSuffix ? renameTagPathWithPrefix(path6, oldPrefix, newPrefix) : canonicalizeTagPath(newPrefix);
11776
12293
  output += `#${nextPath}`;
11777
12294
  changed = true;
11778
12295
  } else {
@@ -11966,26 +12483,26 @@ function buildTagReferenceLookup(nodes, changes = [], aliases = []) {
11966
12483
  const idByPath = /* @__PURE__ */ new Map();
11967
12484
  const pathById = /* @__PURE__ */ new Map();
11968
12485
  for (const node of activeTagNodes(nodes)) {
11969
- const path5 = canonicalizeTagPath(node.fullPath);
11970
- if (!path5) {
12486
+ const path6 = canonicalizeTagPath(node.fullPath);
12487
+ if (!path6) {
11971
12488
  continue;
11972
12489
  }
11973
- idByPath.set(normalizeTagLookupKey(path5), node.id);
11974
- pathById.set(node.id, path5);
12490
+ idByPath.set(normalizeTagLookupKey(path6), node.id);
12491
+ pathById.set(node.id, path6);
11975
12492
  }
11976
12493
  for (const change of changes) {
11977
- const path5 = canonicalizeTagPath(change.toPath);
11978
- if (!path5) {
12494
+ const path6 = canonicalizeTagPath(change.toPath);
12495
+ if (!path6) {
11979
12496
  continue;
11980
12497
  }
11981
- idByPath.set(normalizeTagLookupKey(path5), change.id);
12498
+ idByPath.set(normalizeTagLookupKey(path6), change.id);
11982
12499
  }
11983
12500
  for (const alias of aliases) {
11984
- const path5 = canonicalizeTagPath(alias.path);
11985
- if (!path5 || !alias.id) {
12501
+ const path6 = canonicalizeTagPath(alias.path);
12502
+ if (!path6 || !alias.id) {
11986
12503
  continue;
11987
12504
  }
11988
- idByPath.set(normalizeTagLookupKey(path5), alias.id);
12505
+ idByPath.set(normalizeTagLookupKey(path6), alias.id);
11989
12506
  }
11990
12507
  return { idByPath, pathById };
11991
12508
  }
@@ -12045,7 +12562,7 @@ async function applyTagPathChanges(tx, nodes, changes, timestamp) {
12045
12562
  }
12046
12563
  }
12047
12564
  async function renameTag(db, input, options = {}) {
12048
- const path5 = assertPath(input.path, "Tag path");
12565
+ const path6 = assertPath(input.path, "Tag path");
12049
12566
  const newName = parseSingleSegment(input.newName, "New tag name");
12050
12567
  const userId = trimString2(input.userId);
12051
12568
  const tagColumns = await getTableColumns2(db, "c_tag_node");
@@ -12053,7 +12570,7 @@ async function renameTag(db, input, options = {}) {
12053
12570
  assertCanWriteTag(tagColumns, userId, "update");
12054
12571
  assertRequiredColumns2("c_note", noteColumns, REQUIRED_NOTE_TAG_COLUMNS);
12055
12572
  const nodes = await loadTagNodes(db, tagColumns, { userId, dedupeByPath: true });
12056
- const root = requireActiveTagPath(nodes, path5, "Tag path");
12573
+ const root = requireActiveTagPath(nodes, path6, "Tag path");
12057
12574
  const newRootPath = parentPathOf(root.fullPath) ? `${parentPathOf(root.fullPath)}/${newName}` : newName;
12058
12575
  const changes = buildSubtreeChanges2(nodes, root, newRootPath);
12059
12576
  ensureNoTagPathConflict(nodes, changes);
@@ -12076,7 +12593,7 @@ async function renameTag(db, input, options = {}) {
12076
12593
  };
12077
12594
  }
12078
12595
  async function moveTag(db, input, options = {}) {
12079
- const path5 = assertPath(input.path, "Tag path");
12596
+ const path6 = assertPath(input.path, "Tag path");
12080
12597
  const to = assertPath(input.to, "Target parent path");
12081
12598
  const userId = trimString2(input.userId);
12082
12599
  const tagColumns = await getTableColumns2(db, "c_tag_node");
@@ -12084,7 +12601,7 @@ async function moveTag(db, input, options = {}) {
12084
12601
  assertCanWriteTag(tagColumns, userId, "update");
12085
12602
  assertRequiredColumns2("c_note", noteColumns, REQUIRED_NOTE_TAG_COLUMNS);
12086
12603
  const nodes = await loadTagNodes(db, tagColumns, { userId, dedupeByPath: true });
12087
- const root = requireActiveTagPath(nodes, path5, "Tag path");
12604
+ const root = requireActiveTagPath(nodes, path6, "Tag path");
12088
12605
  const parent = requireActiveTagPath(nodes, to, "Target parent path");
12089
12606
  if (root.id === parent.id || isTagPathWithinPrefix(parent.fullPath, root.fullPath)) {
12090
12607
  throw new DinoxError("Cannot move a tag under itself or one of its descendants");
@@ -12371,10 +12888,10 @@ function requireArg2(value, message) {
12371
12888
  return trimmed;
12372
12889
  }
12373
12890
  async function runTagRename(context) {
12374
- const path5 = requireArg2(context.args.path, "Tag path is required");
12891
+ const path6 = requireArg2(context.args.path, "Tag path is required");
12375
12892
  const newName = requireArg2(context.args.newName, "New tag name is required");
12376
12893
  await withTagWriteRuntime(context, async ({ runtime, userId, durability }) => {
12377
- const result = await renameTag(runtime.db, { path: path5, newName, userId }, { dryRun: Boolean(context.options.dryRun) });
12894
+ const result = await renameTag(runtime.db, { path: path6, newName, userId }, { dryRun: Boolean(context.options.dryRun) });
12378
12895
  if (Boolean(context.options.dryRun)) {
12379
12896
  printDryRunPreview(buildTagMutationDryRunPreview({
12380
12897
  config: runtime.config,
@@ -12383,7 +12900,7 @@ async function runTagRename(context) {
12383
12900
  action: "rename_tag",
12384
12901
  risk: "write",
12385
12902
  summary: `Rename tag "${result.fromPath}" to "${result.toPath}".`,
12386
- inputs: { path: path5, new_name: newName },
12903
+ inputs: { path: path6, new_name: newName },
12387
12904
  changes: { updated_tags: result.updatedTags, updated_notes: result.updatedNotes }
12388
12905
  }), runtime);
12389
12906
  return;
@@ -12392,13 +12909,13 @@ async function runTagRename(context) {
12392
12909
  });
12393
12910
  }
12394
12911
  async function runTagMove(context) {
12395
- const path5 = requireArg2(context.args.path, "Tag path is required");
12912
+ const path6 = requireArg2(context.args.path, "Tag path is required");
12396
12913
  const to = typeof context.options.to === "string" ? context.options.to.trim() : "";
12397
12914
  if (!to) {
12398
12915
  throw new DinoxError("--to is required");
12399
12916
  }
12400
12917
  await withTagWriteRuntime(context, async ({ runtime, userId, durability }) => {
12401
- const result = await moveTag(runtime.db, { path: path5, to, userId }, { dryRun: Boolean(context.options.dryRun) });
12918
+ const result = await moveTag(runtime.db, { path: path6, to, userId }, { dryRun: Boolean(context.options.dryRun) });
12402
12919
  if (Boolean(context.options.dryRun)) {
12403
12920
  printDryRunPreview(buildTagMutationDryRunPreview({
12404
12921
  config: runtime.config,
@@ -12407,7 +12924,7 @@ async function runTagMove(context) {
12407
12924
  action: "move_tag",
12408
12925
  risk: "write",
12409
12926
  summary: `Move tag "${result.fromPath}" to "${result.toPath}".`,
12410
- inputs: { path: path5, to },
12927
+ inputs: { path: path6, to },
12411
12928
  changes: { updated_tags: result.updatedTags, updated_notes: result.updatedNotes }
12412
12929
  }), runtime);
12413
12930
  return;
@@ -13017,7 +13534,7 @@ async function buildTodoUpdateDryRunPreview(args) {
13017
13534
  const updates = args.updates ?? [{
13018
13535
  taskId: args.taskId ?? "",
13019
13536
  ...args.noteId !== void 0 ? { noteId: args.noteId } : {},
13020
- ...args.checked !== void 0 ? { checked: args.checked } : {},
13537
+ ...args.status !== void 0 ? { status: args.status } : {},
13021
13538
  ...args.priority !== void 0 ? { priority: args.priority } : {},
13022
13539
  ...args.schedule !== void 0 ? { schedule: args.schedule } : {}
13023
13540
  }];
@@ -13029,16 +13546,16 @@ async function buildTodoUpdateDryRunPreview(args) {
13029
13546
  note_id: plan.noteId,
13030
13547
  note_title: (plan.row.title ?? "").trim(),
13031
13548
  ...result,
13032
- updated: plan.write !== null && (result.checked_from !== result.checked_to || result.priority_from !== result.priority_to || JSON.stringify(result.due_from) !== JSON.stringify(result.due_to) || result.cascaded_task_ids.length > 0)
13549
+ updated: plan.write !== null && (result.status_from !== result.status_to || result.priority_from !== result.priority_to || JSON.stringify(result.due_from) !== JSON.stringify(result.due_to) || result.cascaded_task_ids.length > 0)
13033
13550
  })));
13034
13551
  const warnings = buildExecutionWarnings4(args.config, args.offline);
13035
13552
  if (single) {
13036
13553
  const task = tasks[0];
13037
13554
  const patch = updates[0];
13038
13555
  const changes = {};
13039
- if (patch.checked !== void 0) {
13040
- changes.checked_from = task.checked_from;
13041
- changes.checked_to = task.checked_to;
13556
+ if (patch.status !== void 0) {
13557
+ changes.status_from = task.status_from;
13558
+ changes.status_to = task.status_to;
13042
13559
  }
13043
13560
  if (patch.priority !== void 0) {
13044
13561
  changes.priority_from = task.priority_from;
@@ -13060,7 +13577,7 @@ async function buildTodoUpdateDryRunPreview(args) {
13060
13577
  inputs: {
13061
13578
  task_id: task.task_id,
13062
13579
  note_id: args.noteId?.trim() || null,
13063
- ...patch.checked !== void 0 ? { status_to: patch.checked ? "completed" : "uncompleted" } : {},
13580
+ ...patch.status !== void 0 ? { status_to: patch.status } : {},
13064
13581
  ...patch.priority !== void 0 ? { priority_to: patch.priority ?? "none" } : {},
13065
13582
  ...patch.schedule !== void 0 ? { schedule: patch.schedule } : {}
13066
13583
  },
@@ -13133,12 +13650,12 @@ async function parseJsonInput(value, optionName) {
13133
13650
  throw new DinoxError(`${optionName} must be valid JSON`, { code: "INVALID_ARGUMENT", cause: error });
13134
13651
  }
13135
13652
  }
13136
- function toDraftItems(value, path5 = "--items") {
13653
+ function toDraftItems(value, path6 = "--items") {
13137
13654
  if (!Array.isArray(value)) {
13138
- throw new DinoxError(`${path5} must be a JSON array of task items`, { code: "INVALID_ARGUMENT" });
13655
+ throw new DinoxError(`${path6} must be a JSON array of task items`, { code: "INVALID_ARGUMENT" });
13139
13656
  }
13140
13657
  return value.map((entry, index) => {
13141
- const where = `${path5}[${index}]`;
13658
+ const where = `${path6}[${index}]`;
13142
13659
  if (typeof entry === "string") return { text: entry };
13143
13660
  if (!entry || typeof entry !== "object") {
13144
13661
  throw new DinoxError(`${where} must be a string or an object with "text"`, { code: "INVALID_ARGUMENT" });
@@ -13148,7 +13665,7 @@ function toDraftItems(value, path5 = "--items") {
13148
13665
  throw new DinoxError(`${where}.text must be a string`, { code: "INVALID_ARGUMENT" });
13149
13666
  }
13150
13667
  const draft = { text: item.text };
13151
- if (item.checked !== void 0) draft.checked = item.checked === true;
13668
+ if (item.status !== void 0 && item.status !== null) draft.status = parseTaskStatusValue(item.status, `${where}.status`);
13152
13669
  if (item.priority !== void 0 && item.priority !== null) {
13153
13670
  draft.priority = parsePriorityValue(item.priority, `${where}.priority`);
13154
13671
  }
@@ -13191,8 +13708,7 @@ function toTaskUpdates(value) {
13191
13708
  const noteId = item.note_id ?? item.noteId;
13192
13709
  const update = { taskId };
13193
13710
  if (typeof noteId === "string") update.noteId = noteId;
13194
- if (item.status !== void 0) update.checked = parseTaskCheckedStatus(item.status);
13195
- if (typeof item.checked === "boolean") update.checked = item.checked;
13711
+ if (item.status !== void 0) update.status = parseTaskStatusValue(item.status, `${where}.status`);
13196
13712
  if (item.priority !== void 0) {
13197
13713
  update.priority = item.priority === null ? null : parsePriorityValue(item.priority, `${where}.priority`);
13198
13714
  }
@@ -13202,24 +13718,20 @@ function toTaskUpdates(value) {
13202
13718
  return update;
13203
13719
  });
13204
13720
  }
13205
- function parseTaskStatus(value) {
13721
+ var TASK_STATUS_LIST = TASK_STATUS_VALUES.join(", ");
13722
+ function parseTaskStatusValue(value, optionName) {
13206
13723
  const normalized = typeof value === "string" ? value.trim().toLowerCase() : "";
13207
- if (normalized === "all" || normalized === "completed" || normalized === "uncompleted") {
13208
- return normalized;
13209
- }
13210
- throw new DinoxError("--status must be one of: all, completed, uncompleted");
13724
+ if (isTaskStatus(normalized)) return normalized;
13725
+ throw new DinoxError(`${optionName} must be one of: ${TASK_STATUS_LIST}`, { code: "INVALID_ARGUMENT" });
13211
13726
  }
13212
- function parseTaskCheckedStatus(value) {
13213
- const normalized = typeof value === "string" ? value.trim().toLowerCase() : "";
13214
- if (normalized === "completed" || normalized === "done" || normalized === "true" || normalized === "1") {
13215
- return true;
13216
- }
13217
- if (normalized === "uncompleted" || normalized === "todo" || normalized === "undone" || normalized === "false" || normalized === "0") {
13218
- return false;
13727
+ function parseTaskStatusFilter(value) {
13728
+ if (value === void 0 || value === null) return [];
13729
+ const entries = typeof value === "string" ? value.split(/[\s,,]+/).filter(Boolean) : [];
13730
+ if (entries.length === 0) {
13731
+ throw new DinoxError(`--status must list one or more of: ${TASK_STATUS_LIST}`, { code: "INVALID_ARGUMENT" });
13219
13732
  }
13220
- throw new DinoxError(
13221
- "--status must be one of: completed, uncompleted, done, undone, true, false, 1, 0"
13222
- );
13733
+ const wanted = new Set(entries.map((entry) => parseTaskStatusValue(entry, "--status")));
13734
+ return TASK_STATUS_VALUES.filter((status) => wanted.has(status));
13223
13735
  }
13224
13736
  function parsePositiveIntegerOption2(value, optionName, fallback, max) {
13225
13737
  if (value === void 0 || value === null || value === "") {
@@ -13318,7 +13830,7 @@ async function withTodoDatabase(globals, run) {
13318
13830
  async function runTodoSearch({ args, globals, options }) {
13319
13831
  const searchOptions = options;
13320
13832
  const keyword = args.query?.trim() ?? "";
13321
- const taskStatus = parseTaskStatus(searchOptions.status);
13833
+ const taskStatus = parseTaskStatusFilter(searchOptions.status);
13322
13834
  const taskTagFilter = typeof searchOptions.tags === "string" ? await parseTagFilterInput(searchOptions.tags) : [];
13323
13835
  const taskPriorityFilter = parsePriorityFilter(searchOptions.priority);
13324
13836
  const taskDateRange = parseTaskDateRange({
@@ -13434,7 +13946,7 @@ function parseSingleUpdate(taskId, options) {
13434
13946
  const update = { taskId };
13435
13947
  const noteId = optionalString(options.noteId);
13436
13948
  if (noteId !== void 0) update.noteId = noteId;
13437
- if (options.status !== void 0) update.checked = parseTaskCheckedStatus(options.status);
13949
+ if (options.status !== void 0) update.status = parseTaskStatusValue(options.status, "--status");
13438
13950
  if (options.priority !== void 0) update.priority = parsePriorityValue(options.priority, "--priority");
13439
13951
  const schedule = parseScheduleOptions(options.due, options.time);
13440
13952
  if (options.clearDue) {
@@ -13486,7 +13998,7 @@ async function runTodoUpdate({ args, globals, options }) {
13486
13998
  offline,
13487
13999
  taskId: update.taskId,
13488
14000
  noteId: update.noteId,
13489
- checked: update.checked,
14001
+ status: update.status,
13490
14002
  priority: update.priority,
13491
14003
  schedule: update.schedule
13492
14004
  });
@@ -13513,7 +14025,7 @@ var todoSearchCommand = {
13513
14025
  }
13514
14026
  ],
13515
14027
  options: [
13516
- { flags: "--status <status>", description: "Task status: all | completed | uncompleted", defaultValue: "all" },
14028
+ { flags: "--status <list>", description: "Statuses to keep, comma-separated: backlog,todo,in_progress,done,cancelled (omit for every status)" },
13517
14029
  { flags: "--tags <string|@file>", description: "Tags every task must carry, via its own #tag or its note's tags (JSON array or comma/newline-separated)" },
13518
14030
  { flags: "--priority <list>", description: "Priorities to keep, comma-separated: high,medium,low,none" },
13519
14031
  { flags: "--from <date>", description: "Task date range start (YYYY-MM-DD or ISO datetime); matches tasks whose schedule overlaps the range" },
@@ -13536,9 +14048,9 @@ var todoSearchCommand = {
13536
14048
  metaFields: ["stale", "meta.query", "meta.returned_count", "meta.total_count", "meta.total_count_is_lower_bound", "meta.matched_note_count", "meta.limit", "meta.offset", "meta.has_more", "meta.next_cursor", "meta.scan_limit", "meta.scanned_note_count", "meta.scan_truncated", "meta.truncated", "meta.applied_filters.status", "meta.applied_filters.tags", "meta.applied_filters.priority", "meta.applied_filters.include_deleted", "meta.applied_filters.date_range"]
13537
14049
  },
13538
14050
  examples: [
13539
- 'dino todo search "\u62A5\u9500" --status uncompleted --format json',
14051
+ 'dino todo search "\u62A5\u9500" --status backlog,todo,in_progress --format json',
13540
14052
  "dino todo search --days 7 --format json",
13541
- "dino todo search --status uncompleted --priority high,medium --format json"
14053
+ "dino todo search --status todo,in_progress --priority high,medium --format json"
13542
14054
  ]
13543
14055
  },
13544
14056
  action: runTodoSearch
@@ -13553,7 +14065,7 @@ var NEW_TASK_OPTIONS = [
13553
14065
  { flags: "--tasks <string|@file>", description: "Task list (JSON array or comma/newline-separated)" },
13554
14066
  {
13555
14067
  flags: "--items <json|@file>",
13556
- description: "Structured tasks: JSON array of {text, checked?, priority?, schedule?: {date, time?}, subtasks?: [...]}"
14068
+ description: "Structured tasks: JSON array of {text, status?, priority?, schedule?: {date, time?}, subtasks?: [...]} (status: backlog|todo|in_progress|done|cancelled, default todo)"
13557
14069
  },
13558
14070
  { flags: "--priority <priority>", description: "Priority for --task/--tasks: high|medium|low" },
13559
14071
  { flags: "--due <date>", description: "Due date for --task/--tasks (local YYYY-MM-DD)" },
@@ -13584,7 +14096,7 @@ var todoAppendCommand = {
13584
14096
  output: {
13585
14097
  type: "structured",
13586
14098
  summary: "Append result with target note, created tasks, and write receipt",
13587
- fields: ["note_id", "appended_count", "source", "created", "day_key", "parent_task_id", "tasks.task_id", "tasks.text", "tasks.priority", "tasks.parent_task_id", "tasks.due_time", ...TODO_WRITE_RECEIPT_FIELDS]
14099
+ fields: ["note_id", "appended_count", "source", "created", "day_key", "parent_task_id", "tasks.task_id", "tasks.text", "tasks.status", "tasks.priority", "tasks.parent_task_id", "tasks.due_time", ...TODO_WRITE_RECEIPT_FIELDS]
13588
14100
  },
13589
14101
  examples: [
13590
14102
  'dino todo append "\u8865\u4EA4\u62A5\u9500\u5355" --priority high --due 2026-11-10 --format json',
@@ -13617,7 +14129,7 @@ var todoCreateCommand = {
13617
14129
  output: {
13618
14130
  type: "structured",
13619
14131
  summary: "Creation result with new note id, created task count, and write receipt",
13620
- fields: ["note_id", "created_count", "title", "tasks.task_id", "tasks.text", "tasks.priority", "tasks.parent_task_id", "tasks.due_time", ...TODO_WRITE_RECEIPT_FIELDS]
14132
+ fields: ["note_id", "created_count", "title", "tasks.task_id", "tasks.text", "tasks.status", "tasks.priority", "tasks.parent_task_id", "tasks.due_time", ...TODO_WRITE_RECEIPT_FIELDS]
13621
14133
  },
13622
14134
  examples: ['dino todo create --task "\u8865\u4EA4\u62A5\u9500\u5355" --task "\u6574\u7406\u53D1\u7968" --format json']
13623
14135
  },
@@ -13625,7 +14137,7 @@ var todoCreateCommand = {
13625
14137
  };
13626
14138
  var todoUpdateCommand = {
13627
14139
  name: "update",
13628
- description: "Update a task's status, priority, or due time by task id (checking cascades to subtasks)",
14140
+ description: "Update a task's status, priority, or due time by task id (closing cascades to subtasks, reopening to parents)",
13629
14141
  arguments: [
13630
14142
  {
13631
14143
  syntax: "[taskId]",
@@ -13635,7 +14147,7 @@ var todoUpdateCommand = {
13635
14147
  options: [
13636
14148
  {
13637
14149
  flags: "--status <status>",
13638
- description: "Target status: completed|uncompleted|done|undone|true|false|1|0"
14150
+ description: "Set the status: backlog|todo|in_progress|done|cancelled"
13639
14151
  },
13640
14152
  { flags: "--priority <priority>", description: "Set priority: high|medium|low, or none to clear" },
13641
14153
  { flags: "--due <date>", description: "Set the due date (local YYYY-MM-DD)" },
@@ -13657,10 +14169,10 @@ var todoUpdateCommand = {
13657
14169
  output: {
13658
14170
  type: "structured",
13659
14171
  summary: "Mutation result with the task's new state, cascaded tasks, and write receipt (batch: per-task results and per-note receipts)",
13660
- fields: ["task_id", "checked", "priority", "due_time", "cascaded_task_ids", "updated", "note_id", "updated_count", "note_ids", "tasks.task_id", "tasks.updated", "notes.note_id", ...TODO_WRITE_RECEIPT_FIELDS]
14172
+ fields: ["task_id", "status", "priority", "due_time", "cascaded_task_ids", "updated", "note_id", "updated_count", "note_ids", "tasks.task_id", "tasks.updated", "notes.note_id", ...TODO_WRITE_RECEIPT_FIELDS]
13661
14173
  },
13662
14174
  examples: [
13663
- "dino todo update <taskId> --note-id <noteId> --status completed --format json",
14175
+ "dino todo update <taskId> --note-id <noteId> --status done --format json",
13664
14176
  "dino todo update <taskId> --priority high --due 2026-11-10 --time 09:30 --format json",
13665
14177
  `dino todo update --updates '[{"task_id":"<id>","status":"done"},{"task_id":"<id2>","priority":"none"}]' --format json`
13666
14178
  ]
@@ -13996,7 +14508,7 @@ function parseMcpGroups(raw) {
13996
14508
  }
13997
14509
  async function runMcp(context) {
13998
14510
  const groups = parseMcpGroups(context.options.groups);
13999
- const { serveStandaloneMcpOverStdio } = await import("./mcpServer-NYJAKMVH.js");
14511
+ const { serveStandaloneMcpOverStdio } = await import("./mcpServer-G2WEAD2O.js");
14000
14512
  await serveStandaloneMcpOverStdio({ readOnly: context.options.readOnly === true, groups });
14001
14513
  }
14002
14514
  var mcpCommandDescriptor = {
@@ -14080,8 +14592,8 @@ var COMMAND_SCHEMA_MAP = new Map(COMMAND_SCHEMAS.map((schema) => [schema.path, s
14080
14592
  function listCommandSchemas() {
14081
14593
  return [...COMMAND_SCHEMAS];
14082
14594
  }
14083
- function findCommandSchema(path5) {
14084
- return COMMAND_SCHEMA_MAP.get(path5) ?? null;
14595
+ function findCommandSchema(path6) {
14596
+ return COMMAND_SCHEMA_MAP.get(path6) ?? null;
14085
14597
  }
14086
14598
 
14087
14599
  export {