@stll/folio-cli 0.5.2 → 0.5.4

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.
@@ -2,7 +2,7 @@ import { FolioCliError } from "./errors.js";
2
2
  import { Result } from "better-result";
3
3
  //#region src/main-document-part.d.ts
4
4
  /** Why a file is not a readable WordprocessingML package. */
5
- declare const INVALID_PACKAGE_REASONS: {
5
+ export declare const INVALID_PACKAGE_REASONS: {
6
6
  readonly notZip: "notZip";
7
7
  readonly duplicatePartName: "duplicatePartName";
8
8
  readonly contentTypesMissing: "contentTypesMissing";
@@ -16,11 +16,10 @@ declare const INVALID_PACKAGE_REASONS: {
16
16
  readonly mainPartRoot: "mainPartRoot";
17
17
  readonly mainPartLocation: "mainPartLocation";
18
18
  };
19
- type InvalidPackageReason = (typeof INVALID_PACKAGE_REASONS)[keyof typeof INVALID_PACKAGE_REASONS];
19
+ export type InvalidPackageReason = (typeof INVALID_PACKAGE_REASONS)[keyof typeof INVALID_PACKAGE_REASONS];
20
20
  /**
21
21
  * Refuse, as `invalid_document`, a file that is not a WordprocessingML
22
22
  * package with a main document part folio reads.
23
23
  */
24
- declare const checkWordprocessingPackage: (filePath: string, bytes: Uint8Array) => Promise<Result<void, FolioCliError>>;
25
- //#endregion
26
- export { INVALID_PACKAGE_REASONS, InvalidPackageReason, checkWordprocessingPackage };
24
+ export declare const checkWordprocessingPackage: (filePath: string, bytes: Uint8Array) => Promise<Result<void, FolioCliError>>;
25
+ //#endregion
@@ -39,9 +39,9 @@ const MAIN_DOCUMENT_CONTENT_TYPES = /* @__PURE__ */ new Set([
39
39
  "application/vnd.ms-word.template.macroEnabledTemplate.main+xml"
40
40
  ]);
41
41
  /** `[Content_Types].xml` and `_rels/.rels` are indexes; this bounds their inflation. */
42
- const MAX_PACKAGE_INDEX_BYTES = 1024 * 1024;
42
+ const MAX_PACKAGE_INDEX_BYTES = 1048576;
43
43
  /** How much of the main part is inflated to find its root element. */
44
- const MAX_ROOT_SCAN_BYTES = 64 * 1024;
44
+ const MAX_ROOT_SCAN_BYTES = 65536;
45
45
  /** Why a file is not a readable WordprocessingML package. */
46
46
  const INVALID_PACKAGE_REASONS = {
47
47
  notZip: "notZip",
@@ -1,13 +1,13 @@
1
1
  import { ToolCallResult, ToolError, ToolInputIssue, ToolOutcome } from "./types.js";
2
2
  //#region src/mcp-kit/envelope.d.ts
3
3
  /** Error codes the surface itself answers with; a tool adds its own. */
4
- declare const KIT_ERROR_CODES: {
4
+ export declare const KIT_ERROR_CODES: {
5
5
  readonly validation: "validation_error";
6
6
  readonly unknownTool: "unknown_tool";
7
7
  readonly notFound: "not_found";
8
8
  readonly internal: "internal_error";
9
9
  };
10
- declare const toolError: (error: {
10
+ export declare const toolError: (error: {
11
11
  code: string;
12
12
  message: string;
13
13
  hint?: string | undefined;
@@ -15,13 +15,12 @@ declare const toolError: (error: {
15
15
  issues?: readonly ToolInputIssue[] | undefined;
16
16
  details?: unknown;
17
17
  }) => ToolError;
18
- declare const failure: (error: Parameters<typeof toolError>[0]) => ToolOutcome;
19
- declare const success: (value: unknown) => ToolOutcome;
20
- declare const validationError: (message: string, issues: readonly ToolInputIssue[], hint?: string) => ToolOutcome;
18
+ export declare const failure: (error: Parameters<typeof toolError>[0]) => ToolOutcome;
19
+ export declare const success: (value: unknown) => ToolOutcome;
20
+ export declare const validationError: (message: string, issues: readonly ToolInputIssue[], hint?: string) => ToolOutcome;
21
21
  /** Encode an outcome as a `tools/call` result, with the input notes after a success. */
22
- declare const toCallResult: (outcome: ToolOutcome, notes?: readonly string[]) => ToolCallResult;
22
+ export declare const toCallResult: (outcome: ToolOutcome, notes?: readonly string[]) => ToolCallResult;
23
23
  /** Up to three known names close to `name`, closest first. */
24
- declare const closestNames: (name: string, known: readonly string[]) => string[];
25
- declare const didYouMean: (suggestions: readonly string[]) => string;
26
- //#endregion
27
- export { KIT_ERROR_CODES, closestNames, didYouMean, failure, success, toCallResult, toolError, validationError };
24
+ export declare const closestNames: (name: string, known: readonly string[]) => string[];
25
+ export declare const didYouMean: (suggestions: readonly string[]) => string;
26
+ //#endregion
@@ -1,4 +1,11 @@
1
+ import { distance } from "@stll/fuzzy-search";
1
2
  //#region src/mcp-kit/envelope.ts
3
+ /**
4
+ * How answers go on the wire: a success is its JSON payload, a failure is
5
+ * `{ "error": { code, message, hint, retryable } }` with `isError` set, and
6
+ * any "read X as Y" notes from lenient input reading ride after the payload
7
+ * as their own text block, so the payload stays the tool's contract.
8
+ */
2
9
  /** Error codes the surface itself answers with; a tool adds its own. */
3
10
  const KIT_ERROR_CODES = {
4
11
  validation: "validation_error",
@@ -52,26 +59,14 @@ const toCallResult = (outcome, notes = []) => {
52
59
  isError: false
53
60
  };
54
61
  };
55
- const editDistance = (a, b) => {
56
- let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
57
- for (let i = 1; i <= a.length; i += 1) {
58
- const current = [i];
59
- for (let j = 1; j <= b.length; j += 1) {
60
- const substitution = (previous[j - 1] ?? 0) + (a[i - 1] === b[j - 1] ? 0 : 1);
61
- current[j] = Math.min((previous[j] ?? 0) + 1, (current[j - 1] ?? 0) + 1, substitution);
62
- }
63
- previous = current;
64
- }
65
- return previous[b.length] ?? 0;
66
- };
67
62
  /** Up to three known names close to `name`, closest first. */
68
63
  const closestNames = (name, known) => {
69
- const lowered = name.toLowerCase();
64
+ const lowered = name.toWellFormed().toLowerCase();
70
65
  return known.map((candidate) => {
71
- const lower = candidate.toLowerCase();
66
+ const lower = candidate.toWellFormed().toLowerCase();
72
67
  return {
73
68
  candidate,
74
- distance: lower.includes(lowered) || lowered.includes(lower) ? 0 : editDistance(lowered, lower)
69
+ distance: lower.includes(lowered) || lowered.includes(lower) ? 0 : distance(lowered, lower, "levenshtein")
75
70
  };
76
71
  }).filter(({ distance }) => distance <= Math.max(2, Math.floor(name.length / 3))).toSorted((a, b) => a.distance - b.distance || a.candidate.localeCompare(b.candidate)).slice(0, 3).map(({ candidate }) => candidate);
77
72
  };
@@ -1,6 +1,6 @@
1
1
  import { JsonSchema, ToolAccess, ToolInputIssue } from "./types.js";
2
2
  //#region src/mcp-kit/input.d.ts
3
- type ReadInput = {
3
+ export type ReadInput = {
4
4
  ok: true;
5
5
  value: Record<string, unknown>;
6
6
  notes: readonly string[];
@@ -18,6 +18,6 @@ type ReadInputOptions = {
18
18
  exactProperties?: readonly string[] | undefined;
19
19
  };
20
20
  /** Check and leniently read one call's arguments against the tool's schema. */
21
- declare const readToolInput: ({ schema, value, access, exactProperties }: ReadInputOptions) => ReadInput;
21
+ export declare const readToolInput: ({ schema, value, access, exactProperties }: ReadInputOptions) => ReadInput;
22
22
  //#endregion
23
- export { ReadInput, readToolInput };
23
+ export {};
@@ -1,20 +1,19 @@
1
1
  import { JsonSchema, ListedTool } from "./types.js";
2
2
  //#region src/mcp-kit/schema.d.ts
3
- type CompactSchemaOptions = {
3
+ export type CompactSchemaOptions = {
4
4
  /** Keep descriptions this many property levels deep; 0 (the default) keeps none. */
5
5
  describedDepth?: number;
6
6
  };
7
7
  /** The schema without annotation keywords, descriptions kept only as deep as asked. */
8
- declare const compactSchema: (schema: JsonSchema, { describedDepth }?: CompactSchemaOptions) => JsonSchema;
8
+ export declare const compactSchema: (schema: JsonSchema, { describedDepth }?: CompactSchemaOptions) => JsonSchema;
9
9
  /**
10
10
  * Hoist every object subschema that occurs more than once and serializes to
11
11
  * at least `minBytes` into `$defs`, referenced by `$ref`: a schema that
12
12
  * repeats one shape for several properties states it once.
13
13
  */
14
- declare const hoistRepeatedSchemas: (schema: JsonSchema, { minBytes }?: {
14
+ export declare const hoistRepeatedSchemas: (schema: JsonSchema, { minBytes }?: {
15
15
  minBytes?: number;
16
16
  }) => JsonSchema;
17
17
  /** The UTF-8 size of what `tools/list` sends for these tools. */
18
- declare const advertisedBytes: (tools: readonly ListedTool[]) => number;
19
- //#endregion
20
- export { CompactSchemaOptions, advertisedBytes, compactSchema, hoistRepeatedSchemas };
18
+ export declare const advertisedBytes: (tools: readonly ListedTool[]) => number;
19
+ //#endregion
@@ -1,19 +1,18 @@
1
1
  import { ListedTool, ToolCallResult, ToolDefinition } from "./types.js";
2
2
  //#region src/mcp-kit/surface.d.ts
3
- declare const CAPABILITY_TOOL_NAMES: {
3
+ export declare const CAPABILITY_TOOL_NAMES: {
4
4
  readonly list: "list_capabilities";
5
5
  readonly describe: "describe_capability";
6
6
  readonly invoke: "invoke_capability";
7
7
  };
8
- type ToolSurfaceOptions<Context> = {
8
+ export type ToolSurfaceOptions<Context> = {
9
9
  readonly tools: readonly ToolDefinition<Context>[];
10
10
  };
11
- type ToolSurface<Context> = {
11
+ export type ToolSurface<Context> = {
12
12
  /** What `tools/list` returns: the direct tools, then the capability tools. */
13
13
  readonly listTools: () => ListedTool[];
14
14
  readonly callTool: (name: string, args: unknown, context: Context) => Promise<ToolCallResult>;
15
15
  };
16
16
  /** Build a surface over `tools`. Names must be unique and not a capability tool's. */
17
- declare const createToolSurface: <Context>({ tools }: ToolSurfaceOptions<Context>) => ToolSurface<Context>;
18
- //#endregion
19
- export { CAPABILITY_TOOL_NAMES, ToolSurface, ToolSurfaceOptions, createToolSurface };
17
+ export declare const createToolSurface: <Context>({ tools }: ToolSurfaceOptions<Context>) => ToolSurface<Context>;
18
+ //#endregion
@@ -6,13 +6,13 @@
6
6
  * JSON payload or one error shape.
7
7
  */
8
8
  /** A JSON Schema object, as plain JSON. */
9
- type JsonSchema = {
9
+ export type JsonSchema = {
10
10
  readonly [keyword: string]: unknown;
11
11
  };
12
12
  /** Whether a call only reads or may change state. */
13
- type ToolAccess = "read" | "write";
13
+ export type ToolAccess = "read" | "write";
14
14
  /** One problem with one input value. */
15
- type ToolInputIssue = {
15
+ export type ToolInputIssue = {
16
16
  readonly path: string;
17
17
  readonly message: string;
18
18
  };
@@ -21,7 +21,7 @@ type ToolInputIssue = {
21
21
  * `hint` says what to do next, and `retryable` says whether the same call
22
22
  * can succeed once the caller has done it (re-read, waited).
23
23
  */
24
- type ToolError = {
24
+ export type ToolError = {
25
25
  readonly code: string;
26
26
  readonly message: string;
27
27
  readonly hint?: string;
@@ -29,14 +29,14 @@ type ToolError = {
29
29
  readonly issues?: readonly ToolInputIssue[];
30
30
  readonly details?: unknown;
31
31
  };
32
- type ToolOutcome = {
32
+ export type ToolOutcome = {
33
33
  readonly ok: true;
34
34
  readonly value: unknown;
35
35
  } | {
36
36
  readonly ok: false;
37
37
  readonly error: ToolError;
38
38
  };
39
- type ToolDefinition<Context> = {
39
+ export type ToolDefinition<Context> = {
40
40
  readonly name: string;
41
41
  /** One short sentence. A direct tool sends it on every turn, so every word costs. */
42
42
  readonly summary: string;
@@ -73,7 +73,7 @@ type ToolDefinition<Context> = {
73
73
  readonly run: (args: Record<string, unknown>, context: Context) => Promise<ToolOutcome>;
74
74
  };
75
75
  /** A tool as `tools/list` advertises it. */
76
- type ListedTool = {
76
+ export type ListedTool = {
77
77
  name: string;
78
78
  description: string;
79
79
  inputSchema: {
@@ -87,12 +87,11 @@ type ListedTool = {
87
87
  };
88
88
  };
89
89
  /** A `tools/call` answer: a JSON payload or `{ error }`, as text. */
90
- type ToolCallResult = {
90
+ export type ToolCallResult = {
91
91
  content: {
92
92
  type: "text";
93
93
  text: string;
94
94
  }[];
95
95
  isError: boolean;
96
96
  };
97
- //#endregion
98
- export { JsonSchema, ListedTool, ToolAccess, ToolCallResult, ToolDefinition, ToolError, ToolInputIssue, ToolOutcome };
97
+ //#endregion
package/dist/mcp.d.ts CHANGED
@@ -5,8 +5,8 @@ import { Readable, Writable } from "node:stream";
5
5
  import { Server, Tool } from "@modelcontextprotocol/server";
6
6
  //#region src/mcp.d.ts
7
7
  /** Limits on what one MCP tool call returns. */
8
- declare const MCP_READ_BOUNDS: FolioReadBounds;
9
- type FolioMcpServerOptions = {
8
+ export declare const MCP_READ_BOUNDS: FolioReadBounds;
9
+ export type FolioMcpServerOptions = {
10
10
  roots: AllowedRoots;
11
11
  /** Author for every change; `undefined` refuses writes with `author_required`. */
12
12
  author: string | undefined;
@@ -14,21 +14,21 @@ type FolioMcpServerOptions = {
14
14
  now?: () => Date;
15
15
  };
16
16
  /** The tool's full MCP input schema: its own arguments plus the file envelope. */
17
- declare const mcpInputSchema: (tool: FolioFileToolSpec) => JsonObjectSchema;
17
+ export declare const mcpInputSchema: (tool: FolioFileToolSpec) => JsonObjectSchema;
18
18
  /**
19
19
  * Blocks as lines, a table row on one line: `| [id] cell | [id] cell |`,
20
20
  * a cell's paragraphs side by side. Empty cells hold no block and show none.
21
21
  */
22
- declare const blockLines: (blocks: readonly unknown[]) => string;
22
+ export declare const blockLines: (blocks: readonly unknown[]) => string;
23
23
  /** What `tools/list` returns. */
24
- declare const listMcpTools: () => Tool[];
24
+ export declare const listMcpTools: () => Tool[];
25
25
  /** A low-level MCP server exposing the file tools; connect it to a transport. */
26
- declare const createFolioMcpServer: (options: FolioMcpServerOptions) => Server;
26
+ export declare const createFolioMcpServer: (options: FolioMcpServerOptions) => Server;
27
27
  type ServeOptions = FolioMcpServerOptions & {
28
28
  input: Readable;
29
29
  output: Writable;
30
30
  };
31
31
  /** Serve the file tools over stdio until the client disconnects. */
32
- declare const serveFolioMcp: ({ input, output, ...options }: ServeOptions) => Promise<void>;
32
+ export declare const serveFolioMcp: ({ input, output, ...options }: ServeOptions) => Promise<void>;
33
33
  //#endregion
34
- export { FolioMcpServerOptions, MCP_READ_BOUNDS, blockLines, createFolioMcpServer, listMcpTools, mcpInputSchema, serveFolioMcp };
34
+ export {};
package/dist/mcp.js CHANGED
@@ -10,9 +10,9 @@ import { checkWithinRoots } from "./roots.js";
10
10
  import { Result, panic } from "better-result";
11
11
  import { SUGGEST_CHANGES_OPERATION_TYPES, describeSuggestChangesCapabilities } from "@stll/folio-agents/tools";
12
12
  import { FOLIO_DOCUMENT_OPERATION_KEYS_BY_TYPE } from "@stll/folio-core/server";
13
- import { FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA } from "@stll/folio-agents/operation-schema";
14
13
  import { ProtocolError, ProtocolErrorCode, Server } from "@modelcontextprotocol/server";
15
14
  import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
15
+ import { FOLIO_DOCUMENT_OPERATION_BATCH_JSON_SCHEMA } from "@stll/folio-agents/operation-schema";
16
16
  //#region src/mcp.ts
17
17
  /**
18
18
  * `folio mcp`: the file tool registry as a Model Context Protocol server over
@@ -32,7 +32,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
32
32
  const MCP_READ_BOUNDS = {
33
33
  defaultMaxBlocks: 200,
34
34
  maxMatches: 100,
35
- maxResponseBytes: 256 * 1024
35
+ maxResponseBytes: 262144
36
36
  };
37
37
  const ABOUT_URI = "folio://about";
38
38
  const OPERATIONS_SCHEMA_URI = "folio://schema/operations";
@@ -521,7 +521,8 @@ const toOutcome = (options, result) => {
521
521
  });
522
522
  }
523
523
  const data = recordOf(result.value);
524
- return success("txId" in data ? compactWrite(options, data) : compactRead(options, data));
524
+ const wrote = "txId" in data;
525
+ return success(wrote ? compactWrite(options, data) : compactRead(options, data));
525
526
  };
526
527
  /** Fill in a main-story range's `type` and `story`, which find_text leaves out. */
527
528
  const withFullRanges = (operations) => Array.isArray(operations) ? operations.map((operation) => {
@@ -10,6 +10,6 @@ type WriteOutputOptions = {
10
10
  /** The document rendered, which the output must not replace. */
11
11
  input: FileIdentity;
12
12
  };
13
- declare const writeOutputFile: ({ target, bytes, overwrite, input }: WriteOutputOptions) => Promise<Result<string, FolioCliError>>;
13
+ export declare const writeOutputFile: ({ target, bytes, overwrite, input }: WriteOutputOptions) => Promise<Result<string, FolioCliError>>;
14
14
  //#endregion
15
- export { writeOutputFile };
15
+ export {};
package/dist/output.d.ts CHANGED
@@ -1,24 +1,24 @@
1
1
  import { FolioCliError, FolioCliErrorCode, PublicErrorDetails } from "./errors.js";
2
2
  //#region src/output.d.ts
3
- declare const OUTPUT_FORMATS: readonly ["json", "text"];
4
- type OutputFormat = (typeof OUTPUT_FORMATS)[number];
5
- declare const isOutputFormat: (value: unknown) => value is OutputFormat;
6
- type FailureBody = {
3
+ export declare const OUTPUT_FORMATS: readonly ["json", "text"];
4
+ export type OutputFormat = (typeof OUTPUT_FORMATS)[number];
5
+ export declare const isOutputFormat: (value: unknown) => value is OutputFormat;
6
+ export type FailureBody = {
7
7
  code: FolioCliErrorCode;
8
8
  message: string;
9
9
  hint?: string;
10
10
  details?: PublicErrorDetails;
11
11
  };
12
- type Envelope = {
12
+ export type Envelope = {
13
13
  ok: true;
14
14
  data: unknown;
15
15
  } | {
16
16
  ok: false;
17
17
  error: FailureBody;
18
18
  };
19
- declare const successEnvelope: (data: unknown) => Envelope;
20
- declare const failureEnvelope: ({ code, message, hint, details }: FolioCliError) => Envelope;
21
- type RenderedOutput = {
19
+ export declare const successEnvelope: (data: unknown) => Envelope;
20
+ export declare const failureEnvelope: ({ code, message, hint, details }: FolioCliError) => Envelope;
21
+ export type RenderedOutput = {
22
22
  stdout: string;
23
23
  stderr: string;
24
24
  };
@@ -28,6 +28,6 @@ type RenderEnvelopeOptions = {
28
28
  /** The tool that produced the data, for its text rendering. */
29
29
  tool: string;
30
30
  };
31
- declare const renderEnvelope: ({ envelope, format, tool }: RenderEnvelopeOptions) => RenderedOutput;
31
+ export declare const renderEnvelope: ({ envelope, format, tool }: RenderEnvelopeOptions) => RenderedOutput;
32
32
  //#endregion
33
- export { Envelope, FailureBody, OUTPUT_FORMATS, OutputFormat, RenderedOutput, failureEnvelope, isOutputFormat, renderEnvelope, successEnvelope };
33
+ export {};
@@ -1,18 +1,18 @@
1
1
  import { FolioCliError } from "./errors.js";
2
2
  import { Result } from "better-result";
3
3
  //#region src/package-parts.d.ts
4
- type PartChange = "added" | "modified" | "removed";
5
- type ChangedPart = {
4
+ export type PartChange = "added" | "modified" | "removed";
5
+ export type ChangedPart = {
6
6
  part: string;
7
7
  change: PartChange;
8
8
  };
9
9
  /** Parts added, removed, or whose uncompressed content differs, sorted by name. */
10
- declare const diffPackages: (before: Uint8Array, after: Uint8Array) => Promise<Result<ChangedPart[], FolioCliError>>;
10
+ export declare const diffPackages: (before: Uint8Array, after: Uint8Array) => Promise<Result<ChangedPart[], FolioCliError>>;
11
11
  /**
12
12
  * The first revision id above every WordprocessingML `id` attribute in the
13
13
  * package, so new revisions never collide with an existing one.
14
14
  */
15
- declare const nextRevisionIdSeed: (bytes: Uint8Array) => Promise<Result<number, FolioCliError>>;
15
+ export declare const nextRevisionIdSeed: (bytes: Uint8Array) => Promise<Result<number, FolioCliError>>;
16
16
  /**
17
17
  * Check what a save wrote before it replaces anything: the package opens,
18
18
  * every changed XML part is well formed, every relationship id a changed
@@ -20,6 +20,5 @@ declare const nextRevisionIdSeed: (bytes: Uint8Array) => Promise<Result<number,
20
20
  * names exists, the package still has the main document part folio reads,
21
21
  * and it parses as a document again.
22
22
  */
23
- declare const checkPackageIntegrity: (bytes: Uint8Array<ArrayBuffer>, changedParts: readonly ChangedPart[]) => Promise<Result<void, FolioCliError>>;
24
- //#endregion
25
- export { ChangedPart, PartChange, checkPackageIntegrity, diffPackages, nextRevisionIdSeed };
23
+ export declare const checkPackageIntegrity: (bytes: Uint8Array<ArrayBuffer>, changedParts: readonly ChangedPart[]) => Promise<Result<void, FolioCliError>>;
24
+ //#endregion
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.5.2";
2
+ var version = "0.5.4";
3
3
  //#endregion
4
4
  export { version };
@@ -1,8 +1,7 @@
1
1
  import { FolioCliIo } from "./cli.js";
2
2
  //#region src/preview-commands.d.ts
3
- declare const RENDER_HELP: string;
4
- declare const runRender: (rest: readonly string[], io: FolioCliIo) => Promise<number>;
5
- declare const SERVE_HELP: string;
6
- declare const runServe: (rest: readonly string[], io: FolioCliIo) => Promise<number>;
7
- //#endregion
8
- export { RENDER_HELP, SERVE_HELP, runRender, runServe };
3
+ export declare const RENDER_HELP: string;
4
+ export declare const runRender: (rest: readonly string[], io: FolioCliIo) => Promise<number>;
5
+ export declare const SERVE_HELP: string;
6
+ export declare const runServe: (rest: readonly string[], io: FolioCliIo) => Promise<number>;
7
+ //#endregion
@@ -20,8 +20,9 @@ const usageError = (message, hint) => cliError({
20
20
  hint
21
21
  });
22
22
  const emit = (io, format, result) => {
23
+ const envelope = result.isOk() ? successEnvelope(result.value) : failureEnvelope(result.error);
23
24
  const rendered = renderEnvelope({
24
- envelope: result.isOk() ? successEnvelope(result.value) : failureEnvelope(result.error),
25
+ envelope,
25
26
  format,
26
27
  tool: "render"
27
28
  });
@@ -1,7 +1,7 @@
1
1
  import { FolioCliError } from "./errors.js";
2
2
  import { Result } from "better-result";
3
3
  //#region src/provenance.d.ts
4
- declare const AUTHOR_ENV = "FOLIO_AUTHOR";
4
+ export declare const AUTHOR_ENV = "FOLIO_AUTHOR";
5
5
  type ResolveAuthorOptions = {
6
6
  /** `--author`, or the MCP server's configured author. */
7
7
  explicit: string | undefined;
@@ -10,8 +10,8 @@ type ResolveAuthorOptions = {
10
10
  cwd: string;
11
11
  };
12
12
  /** `--author`, then `FOLIO_AUTHOR`, then git `user.name`; refuses when none is set. */
13
- declare const resolveAuthor: ({ explicit, env, cwd }: ResolveAuthorOptions) => Result<string, FolioCliError>;
13
+ export declare const resolveAuthor: ({ explicit, env, cwd }: ResolveAuthorOptions) => Result<string, FolioCliError>;
14
14
  /** The transaction timestamp: `--date` when given (for reproducible output), else now. */
15
- declare const resolveTransactionDate: (explicit: string | undefined, now?: () => Date) => Result<string, FolioCliError>;
15
+ export declare const resolveTransactionDate: (explicit: string | undefined, now?: () => Date) => Result<string, FolioCliError>;
16
16
  //#endregion
17
- export { AUTHOR_ENV, resolveAuthor, resolveTransactionDate };
17
+ export {};
@@ -1,18 +1,18 @@
1
1
  import { FolioAgentToolName } from "@stll/folio-agents/types";
2
2
  //#region src/registry.d.ts
3
- type JsonObjectSchema = {
3
+ export type JsonObjectSchema = {
4
4
  readonly type: "object";
5
5
  readonly properties: Readonly<Record<string, unknown>>;
6
6
  readonly required: readonly string[];
7
7
  readonly additionalProperties: false;
8
8
  };
9
9
  /** A positional argument after `<file>` that sets one tool argument. */
10
- type FolioPositionalSpec = {
10
+ export type FolioPositionalSpec = {
11
11
  readonly name: string;
12
12
  readonly property: string;
13
13
  };
14
14
  /** One `folio <name>` command. */
15
- type FolioCommandSpec = {
15
+ export type FolioCommandSpec = {
16
16
  readonly name: string;
17
17
  readonly summary: string;
18
18
  /** Arguments the command implies (`accept` sets `action: "accept"`). */
@@ -37,7 +37,7 @@ type FolioToolSpecBase = {
37
37
  * accepts or rejects tracked changes; `compare` diffs two files and, given a
38
38
  * destination, writes a redline.
39
39
  */
40
- type FolioFileToolSpec = (FolioToolSpecBase & {
40
+ export type FolioFileToolSpec = (FolioToolSpecBase & {
41
41
  readonly type: "agentRead";
42
42
  readonly agentTool: FolioAgentToolName;
43
43
  }) | (FolioToolSpecBase & {
@@ -51,19 +51,19 @@ type FolioFileToolSpec = (FolioToolSpecBase & {
51
51
  readonly type: "compare";
52
52
  });
53
53
  /** Whether a tool call may write, which decides its envelope and flags. */
54
- type FolioToolAccess = "read" | "write" | "readOrWrite";
55
- declare const toolAccess: (tool: FolioFileToolSpec) => FolioToolAccess;
54
+ export type FolioToolAccess = "read" | "write" | "readOrWrite";
55
+ export declare const toolAccess: (tool: FolioFileToolSpec) => FolioToolAccess;
56
56
  /** Largest page `read_document` returns on any surface. */
57
- declare const MAX_READ_BLOCKS = 1000;
58
- declare const RESOLVE_CHANGE_ACTIONS: readonly ["accept", "reject"];
59
- type ResolveChangeAction = (typeof RESOLVE_CHANGE_ACTIONS)[number];
60
- declare const FOLIO_FILE_TOOLS: readonly FolioFileToolSpec[];
61
- declare const findFileTool: (name: string) => FolioFileToolSpec | undefined;
62
- type FolioResolvedCommand = {
57
+ export declare const MAX_READ_BLOCKS = 1000;
58
+ export declare const RESOLVE_CHANGE_ACTIONS: readonly ["accept", "reject"];
59
+ export type ResolveChangeAction = (typeof RESOLVE_CHANGE_ACTIONS)[number];
60
+ export declare const FOLIO_FILE_TOOLS: readonly FolioFileToolSpec[];
61
+ export declare const findFileTool: (name: string) => FolioFileToolSpec | undefined;
62
+ export type FolioResolvedCommand = {
63
63
  tool: FolioFileToolSpec;
64
64
  command: FolioCommandSpec;
65
65
  };
66
- declare const findCommand: (name: string) => FolioResolvedCommand | undefined;
67
- declare const listCommands: () => readonly FolioResolvedCommand[];
66
+ export declare const findCommand: (name: string) => FolioResolvedCommand | undefined;
67
+ export declare const listCommands: () => readonly FolioResolvedCommand[];
68
68
  //#endregion
69
- export { FOLIO_FILE_TOOLS, FolioCommandSpec, FolioFileToolSpec, FolioPositionalSpec, FolioResolvedCommand, FolioToolAccess, JsonObjectSchema, MAX_READ_BLOCKS, RESOLVE_CHANGE_ACTIONS, ResolveChangeAction, findCommand, findFileTool, listCommands, toolAccess };
69
+ export {};
package/dist/render.d.ts CHANGED
@@ -4,32 +4,32 @@ import { Result } from "better-result";
4
4
  import { DisplayList } from "@stll/folio-core/display-list/types";
5
5
  import { FontsourceFaces } from "@stll/folio-core/fonts/fontsourceFaces";
6
6
  //#region src/render.d.ts
7
- declare const RENDER_FORMATS: readonly ["pdf", "png", "html"];
8
- type RenderFormat = (typeof RENDER_FORMATS)[number];
7
+ export declare const RENDER_FORMATS: readonly ["pdf", "png", "html"];
8
+ export type RenderFormat = (typeof RENDER_FORMATS)[number];
9
9
  /** The CLI's `@fontsource` faces, shared by every render in the process. */
10
- declare const cliFontFaces: () => FontsourceFaces;
10
+ export declare const cliFontFaces: () => FontsourceFaces;
11
11
  /** The document's display list, measured with the CLI's faces. */
12
- declare const buildDisplayList: (file: LoadedFile) => Promise<Result<DisplayList, FolioCliError>>;
12
+ export declare const buildDisplayList: (file: LoadedFile) => Promise<Result<DisplayList, FolioCliError>>;
13
13
  /** Refuse page numbers the document does not have; `undefined` keeps every page. */
14
- declare const checkPages: (list: DisplayList, pages: readonly number[] | undefined) => Result<DisplayList, FolioCliError>;
14
+ export declare const checkPages: (list: DisplayList, pages: readonly number[] | undefined) => Result<DisplayList, FolioCliError>;
15
15
  /** Standalone HTML for the list, with its faces inlined. */
16
- declare const displayListHtml: (list: DisplayList, title: string) => string;
16
+ export declare const displayListHtml: (list: DisplayList, title: string) => string;
17
17
  type RenderPdfOptions = {
18
18
  file: LoadedFile;
19
19
  pages: readonly number[] | undefined;
20
20
  timestamp: string;
21
21
  };
22
- type RenderedOutput = {
22
+ export type RenderedOutput = {
23
23
  bytes: Uint8Array;
24
24
  pageCount: number;
25
25
  };
26
- declare const renderPdf: ({ file, pages, timestamp }: RenderPdfOptions) => Promise<Result<RenderedOutput, FolioCliError>>;
26
+ export declare const renderPdf: ({ file, pages, timestamp }: RenderPdfOptions) => Promise<Result<RenderedOutput, FolioCliError>>;
27
27
  type RenderPngOptions = {
28
28
  file: LoadedFile;
29
29
  page: number;
30
30
  scale: number;
31
31
  };
32
32
  /** One page as a PNG: the DOM backend's page, screenshotted in headless Chromium. */
33
- declare const renderPng: ({ file, page, scale }: RenderPngOptions) => Promise<Result<RenderedOutput, FolioCliError>>;
33
+ export declare const renderPng: ({ file, page, scale }: RenderPngOptions) => Promise<Result<RenderedOutput, FolioCliError>>;
34
34
  //#endregion
35
- export { RENDER_FORMATS, RenderFormat, RenderedOutput, buildDisplayList, checkPages, cliFontFaces, displayListHtml, renderPdf, renderPng };
35
+ export {};
package/dist/render.js CHANGED
@@ -3,8 +3,8 @@ import { createRequire } from "node:module";
3
3
  import { Result } from "better-result";
4
4
  import { existsSync, readFileSync } from "node:fs";
5
5
  import path from "node:path";
6
- import { selectDisplayPages } from "@stll/folio-core/display-list/selectDisplayPages";
7
6
  import { renderDisplayListToHtml } from "@stll/folio-core/display-list/html/renderDisplayListToHtml";
7
+ import { selectDisplayPages } from "@stll/folio-core/display-list/selectDisplayPages";
8
8
  import { buildDocxDisplayList, writeDisplayListPdf } from "@stll/folio-core/export-pdf";
9
9
  import { createFontsourceFaces } from "@stll/folio-core/fonts/fontsourceFaces";
10
10
  //#region src/render.ts
package/dist/roots.d.ts CHANGED
@@ -2,9 +2,9 @@ import { FolioCliError } from "./errors.js";
2
2
  import { Result } from "better-result";
3
3
  //#region src/roots.d.ts
4
4
  /** Real paths of the allowed root directories. */
5
- type AllowedRoots = readonly string[];
5
+ export type AllowedRoots = readonly string[];
6
6
  /** Resolve each root to its real path; every root must be an existing directory. */
7
- declare const resolveRoots: (roots: readonly string[]) => Promise<Result<AllowedRoots, FolioCliError>>;
7
+ export declare const resolveRoots: (roots: readonly string[]) => Promise<Result<AllowedRoots, FolioCliError>>;
8
8
  type CheckWithinRootsOptions = {
9
9
  roots: AllowedRoots;
10
10
  /** As the caller passed it; a relative path resolves against the first root. */
@@ -16,6 +16,6 @@ type CheckWithinRootsOptions = {
16
16
  * Refuse a path outside every allowed root, returning the resolved path the
17
17
  * call should use.
18
18
  */
19
- declare const checkWithinRoots: ({ roots, target, argument }: CheckWithinRootsOptions) => Promise<Result<string, FolioCliError>>;
19
+ export declare const checkWithinRoots: ({ roots, target, argument }: CheckWithinRootsOptions) => Promise<Result<string, FolioCliError>>;
20
20
  //#endregion
21
- export { AllowedRoots, checkWithinRoots, resolveRoots };
21
+ export {};
package/dist/save.d.ts CHANGED
@@ -5,9 +5,9 @@ import "./execute-write.js";
5
5
  import { Result } from "better-result";
6
6
  //#region src/save.d.ts
7
7
  /** How the editor produced the bytes, as it reports it. */
8
- declare const EDITOR_SAVE_STRATEGIES: readonly ["selective", "full-repack", "unspecified"];
9
- type EditorSaveStrategy = (typeof EDITOR_SAVE_STRATEGIES)[number];
10
- type SaveDocumentOptions = {
8
+ export declare const EDITOR_SAVE_STRATEGIES: readonly ["selective", "full-repack", "unspecified"];
9
+ export type EditorSaveStrategy = (typeof EDITOR_SAVE_STRATEGIES)[number];
10
+ export type SaveDocumentOptions = {
11
11
  /** The document the editor opened. */
12
12
  path: string;
13
13
  /** The whole package the editor serialized. */
@@ -39,10 +39,9 @@ type SaveDocumentOptions = {
39
39
  * `expectedVersion`, a lease another live holder keeps, bytes that do not
40
40
  * open as a document, and anything over 64 MiB, writing nothing.
41
41
  */
42
- declare const saveDocumentBytes: (options: SaveDocumentOptions) => Promise<Result<Readonly<Record<string, unknown>>, FolioCliError>>;
43
- declare const SAVE_HELP: string;
42
+ export declare const saveDocumentBytes: (options: SaveDocumentOptions) => Promise<Result<Readonly<Record<string, unknown>>, FolioCliError>>;
43
+ export declare const SAVE_HELP: string;
44
44
  /** `--flush-wait <ms>`: a whole number of milliseconds from 0. */
45
- declare const parseFlushWait: (value: string | undefined) => Result<number | undefined, FolioCliError>;
46
- declare const runSave: (rest: readonly string[], io: FolioCliIo) => Promise<number>;
47
- //#endregion
48
- export { EDITOR_SAVE_STRATEGIES, EditorSaveStrategy, SAVE_HELP, SaveDocumentOptions, parseFlushWait, runSave, saveDocumentBytes };
45
+ export declare const parseFlushWait: (value: string | undefined) => Result<number | undefined, FolioCliError>;
46
+ export declare const runSave: (rest: readonly string[], io: FolioCliIo) => Promise<number>;
47
+ //#endregion