@bettercms-ai/convert 0.10.0 → 0.12.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/index.d.ts CHANGED
@@ -197,6 +197,83 @@ declare function locate(brief: BriefLike, sources: SourceFile[], options?: Locat
197
197
  unlocated: UnlocatedPath[];
198
198
  };
199
199
 
200
+ /**
201
+ * What to DO about a path this run could not bind — an instruction, never a category name.
202
+ *
203
+ * 🔴 A REASON IS A DIAGNOSIS AND AN AGENT CANNOT ACT ON ONE. `IN_EXPRESSION` tells a coding agent
204
+ * that something, somewhere, is an expression; it does not say which file, which line, or what to
205
+ * type. So every pending row leaves with a `fix`: one file, one line, the bytes that are there
206
+ * now, and the one edit that makes the path bindable on the next run. The closed `action` set is
207
+ * the contract the server validates (`src/lib/validation/schemas/conversion-receipt.ts`) and the
208
+ * loop `get_next_steps` reads — an unknown action is a 400, so it is minted in exactly one place.
209
+ */
210
+
211
+ /**
212
+ * The edits an agent can be asked for, and nothing else.
213
+ *
214
+ * `wrap-span` the value has no element of its own — wrap it in `<span data-bcms-field>`.
215
+ * `declare-attr` the element is there — add `data-bcms-field` to it at file:line.
216
+ * `declare-richtext` the container renders markup — bind it with the richtext helper.
217
+ * `bind-expression` the value is computed — replace the expression with the helper's read.
218
+ * `bind-data` the copy lives in a data file or a content entry — bind THAT field.
219
+ * `manual` none of the above is true, and `why` says what a human has to decide.
220
+ */
221
+ type FixAction = "wrap-span" | "declare-attr" | "bind-expression" | "declare-richtext" | "bind-data" | "manual";
222
+ /** One mechanical instruction, at one place in one file. @see FixAction */
223
+ interface PendingFix {
224
+ file: string;
225
+ /** 1-based. */
226
+ line: number;
227
+ /** 1-based, when the literal was found on the line. */
228
+ col?: number;
229
+ /** The bytes at `line`, trimmed — so the agent can see it is looking at the right place. */
230
+ snippet: string;
231
+ action: FixAction;
232
+ /** One sentence, present whenever the action alone does not say enough. */
233
+ why?: string;
234
+ }
235
+ /** Everything about one pending path a fix is derived from. Pure input; no filesystem. */
236
+ interface FixInput {
237
+ /** The copy the repository renders, flattened. Empty when the brief captured none. */
238
+ literal: string;
239
+ kind: string;
240
+ /** The richtext value IS the element's whole inline subtree. @see brief.ts */
241
+ inline?: true;
242
+ /** Files this path's copy was found in, best first. May be empty. */
243
+ candidates: string[];
244
+ /** Source, by path — only the files named in `candidates` need be present. */
245
+ contents: ReadonlyMap<string, string>;
246
+ /** How many ROUTES share this `(scope, path)` in the pending list. @see sharedChrome */
247
+ routes: number;
248
+ }
249
+ /**
250
+ * Where `literal` sits in `content` — tolerant of the two things every template does to copy.
251
+ *
252
+ * A template wraps its copy across lines and indents it, and it puts inline markup in the middle
253
+ * of it (`Read <strong>this</strong> now`). Both are invisible to a reader and fatal to
254
+ * `indexOf`, so the words are matched with whitespace OR a tag between them. Bounded at
255
+ * `MAX_WORDS`, because a paragraph's first dozen words identify it as well as all ninety do.
256
+ */
257
+ declare function findLiteral(content: string, literal: string): {
258
+ index: number;
259
+ length: number;
260
+ } | null;
261
+ /**
262
+ * The fix for one pending row. Always answers: a row without one is a row an agent cannot act on.
263
+ *
264
+ * The FILE is the row's own when it has one (the lane that refused named it), and otherwise the
265
+ * first candidate `locate` found — and when there is neither, the fix still names the route's page
266
+ * file with line 1, because "go and look here" beats "go and look".
267
+ */
268
+ declare function fixFor(row: PendingPath, input: FixInput): PendingFix;
269
+ /**
270
+ * How many ROUTES each `(scope, path)` is pending on — the shared-chrome tell. @see actionFor
271
+ *
272
+ * Counted over the whole pending list rather than per row: one nav label pending on twelve routes
273
+ * is one element, and the fix for every one of those rows is the same sentence about promotion.
274
+ */
275
+ declare function routeCounts(pending: readonly PendingPath[]): Map<string, number>;
276
+
200
277
  /**
201
278
  * What the conversion did, and — the half that matters — what it did not.
202
279
  *
@@ -209,6 +286,7 @@ declare function locate(brief: BriefLike, sources: SourceFile[], options?: Locat
209
286
  * sentence appears in three files" and "this field is bound" are different questions — and a path
210
287
  * is only `rewritten` when EVERY located occurrence of it was.
211
288
  */
289
+
212
290
  type PendingReason = "NO_ORIGINAL" | "NOT_IN_SOURCE" | "DIALECT_UNSUPPORTED" | "IN_EXPRESSION" | "IN_SCRIPT_OR_COMMENT" | "IN_DATA_FILE" | "AMBIGUOUS_LITERAL" | "KIND_MISMATCH" | "SUBSTRING_ONLY"
213
291
  /** An INLINE richtext value whose element holds a component, a `<slot>` or an expression. */
214
292
  | "SUBTREE_NOT_HTML" | "PROP_TARGET_NOT_FOUND" | "PROP_DRILLED_DEEP" | "REPEATER_FIXED_LENGTH"
@@ -231,6 +309,15 @@ interface PendingPath {
231
309
  line?: number;
232
310
  /** What to do about it, in prose — a recipe, not a diagnosis. @see message */
233
311
  hint?: string;
312
+ /**
313
+ * The EDIT that makes this path bindable on the next run — one file, one line, one action.
314
+ *
315
+ * 🔴 THE REASON IS A DIAGNOSIS AND NOBODY CAN ACT ON ONE. Every row carries this, because a
316
+ * conversion ends when nothing is pending and the only way an agent gets there is by being told
317
+ * what to type and where. OPTIONAL in the type so a receipt written by an older version of this
318
+ * package still parses; this package emits one for every row. @see fix.ts
319
+ */
320
+ fix?: PendingFix;
234
321
  }
235
322
  /**
236
323
  * One path that was already DECLARED before this run — and how honestly.
@@ -829,7 +916,7 @@ declare function attrsFor(path: string, kind: string, props?: AttrBinding[], sco
829
916
  declare function propsAttribute(props: AttrBinding[]): string;
830
917
 
831
918
  /** Bumped whenever the emitted source changes. `isKnownHelper` upgrades anything older. */
832
- declare const HELPER_VERSION = 6;
919
+ declare const HELPER_VERSION = 7;
833
920
  /** Where each dialect's helper lives. Null = this dialect reads nothing at build time. */
834
921
  declare const HELPER_PATH: Record<Dialect, string | null>;
835
922
  /** The directory the snapshots live in, at the repository root. */
@@ -1416,6 +1503,11 @@ declare function carryFor(options: {
1416
1503
  * an unexpected extra key is simply carried past. The shape is frozen; the reader is not brittle.
1417
1504
  */
1418
1505
  interface ComponentizePlanField {
1506
+ /**
1507
+ * Where an instance holds this leaf's copy (`h2_latest`, `group_webgl[0].a_webgl`) — allocated by the
1508
+ * server, which alone knows the dedupe suffixes and table keys. Absent from older plans.
1509
+ */
1510
+ overrideKey?: string;
1419
1511
  /** The leaf's key inside the group — `title`, `items[0].q`. */
1420
1512
  key?: string;
1421
1513
  /** The whole page path — `hero.title`. Derived from `groupKey` + `key` when absent. */
@@ -1559,6 +1651,15 @@ interface ComponentizeReceipt {
1559
1651
  sections: SectionsReceipt;
1560
1652
  /** The component slugs this run wrote a file for, sorted. */
1561
1653
  components: string[];
1654
+ /**
1655
+ * The file each of those components was written to — what lets the server record a component's source
1656
+ * (kind `section`) without anyone claiming it by hand. Additive: readers of `components` are unchanged.
1657
+ */
1658
+ componentFiles?: {
1659
+ slug: string;
1660
+ path: string;
1661
+ export: "default";
1662
+ }[];
1562
1663
  /**
1563
1664
  * Sections the SERVER already marked pending (`NO_GROUP_ROOT`, `ALREADY_COMPONENTIZED`, …).
1564
1665
  *
@@ -1706,4 +1807,4 @@ declare function convertSources(briefIn: Brief, sources: SourceFile[], options?:
1706
1807
  receipt: ConversionReceipt;
1707
1808
  }>;
1708
1809
 
1709
- export { ASTRO_LANE_PENDING, type AstNode, type AttrBinding, type Brief, type BriefForm, type BriefPage, type BriefPath, COMPONENT_DIR, CONTENT_DIR, type CanvasResult, type CanvasSource, type Carried, type ComponentizeOptions, type ComponentizePlan, type ComponentizePlanComponent, type ComponentizePlanField, type ComponentizePlanPage, type ComponentizePlanSection, type ComponentizeReceipt, type ConversionReceipt, ConvertError, type ConvertErrorCode, type ConvertOptions, DIALECT_RULES, type DataMember, type DataResult, type DeclaredPath, type Dialect, type DynamicBinding, FORM_SCRIPT, type FileDeclaration, type FindSitesResult, FormInvariantError, type FormPendingReason, type FormsReceipt, HELPER_PATH, HELPER_VERSION, type ImageResult, type ImageTarget, type ImportedFrom, type LlmFallback, type LocatedPath, type Node, PARSE_FILE, type ParsedFile, type ParserError, type PathLocator, type PendingForm, type PendingPath, type PendingReason, type PendingSection, type PlanFile, REGISTRY_MARKER, type ReceiptFile, ReceiptInvariantError, type ReceiptNote, type Rewrite, SECTIONS_LIB, SECTION_MARKER, SKIP_DIRS, SKIP_FILES, SOURCE_EXTENSIONS, SSR_DRAFT_RECIPE, STUB_CONTENT, SectionInvariantError, type SectionPendingReason, type SectionsReceipt, type Site, type SiteWhere, type SourceFile, type Splice, type TargetIdentity, type UnlocatedPath, type ValidationCode, ValidationError, type Xray, type XrayBucket, aliasesFrom, assertForms, assertReceipt, assertSections, assetCandidates, assetImport, attrsFor, bindDataLiterals, bindImages, briefDigest, canvasBridge, carryFor, componentizeSources, convertSources, convertedHere, coverageOf, declaringElements, dialectOf, exportedFunction, extendedConfigs, findSites, findSitesTolerant, flat, helperSource, importsIn, isDecorativeGlyph, isDynamicRoute, isKnownHelper, isSourceCandidate, locate, measureUnaddressable, overlapping, pageFilesFor, parseFile, propsAttribute, readBrief, readComponentizePlan, readDeclarations, readExpr, readPlan, relativeImport, resolveSpecifier, rewriteFile, routeOfFile, stripTags, unreadableConfigs, walkAst, wireForms };
1810
+ export { ASTRO_LANE_PENDING, type AstNode, type AttrBinding, type Brief, type BriefForm, type BriefPage, type BriefPath, COMPONENT_DIR, CONTENT_DIR, type CanvasResult, type CanvasSource, type Carried, type ComponentizeOptions, type ComponentizePlan, type ComponentizePlanComponent, type ComponentizePlanField, type ComponentizePlanPage, type ComponentizePlanSection, type ComponentizeReceipt, type ConversionReceipt, ConvertError, type ConvertErrorCode, type ConvertOptions, DIALECT_RULES, type DataMember, type DataResult, type DeclaredPath, type Dialect, type DynamicBinding, FORM_SCRIPT, type FileDeclaration, type FindSitesResult, type FixAction, FormInvariantError, type FormPendingReason, type FormsReceipt, HELPER_PATH, HELPER_VERSION, type ImageResult, type ImageTarget, type ImportedFrom, type LlmFallback, type LocatedPath, type Node, PARSE_FILE, type ParsedFile, type ParserError, type PathLocator, type PendingFix, type PendingForm, type PendingPath, type PendingReason, type PendingSection, type PlanFile, REGISTRY_MARKER, type ReceiptFile, ReceiptInvariantError, type ReceiptNote, type Rewrite, SECTIONS_LIB, SECTION_MARKER, SKIP_DIRS, SKIP_FILES, SOURCE_EXTENSIONS, SSR_DRAFT_RECIPE, STUB_CONTENT, SectionInvariantError, type SectionPendingReason, type SectionsReceipt, type Site, type SiteWhere, type SourceFile, type Splice, type TargetIdentity, type UnlocatedPath, type ValidationCode, ValidationError, type Xray, type XrayBucket, aliasesFrom, assertForms, assertReceipt, assertSections, assetCandidates, assetImport, attrsFor, bindDataLiterals, bindImages, briefDigest, canvasBridge, carryFor, componentizeSources, convertSources, convertedHere, coverageOf, declaringElements, dialectOf, exportedFunction, extendedConfigs, findLiteral, findSites, findSitesTolerant, fixFor, flat, helperSource, importsIn, isDecorativeGlyph, isDynamicRoute, isKnownHelper, isSourceCandidate, locate, measureUnaddressable, overlapping, pageFilesFor, parseFile, propsAttribute, readBrief, readComponentizePlan, readDeclarations, readExpr, readPlan, relativeImport, resolveSpecifier, rewriteFile, routeCounts, routeOfFile, stripTags, unreadableConfigs, walkAst, wireForms };