markform 0.1.3 → 0.1.5
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/README.md +110 -70
- package/dist/ai-sdk.d.mts +2 -2
- package/dist/ai-sdk.mjs +5 -5
- package/dist/{apply-00UmzDKL.mjs → apply-BCCiJzQr.mjs} +371 -26
- package/dist/bin.mjs +6 -6
- package/dist/{cli-D--Lel-e.mjs → cli-D469amuk.mjs} +386 -96
- package/dist/cli.mjs +6 -6
- package/dist/{coreTypes-BXhhz9Iq.d.mts → coreTypes-9XZSNOv6.d.mts} +1878 -325
- package/dist/{coreTypes-Dful87E0.mjs → coreTypes-pyctKRgc.mjs} +79 -5
- package/dist/index.d.mts +142 -5
- package/dist/index.mjs +5 -5
- package/dist/session-B_stoXQn.mjs +4 -0
- package/dist/{session-Bqnwi9wp.mjs → session-uF0e6m6k.mjs} +9 -5
- package/dist/{shared-N_s1M-_K.mjs → shared-BqPnYXrn.mjs} +82 -1
- package/dist/shared-CZsyShck.mjs +3 -0
- package/dist/{src-Dm8jZ5dl.mjs → src-Df0XX7UB.mjs} +818 -125
- package/docs/markform-apis.md +194 -0
- package/{DOCS.md → docs/markform-reference.md} +130 -69
- package/{SPEC.md → docs/markform-spec.md} +359 -108
- package/examples/earnings-analysis/earnings-analysis.form.md +88 -800
- package/examples/earnings-analysis/earnings-analysis.valid.ts +16 -148
- package/examples/movie-research/movie-research-basic.form.md +41 -37
- package/examples/movie-research/movie-research-deep.form.md +110 -98
- package/examples/movie-research/movie-research-minimal.form.md +29 -15
- package/examples/simple/simple-mock-filled.form.md +105 -41
- package/examples/simple/simple-skipped-filled.form.md +103 -41
- package/examples/simple/simple-with-skips.session.yaml +93 -25
- package/examples/simple/simple.form.md +86 -32
- package/examples/simple/simple.session.yaml +98 -25
- package/examples/startup-deep-research/startup-deep-research.form.md +130 -103
- package/examples/startup-research/startup-research-mock-filled.form.md +55 -55
- package/examples/startup-research/startup-research.form.md +36 -36
- package/package.json +18 -19
- package/dist/session-DdAtY2Ni.mjs +0 -4
- package/dist/shared-D7gf27Tr.mjs +0 -3
- package/examples/celebrity-deep-research/celebrity-deep-research.form.md +0 -912
|
@@ -49,8 +49,60 @@ const FieldKindSchema = z.enum([
|
|
|
49
49
|
"url",
|
|
50
50
|
"url_list",
|
|
51
51
|
"date",
|
|
52
|
+
"year",
|
|
53
|
+
"table"
|
|
54
|
+
]);
|
|
55
|
+
/** Base column type name schema */
|
|
56
|
+
const ColumnTypeNameSchema = z.enum([
|
|
57
|
+
"string",
|
|
58
|
+
"number",
|
|
59
|
+
"url",
|
|
60
|
+
"date",
|
|
52
61
|
"year"
|
|
53
62
|
]);
|
|
63
|
+
/**
|
|
64
|
+
* Column type specification schema (for parsing attributes).
|
|
65
|
+
* Either a simple type name or an object with type and required.
|
|
66
|
+
*/
|
|
67
|
+
const ColumnTypeSpecSchema = z.union([ColumnTypeNameSchema, z.object({
|
|
68
|
+
type: ColumnTypeNameSchema,
|
|
69
|
+
required: z.boolean()
|
|
70
|
+
})]);
|
|
71
|
+
/**
|
|
72
|
+
* Table column schema (normalized form after parsing).
|
|
73
|
+
* Always has explicit required flag.
|
|
74
|
+
*/
|
|
75
|
+
const TableColumnSchema = z.object({
|
|
76
|
+
id: IdSchema,
|
|
77
|
+
label: z.string(),
|
|
78
|
+
type: ColumnTypeNameSchema,
|
|
79
|
+
required: z.boolean()
|
|
80
|
+
});
|
|
81
|
+
/** Cell value schema (never null - use sentinels for skipped) */
|
|
82
|
+
const CellValueSchema = z.union([z.string(), z.number()]);
|
|
83
|
+
/** Cell response schema */
|
|
84
|
+
const CellResponseSchema = z.object({
|
|
85
|
+
state: z.enum([
|
|
86
|
+
"answered",
|
|
87
|
+
"skipped",
|
|
88
|
+
"aborted"
|
|
89
|
+
]),
|
|
90
|
+
value: CellValueSchema.optional(),
|
|
91
|
+
reason: z.string().optional()
|
|
92
|
+
});
|
|
93
|
+
/** Table row response schema */
|
|
94
|
+
const TableRowResponseSchema = z.record(IdSchema, CellResponseSchema);
|
|
95
|
+
/** Table value schema */
|
|
96
|
+
const TableValueSchema = z.object({
|
|
97
|
+
kind: z.literal("table"),
|
|
98
|
+
rows: z.array(TableRowResponseSchema)
|
|
99
|
+
});
|
|
100
|
+
/** Table row patch schema (simplified for patches) */
|
|
101
|
+
const TableRowPatchSchema = z.record(IdSchema, z.union([
|
|
102
|
+
CellValueSchema,
|
|
103
|
+
z.null(),
|
|
104
|
+
z.string()
|
|
105
|
+
]));
|
|
54
106
|
const FieldPriorityLevelSchema = z.enum([
|
|
55
107
|
"high",
|
|
56
108
|
"medium",
|
|
@@ -66,7 +118,10 @@ const FieldBaseSchemaPartial = {
|
|
|
66
118
|
required: z.boolean(),
|
|
67
119
|
priority: FieldPriorityLevelSchema,
|
|
68
120
|
role: z.string(),
|
|
69
|
-
validate: z.array(ValidatorRefSchema).optional()
|
|
121
|
+
validate: z.array(ValidatorRefSchema).optional(),
|
|
122
|
+
report: z.boolean().optional(),
|
|
123
|
+
placeholder: z.string().optional(),
|
|
124
|
+
examples: z.array(z.string()).optional()
|
|
70
125
|
};
|
|
71
126
|
const StringFieldSchema = z.object({
|
|
72
127
|
...FieldBaseSchemaPartial,
|
|
@@ -135,6 +190,14 @@ const YearFieldSchema = z.object({
|
|
|
135
190
|
min: z.number().int().optional(),
|
|
136
191
|
max: z.number().int().optional()
|
|
137
192
|
});
|
|
193
|
+
/** Table field schema (extends FieldBase pattern) */
|
|
194
|
+
const TableFieldSchema = z.object({
|
|
195
|
+
...FieldBaseSchemaPartial,
|
|
196
|
+
kind: z.literal("table"),
|
|
197
|
+
columns: z.array(TableColumnSchema),
|
|
198
|
+
minRows: z.number().int().nonnegative().optional(),
|
|
199
|
+
maxRows: z.number().int().positive().optional()
|
|
200
|
+
});
|
|
138
201
|
const FieldSchema = z.discriminatedUnion("kind", [
|
|
139
202
|
StringFieldSchema,
|
|
140
203
|
NumberFieldSchema,
|
|
@@ -145,7 +208,8 @@ const FieldSchema = z.discriminatedUnion("kind", [
|
|
|
145
208
|
UrlFieldSchema,
|
|
146
209
|
UrlListFieldSchema,
|
|
147
210
|
DateFieldSchema,
|
|
148
|
-
YearFieldSchema
|
|
211
|
+
YearFieldSchema,
|
|
212
|
+
TableFieldSchema
|
|
149
213
|
]);
|
|
150
214
|
const FieldGroupSchema = z.object({
|
|
151
215
|
id: IdSchema,
|
|
@@ -208,7 +272,8 @@ const FieldValueSchema = z.discriminatedUnion("kind", [
|
|
|
208
272
|
UrlValueSchema,
|
|
209
273
|
UrlListValueSchema,
|
|
210
274
|
DateValueSchema,
|
|
211
|
-
YearValueSchema
|
|
275
|
+
YearValueSchema,
|
|
276
|
+
TableValueSchema
|
|
212
277
|
]);
|
|
213
278
|
const FieldResponseSchema = z.object({
|
|
214
279
|
state: AnswerStateSchema,
|
|
@@ -297,7 +362,9 @@ const IssueScopeSchema = z.enum([
|
|
|
297
362
|
"form",
|
|
298
363
|
"group",
|
|
299
364
|
"field",
|
|
300
|
-
"option"
|
|
365
|
+
"option",
|
|
366
|
+
"column",
|
|
367
|
+
"cell"
|
|
301
368
|
]);
|
|
302
369
|
const InspectIssueSchema = z.object({
|
|
303
370
|
ref: z.union([IdSchema, z.string()]),
|
|
@@ -431,6 +498,12 @@ const SetYearPatchSchema = z.object({
|
|
|
431
498
|
fieldId: IdSchema,
|
|
432
499
|
value: z.number().int().nullable()
|
|
433
500
|
});
|
|
501
|
+
/** Set table patch schema */
|
|
502
|
+
const SetTablePatchSchema = z.object({
|
|
503
|
+
op: z.literal("set_table"),
|
|
504
|
+
fieldId: IdSchema,
|
|
505
|
+
rows: z.array(TableRowPatchSchema)
|
|
506
|
+
});
|
|
434
507
|
const ClearFieldPatchSchema = z.object({
|
|
435
508
|
op: z.literal("clear_field"),
|
|
436
509
|
fieldId: IdSchema
|
|
@@ -468,6 +541,7 @@ const PatchSchema = z.discriminatedUnion("op", [
|
|
|
468
541
|
SetUrlListPatchSchema,
|
|
469
542
|
SetDatePatchSchema,
|
|
470
543
|
SetYearPatchSchema,
|
|
544
|
+
SetTablePatchSchema,
|
|
471
545
|
ClearFieldPatchSchema,
|
|
472
546
|
SkipFieldPatchSchema,
|
|
473
547
|
AbortFieldPatchSchema,
|
|
@@ -534,4 +608,4 @@ const MarkformFrontmatterSchema = z.object({
|
|
|
534
608
|
});
|
|
535
609
|
|
|
536
610
|
//#endregion
|
|
537
|
-
export {
|
|
611
|
+
export { SetUrlPatchSchema as $, MultiCheckboxStateSchema as A, ProgressSummarySchema as B, HarnessConfigSchema as C, ValidatorRefSchema as Ct, IssueReasonSchema as D, InspectResultSchema as E, OptionIdSchema as F, SetDatePatchSchema as G, SessionTranscriptSchema as H, OptionSchema as I, SetSingleSelectPatchSchema as J, SetMultiSelectPatchSchema as K, PatchSchema as L, MultiSelectValueSchema as M, NumberFieldSchema as N, IssueScopeSchema as O, NumberValueSchema as P, SetUrlListPatchSchema as Q, ProgressCountsSchema as R, FormSchemaSchema as S, ValidationIssueSchema as St, InspectIssueSchema as T, YearValueSchema as Tt, SessionTurnSchema as U, SessionFinalSchema as V, SetCheckboxesPatchSchema as W, SetStringPatchSchema as X, SetStringListPatchSchema as Y, SetTablePatchSchema as Z, FieldKindSchema as _, TableValueSchema as _t, CheckboxProgressCountsSchema as a, SourcePositionSchema as at, FieldSchema as b, UrlListValueSchema as bt, CheckboxesValueSchema as c, StringFieldSchema as ct, DateFieldSchema as d, StringValueSchema as dt, SetYearPatchSchema as et, DateValueSchema as f, StructureSummarySchema as ft, FieldGroupSchema as g, TableRowResponseSchema as gt, ExplicitCheckboxValueSchema as h, TableRowPatchSchema as ht, CheckboxModeSchema as i, SingleSelectValueSchema as it, MultiSelectFieldSchema as j, MarkformFrontmatterSchema as k, ClearFieldPatchSchema as l, StringListFieldSchema as lt, DocumentationTagSchema as m, TableFieldSchema as mt, ApplyResultSchema as n, SimpleCheckboxStateSchema as nt, CheckboxValueSchema as o, SourceRangeSchema as ot, DocumentationBlockSchema as p, TableColumnSchema as pt, SetNumberPatchSchema as q, CellResponseSchema as r, SingleSelectFieldSchema as rt, CheckboxesFieldSchema as s, StepResultSchema as st, AnswerStateSchema as t, SeveritySchema as tt, ColumnTypeNameSchema as u, StringListValueSchema as ut, FieldProgressSchema as v, UrlFieldSchema as vt, IdSchema as w, YearFieldSchema as wt, FieldValueSchema as x, UrlValueSchema as xt, FieldResponseSchema as y, UrlListFieldSchema as yt, ProgressStateSchema as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { $ as
|
|
3
|
+
import { $ as InspectIssue, $n as ValidationIssue, $t as SetStringListPatch, A as ExplicitCheckboxValueSchema, An as StringListValueSchema, At as ProgressState, B as FieldResponseSchema, Bn as TableRowPatchSchema, Bt as SessionTurn, C as DateValue, Cn as StepResult, Ct as OptionIdSchema, D as DocumentationTag, Dn as StringListField, Dt as PatchSchema, E as DocumentationBlockSchema, En as StringFieldSchema, Et as Patch, F as FieldKind, Fn as TableColumn, Ft as QualifiedOptionRef, G as FormSchema, Gn as UrlField, Gt as SetDatePatch, H as FieldValue, Hn as TableRowResponseSchema, Ht as SessionTurnStats, I as FieldKindSchema, In as TableColumnSchema, It as SessionFinal, J as HarnessConfig, Jn as UrlListFieldSchema, Jt as SetMultiSelectPatchSchema, K as FormSchemaSchema, Kn as UrlFieldSchema, Kt as SetDatePatchSchema, L as FieldProgress, Ln as TableField, Lt as SessionFinalSchema, M as FieldBase, Mn as StringValueSchema, Mt as ProgressSummary, N as FieldGroup, Nn as StructureSummary, Nt as ProgressSummarySchema, O as DocumentationTagSchema, On as StringListFieldSchema, Ot as ProgressCounts, P as FieldGroupSchema, Pn as StructureSummarySchema, Pt as QualifiedColumnRef, Q as IdSchema, Qn as UrlValueSchema, Qt as SetSingleSelectPatchSchema, R as FieldProgressSchema, Rn as TableFieldSchema, Rt as SessionTranscript, S as DateFieldSchema, Sn as SourceRangeSchema, St as OptionId, T as DocumentationBlock, Tn as StringField, Tt as ParsedForm, U as FieldValueSchema, Un as TableValue, Ut as SetCheckboxesPatch, V as FieldSchema, Vn as TableRowResponse, Vt as SessionTurnSchema, W as FillMode, Wn as TableValueSchema, Wt as SetCheckboxesPatchSchema, X as Id, Xn as UrlListValueSchema, Xt as SetNumberPatchSchema, Y as HarnessConfigSchema, Yn as UrlListValue, Yt as SetNumberPatch, Z as IdIndexEntry, Zn as UrlValue, Zt as SetSingleSelectPatch, _ as ClearFieldPatch, _n as SingleSelectValue, _t as NumberField, a as CellResponse, an as SetUrlListPatch, ar as ValidatorRegistry, at as IssueScope, b as ColumnTypeNameSchema, bn as SourcePositionSchema, bt as NumberValueSchema, c as CheckboxModeSchema, cn as SetUrlPatchSchema, cr as YearValue, ct as MarkformFrontmatterSchema, d as CheckboxValue, dn as Severity, dt as MultiSelectField, en as SetStringListPatchSchema, er as ValidationIssueSchema, et as InspectIssueSchema, f as CheckboxValueSchema, fn as SeveritySchema, ft as MultiSelectFieldSchema, g as CheckboxesValueSchema, gn as SingleSelectFieldSchema, gt as Note, h as CheckboxesValue, hn as SingleSelectField, ht as NodeType, i as ApplyResultSchema, in as SetTablePatchSchema, ir as ValidatorRefSchema, it as IssueReasonSchema, j as Field, jn as StringValue, jt as ProgressStateSchema, k as ExplicitCheckboxValue, kn as StringListValue, kt as ProgressCountsSchema, l as CheckboxProgressCounts, ln as SetYearPatch, lr as YearValueSchema, lt as MultiCheckboxState, m as CheckboxesFieldSchema, mn as SimpleCheckboxStateSchema, mt as MultiSelectValueSchema, n as AnswerStateSchema, nn as SetStringPatchSchema, nr as ValidatorFn, nt as InspectResultSchema, o as CellResponseSchema, on as SetUrlListPatchSchema, or as YearField, ot as IssueScopeSchema, p as CheckboxesField, pn as SimpleCheckboxState, pt as MultiSelectValue, q as FrontmatterHarnessConfig, qn as UrlListField, qt as SetMultiSelectPatch, r as ApplyResult, rn as SetTablePatch, rr as ValidatorRef, rt as IssueReason, s as CheckboxMode, sn as SetUrlPatch, sr as YearFieldSchema, st as MarkformFrontmatter, t as AnswerState, tn as SetStringPatch, tr as ValidatorContext, tt as InspectResult, u as CheckboxProgressCountsSchema, un as SetYearPatchSchema, ut as MultiCheckboxStateSchema, v as ClearFieldPatchSchema, vn as SingleSelectValueSchema, vt as NumberFieldSchema, w as DateValueSchema, wn as StepResultSchema, wt as OptionSchema, x as DateField, xn as SourceRange, xt as Option, y as ColumnTypeName, yn as SourcePosition, yt as NumberValue, z as FieldResponse, zn as TableRowPatch, zt as SessionTranscriptSchema } from "./coreTypes-9XZSNOv6.mjs";
|
|
4
4
|
import "@markdoc/markdoc";
|
|
5
|
-
import { LanguageModel } from "ai";
|
|
5
|
+
import { LanguageModel, Tool } from "ai";
|
|
6
6
|
|
|
7
7
|
//#region src/engine/parseHelpers.d.ts
|
|
8
8
|
|
|
@@ -178,6 +178,130 @@ declare function serializeSession(session: SessionTranscript): string;
|
|
|
178
178
|
*/
|
|
179
179
|
declare function applyPatches(form: ParsedForm, patches: Patch[]): ApplyResult;
|
|
180
180
|
//#endregion
|
|
181
|
+
//#region src/engine/table/parseTable.d.ts
|
|
182
|
+
/** Result of parsing a markdown table */
|
|
183
|
+
type ParseTableResult = {
|
|
184
|
+
ok: true;
|
|
185
|
+
value: TableValue;
|
|
186
|
+
} | {
|
|
187
|
+
ok: false;
|
|
188
|
+
error: string;
|
|
189
|
+
};
|
|
190
|
+
/** Parsed raw table structure before type coercion */
|
|
191
|
+
interface ParsedRawTable {
|
|
192
|
+
headers: string[];
|
|
193
|
+
rows: string[][];
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Parse a cell value according to its column type.
|
|
197
|
+
* Returns a CellResponse with appropriate state.
|
|
198
|
+
*/
|
|
199
|
+
declare function parseCellValue(rawValue: string, columnType: ColumnTypeName): CellResponse;
|
|
200
|
+
/**
|
|
201
|
+
* Parse a markdown table with column schema for type coercion.
|
|
202
|
+
*
|
|
203
|
+
* @param content - The markdown table content
|
|
204
|
+
* @param columns - Column definitions from the table field schema
|
|
205
|
+
* @param dataStartLine - Optional line index where data rows start (skips header validation)
|
|
206
|
+
* @returns Parsed table value with typed cells
|
|
207
|
+
*/
|
|
208
|
+
declare function parseMarkdownTable(content: string, columns: TableColumn[], dataStartLine?: number): ParseTableResult;
|
|
209
|
+
/**
|
|
210
|
+
* Parse just the raw table structure without schema.
|
|
211
|
+
* Useful for validation and error reporting.
|
|
212
|
+
*/
|
|
213
|
+
declare function parseRawTable(content: string): {
|
|
214
|
+
ok: true;
|
|
215
|
+
headers: string[];
|
|
216
|
+
rows: string[][];
|
|
217
|
+
} | {
|
|
218
|
+
ok: false;
|
|
219
|
+
error: string;
|
|
220
|
+
};
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/engine/scopeRef.d.ts
|
|
223
|
+
/** Simple field reference */
|
|
224
|
+
interface FieldScopeRef {
|
|
225
|
+
type: 'field';
|
|
226
|
+
fieldId: Id;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Qualified reference - could be option or column.
|
|
230
|
+
* Disambiguation happens during resolution with schema context.
|
|
231
|
+
*/
|
|
232
|
+
interface QualifiedScopeRef {
|
|
233
|
+
type: 'qualified';
|
|
234
|
+
fieldId: Id;
|
|
235
|
+
qualifierId: Id;
|
|
236
|
+
}
|
|
237
|
+
/** Cell reference - table field specific */
|
|
238
|
+
interface CellScopeRef {
|
|
239
|
+
type: 'cell';
|
|
240
|
+
fieldId: Id;
|
|
241
|
+
row: number;
|
|
242
|
+
columnId: Id;
|
|
243
|
+
}
|
|
244
|
+
/** Union of all parsed scope reference types */
|
|
245
|
+
type ParsedScopeRef = FieldScopeRef | QualifiedScopeRef | CellScopeRef;
|
|
246
|
+
/** Result of parsing a scope reference */
|
|
247
|
+
type ParseScopeRefResult = {
|
|
248
|
+
ok: true;
|
|
249
|
+
ref: ParsedScopeRef;
|
|
250
|
+
} | {
|
|
251
|
+
ok: false;
|
|
252
|
+
error: string;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Parse a scope reference string into a structured format.
|
|
256
|
+
*
|
|
257
|
+
* @param refStr - The scope reference string to parse
|
|
258
|
+
* @returns Parsed scope reference or error
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* parseScopeRef('myField')
|
|
262
|
+
* // => { ok: true, ref: { type: 'field', fieldId: 'myField' } }
|
|
263
|
+
*
|
|
264
|
+
* parseScopeRef('myField.optA')
|
|
265
|
+
* // => { ok: true, ref: { type: 'qualified', fieldId: 'myField', qualifierId: 'optA' } }
|
|
266
|
+
*
|
|
267
|
+
* parseScopeRef('myTable[2].name')
|
|
268
|
+
* // => { ok: true, ref: { type: 'cell', fieldId: 'myTable', row: 2, columnId: 'name' } }
|
|
269
|
+
*/
|
|
270
|
+
declare function parseScopeRef(refStr: string): ParseScopeRefResult;
|
|
271
|
+
/**
|
|
272
|
+
* Serialize a parsed scope reference back to a string.
|
|
273
|
+
*
|
|
274
|
+
* @param ref - The parsed scope reference
|
|
275
|
+
* @returns Serialized string
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* serializeScopeRef({ type: 'field', fieldId: 'myField' })
|
|
279
|
+
* // => 'myField'
|
|
280
|
+
*
|
|
281
|
+
* serializeScopeRef({ type: 'qualified', fieldId: 'myField', qualifierId: 'optA' })
|
|
282
|
+
* // => 'myField.optA'
|
|
283
|
+
*
|
|
284
|
+
* serializeScopeRef({ type: 'cell', fieldId: 'myTable', row: 2, columnId: 'name' })
|
|
285
|
+
* // => 'myTable[2].name'
|
|
286
|
+
*/
|
|
287
|
+
declare function serializeScopeRef(ref: ParsedScopeRef): string;
|
|
288
|
+
/**
|
|
289
|
+
* Check if a scope reference is a cell reference.
|
|
290
|
+
*/
|
|
291
|
+
declare function isCellRef(ref: ParsedScopeRef): ref is CellScopeRef;
|
|
292
|
+
/**
|
|
293
|
+
* Check if a scope reference is a qualified reference.
|
|
294
|
+
*/
|
|
295
|
+
declare function isQualifiedRef(ref: ParsedScopeRef): ref is QualifiedScopeRef;
|
|
296
|
+
/**
|
|
297
|
+
* Check if a scope reference is a simple field reference.
|
|
298
|
+
*/
|
|
299
|
+
declare function isFieldRef(ref: ParsedScopeRef): ref is FieldScopeRef;
|
|
300
|
+
/**
|
|
301
|
+
* Extract the field ID from any scope reference.
|
|
302
|
+
*/
|
|
303
|
+
declare function getFieldId(ref: ParsedScopeRef): Id;
|
|
304
|
+
//#endregion
|
|
181
305
|
//#region src/engine/valueCoercion.d.ts
|
|
182
306
|
/** Raw value that can be coerced to a field value. */
|
|
183
307
|
type RawFieldValue = string | number | boolean | string[] | Record<string, unknown> | null;
|
|
@@ -424,6 +548,19 @@ interface FillOptions {
|
|
|
424
548
|
onTurnComplete?: (progress: TurnProgress) => void;
|
|
425
549
|
/** AbortSignal for cancellation */
|
|
426
550
|
signal?: AbortSignal;
|
|
551
|
+
/**
|
|
552
|
+
* Enable provider web search tools.
|
|
553
|
+
*
|
|
554
|
+
* **Required** — must explicitly choose to avoid accidental tool exposure.
|
|
555
|
+
*/
|
|
556
|
+
enableWebSearch: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* Additional custom tools for the agent.
|
|
559
|
+
*
|
|
560
|
+
* Tools are merged with enabled built-in tools.
|
|
561
|
+
* If a custom tool has the same name as a built-in tool, the custom tool wins.
|
|
562
|
+
*/
|
|
563
|
+
additionalTools?: Record<string, Tool>;
|
|
427
564
|
/**
|
|
428
565
|
* TEST ONLY: Override agent for testing with MockAgent.
|
|
429
566
|
* When provided, model is ignored and this agent is used instead.
|
|
@@ -654,7 +791,7 @@ declare function validateResearchForm(form: ParsedForm): {
|
|
|
654
791
|
* This is the main library entry point that exports the core engine,
|
|
655
792
|
* types, and utilities for working with .form.md files.
|
|
656
793
|
*/
|
|
657
|
-
/** Markform version. */
|
|
658
|
-
declare const VERSION
|
|
794
|
+
/** Markform version (read from package.json). */
|
|
795
|
+
declare const VERSION: string;
|
|
659
796
|
//#endregion
|
|
660
|
-
export { type AgentResponse, type AnswerState, AnswerStateSchema, type ApplyResult, ApplyResultSchema, type CheckboxMode, CheckboxModeSchema, type CheckboxProgressCounts, CheckboxProgressCountsSchema, type CheckboxValue, CheckboxValueSchema, type CheckboxesField, CheckboxesFieldSchema, type CheckboxesValue, CheckboxesValueSchema, type ClearFieldPatch, ClearFieldPatchSchema, type CoerceInputContextResult, type CoercionResult, type ComputedSummaries, type DocumentationBlock, DocumentationBlockSchema, type DocumentationTag, DocumentationTagSchema, type ExplicitCheckboxValue, ExplicitCheckboxValueSchema, type Field, type FieldBase, type FieldGroup, FieldGroupSchema, type FieldKind, FieldKindSchema, type FieldProgress, FieldProgressSchema, type FieldResponse, FieldResponseSchema, FieldSchema, type FieldValue, FieldValueSchema, type FillOptions, type FillResult, type FillStatus, FormHarness, type FormSchema, FormSchemaSchema, type FrontmatterHarnessConfig, type HarnessConfig, HarnessConfigSchema, type Id, type IdIndexEntry, IdSchema, type InputContext, type InspectIssue, InspectIssueSchema, type InspectOptions, type InspectResult, InspectResultSchema, type IssueReason, IssueReasonSchema, type IssueScope, IssueScopeSchema, type MarkformFrontmatter, MarkformFrontmatterSchema, MockAgent, type MultiCheckboxState, MultiCheckboxStateSchema, type MultiSelectField, MultiSelectFieldSchema, type MultiSelectValue, MultiSelectValueSchema, type NodeType, type NumberField, NumberFieldSchema, type NumberValue, NumberValueSchema, type Option, type OptionId, OptionIdSchema, OptionSchema, ParseError, type ParsedForm, type Patch, PatchSchema, type ProgressCounts, ProgressCountsSchema, type ProgressState, ProgressStateSchema, type ProgressSummary, ProgressSummarySchema, type QualifiedOptionRef, type RawFieldValue, type ResearchOptions, type ResearchResult, type ResearchStatus, type SerializeOptions, type SessionFinal, SessionFinalSchema, type SessionTranscript, SessionTranscriptSchema, type SessionTurn, SessionTurnSchema, type SessionTurnStats, type SetCheckboxesPatch, SetCheckboxesPatchSchema, type SetMultiSelectPatch, SetMultiSelectPatchSchema, type SetNumberPatch, SetNumberPatchSchema, type SetSingleSelectPatch, SetSingleSelectPatchSchema, type SetStringListPatch, SetStringListPatchSchema, type SetStringPatch, SetStringPatchSchema, type Severity, SeveritySchema, type SimpleCheckboxState, SimpleCheckboxStateSchema, type SingleSelectField, SingleSelectFieldSchema, type SingleSelectValue, SingleSelectValueSchema, type SourcePosition, SourcePositionSchema, type SourceRange, SourceRangeSchema, type StepResult, StepResultSchema, type StringField, StringFieldSchema, type StringListField, StringListFieldSchema, type StringListValue, StringListValueSchema, type StringValue, StringValueSchema, type StructureSummary, StructureSummarySchema, type TurnProgress, type TurnStats, VERSION, type ValidateOptions, type ValidateResult, type ValidationIssue, ValidationIssueSchema, type ValidatorContext, type ValidatorFn, type ValidatorRef, ValidatorRefSchema, type ValidatorRegistry, applyPatches, coerceInputContext, coerceToFieldPatch, computeAllSummaries, computeFormState, computeProgressSummary, computeStructureSummary, createHarness, createMockAgent, fillForm, findFieldById, inspect, isFormComplete, isResearchForm, parseForm, parseSession, resolveHarnessConfig, runResearch, serialize, serializeSession, validate, validateResearchForm };
|
|
797
|
+
export { type AgentResponse, type AnswerState, AnswerStateSchema, type ApplyResult, ApplyResultSchema, type CellResponse, CellResponseSchema, type CellScopeRef, type CheckboxMode, CheckboxModeSchema, type CheckboxProgressCounts, CheckboxProgressCountsSchema, type CheckboxValue, CheckboxValueSchema, type CheckboxesField, CheckboxesFieldSchema, type CheckboxesValue, CheckboxesValueSchema, type ClearFieldPatch, ClearFieldPatchSchema, type CoerceInputContextResult, type CoercionResult, type ColumnTypeName, ColumnTypeNameSchema, type ComputedSummaries, type DateField, DateFieldSchema, type DateValue, DateValueSchema, type DocumentationBlock, DocumentationBlockSchema, type DocumentationTag, DocumentationTagSchema, type ExplicitCheckboxValue, ExplicitCheckboxValueSchema, type Field, type FieldBase, type FieldGroup, FieldGroupSchema, type FieldKind, FieldKindSchema, type FieldProgress, FieldProgressSchema, type FieldResponse, FieldResponseSchema, FieldSchema, type FieldScopeRef, type FieldValue, FieldValueSchema, type FillOptions, type FillResult, type FillStatus, FormHarness, type FormSchema, FormSchemaSchema, type FrontmatterHarnessConfig, type HarnessConfig, HarnessConfigSchema, type Id, type IdIndexEntry, IdSchema, type InputContext, type InspectIssue, InspectIssueSchema, type InspectOptions, type InspectResult, InspectResultSchema, type IssueReason, IssueReasonSchema, type IssueScope, IssueScopeSchema, type MarkformFrontmatter, MarkformFrontmatterSchema, MockAgent, type MultiCheckboxState, MultiCheckboxStateSchema, type MultiSelectField, MultiSelectFieldSchema, type MultiSelectValue, MultiSelectValueSchema, type NodeType, type NumberField, NumberFieldSchema, type NumberValue, NumberValueSchema, type Option, type OptionId, OptionIdSchema, OptionSchema, ParseError, type ParseScopeRefResult, type ParseTableResult, type ParsedForm, type ParsedRawTable, type ParsedScopeRef, type Patch, PatchSchema, type ProgressCounts, ProgressCountsSchema, type ProgressState, ProgressStateSchema, type ProgressSummary, ProgressSummarySchema, type QualifiedColumnRef, type QualifiedOptionRef, type QualifiedScopeRef, type RawFieldValue, type ResearchOptions, type ResearchResult, type ResearchStatus, type SerializeOptions, type SessionFinal, SessionFinalSchema, type SessionTranscript, SessionTranscriptSchema, type SessionTurn, SessionTurnSchema, type SessionTurnStats, type SetCheckboxesPatch, SetCheckboxesPatchSchema, type SetDatePatch, SetDatePatchSchema, type SetMultiSelectPatch, SetMultiSelectPatchSchema, type SetNumberPatch, SetNumberPatchSchema, type SetSingleSelectPatch, SetSingleSelectPatchSchema, type SetStringListPatch, SetStringListPatchSchema, type SetStringPatch, SetStringPatchSchema, type SetTablePatch, SetTablePatchSchema, type SetUrlListPatch, SetUrlListPatchSchema, type SetUrlPatch, SetUrlPatchSchema, type SetYearPatch, SetYearPatchSchema, type Severity, SeveritySchema, type SimpleCheckboxState, SimpleCheckboxStateSchema, type SingleSelectField, SingleSelectFieldSchema, type SingleSelectValue, SingleSelectValueSchema, type SourcePosition, SourcePositionSchema, type SourceRange, SourceRangeSchema, type StepResult, StepResultSchema, type StringField, StringFieldSchema, type StringListField, StringListFieldSchema, type StringListValue, StringListValueSchema, type StringValue, StringValueSchema, type StructureSummary, StructureSummarySchema, type TableColumn, TableColumnSchema, type TableField, TableFieldSchema, type TableRowPatch, TableRowPatchSchema, type TableRowResponse, TableRowResponseSchema, type TableValue, TableValueSchema, type TurnProgress, type TurnStats, type UrlField, UrlFieldSchema, type UrlListField, UrlListFieldSchema, type UrlListValue, UrlListValueSchema, type UrlValue, UrlValueSchema, VERSION, type ValidateOptions, type ValidateResult, type ValidationIssue, ValidationIssueSchema, type ValidatorContext, type ValidatorFn, type ValidatorRef, ValidatorRefSchema, type ValidatorRegistry, type YearField, YearFieldSchema, type YearValue, YearValueSchema, applyPatches, coerceInputContext, coerceToFieldPatch, computeAllSummaries, computeFormState, computeProgressSummary, computeStructureSummary, createHarness, createMockAgent, fillForm, findFieldById, getFieldId, inspect, isCellRef, isFieldRef, isFormComplete, isQualifiedRef, isResearchForm, parseCellValue, parseForm, parseMarkdownTable, parseRawTable, parseScopeRef, parseSession, resolveHarnessConfig, runResearch, serialize, serializeScopeRef, serializeSession, validate, validateResearchForm };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { a as computeAllSummaries, c as computeStructureSummary, i as validate, l as isFormComplete, o as computeFormState, r as inspect, s as computeProgressSummary, t as applyPatches, u as serialize } from "./apply-
|
|
3
|
-
import { _ as findFieldById, a as resolveHarnessConfig, d as MockAgent, f as createMockAgent, g as coerceToFieldPatch, h as coerceInputContext, i as runResearch, m as createHarness, n as isResearchForm, o as fillForm, p as FormHarness, r as validateResearchForm, t as VERSION, v as parseForm, y as
|
|
4
|
-
import { n as serializeSession, t as parseSession } from "./session-
|
|
1
|
+
import { $ as SetUrlPatchSchema, A as MultiCheckboxStateSchema, B as ProgressSummarySchema, C as HarnessConfigSchema, Ct as ValidatorRefSchema, D as IssueReasonSchema, E as InspectResultSchema, F as OptionIdSchema, G as SetDatePatchSchema, H as SessionTranscriptSchema, I as OptionSchema, J as SetSingleSelectPatchSchema, K as SetMultiSelectPatchSchema, L as PatchSchema, M as MultiSelectValueSchema, N as NumberFieldSchema, O as IssueScopeSchema, P as NumberValueSchema, Q as SetUrlListPatchSchema, R as ProgressCountsSchema, S as FormSchemaSchema, St as ValidationIssueSchema, T as InspectIssueSchema, Tt as YearValueSchema, U as SessionTurnSchema, V as SessionFinalSchema, W as SetCheckboxesPatchSchema, X as SetStringPatchSchema, Y as SetStringListPatchSchema, Z as SetTablePatchSchema, _ as FieldKindSchema, _t as TableValueSchema, a as CheckboxProgressCountsSchema, at as SourcePositionSchema, b as FieldSchema, bt as UrlListValueSchema, c as CheckboxesValueSchema, ct as StringFieldSchema, d as DateFieldSchema, dt as StringValueSchema, et as SetYearPatchSchema, f as DateValueSchema, ft as StructureSummarySchema, g as FieldGroupSchema, gt as TableRowResponseSchema, h as ExplicitCheckboxValueSchema, ht as TableRowPatchSchema, i as CheckboxModeSchema, it as SingleSelectValueSchema, j as MultiSelectFieldSchema, k as MarkformFrontmatterSchema, l as ClearFieldPatchSchema, lt as StringListFieldSchema, m as DocumentationTagSchema, mt as TableFieldSchema, n as ApplyResultSchema, nt as SimpleCheckboxStateSchema, o as CheckboxValueSchema, ot as SourceRangeSchema, p as DocumentationBlockSchema, pt as TableColumnSchema, q as SetNumberPatchSchema, r as CellResponseSchema, rt as SingleSelectFieldSchema, s as CheckboxesFieldSchema, st as StepResultSchema, t as AnswerStateSchema, tt as SeveritySchema, u as ColumnTypeNameSchema, ut as StringListValueSchema, v as FieldProgressSchema, vt as UrlFieldSchema, w as IdSchema, wt as YearFieldSchema, x as FieldValueSchema, xt as UrlValueSchema, y as FieldResponseSchema, yt as UrlListFieldSchema, z as ProgressStateSchema } from "./coreTypes-pyctKRgc.mjs";
|
|
2
|
+
import { a as computeAllSummaries, c as computeStructureSummary, i as validate, l as isFormComplete, o as computeFormState, r as inspect, s as computeProgressSummary, t as applyPatches, u as serialize } from "./apply-BCCiJzQr.mjs";
|
|
3
|
+
import { C as serializeScopeRef, D as parseRawTable, E as parseMarkdownTable, O as ParseError, S as parseScopeRef, T as parseCellValue, _ as findFieldById, a as resolveHarnessConfig, b as isFieldRef, d as MockAgent, f as createMockAgent, g as coerceToFieldPatch, h as coerceInputContext, i as runResearch, m as createHarness, n as isResearchForm, o as fillForm, p as FormHarness, r as validateResearchForm, t as VERSION, v as getFieldId, w as parseForm, x as isQualifiedRef, y as isCellRef } from "./src-Df0XX7UB.mjs";
|
|
4
|
+
import { n as serializeSession, t as parseSession } from "./session-uF0e6m6k.mjs";
|
|
5
5
|
|
|
6
|
-
export { AnswerStateSchema, ApplyResultSchema, CheckboxModeSchema, CheckboxProgressCountsSchema, CheckboxValueSchema, CheckboxesFieldSchema, CheckboxesValueSchema, ClearFieldPatchSchema, DocumentationBlockSchema, DocumentationTagSchema, ExplicitCheckboxValueSchema, FieldGroupSchema, FieldKindSchema, FieldProgressSchema, FieldResponseSchema, FieldSchema, FieldValueSchema, FormHarness, FormSchemaSchema, HarnessConfigSchema, IdSchema, InspectIssueSchema, InspectResultSchema, IssueReasonSchema, IssueScopeSchema, MarkformFrontmatterSchema, MockAgent, MultiCheckboxStateSchema, MultiSelectFieldSchema, MultiSelectValueSchema, NumberFieldSchema, NumberValueSchema, OptionIdSchema, OptionSchema, ParseError, PatchSchema, ProgressCountsSchema, ProgressStateSchema, ProgressSummarySchema, SessionFinalSchema, SessionTranscriptSchema, SessionTurnSchema, SetCheckboxesPatchSchema, SetMultiSelectPatchSchema, SetNumberPatchSchema, SetSingleSelectPatchSchema, SetStringListPatchSchema, SetStringPatchSchema, SeveritySchema, SimpleCheckboxStateSchema, SingleSelectFieldSchema, SingleSelectValueSchema, SourcePositionSchema, SourceRangeSchema, StepResultSchema, StringFieldSchema, StringListFieldSchema, StringListValueSchema, StringValueSchema, StructureSummarySchema, VERSION, ValidationIssueSchema, ValidatorRefSchema, applyPatches, coerceInputContext, coerceToFieldPatch, computeAllSummaries, computeFormState, computeProgressSummary, computeStructureSummary, createHarness, createMockAgent, fillForm, findFieldById, inspect, isFormComplete, isResearchForm, parseForm, parseSession, resolveHarnessConfig, runResearch, serialize, serializeSession, validate, validateResearchForm };
|
|
6
|
+
export { AnswerStateSchema, ApplyResultSchema, CellResponseSchema, CheckboxModeSchema, CheckboxProgressCountsSchema, CheckboxValueSchema, CheckboxesFieldSchema, CheckboxesValueSchema, ClearFieldPatchSchema, ColumnTypeNameSchema, DateFieldSchema, DateValueSchema, DocumentationBlockSchema, DocumentationTagSchema, ExplicitCheckboxValueSchema, FieldGroupSchema, FieldKindSchema, FieldProgressSchema, FieldResponseSchema, FieldSchema, FieldValueSchema, FormHarness, FormSchemaSchema, HarnessConfigSchema, IdSchema, InspectIssueSchema, InspectResultSchema, IssueReasonSchema, IssueScopeSchema, MarkformFrontmatterSchema, MockAgent, MultiCheckboxStateSchema, MultiSelectFieldSchema, MultiSelectValueSchema, NumberFieldSchema, NumberValueSchema, OptionIdSchema, OptionSchema, ParseError, PatchSchema, ProgressCountsSchema, ProgressStateSchema, ProgressSummarySchema, SessionFinalSchema, SessionTranscriptSchema, SessionTurnSchema, SetCheckboxesPatchSchema, SetDatePatchSchema, SetMultiSelectPatchSchema, SetNumberPatchSchema, SetSingleSelectPatchSchema, SetStringListPatchSchema, SetStringPatchSchema, SetTablePatchSchema, SetUrlListPatchSchema, SetUrlPatchSchema, SetYearPatchSchema, SeveritySchema, SimpleCheckboxStateSchema, SingleSelectFieldSchema, SingleSelectValueSchema, SourcePositionSchema, SourceRangeSchema, StepResultSchema, StringFieldSchema, StringListFieldSchema, StringListValueSchema, StringValueSchema, StructureSummarySchema, TableColumnSchema, TableFieldSchema, TableRowPatchSchema, TableRowResponseSchema, TableValueSchema, UrlFieldSchema, UrlListFieldSchema, UrlListValueSchema, UrlValueSchema, VERSION, ValidationIssueSchema, ValidatorRefSchema, YearFieldSchema, YearValueSchema, applyPatches, coerceInputContext, coerceToFieldPatch, computeAllSummaries, computeFormState, computeProgressSummary, computeStructureSummary, createHarness, createMockAgent, fillForm, findFieldById, getFieldId, inspect, isCellRef, isFieldRef, isFormComplete, isQualifiedRef, isResearchForm, parseCellValue, parseForm, parseMarkdownTable, parseRawTable, parseScopeRef, parseSession, resolveHarnessConfig, runResearch, serialize, serializeScopeRef, serializeSession, validate, validateResearchForm };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as SessionTranscriptSchema } from "./coreTypes-pyctKRgc.mjs";
|
|
2
2
|
import YAML from "yaml";
|
|
3
3
|
|
|
4
4
|
//#region src/engine/session.ts
|
|
@@ -70,13 +70,15 @@ function camelToSnake(str) {
|
|
|
70
70
|
*/
|
|
71
71
|
function toCamelCaseDeep(obj, preserveKeys = false) {
|
|
72
72
|
if (obj === null || obj === void 0) return obj;
|
|
73
|
-
if (Array.isArray(obj)) return obj.map((item) => toCamelCaseDeep(item,
|
|
73
|
+
if (Array.isArray(obj)) return obj.map((item) => toCamelCaseDeep(item, preserveKeys));
|
|
74
74
|
if (typeof obj === "object") {
|
|
75
75
|
const result = {};
|
|
76
76
|
const record = obj;
|
|
77
77
|
for (const [key, value] of Object.entries(record)) {
|
|
78
78
|
const resultKey = preserveKeys ? key : snakeToCamel(key);
|
|
79
|
-
|
|
79
|
+
const isCheckboxValues = key === "values" && record.op === "set_checkboxes";
|
|
80
|
+
const isTableRows = key === "rows" && record.op === "set_table";
|
|
81
|
+
result[resultKey] = toCamelCaseDeep(value, isCheckboxValues || isTableRows);
|
|
80
82
|
}
|
|
81
83
|
return result;
|
|
82
84
|
}
|
|
@@ -93,13 +95,15 @@ function toCamelCaseDeep(obj, preserveKeys = false) {
|
|
|
93
95
|
*/
|
|
94
96
|
function toSnakeCaseDeep(obj, preserveKeys = false) {
|
|
95
97
|
if (obj === null || obj === void 0) return obj;
|
|
96
|
-
if (Array.isArray(obj)) return obj.map((item) => toSnakeCaseDeep(item,
|
|
98
|
+
if (Array.isArray(obj)) return obj.map((item) => toSnakeCaseDeep(item, preserveKeys));
|
|
97
99
|
if (typeof obj === "object") {
|
|
98
100
|
const result = {};
|
|
99
101
|
const record = obj;
|
|
100
102
|
for (const [key, value] of Object.entries(record)) {
|
|
101
103
|
const resultKey = preserveKeys ? key : camelToSnake(key);
|
|
102
|
-
|
|
104
|
+
const isCheckboxValues = key === "values" && record.op === "set_checkboxes";
|
|
105
|
+
const isTableRows = key === "rows" && record.op === "set_table";
|
|
106
|
+
result[resultKey] = toSnakeCaseDeep(value, isCheckboxValues || isTableRows);
|
|
103
107
|
}
|
|
104
108
|
return result;
|
|
105
109
|
}
|
|
@@ -2,6 +2,7 @@ import YAML from "yaml";
|
|
|
2
2
|
import { relative } from "node:path";
|
|
3
3
|
import pc from "picocolors";
|
|
4
4
|
import { mkdir } from "node:fs/promises";
|
|
5
|
+
import * as p from "@clack/prompts";
|
|
5
6
|
|
|
6
7
|
//#region src/cli/lib/naming.ts
|
|
7
8
|
/**
|
|
@@ -42,6 +43,86 @@ function convertKeysToSnakeCase(obj) {
|
|
|
42
43
|
//#endregion
|
|
43
44
|
//#region src/cli/lib/shared.ts
|
|
44
45
|
/**
|
|
46
|
+
* Format elapsed time for display.
|
|
47
|
+
*/
|
|
48
|
+
function formatElapsedTime(ms) {
|
|
49
|
+
const seconds = ms / 1e3;
|
|
50
|
+
if (seconds < 60) return `${seconds.toFixed(1)}s`;
|
|
51
|
+
return `${Math.floor(seconds / 60)}m ${(seconds % 60).toFixed(0)}s`;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Format spinner message based on context type.
|
|
55
|
+
*/
|
|
56
|
+
function formatSpinnerMessage(context, elapsedMs) {
|
|
57
|
+
const elapsed = formatElapsedTime(elapsedMs);
|
|
58
|
+
if (context.type === "api") {
|
|
59
|
+
const turnInfo = context.turnNumber !== void 0 ? ` turn ${context.turnNumber}` : "";
|
|
60
|
+
return `${context.provider}/${context.model}${turnInfo} ${pc.dim(`(${elapsed})`)}`;
|
|
61
|
+
}
|
|
62
|
+
return `${context.operation} ${pc.dim(`(${elapsed})`)}`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a context-aware spinner with elapsed time tracking.
|
|
66
|
+
*
|
|
67
|
+
* The spinner automatically updates its message with elapsed time.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const spinner = createSpinner({
|
|
72
|
+
* type: 'api',
|
|
73
|
+
* provider: 'anthropic',
|
|
74
|
+
* model: 'claude-sonnet-4',
|
|
75
|
+
* turnNumber: 1,
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // Do async work...
|
|
79
|
+
* const result = await agent.generatePatches(...);
|
|
80
|
+
*
|
|
81
|
+
* spinner.stop('Done');
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
function createSpinner(context) {
|
|
85
|
+
const startTime = Date.now();
|
|
86
|
+
const spinner = p.spinner();
|
|
87
|
+
let currentContext = context;
|
|
88
|
+
let intervalId = null;
|
|
89
|
+
const initialMessage = formatSpinnerMessage(currentContext, 0);
|
|
90
|
+
spinner.start(initialMessage);
|
|
91
|
+
intervalId = setInterval(() => {
|
|
92
|
+
const elapsed = Date.now() - startTime;
|
|
93
|
+
spinner.message(formatSpinnerMessage(currentContext, elapsed));
|
|
94
|
+
}, 1e3);
|
|
95
|
+
const cleanup = () => {
|
|
96
|
+
if (intervalId) {
|
|
97
|
+
clearInterval(intervalId);
|
|
98
|
+
intervalId = null;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return {
|
|
102
|
+
message(msg) {
|
|
103
|
+
spinner.message(msg);
|
|
104
|
+
},
|
|
105
|
+
update(newContext) {
|
|
106
|
+
currentContext = newContext;
|
|
107
|
+
const elapsed = Date.now() - startTime;
|
|
108
|
+
spinner.message(formatSpinnerMessage(currentContext, elapsed));
|
|
109
|
+
},
|
|
110
|
+
stop(msg) {
|
|
111
|
+
cleanup();
|
|
112
|
+
const elapsed = Date.now() - startTime;
|
|
113
|
+
const defaultMsg = formatSpinnerMessage(currentContext, elapsed);
|
|
114
|
+
spinner.stop(msg ?? `✓ ${defaultMsg}`);
|
|
115
|
+
},
|
|
116
|
+
error(msg) {
|
|
117
|
+
cleanup();
|
|
118
|
+
spinner.stop(pc.red(`✗ ${msg}`));
|
|
119
|
+
},
|
|
120
|
+
getElapsedMs() {
|
|
121
|
+
return Date.now() - startTime;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
45
126
|
* Valid format options for Commander choice validation.
|
|
46
127
|
*/
|
|
47
128
|
const OUTPUT_FORMATS = [
|
|
@@ -173,4 +254,4 @@ async function ensureFormsDir(formsDir) {
|
|
|
173
254
|
}
|
|
174
255
|
|
|
175
256
|
//#endregion
|
|
176
|
-
export {
|
|
257
|
+
export { formatPath as a, logError as c, logTiming as d, logVerbose as f, writeFile as g, shouldUseColors as h, formatOutput as i, logInfo as l, readFile$1 as m, createSpinner as n, getCommandContext as o, logWarn as p, ensureFormsDir as r, logDryRun as s, OUTPUT_FORMATS as t, logSuccess as u };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as formatPath, c as logError, d as logTiming, f as logVerbose, g as writeFile, h as shouldUseColors, i as formatOutput, l as logInfo, m as readFile, n as createSpinner, o as getCommandContext, p as logWarn, r as ensureFormsDir, s as logDryRun, t as OUTPUT_FORMATS, u as logSuccess } from "./shared-BqPnYXrn.mjs";
|
|
2
|
+
|
|
3
|
+
export { writeFile };
|