agent-remnote 0.3.0 → 0.4.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.
package/dist/main.js CHANGED
@@ -74153,6 +74153,9 @@ var ROOT_VALUE_FLAGS = new Set([
74153
74153
  "--ws-port",
74154
74154
  "--repo",
74155
74155
  "--api-base-url",
74156
+ "--api-host",
74157
+ "--api-port",
74158
+ "--api-base-path",
74156
74159
  "--config-file",
74157
74160
  ...BUILTIN_VALUE_FLAGS
74158
74161
  ]);
@@ -74209,6 +74212,10 @@ function normalizeApiBasePath(raw4) {
74209
74212
  return "/v1";
74210
74213
  return trimmed2.startsWith("/") ? trimmed2 : `/${trimmed2}`;
74211
74214
  }
74215
+ function normalizeApiHost(raw4) {
74216
+ const trimmed2 = raw4.trim();
74217
+ return trimmed2 || "0.0.0.0";
74218
+ }
74212
74219
  function normalizeApiBaseUrl(raw4) {
74213
74220
  const trimmed2 = raw4.trim();
74214
74221
  if (!trimmed2)
@@ -74235,6 +74242,18 @@ function normalizeApiBaseUrl(raw4) {
74235
74242
  const normalized = trimmed2.replace(/\/+$/, "");
74236
74243
  return normalized;
74237
74244
  }
74245
+ function normalizeApiPort(raw4) {
74246
+ const value8 = typeof raw4 === "number" ? raw4 : Number.parseInt(String(raw4).trim(), 10);
74247
+ if (!Number.isInteger(value8) || value8 <= 0 || value8 > 65535) {
74248
+ throw new CliError({
74249
+ code: "INVALID_ARGS",
74250
+ message: `Invalid apiPort: ${String(raw4)}`,
74251
+ exitCode: 2,
74252
+ details: { api_port: raw4 }
74253
+ });
74254
+ }
74255
+ return value8;
74256
+ }
74238
74257
  function resolveWsStateFile(spec) {
74239
74258
  const raw4 = spec.trim();
74240
74259
  if (raw4 === "0" || raw4.toLowerCase() === "false") {
@@ -74327,9 +74346,12 @@ var rawConfigSpec = all8({
74327
74346
  statusLineDebug: boolean4("statusLineDebug").pipe(withDefault2(false)),
74328
74347
  statusLineJsonFile: string5("statusLineJsonFile").pipe(withDefault2(defaultStatusLineJsonFilePath())),
74329
74348
  apiBaseUrl: string5("apiBaseUrl").pipe(withDefault2("")),
74330
- apiHost: string5("apiHost").pipe(withDefault2("0.0.0.0")),
74331
- apiPort: port2("apiPort").pipe(withDefault2(3000)),
74332
- apiBasePath: string5("apiBasePath").pipe(withDefault2("/v1")),
74349
+ apiHost: string5("apiHost").pipe(withDefault2("")),
74350
+ apiPort: integer2("apiPort").pipe(withDefault2(-1), validate3({
74351
+ message: "apiPort must be -1 or a valid port",
74352
+ validation: (n) => Number.isInteger(n) && (n === -1 || n > 0 && n <= 65535)
74353
+ })),
74354
+ apiBasePath: string5("apiBasePath").pipe(withDefault2("")),
74333
74355
  apiPidFile: string5("apiPidFile").pipe(withDefault2(defaultApiPidFilePath())),
74334
74356
  apiLogFile: string5("apiLogFile").pipe(withDefault2(defaultApiLogFilePath())),
74335
74357
  apiStateFile: string5("apiStateFile").pipe(withDefault2(defaultApiStateFilePath()))
@@ -74390,11 +74412,16 @@ function readUserConfigFile(configFile) {
74390
74412
  }
74391
74413
  const config3 = parsed;
74392
74414
  const api = config3.api;
74393
- const nestedBaseUrl = api && typeof api === "object" && !Array.isArray(api) ? api.baseUrl : undefined;
74415
+ const apiObject = api && typeof api === "object" && !Array.isArray(api) ? api : undefined;
74416
+ const nestedBaseUrl = apiObject?.baseUrl;
74417
+ const nestedHost = apiObject?.host;
74418
+ const nestedPort = apiObject?.port;
74419
+ const nestedBasePath = apiObject?.basePath;
74394
74420
  const apiBaseUrl = config3.apiBaseUrl ?? nestedBaseUrl;
74395
- if (apiBaseUrl === undefined)
74396
- return {};
74397
- if (typeof apiBaseUrl !== "string") {
74421
+ const apiHostRaw = config3.apiHost ?? nestedHost;
74422
+ const apiPortRaw = config3.apiPort ?? nestedPort;
74423
+ const apiBasePathRaw = config3.apiBasePath ?? nestedBasePath;
74424
+ if (apiBaseUrl !== undefined && typeof apiBaseUrl !== "string") {
74398
74425
  throw new CliError({
74399
74426
  code: "INVALID_ARGS",
74400
74427
  message: `Config key apiBaseUrl must be a string: ${file6}`,
@@ -74402,7 +74429,43 @@ function readUserConfigFile(configFile) {
74402
74429
  details: { config_file: file6 }
74403
74430
  });
74404
74431
  }
74405
- return { apiBaseUrl };
74432
+ const apiHost = apiHostRaw === undefined ? undefined : (() => {
74433
+ if (typeof apiHostRaw !== "string") {
74434
+ throw new CliError({
74435
+ code: "INVALID_ARGS",
74436
+ message: `Config key apiHost must be a string: ${file6}`,
74437
+ exitCode: 2,
74438
+ details: { config_file: file6 }
74439
+ });
74440
+ }
74441
+ return normalizeApiHost(apiHostRaw);
74442
+ })();
74443
+ const apiPort = apiPortRaw === undefined ? undefined : (() => {
74444
+ if (typeof apiPortRaw !== "number" && typeof apiPortRaw !== "string") {
74445
+ throw new CliError({
74446
+ code: "INVALID_ARGS",
74447
+ message: `Config key apiPort must be a valid port number: ${file6}`,
74448
+ exitCode: 2,
74449
+ details: { config_file: file6 }
74450
+ });
74451
+ }
74452
+ return normalizeApiPort(apiPortRaw);
74453
+ })();
74454
+ const apiBasePath = apiBasePathRaw === undefined ? undefined : (() => {
74455
+ if (typeof apiBasePathRaw !== "string") {
74456
+ throw new CliError({
74457
+ code: "INVALID_ARGS",
74458
+ message: `Config key apiBasePath must be a string: ${file6}`,
74459
+ exitCode: 2,
74460
+ details: { config_file: file6 }
74461
+ });
74462
+ }
74463
+ return normalizeApiBasePath(apiBasePathRaw);
74464
+ })();
74465
+ if (apiBaseUrl === undefined && apiHost === undefined && apiPort === undefined && apiBasePath === undefined) {
74466
+ return {};
74467
+ }
74468
+ return { apiBaseUrl, apiHost, apiPort, apiBasePath };
74406
74469
  }
74407
74470
  function resolveConfig() {
74408
74471
  return gen2(function* () {
@@ -74434,6 +74497,11 @@ function resolveConfig() {
74434
74497
  });
74435
74498
  const apiBaseUrlRaw = optionalTrimmed(raw4.apiBaseUrl) ?? optionalTrimmed(userConfig.apiBaseUrl ?? "");
74436
74499
  const apiBaseUrl = apiBaseUrlRaw ? normalizeApiBaseUrl(apiBaseUrlRaw) : undefined;
74500
+ const apiHostRaw = optionalTrimmed(raw4.apiHost ?? "") ?? optionalTrimmed(userConfig.apiHost ?? "") ?? "0.0.0.0";
74501
+ const apiHost = normalizeApiHost(apiHostRaw);
74502
+ const apiPort = raw4.apiPort && raw4.apiPort > 0 ? raw4.apiPort : userConfig.apiPort ?? 3000;
74503
+ const apiBasePathRaw = optionalTrimmed(raw4.apiBasePath ?? "") ?? optionalTrimmed(userConfig.apiBasePath ?? "") ?? "/v1";
74504
+ const apiBasePath = normalizeApiBasePath(apiBasePathRaw);
74437
74505
  return {
74438
74506
  format: format8,
74439
74507
  quiet: raw4.quiet,
@@ -74455,9 +74523,9 @@ function resolveConfig() {
74455
74523
  statusLineDebug: raw4.statusLineDebug,
74456
74524
  statusLineJsonFile: resolveUserFilePath(raw4.statusLineJsonFile),
74457
74525
  apiBaseUrl,
74458
- apiHost: raw4.apiHost.trim() || "0.0.0.0",
74459
- apiPort: raw4.apiPort,
74460
- apiBasePath: normalizeApiBasePath(raw4.apiBasePath),
74526
+ apiHost,
74527
+ apiPort,
74528
+ apiBasePath,
74461
74529
  apiPidFile: resolveUserFilePath(raw4.apiPidFile),
74462
74530
  apiLogFile: resolveUserFilePath(raw4.apiLogFile),
74463
74531
  apiStateFile: resolveUserFilePath(raw4.apiStateFile)
@@ -74486,6 +74554,12 @@ function canonicalKey(input) {
74486
74554
  }
74487
74555
  if (key === "apiBaseUrl" || key === "api.baseUrl" || key === "api-base-url")
74488
74556
  return "apiBaseUrl";
74557
+ if (key === "apiHost" || key === "api.host" || key === "api-host")
74558
+ return "apiHost";
74559
+ if (key === "apiPort" || key === "api.port" || key === "api-port")
74560
+ return "apiPort";
74561
+ if (key === "apiBasePath" || key === "api.basePath" || key === "api-base-path")
74562
+ return "apiBasePath";
74489
74563
  throw new CliError({ code: "INVALID_ARGS", message: `Unsupported config key: ${key}`, exitCode: 2 });
74490
74564
  }
74491
74565
  function isPlainObject(value8) {
@@ -74513,11 +74587,82 @@ function readApiBaseUrl(doc) {
74513
74587
  }
74514
74588
  return { value: rootValue ?? nestedValue, errors: errors3 };
74515
74589
  }
74590
+ function normalizeApiHostCandidate(candidate, keyName, errors3) {
74591
+ if (candidate === undefined)
74592
+ return;
74593
+ if (typeof candidate !== "string") {
74594
+ errors3.push(`Config key ${keyName} must be a string`);
74595
+ return;
74596
+ }
74597
+ return normalizeApiHost(candidate);
74598
+ }
74599
+ function readApiHost(doc) {
74600
+ const errors3 = [];
74601
+ const root = doc.apiHost;
74602
+ const api = doc.api;
74603
+ const nested4 = isPlainObject(api) ? api.host : undefined;
74604
+ const rootValue = normalizeApiHostCandidate(root, "apiHost", errors3);
74605
+ const nestedValue = normalizeApiHostCandidate(nested4, "api.host", errors3);
74606
+ if (rootValue !== undefined && nestedValue !== undefined && rootValue !== nestedValue) {
74607
+ errors3.push("Config keys apiHost and api.host conflict");
74608
+ }
74609
+ return { value: rootValue ?? nestedValue, errors: errors3 };
74610
+ }
74611
+ function normalizeApiPortCandidate(candidate, keyName, errors3) {
74612
+ if (candidate === undefined)
74613
+ return;
74614
+ if (typeof candidate !== "number" && typeof candidate !== "string") {
74615
+ errors3.push(`Config key ${keyName} must be a valid port number`);
74616
+ return;
74617
+ }
74618
+ try {
74619
+ return normalizeApiPort(candidate);
74620
+ } catch (error4) {
74621
+ errors3.push(isCliError(error4) ? error4.message : `Config key ${keyName} must be a valid port number`);
74622
+ return;
74623
+ }
74624
+ }
74625
+ function readApiPort(doc) {
74626
+ const errors3 = [];
74627
+ const root = doc.apiPort;
74628
+ const api = doc.api;
74629
+ const nested4 = isPlainObject(api) ? api.port : undefined;
74630
+ const rootValue = normalizeApiPortCandidate(root, "apiPort", errors3);
74631
+ const nestedValue = normalizeApiPortCandidate(nested4, "api.port", errors3);
74632
+ if (rootValue !== undefined && nestedValue !== undefined && rootValue !== nestedValue) {
74633
+ errors3.push("Config keys apiPort and api.port conflict");
74634
+ }
74635
+ return { value: rootValue ?? nestedValue, errors: errors3 };
74636
+ }
74637
+ function normalizeApiBasePathCandidate(candidate, keyName, errors3) {
74638
+ if (candidate === undefined)
74639
+ return;
74640
+ if (typeof candidate !== "string") {
74641
+ errors3.push(`Config key ${keyName} must be a string`);
74642
+ return;
74643
+ }
74644
+ return normalizeApiBasePath(candidate);
74645
+ }
74646
+ function readApiBasePath(doc) {
74647
+ const errors3 = [];
74648
+ const root = doc.apiBasePath;
74649
+ const api = doc.api;
74650
+ const nested4 = isPlainObject(api) ? api.basePath : undefined;
74651
+ const rootValue = normalizeApiBasePathCandidate(root, "apiBasePath", errors3);
74652
+ const nestedValue = normalizeApiBasePathCandidate(nested4, "api.basePath", errors3);
74653
+ if (rootValue !== undefined && nestedValue !== undefined && rootValue !== nestedValue) {
74654
+ errors3.push("Config keys apiBasePath and api.basePath conflict");
74655
+ }
74656
+ return { value: rootValue ?? nestedValue, errors: errors3 };
74657
+ }
74516
74658
  function inspectDoc(configFile, exists3, doc) {
74517
74659
  const apiBaseUrl = readApiBaseUrl(doc);
74660
+ const apiHost = readApiHost(doc);
74661
+ const apiPort = readApiPort(doc);
74662
+ const apiBasePath = readApiBasePath(doc);
74518
74663
  const unknownKeys = [];
74519
74664
  for (const key of Object.keys(doc)) {
74520
- if (key === "apiBaseUrl")
74665
+ if (key === "apiBaseUrl" || key === "apiHost" || key === "apiPort" || key === "apiBasePath")
74521
74666
  continue;
74522
74667
  if (key !== "api") {
74523
74668
  unknownKeys.push(key);
@@ -74528,18 +74673,25 @@ function inspectDoc(configFile, exists3, doc) {
74528
74673
  continue;
74529
74674
  }
74530
74675
  for (const nestedKey of Object.keys(api)) {
74531
- if (nestedKey === "baseUrl")
74676
+ if (nestedKey === "baseUrl" || nestedKey === "host" || nestedKey === "port" || nestedKey === "basePath") {
74532
74677
  continue;
74678
+ }
74533
74679
  unknownKeys.push(`api.${nestedKey}`);
74534
74680
  }
74535
74681
  }
74682
+ const errors3 = [...apiBaseUrl.errors, ...apiHost.errors, ...apiPort.errors, ...apiBasePath.errors];
74536
74683
  return {
74537
74684
  configFile,
74538
74685
  exists: exists3,
74539
- values: { apiBaseUrl: apiBaseUrl.value },
74686
+ values: {
74687
+ apiBaseUrl: apiBaseUrl.value,
74688
+ apiHost: apiHost.value,
74689
+ apiPort: apiPort.value,
74690
+ apiBasePath: apiBasePath.value
74691
+ },
74540
74692
  unknownKeys,
74541
- errors: apiBaseUrl.errors,
74542
- valid: apiBaseUrl.errors.length === 0
74693
+ errors: errors3,
74694
+ valid: errors3.length === 0
74543
74695
  };
74544
74696
  }
74545
74697
  async function ensureDir(filePath) {
@@ -74612,6 +74764,36 @@ function setApiBaseUrl(doc, value8) {
74612
74764
  }
74613
74765
  return next4;
74614
74766
  }
74767
+ function setApiHost(doc, value8) {
74768
+ const next4 = cloneDoc(doc);
74769
+ next4.apiHost = normalizeApiHost(value8);
74770
+ const api = next4.api;
74771
+ if (isPlainObject(api)) {
74772
+ delete api.host;
74773
+ removeEmptyApiObject(next4);
74774
+ }
74775
+ return next4;
74776
+ }
74777
+ function setApiPort(doc, value8) {
74778
+ const next4 = cloneDoc(doc);
74779
+ next4.apiPort = normalizeApiPort(value8);
74780
+ const api = next4.api;
74781
+ if (isPlainObject(api)) {
74782
+ delete api.port;
74783
+ removeEmptyApiObject(next4);
74784
+ }
74785
+ return next4;
74786
+ }
74787
+ function setApiBasePath(doc, value8) {
74788
+ const next4 = cloneDoc(doc);
74789
+ next4.apiBasePath = normalizeApiBasePath(value8);
74790
+ const api = next4.api;
74791
+ if (isPlainObject(api)) {
74792
+ delete api.basePath;
74793
+ removeEmptyApiObject(next4);
74794
+ }
74795
+ return next4;
74796
+ }
74615
74797
  function unsetApiBaseUrl(doc) {
74616
74798
  const next4 = cloneDoc(doc);
74617
74799
  let removed = false;
@@ -74627,6 +74809,51 @@ function unsetApiBaseUrl(doc) {
74627
74809
  }
74628
74810
  return { next: next4, removed };
74629
74811
  }
74812
+ function unsetApiHost(doc) {
74813
+ const next4 = cloneDoc(doc);
74814
+ let removed = false;
74815
+ if (Object.prototype.hasOwnProperty.call(next4, "apiHost")) {
74816
+ delete next4.apiHost;
74817
+ removed = true;
74818
+ }
74819
+ const api = next4.api;
74820
+ if (isPlainObject(api) && Object.prototype.hasOwnProperty.call(api, "host")) {
74821
+ delete api.host;
74822
+ removeEmptyApiObject(next4);
74823
+ removed = true;
74824
+ }
74825
+ return { next: next4, removed };
74826
+ }
74827
+ function unsetApiPort(doc) {
74828
+ const next4 = cloneDoc(doc);
74829
+ let removed = false;
74830
+ if (Object.prototype.hasOwnProperty.call(next4, "apiPort")) {
74831
+ delete next4.apiPort;
74832
+ removed = true;
74833
+ }
74834
+ const api = next4.api;
74835
+ if (isPlainObject(api) && Object.prototype.hasOwnProperty.call(api, "port")) {
74836
+ delete api.port;
74837
+ removeEmptyApiObject(next4);
74838
+ removed = true;
74839
+ }
74840
+ return { next: next4, removed };
74841
+ }
74842
+ function unsetApiBasePath(doc) {
74843
+ const next4 = cloneDoc(doc);
74844
+ let removed = false;
74845
+ if (Object.prototype.hasOwnProperty.call(next4, "apiBasePath")) {
74846
+ delete next4.apiBasePath;
74847
+ removed = true;
74848
+ }
74849
+ const api = next4.api;
74850
+ if (isPlainObject(api) && Object.prototype.hasOwnProperty.call(api, "basePath")) {
74851
+ delete api.basePath;
74852
+ removeEmptyApiObject(next4);
74853
+ removed = true;
74854
+ }
74855
+ return { next: next4, removed };
74856
+ }
74630
74857
  function isEmptyDoc(doc) {
74631
74858
  return Object.keys(doc).length === 0;
74632
74859
  }
@@ -74670,7 +74897,7 @@ var UserConfigFileLive = succeed10(UserConfigFile, {
74670
74897
  catch: (error4) => toCliFailure(error4, "Invalid config file")
74671
74898
  });
74672
74899
  const inspection = inspectDoc(configFile, parsed.exists, doc);
74673
- const value8 = targetKey === "apiBaseUrl" ? inspection.values.apiBaseUrl ?? null : null;
74900
+ const value8 = targetKey === "apiBaseUrl" ? inspection.values.apiBaseUrl ?? null : targetKey === "apiHost" ? inspection.values.apiHost ?? null : targetKey === "apiPort" ? inspection.values.apiPort ?? null : targetKey === "apiBasePath" ? inspection.values.apiBasePath ?? null : null;
74674
74901
  return {
74675
74902
  configFile,
74676
74903
  key: targetKey,
@@ -74692,6 +74919,15 @@ var UserConfigFileLive = succeed10(UserConfigFile, {
74692
74919
  const next4 = targetKey === "apiBaseUrl" ? yield* try_3({
74693
74920
  try: () => setApiBaseUrl(doc, value8),
74694
74921
  catch: (error4) => toCliFailure(error4, "Invalid config value")
74922
+ }) : targetKey === "apiHost" ? yield* try_3({
74923
+ try: () => setApiHost(doc, value8),
74924
+ catch: (error4) => toCliFailure(error4, "Invalid config value")
74925
+ }) : targetKey === "apiPort" ? yield* try_3({
74926
+ try: () => setApiPort(doc, value8),
74927
+ catch: (error4) => toCliFailure(error4, "Invalid config value")
74928
+ }) : targetKey === "apiBasePath" ? yield* try_3({
74929
+ try: () => setApiBasePath(doc, value8),
74930
+ catch: (error4) => toCliFailure(error4, "Invalid config value")
74695
74931
  }) : doc;
74696
74932
  yield* tryPromise2({
74697
74933
  try: async () => await writeDoc(configFile, next4),
@@ -74705,7 +74941,7 @@ var UserConfigFileLive = succeed10(UserConfigFile, {
74705
74941
  return {
74706
74942
  configFile,
74707
74943
  key: targetKey,
74708
- value: String(next4.apiBaseUrl ?? ""),
74944
+ value: targetKey === "apiBaseUrl" ? String(next4.apiBaseUrl ?? "") : targetKey === "apiHost" ? String(next4.apiHost ?? "") : targetKey === "apiPort" ? Number(next4.apiPort) : targetKey === "apiBasePath" ? String(next4.apiBasePath ?? "") : "",
74709
74945
  changed: true
74710
74946
  };
74711
74947
  }),
@@ -74728,7 +74964,7 @@ var UserConfigFileLive = succeed10(UserConfigFile, {
74728
74964
  fileDeleted: false
74729
74965
  };
74730
74966
  }
74731
- const result = targetKey === "apiBaseUrl" ? unsetApiBaseUrl(doc) : { next: doc, removed: false };
74967
+ const result = targetKey === "apiBaseUrl" ? unsetApiBaseUrl(doc) : targetKey === "apiHost" ? unsetApiHost(doc) : targetKey === "apiPort" ? unsetApiPort(doc) : targetKey === "apiBasePath" ? unsetApiBasePath(doc) : { next: doc, removed: false };
74732
74968
  if (!result.removed) {
74733
74969
  return {
74734
74970
  configFile,
@@ -74911,6 +75147,9 @@ var configListCommand = exports_Command.make("list", {}, () => gen2(function* ()
74911
75147
  `- exists: ${data.exists}`,
74912
75148
  `- valid: ${data.valid}`,
74913
75149
  `- apiBaseUrl: ${data.values.apiBaseUrl ?? ""}`,
75150
+ `- apiHost: ${data.values.apiHost ?? ""}`,
75151
+ `- apiPort: ${data.values.apiPort ?? ""}`,
75152
+ `- apiBasePath: ${data.values.apiBasePath ?? ""}`,
74914
75153
  `- unknown_keys: ${data.unknown_keys.join(", ")}`,
74915
75154
  `- errors: ${data.errors.join(" | ")}`
74916
75155
  ];
@@ -75224,6 +75463,10 @@ var configValidateCommand = exports_Command.make("validate", {}, () => gen2(func
75224
75463
  `- config_file: ${data.config_file}`,
75225
75464
  `- exists: ${data.exists}`,
75226
75465
  `- valid: ${data.valid}`,
75466
+ `- apiBaseUrl: ${data.values.apiBaseUrl ?? ""}`,
75467
+ `- apiHost: ${data.values.apiHost ?? ""}`,
75468
+ `- apiPort: ${data.values.apiPort ?? ""}`,
75469
+ `- apiBasePath: ${data.values.apiBasePath ?? ""}`,
75227
75470
  `- unknown_keys: ${data.unknown_keys.join(", ")}`,
75228
75471
  `- errors: ${data.errors.join(" | ")}`
75229
75472
  ];
@@ -84870,7 +85113,12 @@ async function executeSearchRemOverviewWithDb(db, params3) {
84870
85113
  const offset2 = parsed.dateOffsetDays ?? 0;
84871
85114
  const now2 = new Date;
84872
85115
  const target2 = new Date(now2.getFullYear(), now2.getMonth(), now2.getDate() + offset2);
84873
- const format9 = await getDateFormatting(db) ?? "yyyy/MM/dd";
85116
+ let format9 = "yyyy/MM/dd";
85117
+ try {
85118
+ format9 = await getDateFormatting(db) ?? "yyyy/MM/dd";
85119
+ } catch {
85120
+ format9 = "yyyy/MM/dd";
85121
+ }
84874
85122
  effectiveQuery = formatDateWithPattern(target2, format9);
84875
85123
  }
84876
85124
  const items = searchRems(db, {
@@ -92418,89 +92666,271 @@ var dailySummaryCommand = exports_Command.make("summary", { days: days2, maxLine
92418
92666
  yield* writeSuccess({ data: result, md: result.markdown ?? "" });
92419
92667
  }).pipe(catchAll2(writeFailure)));
92420
92668
 
92421
- // src/services/FileInput.ts
92422
- import { promises as fs16 } from "node:fs";
92423
- class FileInput extends Tag2("FileInput")() {
92669
+ // src/services/RefResolver.ts
92670
+ class RefResolver extends Tag2("RefResolver")() {
92424
92671
  }
92425
- var DEFAULT_MAX_BYTES = 5 * 1024 * 1024;
92426
- async function readAllStdin(maxBytes) {
92427
- if (process.stdin.isTTY) {
92672
+ function stripQuotes(s) {
92673
+ const t = s.trim();
92674
+ if (t.startsWith('"') && t.endsWith('"') || t.startsWith("'") && t.endsWith("'")) {
92675
+ return t.slice(1, -1);
92676
+ }
92677
+ return t;
92678
+ }
92679
+ function parseRef(input) {
92680
+ const raw4 = input.trim();
92681
+ const link3 = tryParseRemnoteLink(raw4);
92682
+ if (link3?.remId) {
92683
+ return { kind: "id", value: link3.remId };
92684
+ }
92685
+ const idx = raw4.indexOf(":");
92686
+ if (idx <= 0) {
92428
92687
  throw new CliError({
92429
92688
  code: "INVALID_ARGS",
92430
- message: "When using -, input must be piped via stdin",
92689
+ message: `Invalid ref: ${input}`,
92690
+ exitCode: 2,
92691
+ hint: [
92692
+ "Example: --ref id:xxx",
92693
+ 'Example: --ref "remnote://w/<workspaceId>/<remId>"',
92694
+ "Example: --ref page:Demo",
92695
+ "Example: --ref title:Demo",
92696
+ "Example: --ref daily:today",
92697
+ "Example: --ref daily:-1"
92698
+ ]
92699
+ });
92700
+ }
92701
+ const kind = raw4.slice(0, idx).trim();
92702
+ const value8 = stripQuotes(raw4.slice(idx + 1));
92703
+ if (!value8) {
92704
+ throw new CliError({
92705
+ code: "INVALID_ARGS",
92706
+ message: `Invalid ref (missing value): ${input}`,
92431
92707
  exitCode: 2
92432
92708
  });
92433
92709
  }
92434
- const chunks2 = [];
92435
- let totalBytes = 0;
92436
- for await (const chunk4 of process.stdin) {
92437
- const buf = Buffer.isBuffer(chunk4) ? chunk4 : Buffer.from(String(chunk4));
92438
- totalBytes += buf.byteLength;
92439
- if (totalBytes > maxBytes) {
92440
- throw new CliError({
92441
- code: "PAYLOAD_TOO_LARGE",
92442
- message: `Input is too large (${totalBytes} bytes); split it and try again`,
92443
- exitCode: 2,
92444
- details: { bytes: totalBytes, max_bytes: maxBytes }
92445
- });
92710
+ if (kind === "id" || kind === "title" || kind === "daily") {
92711
+ if (kind === "id") {
92712
+ const link22 = tryParseRemnoteLink(value8);
92713
+ return { kind, value: link22?.remId ?? value8 };
92446
92714
  }
92447
- chunks2.push(buf);
92715
+ return { kind, value: value8 };
92448
92716
  }
92449
- return Buffer.concat(chunks2).toString("utf8");
92450
- }
92451
- async function readTextFromFilePath(pathSpec, maxBytes) {
92452
- const trimmed2 = pathSpec.trim();
92453
- if (!trimmed2) {
92454
- throw new CliError({ code: "INVALID_ARGS", message: "File path cannot be empty", exitCode: 2 });
92717
+ if (kind === "page") {
92718
+ return { kind, value: value8 };
92455
92719
  }
92456
- const resolved = resolveUserFilePath(trimmed2);
92457
- try {
92458
- const stat3 = await fs16.stat(resolved);
92459
- if (!stat3.isFile()) {
92460
- throw new CliError({ code: "INVALID_ARGS", message: `Not a file: ${resolved}`, exitCode: 2 });
92461
- }
92462
- if (Number.isFinite(stat3.size) && stat3.size > maxBytes) {
92463
- throw new CliError({
92464
- code: "PAYLOAD_TOO_LARGE",
92465
- message: `Input is too large (${stat3.size} bytes); split it and try again`,
92466
- exitCode: 2,
92467
- details: { bytes: stat3.size, max_bytes: maxBytes, file: resolved }
92468
- });
92469
- }
92470
- return await fs16.readFile(resolved, "utf8");
92471
- } catch (error4) {
92472
- if (isCliError(error4))
92473
- throw error4;
92474
- if (error4?.code === "ENOENT") {
92475
- throw new CliError({ code: "INVALID_ARGS", message: `File not found: ${resolved}`, exitCode: 2 });
92476
- }
92720
+ throw new CliError({
92721
+ code: "INVALID_ARGS",
92722
+ message: `Unsupported ref: ${input}`,
92723
+ exitCode: 2,
92724
+ hint: ["Supported prefixes: id:/page:/title:/daily:"]
92725
+ });
92726
+ }
92727
+ function parseDailyOffset(value8) {
92728
+ const v = value8.trim().toLowerCase();
92729
+ if (v === "today" || v === "now" || v === "0")
92730
+ return 0;
92731
+ if (v === "yesterday")
92732
+ return -1;
92733
+ if (v === "tomorrow")
92734
+ return 1;
92735
+ const n = Number.parseInt(v, 10);
92736
+ if (!Number.isFinite(n)) {
92477
92737
  throw new CliError({
92478
- code: "INTERNAL",
92479
- message: "Failed to read file",
92480
- exitCode: 1,
92481
- details: { file: resolved, error: String(error4?.message || error4) }
92738
+ code: "INVALID_ARGS",
92739
+ message: `Invalid daily ref: ${value8} (expected today/yesterday/tomorrow or an integer offset)`,
92740
+ exitCode: 2
92482
92741
  });
92483
92742
  }
92743
+ return n;
92484
92744
  }
92485
- function normalizeFileSpec(spec) {
92486
- const s = spec.trim();
92487
- if (s.startsWith("@"))
92488
- return s.slice(1).trim();
92489
- return s;
92490
- }
92491
- var FileInputLive = succeed10(FileInput, {
92492
- readTextFromFileSpec: ({ spec, maxBytes }) => tryPromise2({
92493
- try: async () => {
92494
- const limit = typeof maxBytes === "number" && Number.isFinite(maxBytes) && maxBytes > 0 ? maxBytes : DEFAULT_MAX_BYTES;
92495
- const normalized = normalizeFileSpec(spec);
92496
- if (normalized === "-")
92497
- return await readAllStdin(limit);
92498
- return await readTextFromFilePath(normalized, limit);
92499
- },
92500
- catch: (error4) => {
92501
- if (isCliError(error4))
92502
- return error4;
92503
- return new CliError({
92745
+ var RefResolverLive = succeed10(RefResolver, {
92746
+ resolve: (ref) => gen2(function* () {
92747
+ const cfg = yield* AppConfig;
92748
+ const parsed = yield* try_3({
92749
+ try: () => parseRef(ref),
92750
+ catch: (e) => e && typeof e === "object" && e._tag === "CliError" ? e : new CliError({ code: "INVALID_ARGS", message: `Invalid ref: ${ref}`, exitCode: 2 })
92751
+ });
92752
+ if (parsed.kind === "id")
92753
+ return parsed.value;
92754
+ const dailyOffset = parsed.kind === "daily" ? yield* try_3({
92755
+ try: () => parseDailyOffset(parsed.value),
92756
+ catch: (e) => e && typeof e === "object" && e._tag === "CliError" ? e : new CliError({
92757
+ code: "INVALID_ARGS",
92758
+ message: `Invalid daily ref: ${parsed.value}`,
92759
+ exitCode: 2
92760
+ })
92761
+ }) : undefined;
92762
+ const queryInput = parsed.kind === "title" || parsed.kind === "page" ? { query: parsed.value } : { query: "date", useCurrentDate: true, dateOffsetDays: dailyOffset };
92763
+ const result = yield* tryPromise2({
92764
+ try: async () => await executeSearchRemOverview({
92765
+ ...queryInput,
92766
+ dbPath: cfg.remnoteDb,
92767
+ limit: 1,
92768
+ preferExact: true,
92769
+ exactFirstSingle: true,
92770
+ pagesOnly: parsed.kind === "page" ? true : undefined
92771
+ }),
92772
+ catch: (e) => new CliError({
92773
+ code: "DB_UNAVAILABLE",
92774
+ message: String(e?.message || e || "RemNote DB is unavailable"),
92775
+ exitCode: 1
92776
+ })
92777
+ });
92778
+ const first3 = Array.isArray(result.matches) ? result.matches[0] : undefined;
92779
+ const id2 = first3?.id ? String(first3.id) : "";
92780
+ if (!id2) {
92781
+ return yield* fail8(new CliError({
92782
+ code: "INVALID_ARGS",
92783
+ message: `No Rem found for ref: ${ref}`,
92784
+ exitCode: 2
92785
+ }));
92786
+ }
92787
+ return id2;
92788
+ })
92789
+ });
92790
+
92791
+ // src/commands/daily/rem-id.ts
92792
+ function optionToUndefined10(opt) {
92793
+ return isSome2(opt) ? opt.value : undefined;
92794
+ }
92795
+ function parseDateInput(raw4) {
92796
+ const value8 = new Date(raw4);
92797
+ if (Number.isNaN(value8.getTime())) {
92798
+ throw new CliError({ code: "INVALID_ARGS", message: `Invalid date: ${raw4}`, exitCode: 2 });
92799
+ }
92800
+ return value8;
92801
+ }
92802
+ var date6 = text9("date").pipe(optional5, map34(optionToUndefined10));
92803
+ var offsetDays = integer7("offset-days").pipe(optional5, map34(optionToUndefined10));
92804
+ var dailyRemIdCommand = exports_Command.make("rem-id", { date: date6, offsetDays }, ({ date: date7, offsetDays: offsetDays2 }) => gen2(function* () {
92805
+ if (date7 && offsetDays2 !== undefined) {
92806
+ return yield* fail8(new CliError({ code: "INVALID_ARGS", message: "Choose only one of --date or --offset-days", exitCode: 2 }));
92807
+ }
92808
+ const cfg = yield* AppConfig;
92809
+ const refs = yield* RefResolver;
92810
+ const remDb = yield* RemDb;
92811
+ let ref = `daily:${offsetDays2 ?? 0}`;
92812
+ let remId = "";
92813
+ let dateString;
92814
+ if (date7) {
92815
+ const target2 = parseDateInput(date7);
92816
+ dateString = yield* remDb.withDb(cfg.remnoteDb, async (db) => {
92817
+ const format9 = await getDateFormatting(db) ?? "yyyy/MM/dd";
92818
+ return formatDateWithPattern(target2, format9);
92819
+ }).pipe(map17((r) => r.result), catchAll2(() => succeed8(formatDateWithPattern(target2, "yyyy/MM/dd"))));
92820
+ const searchInput = {
92821
+ query: dateString,
92822
+ dbPath: cfg.remnoteDb,
92823
+ limit: 1,
92824
+ preferExact: true,
92825
+ exactFirstSingle: true,
92826
+ excludePages: true
92827
+ };
92828
+ const result = yield* tryPromise2({
92829
+ try: async () => await executeSearchRemOverview(searchInput),
92830
+ catch: (e) => cliErrorFromUnknown(e, { code: "DB_UNAVAILABLE" })
92831
+ });
92832
+ const first3 = Array.isArray(result.matches) ? result.matches[0] : undefined;
92833
+ remId = first3?.id ? String(first3.id) : "";
92834
+ ref = `daily:${date7}`;
92835
+ if (!remId) {
92836
+ return yield* fail8(new CliError({ code: "INVALID_ARGS", message: `No Daily Rem found for date: ${date7}`, exitCode: 2 }));
92837
+ }
92838
+ } else {
92839
+ remId = yield* refs.resolve(ref);
92840
+ }
92841
+ yield* writeSuccess({
92842
+ data: { ref, remId, dateString },
92843
+ ids: [remId],
92844
+ md: `- ref: ${ref}
92845
+ - rem_id: ${remId}${dateString ? `
92846
+ - date_string: ${dateString}` : ""}
92847
+ `
92848
+ });
92849
+ }).pipe(catchAll2(writeFailure)));
92850
+
92851
+ // src/services/FileInput.ts
92852
+ import { promises as fs16 } from "node:fs";
92853
+ class FileInput extends Tag2("FileInput")() {
92854
+ }
92855
+ var DEFAULT_MAX_BYTES = 5 * 1024 * 1024;
92856
+ async function readAllStdin(maxBytes) {
92857
+ if (process.stdin.isTTY) {
92858
+ throw new CliError({
92859
+ code: "INVALID_ARGS",
92860
+ message: "When using -, input must be piped via stdin",
92861
+ exitCode: 2
92862
+ });
92863
+ }
92864
+ const chunks2 = [];
92865
+ let totalBytes = 0;
92866
+ for await (const chunk4 of process.stdin) {
92867
+ const buf = Buffer.isBuffer(chunk4) ? chunk4 : Buffer.from(String(chunk4));
92868
+ totalBytes += buf.byteLength;
92869
+ if (totalBytes > maxBytes) {
92870
+ throw new CliError({
92871
+ code: "PAYLOAD_TOO_LARGE",
92872
+ message: `Input is too large (${totalBytes} bytes); split it and try again`,
92873
+ exitCode: 2,
92874
+ details: { bytes: totalBytes, max_bytes: maxBytes }
92875
+ });
92876
+ }
92877
+ chunks2.push(buf);
92878
+ }
92879
+ return Buffer.concat(chunks2).toString("utf8");
92880
+ }
92881
+ async function readTextFromFilePath(pathSpec, maxBytes) {
92882
+ const trimmed2 = pathSpec.trim();
92883
+ if (!trimmed2) {
92884
+ throw new CliError({ code: "INVALID_ARGS", message: "File path cannot be empty", exitCode: 2 });
92885
+ }
92886
+ const resolved = resolveUserFilePath(trimmed2);
92887
+ try {
92888
+ const stat3 = await fs16.stat(resolved);
92889
+ if (!stat3.isFile()) {
92890
+ throw new CliError({ code: "INVALID_ARGS", message: `Not a file: ${resolved}`, exitCode: 2 });
92891
+ }
92892
+ if (Number.isFinite(stat3.size) && stat3.size > maxBytes) {
92893
+ throw new CliError({
92894
+ code: "PAYLOAD_TOO_LARGE",
92895
+ message: `Input is too large (${stat3.size} bytes); split it and try again`,
92896
+ exitCode: 2,
92897
+ details: { bytes: stat3.size, max_bytes: maxBytes, file: resolved }
92898
+ });
92899
+ }
92900
+ return await fs16.readFile(resolved, "utf8");
92901
+ } catch (error4) {
92902
+ if (isCliError(error4))
92903
+ throw error4;
92904
+ if (error4?.code === "ENOENT") {
92905
+ throw new CliError({ code: "INVALID_ARGS", message: `File not found: ${resolved}`, exitCode: 2 });
92906
+ }
92907
+ throw new CliError({
92908
+ code: "INTERNAL",
92909
+ message: "Failed to read file",
92910
+ exitCode: 1,
92911
+ details: { file: resolved, error: String(error4?.message || error4) }
92912
+ });
92913
+ }
92914
+ }
92915
+ function normalizeFileSpec(spec) {
92916
+ const s = spec.trim();
92917
+ if (s.startsWith("@"))
92918
+ return s.slice(1).trim();
92919
+ return s;
92920
+ }
92921
+ var FileInputLive = succeed10(FileInput, {
92922
+ readTextFromFileSpec: ({ spec, maxBytes }) => tryPromise2({
92923
+ try: async () => {
92924
+ const limit = typeof maxBytes === "number" && Number.isFinite(maxBytes) && maxBytes > 0 ? maxBytes : DEFAULT_MAX_BYTES;
92925
+ const normalized = normalizeFileSpec(spec);
92926
+ if (normalized === "-")
92927
+ return await readAllStdin(limit);
92928
+ return await readTextFromFilePath(normalized, limit);
92929
+ },
92930
+ catch: (error4) => {
92931
+ if (isCliError(error4))
92932
+ return error4;
92933
+ return new CliError({
92504
92934
  code: "INTERNAL",
92505
92935
  message: "Failed to read input",
92506
92936
  exitCode: 1,
@@ -92639,6 +93069,14 @@ function dropBlankLinesOutsideFences(input) {
92639
93069
  return out.join(`
92640
93070
  `);
92641
93071
  }
93072
+ var STRUCTURED_MARKDOWN_LINE_RE = /^\s{0,3}(?:#{1,6}\s+\S|[-*+]\s+\S|\d+\.\s+\S|```|~~~)/m;
93073
+ function looksLikeStructuredMarkdown(input) {
93074
+ const normalized = input.replace(/\r\n?/g, `
93075
+ `).trim();
93076
+ if (!normalized)
93077
+ return false;
93078
+ return STRUCTURED_MARKDOWN_LINE_RE.test(normalized);
93079
+ }
92642
93080
 
92643
93081
  // src/commands/_waitTxn.ts
92644
93082
  function normalizeTxnStatus(raw4) {
@@ -92976,32 +93414,35 @@ function normalizeOps(rawOps) {
92976
93414
  }
92977
93415
 
92978
93416
  // src/commands/daily/write.ts
92979
- function optionToUndefined10(opt) {
93417
+ function optionToUndefined11(opt) {
92980
93418
  return isSome2(opt) ? opt.value : undefined;
92981
93419
  }
92982
93420
  function readOptionalText(name) {
92983
- return text9(name).pipe(optional5, map34(optionToUndefined10));
93421
+ return text9(name).pipe(optional5, map34(optionToUndefined11));
92984
93422
  }
92985
93423
  var text14 = readOptionalText("text");
93424
+ var markdown = readOptionalText("markdown");
92986
93425
  var mdFile = readOptionalText("md-file");
92987
- var date6 = readOptionalText("date");
92988
- var offsetDays = integer7("offset-days").pipe(optional5, map34(optionToUndefined10));
93426
+ var stdin3 = boolean8("stdin");
93427
+ var date7 = readOptionalText("date");
93428
+ var offsetDays2 = integer7("offset-days").pipe(optional5, map34(optionToUndefined11));
92989
93429
  var createIfMissing = boolean8("create-if-missing");
92990
93430
  var noCreateIfMissing = boolean8("no-create-if-missing");
92991
93431
  var clientId = readOptionalText("client-id");
92992
93432
  var idempotencyKey = readOptionalText("idempotency-key");
92993
93433
  var metaSpec = readOptionalText("meta");
92994
- var priority = integer7("priority").pipe(optional5, map34(optionToUndefined10));
93434
+ var priority = integer7("priority").pipe(optional5, map34(optionToUndefined11));
92995
93435
  var notify = boolean8("no-notify").pipe(map34((v) => !v));
92996
93436
  var ensureDaemon2 = boolean8("no-ensure-daemon").pipe(map34((v) => !v));
93437
+ var forceText = boolean8("force-text");
92997
93438
  var wait = boolean8("wait");
92998
- var timeoutMs = integer7("timeout-ms").pipe(optional5, map34(optionToUndefined10));
92999
- var pollMs = integer7("poll-ms").pipe(optional5, map34(optionToUndefined10));
93000
- var bulk = choice5("bulk", ["auto", "always", "never"]).pipe(optional5, map34(optionToUndefined10));
93439
+ var timeoutMs = integer7("timeout-ms").pipe(optional5, map34(optionToUndefined11));
93440
+ var pollMs = integer7("poll-ms").pipe(optional5, map34(optionToUndefined11));
93441
+ var bulk = choice5("bulk", ["auto", "always", "never"]).pipe(optional5, map34(optionToUndefined11));
93001
93442
  var bundleTitle = readOptionalText("bundle-title");
93002
93443
  var BULK_THRESHOLD_LINES = 80;
93003
93444
  var BULK_THRESHOLD_CHARS = 5000;
93004
- function parseDateInput(raw4) {
93445
+ function parseDateInput2(raw4) {
93005
93446
  const d = new Date(raw4);
93006
93447
  if (isNaN(d.getTime())) {
93007
93448
  throw new CliError({ code: "INVALID_ARGS", message: `Invalid date: ${raw4}`, exitCode: 2 });
@@ -93014,14 +93455,17 @@ function todayAtMidnight() {
93014
93455
  }
93015
93456
  var dailyWriteCommand = exports_Command.make("write", {
93016
93457
  text: text14,
93458
+ markdown,
93017
93459
  mdFile,
93018
- date: date6,
93019
- offsetDays,
93460
+ stdin: stdin3,
93461
+ date: date7,
93462
+ offsetDays: offsetDays2,
93020
93463
  prepend: boolean8("prepend"),
93021
93464
  createIfMissing,
93022
93465
  noCreateIfMissing,
93023
93466
  notify,
93024
93467
  ensureDaemon: ensureDaemon2,
93468
+ forceText,
93025
93469
  dryRun: boolean8("dry-run"),
93026
93470
  bulk,
93027
93471
  bundleTitle,
@@ -93034,14 +93478,17 @@ var dailyWriteCommand = exports_Command.make("write", {
93034
93478
  meta: metaSpec
93035
93479
  }, ({
93036
93480
  text: text15,
93481
+ markdown: markdownInput,
93037
93482
  mdFile: mdFile2,
93038
- date: date7,
93039
- offsetDays: offsetDays2,
93483
+ stdin: stdin4,
93484
+ date: date8,
93485
+ offsetDays: offsetDays3,
93040
93486
  prepend: prepend5,
93041
93487
  createIfMissing: createIfMissing2,
93042
93488
  noCreateIfMissing: noCreateIfMissing2,
93043
93489
  notify: notify2,
93044
93490
  ensureDaemon: ensureDaemon3,
93491
+ forceText: forceText2,
93045
93492
  dryRun,
93046
93493
  bulk: bulk2,
93047
93494
  bundleTitle: bundleTitle2,
@@ -93060,13 +93507,29 @@ var dailyWriteCommand = exports_Command.make("write", {
93060
93507
  exitCode: 2
93061
93508
  }));
93062
93509
  }
93063
- if (text15 && mdFile2) {
93064
- return yield* fail8(new CliError({ code: "INVALID_ARGS", message: "Choose only one of --text or --md-file", exitCode: 2 }));
93510
+ if (dryRun && wait2) {
93511
+ return yield* fail8(new CliError({
93512
+ code: "INVALID_ARGS",
93513
+ message: "--wait is not compatible with --dry-run",
93514
+ exitCode: 2
93515
+ }));
93516
+ }
93517
+ const inputModeCount = Number(text15 !== undefined) + Number(markdownInput !== undefined) + Number(mdFile2 !== undefined) + Number(stdin4);
93518
+ if (inputModeCount > 1) {
93519
+ return yield* fail8(new CliError({
93520
+ code: "INVALID_ARGS",
93521
+ message: "Choose only one of --text, --markdown, --md-file, or --stdin",
93522
+ exitCode: 2
93523
+ }));
93065
93524
  }
93066
- if (!text15 && !mdFile2) {
93067
- return yield* fail8(new CliError({ code: "INVALID_ARGS", message: "You must provide --text or --md-file", exitCode: 2 }));
93525
+ if (inputModeCount === 0) {
93526
+ return yield* fail8(new CliError({
93527
+ code: "INVALID_ARGS",
93528
+ message: "You must provide one of --text, --markdown, --md-file, or --stdin",
93529
+ exitCode: 2
93530
+ }));
93068
93531
  }
93069
- if (date7 && offsetDays2 !== undefined) {
93532
+ if (date8 && offsetDays3 !== undefined) {
93070
93533
  return yield* fail8(new CliError({ code: "INVALID_ARGS", message: "Choose only one of --date or --offset-days", exitCode: 2 }));
93071
93534
  }
93072
93535
  if (createIfMissing2 && noCreateIfMissing2) {
@@ -93080,9 +93543,16 @@ var dailyWriteCommand = exports_Command.make("write", {
93080
93543
  const fileInput = yield* FileInput;
93081
93544
  const payloadSvc = yield* Payload;
93082
93545
  const remDb = yield* RemDb;
93083
- const markdownRaw = mdFile2 ? yield* fileInput.readTextFromFileSpec({ spec: mdFile2 }) : undefined;
93084
- const markdown = markdownRaw !== undefined ? trimBoundaryBlankLines(markdownRaw) : undefined;
93546
+ const markdownRaw = mdFile2 ? yield* fileInput.readTextFromFileSpec({ spec: mdFile2 }) : stdin4 ? yield* fileInput.readTextFromFileSpec({ spec: "-" }) : markdownInput;
93547
+ const markdown2 = markdownRaw !== undefined ? trimBoundaryBlankLines(markdownRaw) : undefined;
93085
93548
  const textValue = text15 !== undefined ? trimBoundaryBlankLines(text15) : undefined;
93549
+ if (textValue && !forceText2 && looksLikeStructuredMarkdown(textValue)) {
93550
+ return yield* fail8(new CliError({
93551
+ code: "INVALID_ARGS",
93552
+ message: "Input passed to --text looks like structured Markdown. Use --markdown, --stdin, or --md-file instead.",
93553
+ exitCode: 2
93554
+ }));
93555
+ }
93086
93556
  const bulkMode = bulk2 ?? "auto";
93087
93557
  const bundleTitleValue = typeof bundleTitle2 === "string" ? bundleTitle2.trim() : "";
93088
93558
  const hasBundleTitle = Boolean(bundleTitleValue);
@@ -93093,24 +93563,24 @@ var dailyWriteCommand = exports_Command.make("write", {
93093
93563
  exitCode: 2
93094
93564
  }));
93095
93565
  }
93096
- const target2 = date7 ? yield* try_3({
93097
- try: () => parseDateInput(date7),
93566
+ const target2 = date8 ? yield* try_3({
93567
+ try: () => parseDateInput2(date8),
93098
93568
  catch: (e) => isCliError(e) ? e : new CliError({ code: "INVALID_ARGS", message: "Invalid date", exitCode: 2 })
93099
- }) : new Date(todayAtMidnight().getTime() + (offsetDays2 ?? 0) * 24 * 3600 * 1000);
93569
+ }) : new Date(todayAtMidnight().getTime() + (offsetDays3 ?? 0) * 24 * 3600 * 1000);
93100
93570
  const dateString = yield* remDb.withDb(cfg.remnoteDb, async (db) => {
93101
93571
  const fmt = await getDateFormatting(db) ?? "yyyy/MM/dd";
93102
93572
  return formatDateWithPattern(target2, fmt);
93103
93573
  }).pipe(map17((r) => r.result), catchAll2(() => succeed8(undefined)));
93104
93574
  const createIfMissingBool = noCreateIfMissing2 ? false : createIfMissing2 ? true : undefined;
93105
- const content = markdown ?? textValue ?? "";
93575
+ const content = markdown2 ?? textValue ?? "";
93106
93576
  const lines3 = typeof content === "string" ? content.split(`
93107
93577
  `).length : 0;
93108
93578
  const chars = typeof content === "string" ? content.length : 0;
93109
93579
  const shouldBundle = bulkMode === "always" || bulkMode === "auto" && (hasBundleTitle || lines3 >= BULK_THRESHOLD_LINES || chars >= BULK_THRESHOLD_CHARS);
93110
93580
  const payload = {
93111
- ...markdown !== undefined ? { markdown } : {},
93581
+ ...markdown2 !== undefined ? { markdown: markdown2 } : {},
93112
93582
  ...textValue !== undefined ? { text: textValue } : {},
93113
- ...date7 ? { date: target2.toISOString() } : { offsetDays: offsetDays2 ?? 0 },
93583
+ ...date8 ? { date: target2.toISOString() } : { offsetDays: offsetDays3 ?? 0 },
93114
93584
  ...dateString ? { dateString } : {},
93115
93585
  ...prepend5 ? { prepend: true } : {},
93116
93586
  ...createIfMissingBool !== undefined ? { createIfMissing: createIfMissingBool } : {},
@@ -93132,13 +93602,6 @@ var dailyWriteCommand = exports_Command.make("write", {
93132
93602
  });
93133
93603
  const metaValue = meta ? yield* payloadSvc.readJson(meta) : undefined;
93134
93604
  if (dryRun) {
93135
- if (wait2) {
93136
- return yield* fail8(new CliError({
93137
- code: "INVALID_ARGS",
93138
- message: "--wait is not compatible with --dry-run",
93139
- exitCode: 2
93140
- }));
93141
- }
93142
93605
  yield* writeSuccess({
93143
93606
  data: { dry_run: true, ops: [op], meta: metaValue ? payloadSvc.normalizeKeys(metaValue) : undefined },
93144
93607
  md: `- dry_run: true
@@ -93174,13 +93637,13 @@ var dailyWriteCommand = exports_Command.make("write", {
93174
93637
  }).pipe(catchAll2(writeFailure)));
93175
93638
 
93176
93639
  // src/commands/daily/index.ts
93177
- var dailyCommand = exports_Command.make("daily", {}).pipe(exports_Command.withSubcommands([dailySummaryCommand, dailyWriteCommand]));
93640
+ var dailyCommand = exports_Command.make("daily", {}).pipe(exports_Command.withSubcommands([dailySummaryCommand, dailyRemIdCommand, dailyWriteCommand]));
93178
93641
 
93179
93642
  // src/commands/read/db/backups.ts
93180
- function optionToUndefined11(opt) {
93643
+ function optionToUndefined12(opt) {
93181
93644
  return isSome2(opt) ? opt.value : undefined;
93182
93645
  }
93183
- var basePath = text9("base-path").pipe(optional5, map34(optionToUndefined11));
93646
+ var basePath = text9("base-path").pipe(optional5, map34(optionToUndefined12));
93184
93647
  var limit = integer7("limit").pipe(withDefault5(50));
93185
93648
  var dbBackupsCommand = exports_Command.make("backups", { basePath, limit }, ({ basePath: basePath2, limit: limit2 }) => tryPromise2({
93186
93649
  try: async () => await executeListRemBackups({
@@ -93199,7 +93662,7 @@ var dbBackupsCommand = exports_Command.make("backups", { basePath, limit }, ({ b
93199
93662
  }), catchAll2(writeFailure)));
93200
93663
 
93201
93664
  // src/commands/read/db/recent.ts
93202
- function optionToUndefined12(opt) {
93665
+ function optionToUndefined13(opt) {
93203
93666
  return isSome2(opt) ? opt.value : undefined;
93204
93667
  }
93205
93668
  function pad2(n) {
@@ -93227,9 +93690,9 @@ function scalar(db, sql, params3) {
93227
93690
  const row = db.prepare(sql).get(...params3);
93228
93691
  return asInt(row?.c ?? row?.count ?? row?.["count(*)"]);
93229
93692
  }
93230
- var days3 = integer7("days").pipe(optional5, map34(optionToUndefined12));
93231
- var maxParents = integer7("max-parents").pipe(optional5, map34(optionToUndefined12));
93232
- var perParent = integer7("per-parent").pipe(optional5, map34(optionToUndefined12));
93693
+ var days3 = integer7("days").pipe(optional5, map34(optionToUndefined13));
93694
+ var maxParents = integer7("max-parents").pipe(optional5, map34(optionToUndefined13));
93695
+ var perParent = integer7("per-parent").pipe(optional5, map34(optionToUndefined13));
93233
93696
  var dbRecentCommand = exports_Command.make("recent", {
93234
93697
  days: days3,
93235
93698
  maxParents,
@@ -93372,130 +93835,8 @@ var readDbCommand = exports_Command.make("db", {}).pipe(exports_Command.withSubc
93372
93835
  // src/commands/db/index.ts
93373
93836
  var dbCommand = readDbCommand;
93374
93837
 
93375
- // src/services/RefResolver.ts
93376
- class RefResolver extends Tag2("RefResolver")() {
93377
- }
93378
- function stripQuotes(s) {
93379
- const t = s.trim();
93380
- if (t.startsWith('"') && t.endsWith('"') || t.startsWith("'") && t.endsWith("'")) {
93381
- return t.slice(1, -1);
93382
- }
93383
- return t;
93384
- }
93385
- function parseRef(input) {
93386
- const raw4 = input.trim();
93387
- const link3 = tryParseRemnoteLink(raw4);
93388
- if (link3?.remId) {
93389
- return { kind: "id", value: link3.remId };
93390
- }
93391
- const idx = raw4.indexOf(":");
93392
- if (idx <= 0) {
93393
- throw new CliError({
93394
- code: "INVALID_ARGS",
93395
- message: `Invalid ref: ${input}`,
93396
- exitCode: 2,
93397
- hint: [
93398
- "Example: --ref id:xxx",
93399
- 'Example: --ref "remnote://w/<workspaceId>/<remId>"',
93400
- "Example: --ref page:Demo",
93401
- "Example: --ref title:Demo",
93402
- "Example: --ref daily:today",
93403
- "Example: --ref daily:-1"
93404
- ]
93405
- });
93406
- }
93407
- const kind = raw4.slice(0, idx).trim();
93408
- const value8 = stripQuotes(raw4.slice(idx + 1));
93409
- if (!value8) {
93410
- throw new CliError({
93411
- code: "INVALID_ARGS",
93412
- message: `Invalid ref (missing value): ${input}`,
93413
- exitCode: 2
93414
- });
93415
- }
93416
- if (kind === "id" || kind === "title" || kind === "daily") {
93417
- if (kind === "id") {
93418
- const link22 = tryParseRemnoteLink(value8);
93419
- return { kind, value: link22?.remId ?? value8 };
93420
- }
93421
- return { kind, value: value8 };
93422
- }
93423
- if (kind === "page") {
93424
- return { kind, value: value8 };
93425
- }
93426
- throw new CliError({
93427
- code: "INVALID_ARGS",
93428
- message: `Unsupported ref: ${input}`,
93429
- exitCode: 2,
93430
- hint: ["Supported prefixes: id:/page:/title:/daily:"]
93431
- });
93432
- }
93433
- function parseDailyOffset(value8) {
93434
- const v = value8.trim().toLowerCase();
93435
- if (v === "today" || v === "now" || v === "0")
93436
- return 0;
93437
- if (v === "yesterday")
93438
- return -1;
93439
- if (v === "tomorrow")
93440
- return 1;
93441
- const n = Number.parseInt(v, 10);
93442
- if (!Number.isFinite(n)) {
93443
- throw new CliError({
93444
- code: "INVALID_ARGS",
93445
- message: `Invalid daily ref: ${value8} (expected today/yesterday/tomorrow or an integer offset)`,
93446
- exitCode: 2
93447
- });
93448
- }
93449
- return n;
93450
- }
93451
- var RefResolverLive = succeed10(RefResolver, {
93452
- resolve: (ref) => gen2(function* () {
93453
- const cfg = yield* AppConfig;
93454
- const parsed = yield* try_3({
93455
- try: () => parseRef(ref),
93456
- catch: (e) => e && typeof e === "object" && e._tag === "CliError" ? e : new CliError({ code: "INVALID_ARGS", message: `Invalid ref: ${ref}`, exitCode: 2 })
93457
- });
93458
- if (parsed.kind === "id")
93459
- return parsed.value;
93460
- const dailyOffset = parsed.kind === "daily" ? yield* try_3({
93461
- try: () => parseDailyOffset(parsed.value),
93462
- catch: (e) => e && typeof e === "object" && e._tag === "CliError" ? e : new CliError({
93463
- code: "INVALID_ARGS",
93464
- message: `Invalid daily ref: ${parsed.value}`,
93465
- exitCode: 2
93466
- })
93467
- }) : undefined;
93468
- const queryInput = parsed.kind === "title" || parsed.kind === "page" ? { query: parsed.value } : { query: "date", useCurrentDate: true, dateOffsetDays: dailyOffset };
93469
- const result = yield* tryPromise2({
93470
- try: async () => await executeSearchRemOverview({
93471
- ...queryInput,
93472
- dbPath: cfg.remnoteDb,
93473
- limit: 1,
93474
- preferExact: true,
93475
- exactFirstSingle: true,
93476
- pagesOnly: parsed.kind === "page" ? true : undefined
93477
- }),
93478
- catch: (e) => new CliError({
93479
- code: "DB_UNAVAILABLE",
93480
- message: String(e?.message || e || "RemNote DB is unavailable"),
93481
- exitCode: 1
93482
- })
93483
- });
93484
- const first3 = Array.isArray(result.matches) ? result.matches[0] : undefined;
93485
- const id2 = first3?.id ? String(first3.id) : "";
93486
- if (!id2) {
93487
- return yield* fail8(new CliError({
93488
- code: "INVALID_ARGS",
93489
- message: `No Rem found for ref: ${ref}`,
93490
- exitCode: 2
93491
- }));
93492
- }
93493
- return id2;
93494
- })
93495
- });
93496
-
93497
93838
  // src/commands/write/wechat/outline.ts
93498
- function optionToUndefined13(opt) {
93839
+ function optionToUndefined14(opt) {
93499
93840
  return isSome2(opt) ? opt.value : undefined;
93500
93841
  }
93501
93842
  function clampInt4(value8, min5, max7) {
@@ -93743,16 +94084,16 @@ function mergeMeta(base, extra) {
93743
94084
  return base;
93744
94085
  return { ...base, ...extra };
93745
94086
  }
93746
- var parent = text9("parent").pipe(optional5, map34(optionToUndefined13));
93747
- var ref = text9("ref").pipe(optional5, map34(optionToUndefined13));
93748
- var cdpPort = integer7("cdp-port").pipe(optional5, map34(optionToUndefined13));
93749
- var maxDepth = integer7("max-depth").pipe(optional5, map34(optionToUndefined13));
93750
- var waitMs = integer7("wait-ms").pipe(optional5, map34(optionToUndefined13));
93751
- var titleSuffix = text9("title-suffix").pipe(optional5, map34(optionToUndefined13));
93752
- var clientId2 = text9("client-id").pipe(optional5, map34(optionToUndefined13));
93753
- var idempotencyKey2 = text9("idempotency-key").pipe(optional5, map34(optionToUndefined13));
93754
- var priority2 = integer7("priority").pipe(optional5, map34(optionToUndefined13));
93755
- var metaSpec2 = text9("meta").pipe(optional5, map34(optionToUndefined13));
94087
+ var parent = text9("parent").pipe(optional5, map34(optionToUndefined14));
94088
+ var ref = text9("ref").pipe(optional5, map34(optionToUndefined14));
94089
+ var cdpPort = integer7("cdp-port").pipe(optional5, map34(optionToUndefined14));
94090
+ var maxDepth = integer7("max-depth").pipe(optional5, map34(optionToUndefined14));
94091
+ var waitMs = integer7("wait-ms").pipe(optional5, map34(optionToUndefined14));
94092
+ var titleSuffix = text9("title-suffix").pipe(optional5, map34(optionToUndefined14));
94093
+ var clientId2 = text9("client-id").pipe(optional5, map34(optionToUndefined14));
94094
+ var idempotencyKey2 = text9("idempotency-key").pipe(optional5, map34(optionToUndefined14));
94095
+ var priority2 = integer7("priority").pipe(optional5, map34(optionToUndefined14));
94096
+ var metaSpec2 = text9("meta").pipe(optional5, map34(optionToUndefined14));
93756
94097
  var notify2 = boolean8("no-notify").pipe(map34((v) => !v));
93757
94098
  var ensureDaemon3 = boolean8("no-ensure-daemon").pipe(map34((v) => !v));
93758
94099
  var wechatOutlineCommand = exports_Command.make("outline", {
@@ -93832,7 +94173,7 @@ var wechatOutlineCommand = exports_Command.make("outline", {
93832
94173
  }));
93833
94174
  }
93834
94175
  const title = suffix ? `${rawTitle}${suffix}` : rawTitle;
93835
- const markdown = dropBlankLinesOutsideFences(outlineify({ title, url: url2, content: rawContent, maxDepth: depth }));
94176
+ const markdown2 = dropBlankLinesOutsideFences(outlineify({ title, url: url2, content: rawContent, maxDepth: depth }));
93836
94177
  const baseMeta = {
93837
94178
  source: "wechat",
93838
94179
  url: url2,
@@ -93845,7 +94186,7 @@ var wechatOutlineCommand = exports_Command.make("outline", {
93845
94186
  const op = yield* try_3({
93846
94187
  try: () => normalizeOp({
93847
94188
  type: "create_tree_with_markdown",
93848
- payload: { parentId: resolvedParent, markdown, parseMode: "smart" }
94189
+ payload: { parentId: resolvedParent, markdown: markdown2, parseMode: "smart" }
93849
94190
  }, payloadSvc.normalizeKeys),
93850
94191
  catch: (e) => isCliError(e) ? e : new CliError({
93851
94192
  code: "INVALID_PAYLOAD",
@@ -94060,32 +94401,32 @@ var HostApiClientLive = succeed10(HostApiClient, {
94060
94401
  });
94061
94402
 
94062
94403
  // src/commands/import/markdown.ts
94063
- function optionToUndefined14(opt) {
94404
+ function optionToUndefined15(opt) {
94064
94405
  return isSome2(opt) ? opt.value : undefined;
94065
94406
  }
94066
94407
  function readOptionalText2(name) {
94067
- return text9(name).pipe(optional5, map34(optionToUndefined14));
94408
+ return text9(name).pipe(optional5, map34(optionToUndefined15));
94068
94409
  }
94069
94410
  var parent2 = readOptionalText2("parent");
94070
94411
  var ref2 = readOptionalText2("ref");
94071
94412
  var file7 = readOptionalText2("file");
94072
94413
  var markdownInline = readOptionalText2("markdown");
94073
- var stdin3 = boolean8("stdin");
94074
- var mode = choice5("mode", ["indent", "native"]).pipe(optional5, map34(optionToUndefined14));
94075
- var indentSize = integer7("indent-size").pipe(optional5, map34(optionToUndefined14));
94076
- var position3 = integer7("position").pipe(optional5, map34(optionToUndefined14));
94077
- var bulk2 = choice5("bulk", ["auto", "always", "never"]).pipe(optional5, map34(optionToUndefined14));
94414
+ var stdin4 = boolean8("stdin");
94415
+ var mode = choice5("mode", ["indent", "native"]).pipe(optional5, map34(optionToUndefined15));
94416
+ var indentSize = integer7("indent-size").pipe(optional5, map34(optionToUndefined15));
94417
+ var position3 = integer7("position").pipe(optional5, map34(optionToUndefined15));
94418
+ var bulk2 = choice5("bulk", ["auto", "always", "never"]).pipe(optional5, map34(optionToUndefined15));
94078
94419
  var bundleTitle2 = readOptionalText2("bundle-title");
94079
94420
  var staged = boolean8("staged");
94080
94421
  var clientId3 = readOptionalText2("client-id");
94081
94422
  var idempotencyKey3 = readOptionalText2("idempotency-key");
94082
94423
  var metaSpec3 = readOptionalText2("meta");
94083
- var priority3 = integer7("priority").pipe(optional5, map34(optionToUndefined14));
94424
+ var priority3 = integer7("priority").pipe(optional5, map34(optionToUndefined15));
94084
94425
  var notify3 = boolean8("no-notify").pipe(map34((v) => !v));
94085
94426
  var ensureDaemon4 = boolean8("no-ensure-daemon").pipe(map34((v) => !v));
94086
94427
  var wait2 = boolean8("wait");
94087
- var timeoutMs2 = integer7("timeout-ms").pipe(optional5, map34(optionToUndefined14));
94088
- var pollMs2 = integer7("poll-ms").pipe(optional5, map34(optionToUndefined14));
94428
+ var timeoutMs2 = integer7("timeout-ms").pipe(optional5, map34(optionToUndefined15));
94429
+ var pollMs2 = integer7("poll-ms").pipe(optional5, map34(optionToUndefined15));
94089
94430
  var BULK_THRESHOLD_LINES2 = 80;
94090
94431
  var BULK_THRESHOLD_CHARS2 = 5000;
94091
94432
  var importMarkdownCommand = exports_Command.make("markdown", {
@@ -94093,7 +94434,7 @@ var importMarkdownCommand = exports_Command.make("markdown", {
94093
94434
  ref: ref2,
94094
94435
  file: file7,
94095
94436
  markdown: markdownInline,
94096
- stdin: stdin3,
94437
+ stdin: stdin4,
94097
94438
  mode,
94098
94439
  indentSize,
94099
94440
  position: position3,
@@ -94114,8 +94455,8 @@ var importMarkdownCommand = exports_Command.make("markdown", {
94114
94455
  parent: parent3,
94115
94456
  ref: ref3,
94116
94457
  file: file8,
94117
- markdown,
94118
- stdin: stdin4,
94458
+ markdown: markdown2,
94459
+ stdin: stdin5,
94119
94460
  mode: mode2,
94120
94461
  indentSize: indentSize2,
94121
94462
  position: position4,
@@ -94150,14 +94491,14 @@ var importMarkdownCommand = exports_Command.make("markdown", {
94150
94491
  }
94151
94492
  const payloadSvc = yield* Payload;
94152
94493
  const fileInput = yield* FileInput;
94153
- if (file8 && markdown || stdin4 && (file8 || markdown)) {
94494
+ if (file8 && markdown2 || stdin5 && (file8 || markdown2)) {
94154
94495
  return yield* fail8(new CliError({
94155
94496
  code: "INVALID_ARGS",
94156
94497
  message: "Choose exactly one of --file / --markdown / --stdin",
94157
94498
  exitCode: 2
94158
94499
  }));
94159
94500
  }
94160
- if (!file8 && !markdown && !stdin4) {
94501
+ if (!file8 && !markdown2 && !stdin5) {
94161
94502
  return yield* fail8(new CliError({
94162
94503
  code: "INVALID_ARGS",
94163
94504
  message: "You must provide --file or --markdown or --stdin",
@@ -94172,7 +94513,7 @@ var importMarkdownCommand = exports_Command.make("markdown", {
94172
94513
  details: { position: position4 }
94173
94514
  }));
94174
94515
  }
94175
- const markdownValueRaw = typeof markdown === "string" ? markdown : yield* fileInput.readTextFromFileSpec({ spec: stdin4 ? "-" : String(file8) });
94516
+ const markdownValueRaw = typeof markdown2 === "string" ? markdown2 : yield* fileInput.readTextFromFileSpec({ spec: stdin5 ? "-" : String(file8) });
94176
94517
  const markdownValue = dropBlankLinesOutsideFences(trimBoundaryBlankLines(markdownValueRaw));
94177
94518
  const bulkMode = bulk3 ?? "auto";
94178
94519
  const bundleTitleValue = typeof bundleTitle3 === "string" ? bundleTitle3.trim() : "";
@@ -94414,17 +94755,17 @@ var opsSchemaCommand = exports_Command.make("schema", { type: text9("type") }, (
94414
94755
  var opsCommand = exports_Command.make("ops", {}).pipe(exports_Command.withSubcommands([opsListCommand, opsSchemaCommand]));
94415
94756
 
94416
94757
  // src/commands/apply.ts
94417
- function optionToUndefined15(opt) {
94758
+ function optionToUndefined16(opt) {
94418
94759
  return isSome2(opt) ? opt.value : undefined;
94419
94760
  }
94420
94761
  function readOptionalText3(name) {
94421
- return text9(name).pipe(optional5, map34(optionToUndefined15));
94762
+ return text9(name).pipe(optional5, map34(optionToUndefined16));
94422
94763
  }
94423
94764
  var payloadSpec = text9("payload");
94424
94765
  var metaSpec4 = readOptionalText3("meta");
94425
94766
  var clientId4 = readOptionalText3("client-id");
94426
94767
  var idempotencyKey4 = readOptionalText3("idempotency-key");
94427
- var priority4 = integer7("priority").pipe(optional5, map34(optionToUndefined15));
94768
+ var priority4 = integer7("priority").pipe(optional5, map34(optionToUndefined16));
94428
94769
  var notify4 = boolean8("no-notify").pipe(map34((v) => !v));
94429
94770
  var ensureDaemon5 = boolean8("no-ensure-daemon").pipe(map34((v) => !v));
94430
94771
  var applyCommand = exports_Command.make("apply", {
@@ -94841,14 +95182,14 @@ function ensureApiDaemon(params3) {
94841
95182
  }
94842
95183
 
94843
95184
  // src/commands/api/ensure.ts
94844
- function optionToUndefined16(opt) {
95185
+ function optionToUndefined17(opt) {
94845
95186
  return isSome2(opt) ? opt.value : undefined;
94846
95187
  }
94847
- var host = text9("host").pipe(optional5, map34(optionToUndefined16));
94848
- var port3 = integer7("port").pipe(optional5, map34(optionToUndefined16));
94849
- var pidFile8 = text9("pid-file").pipe(optional5, map34(optionToUndefined16));
94850
- var logFile5 = text9("log-file").pipe(optional5, map34(optionToUndefined16));
94851
- var stateFile3 = text9("state-file").pipe(optional5, map34(optionToUndefined16));
95188
+ var host = text9("host").pipe(optional5, map34(optionToUndefined17));
95189
+ var port3 = integer7("port").pipe(optional5, map34(optionToUndefined17));
95190
+ var pidFile8 = text9("pid-file").pipe(optional5, map34(optionToUndefined17));
95191
+ var logFile5 = text9("log-file").pipe(optional5, map34(optionToUndefined17));
95192
+ var stateFile3 = text9("state-file").pipe(optional5, map34(optionToUndefined17));
94852
95193
  var apiEnsureCommand = exports_Command.make("ensure", {
94853
95194
  host,
94854
95195
  port: port3,
@@ -94871,11 +95212,11 @@ var apiEnsureCommand = exports_Command.make("ensure", {
94871
95212
  }).pipe(catchAll2(writeFailure)));
94872
95213
 
94873
95214
  // src/commands/api/logs.ts
94874
- function optionToUndefined17(opt) {
95215
+ function optionToUndefined18(opt) {
94875
95216
  return isSome2(opt) ? opt.value : undefined;
94876
95217
  }
94877
- var pidFile9 = text9("pid-file").pipe(optional5, map34(optionToUndefined17));
94878
- var file8 = text9("file").pipe(optional5, map34(optionToUndefined17));
95218
+ var pidFile9 = text9("pid-file").pipe(optional5, map34(optionToUndefined18));
95219
+ var file8 = text9("file").pipe(optional5, map34(optionToUndefined18));
94879
95220
  var apiLogsCommand = exports_Command.make("logs", { pidFile: pidFile9, file: file8, lines: integer7("lines").pipe(withDefault5(200)), follow: boolean8("follow") }, ({ pidFile: pidFile10, file: file9, lines: lines3, follow }) => gen2(function* () {
94880
95221
  const cfg = yield* AppConfig;
94881
95222
  const apiFiles = yield* ApiDaemonFiles;
@@ -94928,14 +95269,14 @@ var apiLogsCommand = exports_Command.make("logs", { pidFile: pidFile9, file: fil
94928
95269
  }).pipe(catchAll2(writeFailure)));
94929
95270
 
94930
95271
  // src/commands/api/restart.ts
94931
- function optionToUndefined18(opt) {
95272
+ function optionToUndefined19(opt) {
94932
95273
  return isSome2(opt) ? opt.value : undefined;
94933
95274
  }
94934
- var host2 = text9("host").pipe(optional5, map34(optionToUndefined18));
94935
- var port4 = integer7("port").pipe(optional5, map34(optionToUndefined18));
94936
- var pidFile10 = text9("pid-file").pipe(optional5, map34(optionToUndefined18));
94937
- var logFile6 = text9("log-file").pipe(optional5, map34(optionToUndefined18));
94938
- var stateFile4 = text9("state-file").pipe(optional5, map34(optionToUndefined18));
95275
+ var host2 = text9("host").pipe(optional5, map34(optionToUndefined19));
95276
+ var port4 = integer7("port").pipe(optional5, map34(optionToUndefined19));
95277
+ var pidFile10 = text9("pid-file").pipe(optional5, map34(optionToUndefined19));
95278
+ var logFile6 = text9("log-file").pipe(optional5, map34(optionToUndefined19));
95279
+ var stateFile4 = text9("state-file").pipe(optional5, map34(optionToUndefined19));
94939
95280
  var apiRestartCommand = exports_Command.make("restart", {
94940
95281
  force: boolean8("force"),
94941
95282
  host: host2,
@@ -96180,23 +96521,23 @@ function runHttpApiRuntime(params3) {
96180
96521
  }
96181
96522
 
96182
96523
  // src/commands/api/serve.ts
96183
- function optionToUndefined19(opt) {
96524
+ function optionToUndefined20(opt) {
96184
96525
  return isSome2(opt) ? opt.value : undefined;
96185
96526
  }
96186
- var host3 = text9("host").pipe(optional5, map34(optionToUndefined19));
96187
- var port5 = integer7("port").pipe(optional5, map34(optionToUndefined19));
96188
- var stateFile5 = text9("state-file").pipe(optional5, map34(optionToUndefined19));
96527
+ var host3 = text9("host").pipe(optional5, map34(optionToUndefined20));
96528
+ var port5 = integer7("port").pipe(optional5, map34(optionToUndefined20));
96529
+ var stateFile5 = text9("state-file").pipe(optional5, map34(optionToUndefined20));
96189
96530
  var apiServeCommand = exports_Command.make("serve", { host: host3, port: port5, stateFile: stateFile5 }, ({ host: host4, port: port6, stateFile: stateFile6 }) => runHttpApiRuntime({ host: host4, port: port6, stateFile: stateFile6 }).pipe(catchAll2(writeFailure)));
96190
96531
 
96191
96532
  // src/commands/api/start.ts
96192
- function optionToUndefined20(opt) {
96533
+ function optionToUndefined21(opt) {
96193
96534
  return isSome2(opt) ? opt.value : undefined;
96194
96535
  }
96195
- var host4 = text9("host").pipe(optional5, map34(optionToUndefined20));
96196
- var port6 = integer7("port").pipe(optional5, map34(optionToUndefined20));
96197
- var pidFile11 = text9("pid-file").pipe(optional5, map34(optionToUndefined20));
96198
- var logFile7 = text9("log-file").pipe(optional5, map34(optionToUndefined20));
96199
- var stateFile6 = text9("state-file").pipe(optional5, map34(optionToUndefined20));
96536
+ var host4 = text9("host").pipe(optional5, map34(optionToUndefined21));
96537
+ var port6 = integer7("port").pipe(optional5, map34(optionToUndefined21));
96538
+ var pidFile11 = text9("pid-file").pipe(optional5, map34(optionToUndefined21));
96539
+ var logFile7 = text9("log-file").pipe(optional5, map34(optionToUndefined21));
96540
+ var stateFile6 = text9("state-file").pipe(optional5, map34(optionToUndefined21));
96200
96541
  var apiStartCommand = exports_Command.make("start", {
96201
96542
  host: host4,
96202
96543
  port: port6,
@@ -96219,11 +96560,11 @@ var apiStartCommand = exports_Command.make("start", {
96219
96560
  }).pipe(catchAll2(writeFailure)));
96220
96561
 
96221
96562
  // src/commands/api/status.ts
96222
- function optionToUndefined21(opt) {
96563
+ function optionToUndefined22(opt) {
96223
96564
  return isSome2(opt) ? opt.value : undefined;
96224
96565
  }
96225
- var pidFile12 = text9("pid-file").pipe(optional5, map34(optionToUndefined21));
96226
- var stateFile7 = text9("state-file").pipe(optional5, map34(optionToUndefined21));
96566
+ var pidFile12 = text9("pid-file").pipe(optional5, map34(optionToUndefined22));
96567
+ var stateFile7 = text9("state-file").pipe(optional5, map34(optionToUndefined22));
96227
96568
  var apiStatusCommand = exports_Command.make("status", { pidFile: pidFile12, stateFile: stateFile7 }, ({ pidFile: pidFile13, stateFile: stateFile8 }) => gen2(function* () {
96228
96569
  const cfg = yield* AppConfig;
96229
96570
  const apiFiles = yield* ApiDaemonFiles;
@@ -96271,11 +96612,11 @@ var apiStatusCommand = exports_Command.make("status", { pidFile: pidFile12, stat
96271
96612
  }).pipe(catchAll2(writeFailure)));
96272
96613
 
96273
96614
  // src/commands/api/stop.ts
96274
- function optionToUndefined22(opt) {
96615
+ function optionToUndefined23(opt) {
96275
96616
  return isSome2(opt) ? opt.value : undefined;
96276
96617
  }
96277
- var pidFile13 = text9("pid-file").pipe(optional5, map34(optionToUndefined22));
96278
- var stateFile8 = text9("state-file").pipe(optional5, map34(optionToUndefined22));
96618
+ var pidFile13 = text9("pid-file").pipe(optional5, map34(optionToUndefined23));
96619
+ var stateFile8 = text9("state-file").pipe(optional5, map34(optionToUndefined23));
96279
96620
  var apiStopCommand = exports_Command.make("stop", { force: boolean8("force"), pidFile: pidFile13, stateFile: stateFile8 }, ({ force, pidFile: pidFile14, stateFile: stateFile9 }) => gen2(function* () {
96280
96621
  const apiFiles = yield* ApiDaemonFiles;
96281
96622
  const proc = yield* Process;
@@ -96436,14 +96777,14 @@ var ACTIONS = {
96436
96777
  aliasRefAllowlist: ["parent_id"],
96437
96778
  compile: ({ input }) => {
96438
96779
  const parent_id = input.parent_id;
96439
- const markdown = input.markdown;
96780
+ const markdown2 = input.markdown;
96440
96781
  if (typeof parent_id !== "string" || !parent_id.trim()) {
96441
96782
  throw new Error("write.md requires input.parent_id");
96442
96783
  }
96443
- if (typeof markdown !== "string") {
96784
+ if (typeof markdown2 !== "string") {
96444
96785
  throw new Error("write.md requires input.markdown");
96445
96786
  }
96446
- const payload = { parent_id, markdown };
96787
+ const payload = { parent_id, markdown: markdown2 };
96447
96788
  if (typeof input.indent_mode === "boolean")
96448
96789
  payload.indent_mode = input.indent_mode;
96449
96790
  if (typeof input.indent_size === "number")
@@ -96465,14 +96806,14 @@ var ACTIONS = {
96465
96806
  aliasRefAllowlist: ["parent_id"],
96466
96807
  compile: ({ input, aliasTempId }) => {
96467
96808
  const parent_id = input.parent_id;
96468
- const markdown = input.markdown;
96809
+ const markdown2 = input.markdown;
96469
96810
  if (typeof parent_id !== "string" || !parent_id.trim()) {
96470
96811
  throw new Error("write.md.single requires input.parent_id");
96471
96812
  }
96472
- if (typeof markdown !== "string") {
96813
+ if (typeof markdown2 !== "string") {
96473
96814
  throw new Error("write.md.single requires input.markdown");
96474
96815
  }
96475
- const payload = { parent_id, markdown };
96816
+ const payload = { parent_id, markdown: markdown2 };
96476
96817
  if (aliasTempId)
96477
96818
  payload.client_temp_id = aliasTempId;
96478
96819
  return { ops: [{ type: "create_single_rem_with_markdown", payload }] };
@@ -96533,8 +96874,8 @@ var ACTIONS = {
96533
96874
  supportsAs: false,
96534
96875
  aliasRefAllowlist: ["target.rem_ids[]", "portal_id"],
96535
96876
  compile: ({ input }) => {
96536
- const markdown = input.markdown;
96537
- if (typeof markdown !== "string") {
96877
+ const markdown2 = input.markdown;
96878
+ if (typeof markdown2 !== "string") {
96538
96879
  throw new Error("replace.block requires input.markdown");
96539
96880
  }
96540
96881
  const target2 = getObject(input.target);
@@ -96547,7 +96888,7 @@ var ACTIONS = {
96547
96888
  throw new Error("replace.block requires input.target.rem_ids[]");
96548
96889
  }
96549
96890
  const payload = {
96550
- markdown,
96891
+ markdown: markdown2,
96551
96892
  target: { mode: "explicit", rem_ids: remIdsRaw }
96552
96893
  };
96553
96894
  if (typeof input.require_same_parent === "boolean")
@@ -96707,22 +97048,22 @@ function makeTempId() {
96707
97048
  }
96708
97049
 
96709
97050
  // src/commands/_writePlanCommand.ts
96710
- function optionToUndefined23(opt) {
97051
+ function optionToUndefined24(opt) {
96711
97052
  return isSome2(opt) ? opt.value : undefined;
96712
97053
  }
96713
97054
  function readOptionalText4(name) {
96714
- return text9(name).pipe(optional5, map34(optionToUndefined23));
97055
+ return text9(name).pipe(optional5, map34(optionToUndefined24));
96715
97056
  }
96716
97057
  var payload = text9("payload");
96717
97058
  var clientId5 = readOptionalText4("client-id");
96718
97059
  var idempotencyKey5 = readOptionalText4("idempotency-key");
96719
97060
  var metaSpec5 = readOptionalText4("meta");
96720
- var priority5 = integer7("priority").pipe(optional5, map34(optionToUndefined23));
97061
+ var priority5 = integer7("priority").pipe(optional5, map34(optionToUndefined24));
96721
97062
  var notify5 = boolean8("no-notify").pipe(map34((v) => !v));
96722
97063
  var ensureDaemon6 = boolean8("no-ensure-daemon").pipe(map34((v) => !v));
96723
97064
  var wait3 = boolean8("wait");
96724
- var timeoutMs3 = integer7("timeout-ms").pipe(optional5, map34(optionToUndefined23));
96725
- var pollMs3 = integer7("poll-ms").pipe(optional5, map34(optionToUndefined23));
97065
+ var timeoutMs3 = integer7("timeout-ms").pipe(optional5, map34(optionToUndefined24));
97066
+ var pollMs3 = integer7("poll-ms").pipe(optional5, map34(optionToUndefined24));
96726
97067
  function makeWritePlanCommand(config3) {
96727
97068
  return exports_Command.make(config3.commandName, {
96728
97069
  payload,
@@ -96867,11 +97208,11 @@ var planApplyCommand = makeWritePlanCommand({
96867
97208
  var planCommand = exports_Command.make("plan", {}).pipe(exports_Command.withSubcommands([planApplyCommand]));
96868
97209
 
96869
97210
  // src/commands/read/selection/current.ts
96870
- function optionToUndefined24(opt) {
97211
+ function optionToUndefined25(opt) {
96871
97212
  return isSome2(opt) ? opt.value : undefined;
96872
97213
  }
96873
- var stateFile9 = text9("state-file").pipe(optional5, map34(optionToUndefined24));
96874
- var staleMs2 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined24));
97214
+ var stateFile9 = text9("state-file").pipe(optional5, map34(optionToUndefined25));
97215
+ var staleMs2 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined25));
96875
97216
  function toCompact(data) {
96876
97217
  return {
96877
97218
  selection_kind: data?.selection_kind ?? "",
@@ -96917,11 +97258,11 @@ var readSelectionCurrentCommand = exports_Command.make("current", { stateFile: s
96917
97258
  }).pipe(catchAll2(writeFailure)));
96918
97259
 
96919
97260
  // src/commands/read/selection/outline.ts
96920
- function optionToUndefined25(opt) {
97261
+ function optionToUndefined26(opt) {
96921
97262
  return isSome2(opt) ? opt.value : undefined;
96922
97263
  }
96923
- var stateFile10 = text9("state-file").pipe(optional5, map34(optionToUndefined25));
96924
- var staleMs3 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined25));
97264
+ var stateFile10 = text9("state-file").pipe(optional5, map34(optionToUndefined26));
97265
+ var staleMs3 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined26));
96925
97266
  var maxDepth2 = integer7("max-depth").pipe(withDefault5(10));
96926
97267
  var maxNodes = integer7("max-nodes").pipe(withDefault5(1000));
96927
97268
  var readSelectionOutlineCommand = exports_Command.make("outline", {
@@ -96932,7 +97273,7 @@ var readSelectionOutlineCommand = exports_Command.make("outline", {
96932
97273
  excludeProperties: boolean8("exclude-properties"),
96933
97274
  includeEmpty: boolean8("include-empty"),
96934
97275
  expandReferences: boolean8("expand-references"),
96935
- maxReferenceDepth: integer7("max-reference-depth").pipe(optional5, map34(optionToUndefined25)),
97276
+ maxReferenceDepth: integer7("max-reference-depth").pipe(optional5, map34(optionToUndefined26)),
96936
97277
  detail: boolean8("detail")
96937
97278
  }, ({
96938
97279
  stateFile: stateFile11,
@@ -97075,11 +97416,11 @@ var readSelectionOutlineCommand = exports_Command.make("outline", {
97075
97416
  }).pipe(catchAll2(writeFailure)));
97076
97417
 
97077
97418
  // src/commands/read/selection/roots.ts
97078
- function optionToUndefined26(opt) {
97419
+ function optionToUndefined27(opt) {
97079
97420
  return isSome2(opt) ? opt.value : undefined;
97080
97421
  }
97081
- var stateFile11 = text9("state-file").pipe(optional5, map34(optionToUndefined26));
97082
- var staleMs4 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined26));
97422
+ var stateFile11 = text9("state-file").pipe(optional5, map34(optionToUndefined27));
97423
+ var staleMs4 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined27));
97083
97424
  var readSelectionRootsCommand = exports_Command.make("roots", { stateFile: stateFile11, staleMs: staleMs4 }, ({ stateFile: stateFile12, staleMs: staleMs5 }) => gen2(function* () {
97084
97425
  const cfg = yield* AppConfig;
97085
97426
  const hostApi = yield* HostApiClient;
@@ -97116,11 +97457,11 @@ var readSelectionRootsCommand = exports_Command.make("roots", { stateFile: state
97116
97457
  }).pipe(catchAll2(writeFailure)));
97117
97458
 
97118
97459
  // src/commands/read/selection/snapshot.ts
97119
- function optionToUndefined27(opt) {
97460
+ function optionToUndefined28(opt) {
97120
97461
  return isSome2(opt) ? opt.value : undefined;
97121
97462
  }
97122
- var stateFile12 = text9("state-file").pipe(optional5, map34(optionToUndefined27));
97123
- var staleMs5 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined27));
97463
+ var stateFile12 = text9("state-file").pipe(optional5, map34(optionToUndefined28));
97464
+ var staleMs5 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined28));
97124
97465
  var readSelectionSnapshotCommand = exports_Command.make("snapshot", { stateFile: stateFile12, staleMs: staleMs5 }, ({ stateFile: stateFile13, staleMs: staleMs6 }) => gen2(function* () {
97125
97466
  const cfg = yield* AppConfig;
97126
97467
  const hostApi = yield* HostApiClient;
@@ -97167,11 +97508,11 @@ var readSelectionSnapshotCommand = exports_Command.make("snapshot", { stateFile:
97167
97508
  var readSelectionCommand = exports_Command.make("selection", {}).pipe(exports_Command.withSubcommands([readSelectionSnapshotCommand, readSelectionRootsCommand, readSelectionCurrentCommand, readSelectionOutlineCommand]));
97168
97509
 
97169
97510
  // src/commands/read/uiContext/describe.ts
97170
- function optionToUndefined28(opt) {
97511
+ function optionToUndefined29(opt) {
97171
97512
  return isSome2(opt) ? opt.value : undefined;
97172
97513
  }
97173
- var stateFile13 = text9("state-file").pipe(optional5, map34(optionToUndefined28));
97174
- var staleMs6 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined28));
97514
+ var stateFile13 = text9("state-file").pipe(optional5, map34(optionToUndefined29));
97515
+ var staleMs6 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined29));
97175
97516
  var selectionLimit = integer7("selection-limit").pipe(withDefault5(5));
97176
97517
  function normalizeText2(value8) {
97177
97518
  return typeof value8 === "string" ? value8.trim() : "";
@@ -97432,11 +97773,11 @@ var readUiContextDescribeCommand = exports_Command.make("describe", { stateFile:
97432
97773
  }).pipe(catchAll2(writeFailure)));
97433
97774
 
97434
97775
  // src/commands/read/uiContext/focused-rem.ts
97435
- function optionToUndefined29(opt) {
97776
+ function optionToUndefined30(opt) {
97436
97777
  return isSome2(opt) ? opt.value : undefined;
97437
97778
  }
97438
- var stateFile14 = text9("state-file").pipe(optional5, map34(optionToUndefined29));
97439
- var staleMs7 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined29));
97779
+ var stateFile14 = text9("state-file").pipe(optional5, map34(optionToUndefined30));
97780
+ var staleMs7 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined30));
97440
97781
  var readUiContextFocusedRemCommand = exports_Command.make("focused-rem", { stateFile: stateFile14, staleMs: staleMs7 }, ({ stateFile: stateFile15, staleMs: staleMs8 }) => gen2(function* () {
97441
97782
  const cfg = yield* AppConfig;
97442
97783
  const hostApi = yield* HostApiClient;
@@ -97464,11 +97805,11 @@ var readUiContextFocusedRemCommand = exports_Command.make("focused-rem", { state
97464
97805
  }).pipe(catchAll2(writeFailure)));
97465
97806
 
97466
97807
  // src/commands/read/uiContext/page.ts
97467
- function optionToUndefined30(opt) {
97808
+ function optionToUndefined31(opt) {
97468
97809
  return isSome2(opt) ? opt.value : undefined;
97469
97810
  }
97470
- var stateFile15 = text9("state-file").pipe(optional5, map34(optionToUndefined30));
97471
- var staleMs8 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined30));
97811
+ var stateFile15 = text9("state-file").pipe(optional5, map34(optionToUndefined31));
97812
+ var staleMs8 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined31));
97472
97813
  var readUiContextPageCommand = exports_Command.make("page", { stateFile: stateFile15, staleMs: staleMs8 }, ({ stateFile: stateFile16, staleMs: staleMs9 }) => gen2(function* () {
97473
97814
  const cfg = yield* AppConfig;
97474
97815
  const hostApi = yield* HostApiClient;
@@ -97496,11 +97837,11 @@ var readUiContextPageCommand = exports_Command.make("page", { stateFile: stateFi
97496
97837
  }).pipe(catchAll2(writeFailure)));
97497
97838
 
97498
97839
  // src/commands/read/uiContext/snapshot.ts
97499
- function optionToUndefined31(opt) {
97840
+ function optionToUndefined32(opt) {
97500
97841
  return isSome2(opt) ? opt.value : undefined;
97501
97842
  }
97502
- var stateFile16 = text9("state-file").pipe(optional5, map34(optionToUndefined31));
97503
- var staleMs9 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined31));
97843
+ var stateFile16 = text9("state-file").pipe(optional5, map34(optionToUndefined32));
97844
+ var staleMs9 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined32));
97504
97845
  var readUiContextSnapshotCommand = exports_Command.make("snapshot", { stateFile: stateFile16, staleMs: staleMs9 }, ({ stateFile: stateFile17, staleMs: staleMs10 }) => gen2(function* () {
97505
97846
  const cfg = yield* AppConfig;
97506
97847
  const hostApi = yield* HostApiClient;
@@ -97534,11 +97875,11 @@ var readUiContextCommand = exports_Command.make("ui-context", {}).pipe(exports_C
97534
97875
  ]));
97535
97876
 
97536
97877
  // src/commands/plugin/current.ts
97537
- function optionToUndefined32(opt) {
97878
+ function optionToUndefined33(opt) {
97538
97879
  return isSome2(opt) ? opt.value : undefined;
97539
97880
  }
97540
- var stateFile17 = text9("state-file").pipe(optional5, map34(optionToUndefined32));
97541
- var staleMs10 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined32));
97881
+ var stateFile17 = text9("state-file").pipe(optional5, map34(optionToUndefined33));
97882
+ var staleMs10 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined33));
97542
97883
  var selectionLimit2 = integer7("selection-limit").pipe(withDefault5(5));
97543
97884
  function toCompact2(data) {
97544
97885
  return {
@@ -97585,10 +97926,10 @@ var pluginCurrentCommand = exports_Command.make("current", { stateFile: stateFil
97585
97926
  }).pipe(catchAll2(writeFailure)));
97586
97927
 
97587
97928
  // src/commands/plugin/search.ts
97588
- function optionToUndefined33(opt) {
97929
+ function optionToUndefined34(opt) {
97589
97930
  return isSome2(opt) ? opt.value : undefined;
97590
97931
  }
97591
- var searchContextRemId = text9("context-rem-id").pipe(optional5, map34(optionToUndefined33));
97932
+ var searchContextRemId = text9("context-rem-id").pipe(optional5, map34(optionToUndefined34));
97592
97933
  var limit2 = integer7("limit").pipe(withDefault5(20));
97593
97934
  var timeoutMs4 = integer7("timeout-ms").pipe(withDefault5(3000));
97594
97935
  var ensureDaemon7 = boolean8("no-ensure-daemon").pipe(map34((v) => !v));
@@ -97644,10 +97985,10 @@ var pluginSearchCommand = exports_Command.make("search", { query: text9("query")
97644
97985
  var pluginCommand = exports_Command.make("plugin", {}).pipe(exports_Command.withSubcommands([pluginCurrentCommand, pluginSearchCommand, readUiContextCommand, readSelectionCommand]));
97645
97986
 
97646
97987
  // src/commands/read/powerup/list.ts
97647
- function optionToUndefined34(opt) {
97988
+ function optionToUndefined35(opt) {
97648
97989
  return isSome2(opt) ? opt.value : undefined;
97649
97990
  }
97650
- var query = text9("query").pipe(optional5, map34(optionToUndefined34));
97991
+ var query = text9("query").pipe(optional5, map34(optionToUndefined35));
97651
97992
  var limit3 = integer7("limit").pipe(withDefault5(50));
97652
97993
  var offset = integer7("offset").pipe(withDefault5(0));
97653
97994
  function safeJsonParse3(input) {
@@ -98002,11 +98343,11 @@ var readPowerupResolveCommand = exports_Command.make("resolve", { powerup: text9
98002
98343
  })), catchAll2(writeFailure)));
98003
98344
 
98004
98345
  // src/commands/read/powerup/schema.ts
98005
- function optionToUndefined35(opt) {
98346
+ function optionToUndefined36(opt) {
98006
98347
  return isSome2(opt) ? opt.value : undefined;
98007
98348
  }
98008
- var powerup = text9("powerup").pipe(optional5, map34(optionToUndefined35));
98009
- var id2 = text9("id").pipe(optional5, map34(optionToUndefined35));
98349
+ var powerup = text9("powerup").pipe(optional5, map34(optionToUndefined36));
98350
+ var id2 = text9("id").pipe(optional5, map34(optionToUndefined36));
98010
98351
  var limit4 = integer7("limit").pipe(withDefault5(50));
98011
98352
  var offset2 = integer7("offset").pipe(withDefault5(0));
98012
98353
  var readPowerupSchemaCommand = exports_Command.make("schema", { powerup, id: id2, includeOptions: boolean8("include-options"), limit: limit4, offset: offset2 }, ({ powerup: powerup2, id: id3, includeOptions, limit: limit5, offset: offset3 }) => gen2(function* () {
@@ -98283,33 +98624,33 @@ function compileTableValueOps(params3) {
98283
98624
  }
98284
98625
 
98285
98626
  // src/commands/write/_shared.ts
98286
- function optionToUndefined36(opt) {
98627
+ function optionToUndefined37(opt) {
98287
98628
  return isSome2(opt) ? opt.value : undefined;
98288
98629
  }
98289
98630
  function readOptionalText5(name) {
98290
- return text9(name).pipe(optional5, map34(optionToUndefined36));
98631
+ return text9(name).pipe(optional5, map34(optionToUndefined37));
98291
98632
  }
98292
98633
  var writeCommonOptions = {
98293
98634
  notify: boolean8("no-notify").pipe(map34((v) => !v)),
98294
98635
  ensureDaemon: boolean8("no-ensure-daemon").pipe(map34((v) => !v)),
98295
98636
  wait: boolean8("wait"),
98296
- timeoutMs: integer7("timeout-ms").pipe(optional5, map34(optionToUndefined36)),
98297
- pollMs: integer7("poll-ms").pipe(optional5, map34(optionToUndefined36)),
98637
+ timeoutMs: integer7("timeout-ms").pipe(optional5, map34(optionToUndefined37)),
98638
+ pollMs: integer7("poll-ms").pipe(optional5, map34(optionToUndefined37)),
98298
98639
  dryRun: boolean8("dry-run"),
98299
- priority: integer7("priority").pipe(optional5, map34(optionToUndefined36)),
98640
+ priority: integer7("priority").pipe(optional5, map34(optionToUndefined37)),
98300
98641
  clientId: readOptionalText5("client-id"),
98301
98642
  idempotencyKey: readOptionalText5("idempotency-key"),
98302
98643
  meta: readOptionalText5("meta")
98303
98644
  };
98304
98645
 
98305
98646
  // src/commands/write/powerup/apply.ts
98306
- var dispatchMode = choice5("dispatch-mode", ["serial", "conflict_parallel"]).pipe(optional5, map34(optionToUndefined36));
98647
+ var dispatchMode = choice5("dispatch-mode", ["serial", "conflict_parallel"]).pipe(optional5, map34(optionToUndefined37));
98307
98648
  var writePowerupApplyCommand = exports_Command.make("apply", {
98308
98649
  rem: text9("rem"),
98309
- tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined36)),
98310
- powerup: text9("powerup").pipe(optional5, map34(optionToUndefined36)),
98311
- text: text9("text").pipe(optional5, map34(optionToUndefined36)),
98312
- values: text9("values").pipe(optional5, map34(optionToUndefined36)),
98650
+ tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined37)),
98651
+ powerup: text9("powerup").pipe(optional5, map34(optionToUndefined37)),
98652
+ text: text9("text").pipe(optional5, map34(optionToUndefined37)),
98653
+ values: text9("values").pipe(optional5, map34(optionToUndefined37)),
98313
98654
  ensureTag: boolean8("no-ensure-tag").pipe(map34((v) => !v)),
98314
98655
  notify: writeCommonOptions.notify,
98315
98656
  ensureDaemon: writeCommonOptions.ensureDaemon,
@@ -98670,11 +99011,11 @@ var writePowerupOptionCommand = exports_Command.make("option", {}).pipe(exports_
98670
99011
 
98671
99012
  // src/commands/write/powerup/property/add.ts
98672
99013
  var writePowerupPropertyAddCommand = exports_Command.make("add", {
98673
- tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined36)),
98674
- powerup: text9("powerup").pipe(optional5, map34(optionToUndefined36)),
99014
+ tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined37)),
99015
+ powerup: text9("powerup").pipe(optional5, map34(optionToUndefined37)),
98675
99016
  name: text9("name"),
98676
- type: text9("type").pipe(optional5, map34(optionToUndefined36)),
98677
- options: text9("options").pipe(optional5, map34(optionToUndefined36)),
99017
+ type: text9("type").pipe(optional5, map34(optionToUndefined37)),
99018
+ options: text9("options").pipe(optional5, map34(optionToUndefined37)),
98678
99019
  notify: writeCommonOptions.notify,
98679
99020
  ensureDaemon: writeCommonOptions.ensureDaemon,
98680
99021
  wait: writeCommonOptions.wait,
@@ -98903,14 +99244,14 @@ var writePowerupPropertySetTypeCommand = exports_Command.make("set-type", {
98903
99244
  var writePowerupPropertyCommand = exports_Command.make("property", {}).pipe(exports_Command.withSubcommands([writePowerupPropertyAddCommand, writePowerupPropertySetTypeCommand]));
98904
99245
 
98905
99246
  // src/commands/write/powerup/record/add.ts
98906
- var dispatchMode2 = choice5("dispatch-mode", ["serial", "conflict_parallel"]).pipe(optional5, map34(optionToUndefined36));
99247
+ var dispatchMode2 = choice5("dispatch-mode", ["serial", "conflict_parallel"]).pipe(optional5, map34(optionToUndefined37));
98907
99248
  var writePowerupRecordAddCommand = exports_Command.make("add", {
98908
- tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined36)),
98909
- powerup: text9("powerup").pipe(optional5, map34(optionToUndefined36)),
98910
- parent: text9("parent").pipe(optional5, map34(optionToUndefined36)),
98911
- ref: text9("ref").pipe(optional5, map34(optionToUndefined36)),
98912
- text: text9("text").pipe(optional5, map34(optionToUndefined36)),
98913
- values: text9("values").pipe(optional5, map34(optionToUndefined36)),
99249
+ tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined37)),
99250
+ powerup: text9("powerup").pipe(optional5, map34(optionToUndefined37)),
99251
+ parent: text9("parent").pipe(optional5, map34(optionToUndefined37)),
99252
+ ref: text9("ref").pipe(optional5, map34(optionToUndefined37)),
99253
+ text: text9("text").pipe(optional5, map34(optionToUndefined37)),
99254
+ values: text9("values").pipe(optional5, map34(optionToUndefined37)),
98914
99255
  extraTag: text9("extra-tag").pipe(repeated5),
98915
99256
  notify: writeCommonOptions.notify,
98916
99257
  ensureDaemon: writeCommonOptions.ensureDaemon,
@@ -99124,8 +99465,8 @@ function rowHasTag(doc, tagId) {
99124
99465
  return Object.prototype.hasOwnProperty.call(tp, tagId);
99125
99466
  }
99126
99467
  var writePowerupRecordDeleteCommand = exports_Command.make("delete", {
99127
- tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined36)),
99128
- powerup: text9("powerup").pipe(optional5, map34(optionToUndefined36)),
99468
+ tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined37)),
99469
+ powerup: text9("powerup").pipe(optional5, map34(optionToUndefined37)),
99129
99470
  rem: text9("rem"),
99130
99471
  validateMembership: boolean8("no-validate-membership").pipe(map34((v) => !v)),
99131
99472
  notify: writeCommonOptions.notify,
@@ -99270,7 +99611,7 @@ var writePowerupRecordDeleteCommand = exports_Command.make("delete", {
99270
99611
  }).pipe(catchAll2(writeFailure)));
99271
99612
 
99272
99613
  // src/commands/write/powerup/record/update.ts
99273
- var dispatchMode3 = choice5("dispatch-mode", ["serial", "conflict_parallel"]).pipe(optional5, map34(optionToUndefined36));
99614
+ var dispatchMode3 = choice5("dispatch-mode", ["serial", "conflict_parallel"]).pipe(optional5, map34(optionToUndefined37));
99274
99615
  function rowHasTag2(doc, tagId) {
99275
99616
  const tp = doc?.tp;
99276
99617
  if (!tp || typeof tp !== "object" || Array.isArray(tp))
@@ -99278,11 +99619,11 @@ function rowHasTag2(doc, tagId) {
99278
99619
  return Object.prototype.hasOwnProperty.call(tp, tagId);
99279
99620
  }
99280
99621
  var writePowerupRecordUpdateCommand = exports_Command.make("update", {
99281
- tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined36)),
99282
- powerup: text9("powerup").pipe(optional5, map34(optionToUndefined36)),
99622
+ tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined37)),
99623
+ powerup: text9("powerup").pipe(optional5, map34(optionToUndefined37)),
99283
99624
  rem: text9("rem"),
99284
- text: text9("text").pipe(optional5, map34(optionToUndefined36)),
99285
- values: text9("values").pipe(optional5, map34(optionToUndefined36)),
99625
+ text: text9("text").pipe(optional5, map34(optionToUndefined37)),
99626
+ values: text9("values").pipe(optional5, map34(optionToUndefined37)),
99286
99627
  validateMembership: boolean8("no-validate-membership").pipe(map34((v) => !v)),
99287
99628
  notify: writeCommonOptions.notify,
99288
99629
  ensureDaemon: writeCommonOptions.ensureDaemon,
@@ -99499,9 +99840,9 @@ var writePowerupRecordCommand = exports_Command.make("record", {}).pipe(exports_
99499
99840
  // src/commands/write/powerup/remove.ts
99500
99841
  var writePowerupRemoveCommand = exports_Command.make("remove", {
99501
99842
  rem: text9("rem"),
99502
- tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined36)),
99503
- powerup: text9("powerup").pipe(optional5, map34(optionToUndefined36)),
99504
- removeProperties: boolean8("remove-properties").pipe(optional5, map34(optionToUndefined36)),
99843
+ tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined37)),
99844
+ powerup: text9("powerup").pipe(optional5, map34(optionToUndefined37)),
99845
+ removeProperties: boolean8("remove-properties").pipe(optional5, map34(optionToUndefined37)),
99505
99846
  notify: writeCommonOptions.notify,
99506
99847
  ensureDaemon: writeCommonOptions.ensureDaemon,
99507
99848
  wait: writeCommonOptions.wait,
@@ -99636,7 +99977,7 @@ var powerupCommand = exports_Command.make("powerup", {}).pipe(exports_Command.wi
99636
99977
  ]));
99637
99978
 
99638
99979
  // src/commands/read/query.ts
99639
- function optionToUndefined37(opt) {
99980
+ function optionToUndefined38(opt) {
99640
99981
  return isSome2(opt) ? opt.value : undefined;
99641
99982
  }
99642
99983
  function buildMarkdown3(items, total) {
@@ -99651,14 +99992,14 @@ function buildMarkdown3(items, total) {
99651
99992
  return lines3.join(`
99652
99993
  `);
99653
99994
  }
99654
- var payload2 = text9("payload").pipe(optional5, map34(optionToUndefined37));
99655
- var text15 = text9("text").pipe(optional5, map34(optionToUndefined37));
99995
+ var payload2 = text9("payload").pipe(optional5, map34(optionToUndefined38));
99996
+ var text15 = text9("text").pipe(optional5, map34(optionToUndefined38));
99656
99997
  var tag7 = text9("tag").pipe(repeated5);
99657
99998
  var limit5 = integer7("limit").pipe(withDefault5(20));
99658
99999
  var offset3 = integer7("offset").pipe(withDefault5(0));
99659
100000
  var snippetLength = integer7("snippet-length").pipe(withDefault5(200));
99660
- var sort2 = choice5("sort", ["rank", "updatedAt", "createdAt"]).pipe(optional5, map34(optionToUndefined37));
99661
- var sortDirection = choice5("sort-direction", ["asc", "desc"]).pipe(optional5, map34(optionToUndefined37));
100001
+ var sort2 = choice5("sort", ["rank", "updatedAt", "createdAt"]).pipe(optional5, map34(optionToUndefined38));
100002
+ var sortDirection = choice5("sort-direction", ["asc", "desc"]).pipe(optional5, map34(optionToUndefined38));
99662
100003
  var readQueryCommand = exports_Command.make("query", { payload: payload2, text: text15, tag: tag7, limit: limit5, offset: offset3, snippetLength, sort: sort2, sortDirection }, ({ payload: payload3, text: text16, tag: tag8, limit: limit6, offset: offset4, snippetLength: snippetLength2, sort: sort3, sortDirection: sortDirection2 }) => gen2(function* () {
99663
100004
  const cfg = yield* AppConfig;
99664
100005
  const payloadSvc = yield* Payload;
@@ -99777,11 +100118,11 @@ var queueConflictsCommand = exports_Command.make("conflicts", {
99777
100118
  }).pipe(catchAll2(writeFailure)));
99778
100119
 
99779
100120
  // src/commands/queue/inspect.ts
99780
- function optionToUndefined38(opt) {
100121
+ function optionToUndefined39(opt) {
99781
100122
  return isSome2(opt) ? opt.value : undefined;
99782
100123
  }
99783
- var txn = text9("txn").pipe(optional5, map34(optionToUndefined38));
99784
- var op = text9("op").pipe(optional5, map34(optionToUndefined38));
100124
+ var txn = text9("txn").pipe(optional5, map34(optionToUndefined39));
100125
+ var op = text9("op").pipe(optional5, map34(optionToUndefined39));
99785
100126
  var queueInspectCommand = exports_Command.make("inspect", { txn, op }, ({ txn: txn2, op: op2 }) => gen2(function* () {
99786
100127
  const cfg = yield* AppConfig;
99787
100128
  const queue = yield* Queue;
@@ -99907,13 +100248,13 @@ var queueStatsCommand = exports_Command.make("stats", { includeConflicts: boolea
99907
100248
  }).pipe(catchAll2(writeFailure)));
99908
100249
 
99909
100250
  // src/commands/queue/wait.ts
99910
- function optionToUndefined39(opt) {
100251
+ function optionToUndefined40(opt) {
99911
100252
  return isSome2(opt) ? opt.value : undefined;
99912
100253
  }
99913
100254
  var queueWaitCommand = exports_Command.make("wait", {
99914
100255
  txn: text9("txn"),
99915
- timeoutMs: integer7("timeout-ms").pipe(optional5, map34(optionToUndefined39)),
99916
- pollMs: integer7("poll-ms").pipe(optional5, map34(optionToUndefined39))
100256
+ timeoutMs: integer7("timeout-ms").pipe(optional5, map34(optionToUndefined40)),
100257
+ pollMs: integer7("poll-ms").pipe(optional5, map34(optionToUndefined40))
99917
100258
  }, ({ txn: txn2, timeoutMs: timeoutMs5, pollMs: pollMs4 }) => gen2(function* () {
99918
100259
  const cfg = yield* AppConfig;
99919
100260
  const hostApi = yield* HostApiClient;
@@ -99946,12 +100287,12 @@ var queueCommand = exports_Command.make("queue", {}).pipe(exports_Command.withSu
99946
100287
  ]));
99947
100288
 
99948
100289
  // src/commands/read/by-reference.ts
99949
- function optionToUndefined40(opt) {
100290
+ function optionToUndefined41(opt) {
99950
100291
  return isSome2(opt) ? opt.value : undefined;
99951
100292
  }
99952
100293
  var reference = text9("reference").pipe(repeated5);
99953
- var timeRange = text9("time").pipe(optional5, map34(optionToUndefined40));
99954
- var maxDepth3 = integer7("max-depth").pipe(optional5, map34(optionToUndefined40));
100294
+ var timeRange = text9("time").pipe(optional5, map34(optionToUndefined41));
100295
+ var maxDepth3 = integer7("max-depth").pipe(optional5, map34(optionToUndefined41));
99955
100296
  var limit6 = integer7("limit").pipe(withDefault5(40));
99956
100297
  var offset4 = integer7("offset").pipe(withDefault5(0));
99957
100298
  var readByReferenceCommand = exports_Command.make("by-reference", { reference, timeRange, maxDepth: maxDepth3, limit: limit6, offset: offset4 }, ({ reference: reference2, timeRange: timeRange2, maxDepth: maxDepth4, limit: limit7, offset: offset5 }) => gen2(function* () {
@@ -99984,10 +100325,10 @@ var readConnectionsCommand = exports_Command.make("connections", { id: text9("id
99984
100325
  }).pipe(catchAll2(writeFailure)));
99985
100326
 
99986
100327
  // src/commands/read/inspect.ts
99987
- function optionToUndefined41(opt) {
100328
+ function optionToUndefined42(opt) {
99988
100329
  return isSome2(opt) ? opt.value : undefined;
99989
100330
  }
99990
- var maxReferenceDepth = integer7("max-reference-depth").pipe(optional5, map34(optionToUndefined41));
100331
+ var maxReferenceDepth = integer7("max-reference-depth").pipe(optional5, map34(optionToUndefined42));
99991
100332
  var readInspectCommand = exports_Command.make("inspect", {
99992
100333
  id: text9("id"),
99993
100334
  expandReferences: boolean8("expand-references"),
@@ -100015,15 +100356,15 @@ var readInspectCommand = exports_Command.make("inspect", {
100015
100356
  }).pipe(catchAll2(writeFailure)));
100016
100357
 
100017
100358
  // src/commands/read/outline.ts
100018
- function optionToUndefined42(opt) {
100359
+ function optionToUndefined43(opt) {
100019
100360
  return isSome2(opt) ? opt.value : undefined;
100020
100361
  }
100021
- var depth = integer7("depth").pipe(optional5, map34(optionToUndefined42));
100022
- var offset5 = integer7("offset").pipe(optional5, map34(optionToUndefined42));
100023
- var nodes = integer7("nodes").pipe(optional5, map34(optionToUndefined42));
100024
- var format9 = choice5("format", ["md", "json"]).pipe(optional5, map34(optionToUndefined42));
100025
- var id3 = text9("id").pipe(optional5, map34(optionToUndefined42));
100026
- var ref3 = text9("ref").pipe(optional5, map34(optionToUndefined42));
100362
+ var depth = integer7("depth").pipe(optional5, map34(optionToUndefined43));
100363
+ var offset5 = integer7("offset").pipe(optional5, map34(optionToUndefined43));
100364
+ var nodes = integer7("nodes").pipe(optional5, map34(optionToUndefined43));
100365
+ var format9 = choice5("format", ["md", "json"]).pipe(optional5, map34(optionToUndefined43));
100366
+ var id3 = text9("id").pipe(optional5, map34(optionToUndefined43));
100367
+ var ref3 = text9("ref").pipe(optional5, map34(optionToUndefined43));
100027
100368
  var readOutlineCommand = exports_Command.make("outline", {
100028
100369
  id: id3,
100029
100370
  ref: ref3,
@@ -100034,7 +100375,7 @@ var readOutlineCommand = exports_Command.make("outline", {
100034
100375
  excludeProperties: boolean8("exclude-properties"),
100035
100376
  includeEmpty: boolean8("include-empty"),
100036
100377
  expandReferences: boolean8("expand-references"),
100037
- maxReferenceDepth: integer7("max-reference-depth").pipe(optional5, map34(optionToUndefined42)),
100378
+ maxReferenceDepth: integer7("max-reference-depth").pipe(optional5, map34(optionToUndefined43)),
100038
100379
  detail: boolean8("detail")
100039
100380
  }, ({
100040
100381
  id: id4,
@@ -100081,12 +100422,12 @@ var readOutlineCommand = exports_Command.make("outline", {
100081
100422
  }).pipe(catchAll2(writeFailure)));
100082
100423
 
100083
100424
  // src/commands/read/page-id.ts
100084
- function optionToUndefined43(opt) {
100425
+ function optionToUndefined44(opt) {
100085
100426
  return isSome2(opt) ? opt.value : undefined;
100086
100427
  }
100087
- var ref4 = text9("ref").pipe(optional5, map34(optionToUndefined43));
100428
+ var ref4 = text9("ref").pipe(optional5, map34(optionToUndefined44));
100088
100429
  var id4 = text9("id").pipe(repeated5);
100089
- var maxHops = integer7("max-hops").pipe(optional5, map34(optionToUndefined43));
100430
+ var maxHops = integer7("max-hops").pipe(optional5, map34(optionToUndefined44));
100090
100431
  var readPageIdCommand = exports_Command.make("page-id", { ref: ref4, id: id4, maxHops, detail: boolean8("detail") }, ({ ref: ref5, id: id5, maxHops: maxHops2, detail }) => gen2(function* () {
100091
100432
  const cfg = yield* AppConfig;
100092
100433
  const refs = yield* RefResolver;
@@ -100136,11 +100477,11 @@ var readPageIdCommand = exports_Command.make("page-id", { ref: ref4, id: id4, ma
100136
100477
  }).pipe(catchAll2(writeFailure)));
100137
100478
 
100138
100479
  // src/commands/read/references.ts
100139
- function optionToUndefined44(opt) {
100480
+ function optionToUndefined45(opt) {
100140
100481
  return isSome2(opt) ? opt.value : undefined;
100141
100482
  }
100142
- var maxDepth4 = integer7("max-depth").pipe(optional5, map34(optionToUndefined44));
100143
- var inboundMaxDepth = integer7("inbound-max-depth").pipe(optional5, map34(optionToUndefined44));
100483
+ var maxDepth4 = integer7("max-depth").pipe(optional5, map34(optionToUndefined45));
100484
+ var inboundMaxDepth = integer7("inbound-max-depth").pipe(optional5, map34(optionToUndefined45));
100144
100485
  var readReferencesCommand = exports_Command.make("references", {
100145
100486
  id: text9("id"),
100146
100487
  includeDescendants: boolean8("include-descendants"),
@@ -100172,10 +100513,10 @@ var readReferencesCommand = exports_Command.make("references", {
100172
100513
 
100173
100514
  // src/commands/read/resolve-ref.ts
100174
100515
  var ids3 = text9("ids").pipe(repeated5);
100175
- function optionToUndefined45(opt) {
100516
+ function optionToUndefined46(opt) {
100176
100517
  return isSome2(opt) ? opt.value : undefined;
100177
100518
  }
100178
- var maxReferenceDepth2 = integer7("max-reference-depth").pipe(optional5, map34(optionToUndefined45));
100519
+ var maxReferenceDepth2 = integer7("max-reference-depth").pipe(optional5, map34(optionToUndefined46));
100179
100520
  var readResolveRefCommand = exports_Command.make("resolve-ref", {
100180
100521
  ids: ids3,
100181
100522
  expandReferences: boolean8("expand-references"),
@@ -100206,13 +100547,14 @@ function normalizeRemIdInput2(raw4) {
100206
100547
  }
100207
100548
  var tag8 = text9("tag").pipe(repeated5);
100208
100549
  var writeRemCreateCommand = exports_Command.make("create", {
100209
- parent: text9("parent").pipe(optional5, map34(optionToUndefined36)),
100210
- ref: text9("ref").pipe(optional5, map34(optionToUndefined36)),
100211
- text: text9("text").pipe(optional5, map34(optionToUndefined36)),
100550
+ parent: text9("parent").pipe(optional5, map34(optionToUndefined37)),
100551
+ ref: text9("ref").pipe(optional5, map34(optionToUndefined37)),
100552
+ text: text9("text").pipe(optional5, map34(optionToUndefined37)),
100212
100553
  isDocument: boolean8("is-document"),
100213
100554
  tag: tag8,
100214
- position: integer7("position").pipe(optional5, map34(optionToUndefined36)),
100215
- clientTempId: text9("client-temp-id").pipe(optional5, map34(optionToUndefined36)),
100555
+ position: integer7("position").pipe(optional5, map34(optionToUndefined37)),
100556
+ clientTempId: text9("client-temp-id").pipe(optional5, map34(optionToUndefined37)),
100557
+ forceText: boolean8("force-text"),
100216
100558
  notify: writeCommonOptions.notify,
100217
100559
  ensureDaemon: writeCommonOptions.ensureDaemon,
100218
100560
  wait: writeCommonOptions.wait,
@@ -100231,6 +100573,7 @@ var writeRemCreateCommand = exports_Command.make("create", {
100231
100573
  tag: tag9,
100232
100574
  position: position4,
100233
100575
  clientTempId,
100576
+ forceText: forceText2,
100234
100577
  notify: notify6,
100235
100578
  ensureDaemon: ensureDaemon8,
100236
100579
  wait: wait4,
@@ -100286,6 +100629,13 @@ var writeRemCreateCommand = exports_Command.make("create", {
100286
100629
  const tags2 = Array.isArray(tag9) ? tag9.map(normalizeRemIdInput2).filter(Boolean) : [];
100287
100630
  const remClientTempId = clientTempId ? String(clientTempId).trim() : makeTempId();
100288
100631
  const textValue = text16 !== undefined ? trimBoundaryBlankLines(text16) : undefined;
100632
+ if (textValue && !forceText2 && looksLikeStructuredMarkdown(textValue)) {
100633
+ return yield* fail8(new CliError({
100634
+ code: "INVALID_ARGS",
100635
+ message: "Input passed to --text looks like structured Markdown. Use import markdown --parent/--ref instead, or pass --force-text to keep it literal.",
100636
+ exitCode: 2
100637
+ }));
100638
+ }
100289
100639
  const payload3 = {
100290
100640
  parentId,
100291
100641
  clientTempId: remClientTempId
@@ -100440,9 +100790,9 @@ function normalizeRemIdInput3(raw4) {
100440
100790
  }
100441
100791
  var writeRemMoveCommand = exports_Command.make("move", {
100442
100792
  rem: text9("rem"),
100443
- parent: text9("parent").pipe(optional5, map34(optionToUndefined36)),
100444
- ref: text9("ref").pipe(optional5, map34(optionToUndefined36)),
100445
- position: integer7("position").pipe(optional5, map34(optionToUndefined36)),
100793
+ parent: text9("parent").pipe(optional5, map34(optionToUndefined37)),
100794
+ ref: text9("ref").pipe(optional5, map34(optionToUndefined37)),
100795
+ position: integer7("position").pipe(optional5, map34(optionToUndefined37)),
100446
100796
  notify: writeCommonOptions.notify,
100447
100797
  ensureDaemon: writeCommonOptions.ensureDaemon,
100448
100798
  wait: writeCommonOptions.wait,
@@ -100645,7 +100995,7 @@ var writeTagAddCommand = exports_Command.make("add", {
100645
100995
  var writeTagRemoveCommand = exports_Command.make("remove", {
100646
100996
  rem: text9("rem"),
100647
100997
  tag: text9("tag"),
100648
- removeProperties: boolean8("remove-properties").pipe(optional5, map34(optionToUndefined36)),
100998
+ removeProperties: boolean8("remove-properties").pipe(optional5, map34(optionToUndefined37)),
100649
100999
  notify: writeCommonOptions.notify,
100650
101000
  ensureDaemon: writeCommonOptions.ensureDaemon,
100651
101001
  wait: writeCommonOptions.wait,
@@ -100956,18 +101306,18 @@ function expandTargetIds(params3) {
100956
101306
  }
100957
101307
 
100958
101308
  // src/commands/write/replace/block.ts
100959
- function optionToUndefined46(opt) {
101309
+ function optionToUndefined47(opt) {
100960
101310
  return isSome2(opt) ? opt.value : undefined;
100961
101311
  }
100962
101312
  function readOptionalText6(name) {
100963
- return text9(name).pipe(optional5, map34(optionToUndefined46));
101313
+ return text9(name).pipe(optional5, map34(optionToUndefined47));
100964
101314
  }
100965
101315
  var selection = boolean8("selection");
100966
101316
  var stateFile18 = readOptionalText6("state-file");
100967
- var staleMs11 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined46));
101317
+ var staleMs11 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined47));
100968
101318
  var ref5 = readOptionalText6("ref");
100969
101319
  var ids4 = text9("id").pipe(repeated5);
100970
- var scope5 = choice5("scope", ["roots", "subtree"]).pipe(optional5, map34(optionToUndefined46));
101320
+ var scope5 = choice5("scope", ["roots", "subtree"]).pipe(optional5, map34(optionToUndefined47));
100971
101321
  var requireComplete = boolean8("require-complete");
100972
101322
  var maxDepth5 = integer7("max-depth").pipe(withDefault5(10));
100973
101323
  var maxNodes2 = integer7("max-nodes").pipe(withDefault5(1000));
@@ -100979,12 +101329,12 @@ var file9 = readOptionalText6("file");
100979
101329
  var clientId6 = readOptionalText6("client-id");
100980
101330
  var idempotencyKey6 = readOptionalText6("idempotency-key");
100981
101331
  var metaSpec6 = readOptionalText6("meta");
100982
- var priority6 = integer7("priority").pipe(optional5, map34(optionToUndefined46));
101332
+ var priority6 = integer7("priority").pipe(optional5, map34(optionToUndefined47));
100983
101333
  var notify6 = boolean8("no-notify").pipe(map34((v) => !v));
100984
101334
  var ensureDaemon8 = boolean8("no-ensure-daemon").pipe(map34((v) => !v));
100985
101335
  var wait4 = boolean8("wait");
100986
- var timeoutMs5 = integer7("timeout-ms").pipe(optional5, map34(optionToUndefined46));
100987
- var pollMs4 = integer7("poll-ms").pipe(optional5, map34(optionToUndefined46));
101336
+ var timeoutMs5 = integer7("timeout-ms").pipe(optional5, map34(optionToUndefined47));
101337
+ var pollMs4 = integer7("poll-ms").pipe(optional5, map34(optionToUndefined47));
100988
101338
  var replaceMarkdownCommand = exports_Command.make("markdown", {
100989
101339
  selection,
100990
101340
  stateFile: stateFile18,
@@ -101024,7 +101374,7 @@ var replaceMarkdownCommand = exports_Command.make("markdown", {
101024
101374
  useCurrentSelection: useCurrentSelection2,
101025
101375
  portalId: portalId2,
101026
101376
  file: file10,
101027
- markdown,
101377
+ markdown: markdown2,
101028
101378
  notify: notify7,
101029
101379
  ensureDaemon: ensureDaemon9,
101030
101380
  wait: wait5,
@@ -101053,17 +101403,17 @@ var replaceMarkdownCommand = exports_Command.make("markdown", {
101053
101403
  const fileInput = yield* FileInput;
101054
101404
  const payloadSvc = yield* Payload;
101055
101405
  const resolvedTarget = yield* resolveReplaceTarget({ selection: selection2, stateFile: stateFile19, staleMs: staleMs12, ref: ref6, ids: id5 });
101056
- if (file10 && markdown) {
101406
+ if (file10 && markdown2) {
101057
101407
  return yield* fail8(new CliError({
101058
101408
  code: "INVALID_ARGS",
101059
101409
  message: "Choose only one of --file or --markdown",
101060
101410
  exitCode: 2
101061
101411
  }));
101062
101412
  }
101063
- if (!file10 && !markdown) {
101413
+ if (!file10 && !markdown2) {
101064
101414
  return yield* fail8(new CliError({ code: "INVALID_ARGS", message: "You must provide --file or --markdown", exitCode: 2 }));
101065
101415
  }
101066
- const mdRaw = typeof markdown === "string" ? markdown : yield* fileInput.readTextFromFileSpec({ spec: String(file10) });
101416
+ const mdRaw = typeof markdown2 === "string" ? markdown2 : yield* fileInput.readTextFromFileSpec({ spec: String(file10) });
101067
101417
  const md = trimBoundaryBlankLines(mdRaw);
101068
101418
  const scopeValue = scope6 ?? "roots";
101069
101419
  if (scopeValue !== "roots") {
@@ -101154,18 +101504,18 @@ var replaceMarkdownCommand = exports_Command.make("markdown", {
101154
101504
  }).pipe(catchAll2(writeFailure)));
101155
101505
 
101156
101506
  // src/commands/write/replace/text.ts
101157
- function optionToUndefined47(opt) {
101507
+ function optionToUndefined48(opt) {
101158
101508
  return isSome2(opt) ? opt.value : undefined;
101159
101509
  }
101160
101510
  function readOptionalText7(name) {
101161
- return text9(name).pipe(optional5, map34(optionToUndefined47));
101511
+ return text9(name).pipe(optional5, map34(optionToUndefined48));
101162
101512
  }
101163
101513
  var selection2 = boolean8("selection");
101164
101514
  var stateFile19 = readOptionalText7("state-file");
101165
- var staleMs12 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined47));
101515
+ var staleMs12 = integer7("stale-ms").pipe(optional5, map34(optionToUndefined48));
101166
101516
  var ref6 = readOptionalText7("ref");
101167
101517
  var ids5 = text9("id").pipe(repeated5);
101168
- var scope6 = choice5("scope", ["roots", "subtree"]).pipe(optional5, map34(optionToUndefined47));
101518
+ var scope6 = choice5("scope", ["roots", "subtree"]).pipe(optional5, map34(optionToUndefined48));
101169
101519
  var maxDepth6 = integer7("max-depth").pipe(withDefault5(10));
101170
101520
  var maxNodes3 = integer7("max-nodes").pipe(withDefault5(1000));
101171
101521
  var requireComplete2 = boolean8("require-complete");
@@ -101177,12 +101527,12 @@ var flags = readOptionalText7("flags");
101177
101527
  var clientId7 = readOptionalText7("client-id");
101178
101528
  var idempotencyKey7 = readOptionalText7("idempotency-key");
101179
101529
  var metaSpec7 = readOptionalText7("meta");
101180
- var priority7 = integer7("priority").pipe(optional5, map34(optionToUndefined47));
101530
+ var priority7 = integer7("priority").pipe(optional5, map34(optionToUndefined48));
101181
101531
  var notify7 = boolean8("no-notify").pipe(map34((v) => !v));
101182
101532
  var ensureDaemon9 = boolean8("no-ensure-daemon").pipe(map34((v) => !v));
101183
101533
  var wait5 = boolean8("wait");
101184
- var timeoutMs6 = integer7("timeout-ms").pipe(optional5, map34(optionToUndefined47));
101185
- var pollMs5 = integer7("poll-ms").pipe(optional5, map34(optionToUndefined47));
101534
+ var timeoutMs6 = integer7("timeout-ms").pipe(optional5, map34(optionToUndefined48));
101535
+ var pollMs5 = integer7("poll-ms").pipe(optional5, map34(optionToUndefined48));
101186
101536
  function tryMakeRegExp(pattern2, rawFlags) {
101187
101537
  const f = typeof rawFlags === "string" && rawFlags.trim() ? rawFlags.trim() : "g";
101188
101538
  const withGlobal = f.includes("g") ? f : `g${f}`;
@@ -101430,11 +101780,11 @@ var writeReplaceCommand = exports_Command.make("replace", {}).pipe(exports_Comma
101430
101780
  var replaceCommand = writeReplaceCommand;
101431
101781
 
101432
101782
  // src/commands/read/search.ts
101433
- function optionToUndefined48(opt) {
101783
+ function optionToUndefined49(opt) {
101434
101784
  return isSome2(opt) ? opt.value : undefined;
101435
101785
  }
101436
- var timeRange2 = text9("time").pipe(optional5, map34(optionToUndefined48));
101437
- var parentId = text9("parent").pipe(optional5, map34(optionToUndefined48));
101786
+ var timeRange2 = text9("time").pipe(optional5, map34(optionToUndefined49));
101787
+ var parentId = text9("parent").pipe(optional5, map34(optionToUndefined49));
101438
101788
  var limit7 = integer7("limit").pipe(withDefault5(10));
101439
101789
  var offset6 = integer7("offset").pipe(withDefault5(0));
101440
101790
  var timeoutMs7 = integer7("timeout-ms").pipe(withDefault5(30000));
@@ -101511,10 +101861,10 @@ function normalizeRemIdInput6(raw4) {
101511
101861
  }
101512
101862
  var writeTableCreateCommand = exports_Command.make("create", {
101513
101863
  tableTag: text9("table-tag"),
101514
- parent: text9("parent").pipe(optional5, map34(optionToUndefined36)),
101515
- ref: text9("ref").pipe(optional5, map34(optionToUndefined36)),
101516
- position: integer7("position").pipe(optional5, map34(optionToUndefined36)),
101517
- clientTempId: text9("client-temp-id").pipe(optional5, map34(optionToUndefined36)),
101864
+ parent: text9("parent").pipe(optional5, map34(optionToUndefined37)),
101865
+ ref: text9("ref").pipe(optional5, map34(optionToUndefined37)),
101866
+ position: integer7("position").pipe(optional5, map34(optionToUndefined37)),
101867
+ clientTempId: text9("client-temp-id").pipe(optional5, map34(optionToUndefined37)),
101518
101868
  notify: writeCommonOptions.notify,
101519
101869
  ensureDaemon: writeCommonOptions.ensureDaemon,
101520
101870
  wait: writeCommonOptions.wait,
@@ -101827,8 +102177,8 @@ var writeTableOptionCommand = exports_Command.make("option", {}).pipe(exports_Co
101827
102177
  var writeTablePropertyAddCommand = exports_Command.make("add", {
101828
102178
  tableTag: text9("table-tag"),
101829
102179
  name: text9("name"),
101830
- type: text9("type").pipe(optional5, map34(optionToUndefined36)),
101831
- options: text9("options").pipe(optional5, map34(optionToUndefined36)),
102180
+ type: text9("type").pipe(optional5, map34(optionToUndefined37)),
102181
+ options: text9("options").pipe(optional5, map34(optionToUndefined37)),
101832
102182
  notify: writeCommonOptions.notify,
101833
102183
  ensureDaemon: writeCommonOptions.ensureDaemon,
101834
102184
  wait: writeCommonOptions.wait,
@@ -102029,10 +102379,10 @@ var writeTablePropertyCommand = exports_Command.make("property", {}).pipe(export
102029
102379
  // src/commands/write/table/record/add.ts
102030
102380
  var writeTableRecordAddCommand = exports_Command.make("add", {
102031
102381
  tableTag: text9("table-tag"),
102032
- parent: text9("parent").pipe(optional5, map34(optionToUndefined36)),
102033
- ref: text9("ref").pipe(optional5, map34(optionToUndefined36)),
102034
- text: text9("text").pipe(optional5, map34(optionToUndefined36)),
102035
- values: text9("values").pipe(optional5, map34(optionToUndefined36)),
102382
+ parent: text9("parent").pipe(optional5, map34(optionToUndefined37)),
102383
+ ref: text9("ref").pipe(optional5, map34(optionToUndefined37)),
102384
+ text: text9("text").pipe(optional5, map34(optionToUndefined37)),
102385
+ values: text9("values").pipe(optional5, map34(optionToUndefined37)),
102036
102386
  notify: writeCommonOptions.notify,
102037
102387
  ensureDaemon: writeCommonOptions.ensureDaemon,
102038
102388
  wait: writeCommonOptions.wait,
@@ -102339,8 +102689,8 @@ function rowHasTag4(doc, tagId) {
102339
102689
  var writeTableRecordUpdateCommand = exports_Command.make("update", {
102340
102690
  tableTag: text9("table-tag"),
102341
102691
  row: text9("row"),
102342
- text: text9("text").pipe(optional5, map34(optionToUndefined36)),
102343
- values: text9("values").pipe(optional5, map34(optionToUndefined36)),
102692
+ text: text9("text").pipe(optional5, map34(optionToUndefined37)),
102693
+ values: text9("values").pipe(optional5, map34(optionToUndefined37)),
102344
102694
  notify: writeCommonOptions.notify,
102345
102695
  ensureDaemon: writeCommonOptions.ensureDaemon,
102346
102696
  wait: writeCommonOptions.wait,
@@ -102553,10 +102903,10 @@ var tableCommand = exports_Command.make("table", {}).pipe(exports_Command.withSu
102553
102903
  var tagCommand = writeTagCommand;
102554
102904
 
102555
102905
  // src/commands/read/todos/list.ts
102556
- function optionToUndefined49(opt) {
102906
+ function optionToUndefined50(opt) {
102557
102907
  return isSome2(opt) ? opt.value : undefined;
102558
102908
  }
102559
- var status2 = choice5("status", ["unfinished", "finished", "all"]).pipe(optional5, map34(optionToUndefined49));
102909
+ var status2 = choice5("status", ["unfinished", "finished", "all"]).pipe(optional5, map34(optionToUndefined50));
102560
102910
  var sort3 = choice5("sort", [
102561
102911
  "dueAsc",
102562
102912
  "dueDesc",
@@ -102564,22 +102914,22 @@ var sort3 = choice5("sort", [
102564
102914
  "updatedAtDesc",
102565
102915
  "createdAtAsc",
102566
102916
  "createdAtDesc"
102567
- ]).pipe(optional5, map34(optionToUndefined49));
102917
+ ]).pipe(optional5, map34(optionToUndefined50));
102568
102918
  var tagId = text9("tag-id").pipe(repeated5);
102569
102919
  var tagTitle = text9("tag-title").pipe(repeated5);
102570
102920
  var preferTodoOnly = boolean8("prefer-todo-only");
102571
102921
  var preferTodoFirst = boolean8("prefer-todo-first");
102572
102922
  var includeDescendants = boolean8("no-descendants").pipe(map34((v) => !v));
102573
- var ancestor = text9("ancestor").pipe(optional5, map34(optionToUndefined49));
102574
- var dueBefore = text9("due-before").pipe(optional5, map34(optionToUndefined49));
102575
- var dueAfter = text9("due-after").pipe(optional5, map34(optionToUndefined49));
102923
+ var ancestor = text9("ancestor").pipe(optional5, map34(optionToUndefined50));
102924
+ var dueBefore = text9("due-before").pipe(optional5, map34(optionToUndefined50));
102925
+ var dueAfter = text9("due-after").pipe(optional5, map34(optionToUndefined50));
102576
102926
  var includeTagOnlyWhenNoStatus = boolean8("no-tag-only-when-no-status").pipe(map34((v) => !v));
102577
102927
  var statusAttrTitle = text9("status-attr-title").pipe(repeated5);
102578
102928
  var unfinishedOptionTitle = text9("unfinished-option-title").pipe(repeated5);
102579
102929
  var finishedOptionTitle = text9("finished-option-title").pipe(repeated5);
102580
102930
  var dueDateAttrTitle = text9("due-date-attr-title").pipe(repeated5);
102581
102931
  var alwaysIncludeTagOnlyTitle = text9("always-include-tag-only-title").pipe(repeated5);
102582
- var snippetLength2 = integer7("snippet-length").pipe(optional5, map34(optionToUndefined49));
102932
+ var snippetLength2 = integer7("snippet-length").pipe(optional5, map34(optionToUndefined50));
102583
102933
  var limit9 = integer7("limit").pipe(withDefault5(20));
102584
102934
  var offset8 = integer7("offset").pipe(withDefault5(0));
102585
102935
  function makeTodosListCommand() {
@@ -102656,8 +103006,8 @@ function makeTodosListCommand() {
102656
103006
  var todosListCommand = makeTodosListCommand();
102657
103007
 
102658
103008
  // src/commands/write/powerup/todo/todoAdd.ts
102659
- var status3 = choice5("status", ["unfinished", "finished", "clear"]).pipe(optional5, map34(optionToUndefined36));
102660
- var dispatchMode4 = choice5("dispatch-mode", ["serial", "conflict_parallel"]).pipe(optional5, map34(optionToUndefined36));
103009
+ var status3 = choice5("status", ["unfinished", "finished", "clear"]).pipe(optional5, map34(optionToUndefined37));
103010
+ var dispatchMode4 = choice5("dispatch-mode", ["serial", "conflict_parallel"]).pipe(optional5, map34(optionToUndefined37));
102661
103011
  function pickTodoSchema(schemas, tagId2) {
102662
103012
  const mapped = schemas.map((s) => ({
102663
103013
  tagId: String(s?.tagId ?? ""),
@@ -102676,10 +103026,10 @@ function pickTodoSchema(schemas, tagId2) {
102676
103026
  }
102677
103027
  var writePowerupTodoAddCommand = exports_Command.make("add", {
102678
103028
  rem: text9("rem"),
102679
- tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined36)),
103029
+ tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined37)),
102680
103030
  status: status3,
102681
- due: text9("due").pipe(optional5, map34(optionToUndefined36)),
102682
- values: text9("values").pipe(optional5, map34(optionToUndefined36)),
103031
+ due: text9("due").pipe(optional5, map34(optionToUndefined37)),
103032
+ values: text9("values").pipe(optional5, map34(optionToUndefined37)),
102683
103033
  notify: writeCommonOptions.notify,
102684
103034
  ensureDaemon: writeCommonOptions.ensureDaemon,
102685
103035
  wait: writeCommonOptions.wait,
@@ -102933,12 +103283,12 @@ function todoWriteEffect(params3) {
102933
103283
  }
102934
103284
 
102935
103285
  // src/commands/write/powerup/todo/todoDone.ts
102936
- var dispatchMode5 = choice5("dispatch-mode", ["serial", "conflict_parallel"]).pipe(optional5, map34(optionToUndefined36));
103286
+ var dispatchMode5 = choice5("dispatch-mode", ["serial", "conflict_parallel"]).pipe(optional5, map34(optionToUndefined37));
102937
103287
  var writePowerupTodoDoneCommand = exports_Command.make("done", {
102938
103288
  rem: text9("rem"),
102939
- tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined36)),
102940
- due: text9("due").pipe(optional5, map34(optionToUndefined36)),
102941
- values: text9("values").pipe(optional5, map34(optionToUndefined36)),
103289
+ tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined37)),
103290
+ due: text9("due").pipe(optional5, map34(optionToUndefined37)),
103291
+ values: text9("values").pipe(optional5, map34(optionToUndefined37)),
102942
103292
  notify: writeCommonOptions.notify,
102943
103293
  ensureDaemon: writeCommonOptions.ensureDaemon,
102944
103294
  wait: writeCommonOptions.wait,
@@ -102995,8 +103345,8 @@ function pickTodoTagId(schemas, tagId2) {
102995
103345
  }
102996
103346
  var writePowerupTodoRemoveCommand = exports_Command.make("remove", {
102997
103347
  rem: text9("rem"),
102998
- tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined36)),
102999
- removeProperties: boolean8("remove-properties").pipe(optional5, map34(optionToUndefined36)),
103348
+ tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined37)),
103349
+ removeProperties: boolean8("remove-properties").pipe(optional5, map34(optionToUndefined37)),
103000
103350
  notify: writeCommonOptions.notify,
103001
103351
  ensureDaemon: writeCommonOptions.ensureDaemon,
103002
103352
  wait: writeCommonOptions.wait,
@@ -103119,12 +103469,12 @@ var writePowerupTodoRemoveCommand = exports_Command.make("remove", {
103119
103469
  }).pipe(catchAll2(writeFailure)));
103120
103470
 
103121
103471
  // src/commands/write/powerup/todo/todoUndone.ts
103122
- var dispatchMode6 = choice5("dispatch-mode", ["serial", "conflict_parallel"]).pipe(optional5, map34(optionToUndefined36));
103472
+ var dispatchMode6 = choice5("dispatch-mode", ["serial", "conflict_parallel"]).pipe(optional5, map34(optionToUndefined37));
103123
103473
  var writePowerupTodoUndoneCommand = exports_Command.make("undone", {
103124
103474
  rem: text9("rem"),
103125
- tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined36)),
103126
- due: text9("due").pipe(optional5, map34(optionToUndefined36)),
103127
- values: text9("values").pipe(optional5, map34(optionToUndefined36)),
103475
+ tagId: text9("tag-id").pipe(optional5, map34(optionToUndefined37)),
103476
+ due: text9("due").pipe(optional5, map34(optionToUndefined37)),
103477
+ values: text9("values").pipe(optional5, map34(optionToUndefined37)),
103128
103478
  notify: writeCommonOptions.notify,
103129
103479
  ensureDaemon: writeCommonOptions.ensureDaemon,
103130
103480
  wait: writeCommonOptions.wait,
@@ -103181,15 +103531,15 @@ var todoCommand = exports_Command.make("todo", {}).pipe(exports_Command.withSubc
103181
103531
  ]));
103182
103532
 
103183
103533
  // src/commands/read/topic/summary.ts
103184
- function optionToUndefined50(opt) {
103534
+ function optionToUndefined51(opt) {
103185
103535
  return isSome2(opt) ? opt.value : undefined;
103186
103536
  }
103187
- var keywords = text9("keywords").pipe(optional5, map34(optionToUndefined50));
103188
- var query2 = text9("query").pipe(optional5, map34(optionToUndefined50));
103189
- var timeRange3 = text9("time").pipe(optional5, map34(optionToUndefined50));
103190
- var maxResults = integer7("max-results").pipe(optional5, map34(optionToUndefined50));
103191
- var maxNodesPerResult = integer7("max-nodes").pipe(optional5, map34(optionToUndefined50));
103192
- var groupBy2 = choice5("group-by", ["none", "parent", "date"]).pipe(optional5, map34(optionToUndefined50));
103537
+ var keywords = text9("keywords").pipe(optional5, map34(optionToUndefined51));
103538
+ var query2 = text9("query").pipe(optional5, map34(optionToUndefined51));
103539
+ var timeRange3 = text9("time").pipe(optional5, map34(optionToUndefined51));
103540
+ var maxResults = integer7("max-results").pipe(optional5, map34(optionToUndefined51));
103541
+ var maxNodesPerResult = integer7("max-nodes").pipe(optional5, map34(optionToUndefined51));
103542
+ var groupBy2 = choice5("group-by", ["none", "parent", "date"]).pipe(optional5, map34(optionToUndefined51));
103193
103543
  var topicSummaryCommand = exports_Command.make("summary", { keywords, query: query2, timeRange: timeRange3, maxResults, maxNodesPerResult, groupBy: groupBy2 }, ({ keywords: keywords2, query: query3, timeRange: timeRange4, maxResults: maxResults2, maxNodesPerResult: maxNodesPerResult2, groupBy: groupBy3 }) => gen2(function* () {
103194
103544
  const cfg = yield* AppConfig;
103195
103545
  const keywordList = keywords2 ? keywords2.split(",").map((s) => s.trim()).filter(Boolean) : undefined;
@@ -103241,8 +103591,8 @@ function looksLikeRef(raw4) {
103241
103591
  var writePortalCreateCommand = exports_Command.make("create", {
103242
103592
  parent: text9("parent"),
103243
103593
  target: text9("target"),
103244
- position: integer7("position").pipe(optional5, map34(optionToUndefined36)),
103245
- clientTempId: text9("client-temp-id").pipe(optional5, map34(optionToUndefined36)),
103594
+ position: integer7("position").pipe(optional5, map34(optionToUndefined37)),
103595
+ clientTempId: text9("client-temp-id").pipe(optional5, map34(optionToUndefined37)),
103246
103596
  notify: writeCommonOptions.notify,
103247
103597
  ensureDaemon: writeCommonOptions.ensureDaemon,
103248
103598
  wait: writeCommonOptions.wait,
@@ -103552,16 +103902,19 @@ var stackStopCommand = exports_Command.make("stop", {}, () => gen2(function* ()
103552
103902
  var stackCommand = exports_Command.make("stack", {}).pipe(exports_Command.withSubcommands([stackEnsureCommand, stackStopCommand, stackStatusCommand]));
103553
103903
 
103554
103904
  // src/commands/index.ts
103555
- function optionToUndefined51(opt) {
103905
+ function optionToUndefined52(opt) {
103556
103906
  return isSome2(opt) ? opt.value : undefined;
103557
103907
  }
103558
- var remnoteDb = text9("remnote-db").pipe(optional5, map34(optionToUndefined51));
103559
- var storeDb = text9("store-db").pipe(optional5, map34(optionToUndefined51));
103560
- var daemonUrl = text9("daemon-url").pipe(optional5, map34(optionToUndefined51));
103561
- var wsPort = integer7("ws-port").pipe(optional5, map34(optionToUndefined51));
103562
- var repo = text9("repo").pipe(optional5, map34(optionToUndefined51));
103563
- var apiBaseUrl = text9("api-base-url").pipe(optional5, map34(optionToUndefined51));
103564
- var configFile = text9("config-file").pipe(optional5, map34(optionToUndefined51));
103908
+ var remnoteDb = text9("remnote-db").pipe(optional5, map34(optionToUndefined52));
103909
+ var storeDb = text9("store-db").pipe(optional5, map34(optionToUndefined52));
103910
+ var daemonUrl = text9("daemon-url").pipe(optional5, map34(optionToUndefined52));
103911
+ var wsPort = integer7("ws-port").pipe(optional5, map34(optionToUndefined52));
103912
+ var repo = text9("repo").pipe(optional5, map34(optionToUndefined52));
103913
+ var apiBaseUrl = text9("api-base-url").pipe(optional5, map34(optionToUndefined52));
103914
+ var apiHost = text9("api-host").pipe(optional5, map34(optionToUndefined52));
103915
+ var apiPort = integer7("api-port").pipe(optional5, map34(optionToUndefined52));
103916
+ var apiBasePath = text9("api-base-path").pipe(optional5, map34(optionToUndefined52));
103917
+ var configFile = text9("config-file").pipe(optional5, map34(optionToUndefined52));
103565
103918
  var appConfigLive = effect(AppConfig, resolveConfig());
103566
103919
  var statusLineUpdaterLive = StatusLineUpdaterLive.pipe(provide3([appConfigLive, QueueLive, StatusLineFileLive, TmuxLive, WsBridgeStateLive]));
103567
103920
  var statusLineLive = StatusLineControllerLive.pipe(provide3(statusLineUpdaterLive), provide3(appConfigLive));
@@ -103578,6 +103931,9 @@ var rootCommand = exports_Command.make("agent-remnote", {
103578
103931
  wsPort,
103579
103932
  repo,
103580
103933
  apiBaseUrl,
103934
+ apiHost,
103935
+ apiPort,
103936
+ apiBasePath,
103581
103937
  configFile
103582
103938
  }).pipe(exports_Command.withSubcommands([
103583
103939
  daemonCommand,
@@ -103789,6 +104145,9 @@ var ROOT_VALUE_FLAGS2 = new Set([
103789
104145
  "--ws-port",
103790
104146
  "--repo",
103791
104147
  "--api-base-url",
104148
+ "--api-host",
104149
+ "--api-port",
104150
+ "--api-base-path",
103792
104151
  "--config-file",
103793
104152
  ...BUILTIN_VALUE_FLAGS2
103794
104153
  ]);
@@ -103823,7 +104182,7 @@ function parseRootConfigFromArgv(argv2) {
103823
104182
  continue;
103824
104183
  }
103825
104184
  if (ROOT_VALUE_FLAGS2.has(flag)) {
103826
- const key = flag === "--remnote-db" ? "remnoteDb" : flag === "--store-db" ? "storeDb" : flag === "--daemon-url" ? "daemonUrl" : flag === "--ws-port" ? "wsPort" : flag === "--repo" ? "repo" : flag === "--api-base-url" ? "apiBaseUrl" : flag === "--config-file" ? "configFile" : null;
104185
+ const key = flag === "--remnote-db" ? "remnoteDb" : flag === "--store-db" ? "storeDb" : flag === "--daemon-url" ? "daemonUrl" : flag === "--ws-port" ? "wsPort" : flag === "--repo" ? "repo" : flag === "--api-base-url" ? "apiBaseUrl" : flag === "--api-host" ? "apiHost" : flag === "--api-port" ? "apiPort" : flag === "--api-base-path" ? "apiBasePath" : flag === "--config-file" ? "configFile" : null;
103827
104186
  if (inlineValue !== null) {
103828
104187
  if (key)
103829
104188
  out.set(key, inlineValue);