@zenera/cli 1.1.19 → 1.1.20

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.
@@ -28,8 +28,8 @@ export declare const CHROME_ROWS = 7;
28
28
  */
29
29
  export declare const THINKING_ROWS = 1;
30
30
  /** How much of the frame the work in flight may take. A branch is a box now,
31
- * not a row, so a fan-out of two costs fourteen of these. */
32
- export declare const ACTIVITY_ROWS = 16;
31
+ * not a row, so a fan-out of two costs twenty-two of these. */
32
+ export declare const ACTIVITY_ROWS = 24;
33
33
  /** The width of the elapsed-time column every call row is drawn behind. */
34
34
  export declare const TIME_COL = 5;
35
35
  export interface Budget {
@@ -58,8 +58,18 @@ export interface Budget {
58
58
  * reasoning, none otherwise — and it never takes the answer's last row.
59
59
  */
60
60
  export declare function budgetOf(rows: number, activity: number, thinking: number): Budget;
61
- /** The rows a branch box may spend on its own calls and its reasoning. */
62
- export declare const BRANCH_ROWS = 5;
61
+ /** The rows a branch box may spend on its own calls, prose and reasoning. */
62
+ export declare const BRANCH_ROWS = 9;
63
+ /**
64
+ * The fewest a box is worth drawing at.
65
+ *
66
+ * One row per branch fit more of them on screen and said nothing about any of
67
+ * them: a box holding a single call is a label, and the reason it is a box at
68
+ * all is that what a branch just did and said is why it is doing this. Below
69
+ * six rows there is no *what it just did* — so a fork too wide to give every
70
+ * branch six is cut to the ones that fit and counted, which is `fitActivity`.
71
+ */
72
+ export declare const BRANCH_MIN = 6;
63
73
  /** Rows a branch box spends on chrome: the title rule and the closing one. */
64
74
  export declare const BOX_CHROME = 2;
65
75
  /**
@@ -67,18 +77,27 @@ export declare const BOX_CHROME = 2;
67
77
  * activity region has to divide between them.
68
78
  *
69
79
  * Every branch gets the same number, because they are the same kind of thing
70
- * and a fan-out is read across, not down. A wide fork spends its rows on being
71
- * complete rather than on being detailed: eight branches showing one call each
72
- * is a picture of the fork, eight rows of one branch is not.
80
+ * and a fan-out is read across, not down.
73
81
  */
74
82
  export declare function branchRows(count: number, allowance: number): number;
75
83
  /**
76
- * How wide the answer is drawn. A line of prose spanning a 200-column terminal
77
- * is measurably harder to read than one that stops, which is why every demo in
84
+ * How wide *prose* is drawn. A line spanning a 200-column terminal is
85
+ * measurably harder to read than one that stops, which is why every demo in
78
86
  * `examples/sdk/` puts its answer in a box of bounded width — the terminal is the
79
87
  * page, not the paragraph.
88
+ *
89
+ * `boxWidth` is what a whole answer is drawn at; this is the floor it starts from.
80
90
  */
81
91
  export declare function answerWidth(columns: number): number;
92
+ /**
93
+ * How wide the box holding `text` has to be.
94
+ *
95
+ * Prose stops at the comfort width, but a fence and a table cannot be
96
+ * reflowed — fold a table row and the columns stop lining up, which is the one
97
+ * thing the table was for — so the box grows to hold the widest of them, as far
98
+ * as the terminal allows and no further.
99
+ */
100
+ export declare function boxWidth(text: string, columns: number): number;
82
101
  /**
83
102
  * A tool payload as a person would read it, rather than as it was serialised.
84
103
  *
@@ -112,18 +131,81 @@ export declare function summarise(name: string, preview: string): string;
112
131
  * still proof that something is happening.
113
132
  */
114
133
  export declare function gistOf(text: string, width: number): string;
115
- /** A run of lines from an answer, and whether it was fenced as code. */
116
- export interface Segment {
117
- code: boolean;
134
+ /** A run of inline text and what it is. Style rides beside the text, never in it. */
135
+ export interface Span {
136
+ text: string;
137
+ bold?: boolean;
138
+ italic?: boolean;
139
+ /** an inline code span, taken verbatim and never scanned again */
140
+ code?: boolean;
141
+ /** where a link points, when its own text does not say */
142
+ href?: string;
143
+ }
144
+ export type BlockKind = 'paragraph' | 'heading' | 'item' | 'quote' | 'code' | 'table' | 'rule';
145
+ /** How a table column is set, when its rule row said. */
146
+ export type Align = 'left' | 'right' | 'center';
147
+ /**
148
+ * One block of an answer.
149
+ *
150
+ * `lines`, `cells` and `spans` are exclusive and say how the block may be
151
+ * drawn: `lines` is verbatim and must be cut rather than wrapped, `cells` is a
152
+ * grid to be laid out by `gridOf`, `spans` is prose and the renderer may do as
153
+ * it likes with it.
154
+ */
155
+ export interface Block {
156
+ kind: BlockKind;
157
+ /** `heading`: its depth, 1–6. `item`: how deep it is nested. */
158
+ level?: number;
118
159
  /** the fence's info string, when it had one */
119
160
  title?: string;
120
- lines: string[];
161
+ /** what a list item is drawn behind — a bullet, or the number that was written */
162
+ marker?: string;
163
+ /** `code` only, whose indentation is its meaning */
164
+ lines?: string[];
165
+ /** `table` only: every row but the rule, as cells, with their markup resolved */
166
+ cells?: Span[][][];
167
+ /** `table` only: how each column is set, and that the first row is a header */
168
+ align?: Align[];
169
+ /** every other kind, with its inline markup resolved */
170
+ spans?: Span[];
121
171
  }
122
172
  /**
123
- * Splits an answer on ``` fences. Prose is left exactly as it was — the common
124
- * answer has no fence in it and comes back in one piece — but a fenced block is
125
- * the one thing a terminal must not reflow: its indentation is its meaning, and
126
- * wrapping it as prose destroys it.
173
+ * The inline markup of one block, resolved.
174
+ *
175
+ * Order is the correctness argument. Code is settled first and never entered
176
+ * again, which is why this is a scanner and not a chain of replaces: in
177
+ * "use `[a](b)` syntax" the brackets are prose, and no regex over the whole
178
+ * string can know that. Everything else recurses on the text between its own
179
+ * markers, so `**bold with `code` in it**` keeps both.
180
+ */
181
+ export declare function inlineOf(text: string, style?: Omit<Span, 'text'>, depth?: number): Span[];
182
+ /**
183
+ * An answer, as the blocks it is made of.
184
+ *
185
+ * Read top down, one line at a time, because that is the order the text
186
+ * arrives in and a stream must be readable before it is finished. The two
187
+ * verbatim kinds win over everything: a pipe inside a fence is whatever the
188
+ * code says it is, and a `#` inside one is a comment, not a heading.
189
+ */
190
+ export declare function blocksOf(text: string): Block[];
191
+ /**
192
+ * A table as its rows, each one a single run of spans.
193
+ *
194
+ * Columns are laid out here and nowhere else, so the drawn table and the plain
195
+ * one are the same table: a cell's width is the length of its text, which is
196
+ * what a `Span` measures whatever styling rides beside it. Nothing a model
197
+ * writes in a cell can move the cell after it.
198
+ */
199
+ export declare function gridOf(block: Block): Span[][];
200
+ /**
201
+ * A block as the row or rows it reads as, with its markers resolved rather
202
+ * than shown, and nothing styled.
203
+ *
204
+ * This is what a sink that cannot style gets — the pre-answer stream, and the
205
+ * plain box `zen meta` draws — so that the text does not visibly change shape
206
+ * at the moment it settles.
127
207
  */
128
- export declare function segmentsOf(text: string): Segment[];
208
+ export declare function textOf(block: Block, width?: number): string;
209
+ /** A whole answer with its markup resolved instead of shown. Still plain text. */
210
+ export declare function unmarked(text: string, width?: number): string;
129
211
  //# sourceMappingURL=wrap.d.ts.map