mainflow 0.32.0 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { B as parseRef, H as refExample, V as parseUntil, Y as stampMs, k as UNTIL_FORMS } from "./dist-IdbnCDqM.js";
3
- import { B as checkHubName, H as loadHub, J as TASK_FILE, Q as nodeStorage, S as readSession, V as HubError, X as nowMinute, Y as requireSlug, _ as untilState, at as findHubRoot, ct as DATA_DIR, d as retroReportFromReceiver, f as receiverFromEnv, g as initHub, l as migrateHub, lt as WriteError, p as RETRY_RULES, q as MAINLINE_FILE, u as retroReport, v as duplicateClaimLines, x as loadSessions, y as sessionBriefing, z as applyOperation } from "./host-CdB_vDY_.js";
3
+ import { B as checkHubName, H as loadHub, J as TASK_FILE, Q as nodeStorage, S as readSession, V as HubError, X as nowMinute, Y as requireSlug, _ as untilState, ct as findHubRoot, d as retroReportFromReceiver, dt as DATA_DIR, et as MAX_FILE_BYTES, f as receiverFromEnv, ft as WriteError, g as initHub, l as migrateHub, p as RETRY_RULES, q as MAINLINE_FILE, u as retroReport, v as duplicateClaimLines, x as loadSessions, y as sessionBriefing, z as applyOperation } from "./host-C7GKIjSc.js";
4
4
  import { t as listProgress } from "./progress-1BfPg2zN.js";
5
- import { C as syncSettings, D as syncPaths, S as hubName, _ as readRemote, a as remoteMode, b as ENV, c as planFetch, d as DaemonRunning, f as DaemonUnavailable, g as silentHint, h as readDaemon, i as queuedCount, l as planFlush, m as probeDaemon, n as hubWriter, o as fetchDenial, p as callDaemon, r as writtenLines, s as hookAnswer, t as CONFIRM_MS, u as startDaemon, v as ServerApi, w as SETTINGS_FILE, x as earlierToken, y as ServerError } from "./operation-CuWhNoIa.js";
5
+ import { C as hubName, O as syncPaths, S as earlierToken, T as SETTINGS_FILE, _ as readRemote, a as remoteMode, b as ServerError, c as planFetch, d as DaemonRunning, f as DaemonUnavailable, g as silentHint, h as readDaemon, i as queuedCount, l as planFlush, m as probeDaemon, n as hubWriter, o as fetchDenial, p as callDaemon, r as writtenLines, s as hookAnswer, t as CONFIRM_MS, u as startDaemon, v as oversizedFiles, w as syncSettings, x as ENV, y as ServerApi } from "./operation-C0dUHUHg.js";
6
6
  import { COMMAND_SPECS, OPTIONS } from "./facts.js";
7
7
  import { hookFallback, parsePayload, runHook } from "./hooks.js";
8
- import { c as watchHubGone, l as CLI_VERSION, r as launchUi, s as startUiInBackground } from "./launch-Bmzqx-TI.js";
8
+ import { c as watchHubGone, l as CLI_VERSION, r as launchUi, s as startUiInBackground } from "./launch-6839iAsc.js";
9
9
  import { randomBytes } from "node:crypto";
10
10
  import { existsSync, readFileSync, readdirSync, realpathSync, rmSync, statSync } from "node:fs";
11
11
  import { basename, isAbsolute, join, relative, resolve, sep } from "node:path";
@@ -916,8 +916,14 @@ const RUNS = {
916
916
  check: ({ root }) => {
917
917
  const hub = loadHub(root);
918
918
  const problems = [...hub.problems, ...loadSessions(root).problems];
919
- printProblems(hub.warnings, "!");
920
- if (problems.length === 0) return done(`✓ ${hub.mainlines.length} mainlines, no problems${hub.warnings.length ? `, ${hub.warnings.length} ${hub.warnings.length === 1 ? "warning" : "warnings"}` : ""}`);
919
+ const oversized = oversizedFiles(root).map(({ path, bytes }) => ({
920
+ file: `${DATA_DIR}/${path}`,
921
+ field: "",
922
+ message: `${bytes} bytes, more than the ${MAX_FILE_BYTES} the sync server keeps of a file, so mainflow sync leaves it out and other environments do not see it; split it, or add it to .mainflow/.gitignore`
923
+ }));
924
+ const warnings = [...hub.warnings, ...oversized];
925
+ printProblems(warnings, "!");
926
+ if (problems.length === 0) return done(`✓ ${hub.mainlines.length} mainlines, no problems${warnings.length ? `, ${warnings.length} ${warnings.length === 1 ? "warning" : "warnings"}` : ""}`);
921
927
  printProblems(problems);
922
928
  return 1;
923
929
  },
package/dist/hooks.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { $ as describeRequest, j as configSchema } from "./dist-IdbnCDqM.js";
2
- import { D as endsWithMarker, E as decorateReply, H as loadHub, O as headerLine, S as readSession, T as matchGrants, V as HubError, Z as readYaml, at as findHubRoot, b as turnReminder, ct as DATA_DIR, i as hostName, it as currentBranch, k as mayDecorate, ot as worktreesOf, w as grantScope, x as loadSessions, y as sessionBriefing } from "./host-CdB_vDY_.js";
3
- import { n as hubWriter, r as writtenLines } from "./operation-CuWhNoIa.js";
2
+ import { D as endsWithMarker, E as decorateReply, H as loadHub, O as headerLine, S as readSession, T as matchGrants, V as HubError, Z as readYaml, b as turnReminder, ct as findHubRoot, dt as DATA_DIR, i as hostName, k as mayDecorate, lt as worktreesOf, st as currentBranch, w as grantScope, x as loadSessions, y as sessionBriefing } from "./host-C7GKIjSc.js";
3
+ import { n as hubWriter, r as writtenLines } from "./operation-C0dUHUHg.js";
4
4
  import { resolveFixed, scanCommand, scopedCwd } from "./grant-commands.js";
5
5
  import { appendFileSync, existsSync, readFileSync } from "node:fs";
6
6
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
@@ -347,6 +347,28 @@ const ACCESS_HEADERS = {
347
347
  clientSecret: "CF-Access-Client-Secret"
348
348
  };
349
349
  /**
350
+ * The largest text the sync server keeps of one file, in UTF-8 bytes: a SQLite row of a Durable Object holds at most
351
+ * 2 MB, path and columns included. The server refuses a write or an upload that would hold a larger file; the sync client
352
+ * leaves such a file out of sync, on disk as it is, and `mainflow check` warns of it (docs/sync.md "同步哪些檔").
353
+ */
354
+ const MAX_FILE_BYTES = 19e5;
355
+ /** The length of `text` in UTF-8 bytes, as TextEncoder encodes it, a lone surrogate as U+FFFD; worked out without encoding it. */
356
+ function textBytes(text) {
357
+ let bytes = 0;
358
+ for (let i = 0; i < text.length; i++) {
359
+ const code = text.charCodeAt(i);
360
+ if (code < 128) bytes += 1;
361
+ else if (code < 2048) bytes += 2;
362
+ else if (code >= 55296 && code < 56320 && (text.charCodeAt(i + 1) & 64512) === 56320) {
363
+ bytes += 4;
364
+ i++;
365
+ } else bytes += 3;
366
+ }
367
+ return bytes;
368
+ }
369
+ /** Whether `text` is larger than the sync server keeps (MAX_FILE_BYTES); a short text is told apart without counting. */
370
+ const exceedsFileLimit = (text) => text.length * 3 > 19e5 && textBytes(text) > 19e5;
371
+ /**
350
372
  * The order of paths in a snapshot: by Unicode code point, which is the order of their UTF-8 bytes and so the order
351
373
  * SQLite gives TEXT. JavaScript compares strings by UTF-16 code unit, which differs only where a character beyond
352
374
  * U+FFFF meets one from U+E000 to U+FFFF.
@@ -7334,4 +7356,4 @@ function openInApp(hub, target, closeAfterMs = 150) {
7334
7356
  return true;
7335
7357
  }
7336
7358
  //#endregion
7337
- export { ACCESS_HEADERS as $, attributeTrace as A, checkHubName as B, transcriptPath as C, endsWithMarker as D, decorateReply as E, renumberFiles as F, linksInto as G, loadHub as H, renumberPath as I, TASK_FILE as J, refIndex as K, renumberText as L, transcriptTitle as M, applyOffline as N, headerLine as O, renumberRequest as P, nodeStorage as Q, scopeOfPath as R, readSession as S, matchGrants as T, dependencyGraph as U, HubError as V, mainlineEdges as W, nowMinute as X, requireSlug as Y, readYaml as Z, untilState as _, openInApp as a, findHubRoot as at, turnReminder as b, syncHost as c, DATA_DIR as ct, retroReportFromReceiver as d, splitFrontMatter as dt, ROUTES as et, receiverFromEnv as f, initHub as g, setArchivedMany as h, hostName as i, currentBranch as it, traceTranscript as j, mayDecorate as k, migrateHub as l, WriteError as lt, ARCHIVE_KINDS as m, DEFAULT_UI_PORT as n, comparePaths as nt, removeHostLink as o, worktreesOf as ot, RETRY_RULES as p, MAINLINE_FILE as q, caddySites as r, requestTime as rt, siteBlock as s, ConflictError as st, APP_BUNDLE_ID as t, SOCKET_MAX_AGE_CLOSE as tt, retroReport as u, contentHash as ut, duplicateClaimLines as v, grantScope as w, loadSessions as x, sessionBriefing as y, applyOperation as z };
7359
+ export { ACCESS_HEADERS as $, attributeTrace as A, checkHubName as B, transcriptPath as C, endsWithMarker as D, decorateReply as E, renumberFiles as F, linksInto as G, loadHub as H, renumberPath as I, TASK_FILE as J, refIndex as K, renumberText as L, transcriptTitle as M, applyOffline as N, headerLine as O, renumberRequest as P, nodeStorage as Q, scopeOfPath as R, readSession as S, matchGrants as T, dependencyGraph as U, HubError as V, mainlineEdges as W, nowMinute as X, requireSlug as Y, readYaml as Z, untilState as _, openInApp as a, requestTime as at, turnReminder as b, syncHost as c, findHubRoot as ct, retroReportFromReceiver as d, DATA_DIR as dt, MAX_FILE_BYTES as et, receiverFromEnv as f, WriteError as ft, initHub as g, setArchivedMany as h, hostName as i, exceedsFileLimit as it, traceTranscript as j, mayDecorate as k, migrateHub as l, worktreesOf as lt, ARCHIVE_KINDS as m, splitFrontMatter as mt, DEFAULT_UI_PORT as n, SOCKET_MAX_AGE_CLOSE as nt, removeHostLink as o, textBytes as ot, RETRY_RULES as p, contentHash as pt, MAINLINE_FILE as q, caddySites as r, comparePaths as rt, siteBlock as s, currentBranch as st, APP_BUNDLE_ID as t, ROUTES as tt, retroReport as u, ConflictError as ut, duplicateClaimLines as v, grantScope as w, loadSessions as x, sessionBriefing as y, applyOperation as z };
package/dist/host.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as openInApp, c as syncHost, i as hostName, n as DEFAULT_UI_PORT, o as removeHostLink, r as caddySites, s as siteBlock, t as APP_BUNDLE_ID } from "./host-CdB_vDY_.js";
1
+ import { a as openInApp, c as syncHost, i as hostName, n as DEFAULT_UI_PORT, o as removeHostLink, r as caddySites, s as siteBlock, t as APP_BUNDLE_ID } from "./host-C7GKIjSc.js";
2
2
  export { APP_BUNDLE_ID, DEFAULT_UI_PORT, caddySites, hostName, openInApp, removeHostLink, siteBlock, syncHost };
@@ -1,4 +1,4 @@
1
- import { c as syncHost, ct as DATA_DIR, i as hostName, lt as WriteError, n as DEFAULT_UI_PORT, o as removeHostLink } from "./host-CdB_vDY_.js";
1
+ import { c as syncHost, dt as DATA_DIR, ft as WriteError, i as hostName, n as DEFAULT_UI_PORT, o as removeHostLink } from "./host-C7GKIjSc.js";
2
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
  import { spawn, spawnSync } from "node:child_process";
@@ -176,7 +176,7 @@ async function launchUi(root, hub, configured, options) {
176
176
  }
177
177
  let server;
178
178
  if (!reuse) {
179
- const { serveUi } = await import("./ui-rwBrbIIF.js");
179
+ const { serveUi } = await import("./ui-Bx2wUBnA.js");
180
180
  server = await serveUi(root, choice.port);
181
181
  writeUiRecord(root, {
182
182
  port: choice.port,
package/dist/launch.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as portCandidates, c as watchHubGone, i as networkProbe, n as choosePort, o as readUiRecord, r as launchUi, s as startUiInBackground, t as PORT_SPAN } from "./launch-Bmzqx-TI.js";
1
+ import { a as portCandidates, c as watchHubGone, i as networkProbe, n as choosePort, o as readUiRecord, r as launchUi, s as startUiInBackground, t as PORT_SPAN } from "./launch-6839iAsc.js";
2
2
  export { PORT_SPAN, choosePort, launchUi, networkProbe, portCandidates, readUiRecord, startUiInBackground, watchHubGone };