markform 0.1.10 → 0.1.12
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/ai-sdk.d.mts +1 -1
- package/dist/ai-sdk.mjs +3 -3
- package/dist/{apply-BTFCHpYV.mjs → apply-WeeBXwXg.mjs} +63 -31
- package/dist/bin.mjs +1 -1
- package/dist/{cli-BZa4fYR9.mjs → cli-R_mVVf4x.mjs} +37 -37
- package/dist/cli.mjs +1 -1
- package/dist/{coreTypes-JCPm418M.d.mts → coreTypes-Cw_cJsa5.d.mts} +30 -30
- package/dist/{coreTypes-B1oI7qvV.mjs → coreTypes-Z8SvQyoL.mjs} +6 -6
- package/dist/index.d.mts +51 -6
- package/dist/index.mjs +5 -5
- package/dist/{session-CzCh6JeY.mjs → session-BJe-hei3.mjs} +1 -1
- package/dist/{session-Dxqwt0RC.mjs → session-DX-DvjRP.mjs} +5 -5
- package/dist/{src-CYnyLwBe.mjs → src-DMQCFp2l.mjs} +75 -51
- package/docs/markform-apis.md +110 -8
- package/docs/markform-spec.md +33 -28
- package/examples/rejection-test/rejection-test.session.yaml +4 -4
- package/examples/simple/simple-mock-filled.schema.json +20 -16
- package/examples/simple/simple-skipped-filled.schema.json +20 -16
- package/examples/simple/simple-with-skips.session.yaml +17 -17
- package/examples/simple/simple.schema.json +20 -16
- package/examples/simple/simple.session.yaml +19 -19
- package/examples/startup-research/startup-research.form.md +34 -33
- package/package.json +1 -1
package/dist/ai-sdk.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { At as PatchSchema, Dt as ParsedForm, Ot as Patch, Q as Id, V as FieldResponse, dr as ValidatorRegistry, q as FormSchema, r as ApplyResult, rt as InspectResult } from "./coreTypes-
|
|
2
|
+
import { At as PatchSchema, Dt as ParsedForm, Ot as Patch, Q as Id, V as FieldResponse, dr as ValidatorRegistry, q as FormSchema, r as ApplyResult, rt as InspectResult } from "./coreTypes-Cw_cJsa5.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/integrations/toolTypes.d.ts
|
package/dist/ai-sdk.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import { L as PatchSchema } from "./coreTypes-
|
|
3
|
-
import { d as
|
|
2
|
+
import { L as PatchSchema } from "./coreTypes-Z8SvQyoL.mjs";
|
|
3
|
+
import { d as serializeForm, i as inspect, t as applyPatches } from "./apply-WeeBXwXg.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
//#region src/integrations/vercelAiSdkTools.ts
|
|
@@ -151,7 +151,7 @@ function createMarkformTools(options) {
|
|
|
151
151
|
description: "Get the canonical Markdown representation of the current form. Use this to see the complete form with all current values in Markform format. The output is deterministic and round-trip safe.",
|
|
152
152
|
inputSchema: GetMarkdownInputSchema,
|
|
153
153
|
execute: () => {
|
|
154
|
-
const markdown =
|
|
154
|
+
const markdown = serializeForm(sessionStore.getForm());
|
|
155
155
|
return Promise.resolve({
|
|
156
156
|
success: true,
|
|
157
157
|
data: { markdown },
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import YAML from "yaml";
|
|
3
3
|
|
|
4
4
|
//#region src/errors.ts
|
|
5
|
-
const VERSION = "0.1.
|
|
5
|
+
const VERSION = "0.1.12";
|
|
6
6
|
/**
|
|
7
7
|
* Base error class for all markform errors.
|
|
8
8
|
* Consumers can catch this to handle any markform error.
|
|
@@ -1121,7 +1121,7 @@ function buildFrontmatter(metadata, specVersion) {
|
|
|
1121
1121
|
* @param opts - Serialization options
|
|
1122
1122
|
* @returns The canonical markdown string
|
|
1123
1123
|
*/
|
|
1124
|
-
function
|
|
1124
|
+
function serializeForm(form, opts) {
|
|
1125
1125
|
const specVersion = opts?.specVersion ?? MF_SPEC_VERSION;
|
|
1126
1126
|
return `${buildFrontmatter(form.metadata, specVersion)}\n\n${serializeFormSchema(form.schema, form.responsesByFieldId, form.docs, form.notes)}\n`;
|
|
1127
1127
|
}
|
|
@@ -1292,7 +1292,7 @@ function shouldIncludeDoc(doc) {
|
|
|
1292
1292
|
* @param form - The parsed form to serialize
|
|
1293
1293
|
* @returns Filtered plain markdown string suitable for sharing
|
|
1294
1294
|
*/
|
|
1295
|
-
function
|
|
1295
|
+
function serializeReport(form) {
|
|
1296
1296
|
const lines = [];
|
|
1297
1297
|
const docsByRef = /* @__PURE__ */ new Map();
|
|
1298
1298
|
for (const doc of form.docs) {
|
|
@@ -2618,6 +2618,36 @@ function findField(form, fieldId) {
|
|
|
2618
2618
|
for (const group of form.schema.groups) for (const field of group.children) if (field.id === fieldId) return field;
|
|
2619
2619
|
}
|
|
2620
2620
|
/**
|
|
2621
|
+
* Coerce a boolean value to the appropriate checkbox string based on mode.
|
|
2622
|
+
*/
|
|
2623
|
+
function coerceBooleanToCheckboxValue(value, mode) {
|
|
2624
|
+
if (mode === "explicit") return value ? "yes" : "no";
|
|
2625
|
+
return value ? "done" : "todo";
|
|
2626
|
+
}
|
|
2627
|
+
/**
|
|
2628
|
+
* Normalize a patch, coercing boolean checkbox values to strings.
|
|
2629
|
+
* Returns a new patch with normalized values, or the original if no normalization needed.
|
|
2630
|
+
*/
|
|
2631
|
+
function normalizePatch(form, patch) {
|
|
2632
|
+
if (patch.op !== "set_checkboxes") return patch;
|
|
2633
|
+
const field = findField(form, patch.fieldId);
|
|
2634
|
+
if (field?.kind !== "checkboxes") return patch;
|
|
2635
|
+
if (!patch.value) return patch;
|
|
2636
|
+
let needsNormalization = false;
|
|
2637
|
+
for (const value of Object.values(patch.value)) if (typeof value === "boolean") {
|
|
2638
|
+
needsNormalization = true;
|
|
2639
|
+
break;
|
|
2640
|
+
}
|
|
2641
|
+
if (!needsNormalization) return patch;
|
|
2642
|
+
const normalizedValues = {};
|
|
2643
|
+
for (const [optId, value] of Object.entries(patch.value)) if (typeof value === "boolean") normalizedValues[optId] = coerceBooleanToCheckboxValue(value, field.checkboxMode);
|
|
2644
|
+
else normalizedValues[optId] = value;
|
|
2645
|
+
return {
|
|
2646
|
+
...patch,
|
|
2647
|
+
value: normalizedValues
|
|
2648
|
+
};
|
|
2649
|
+
}
|
|
2650
|
+
/**
|
|
2621
2651
|
* Create a type mismatch error with field metadata for LLM guidance.
|
|
2622
2652
|
*/
|
|
2623
2653
|
function typeMismatchError(index, op, field) {
|
|
@@ -2655,60 +2685,61 @@ function validatePatch(form, patch, index) {
|
|
|
2655
2685
|
const expectedKind = PATCH_OP_TO_FIELD_KIND[patch.op];
|
|
2656
2686
|
if (expectedKind && field.kind !== expectedKind) return typeMismatchError(index, patch.op, field);
|
|
2657
2687
|
if (patch.op === "set_string_list" && field.kind === "string_list") {
|
|
2658
|
-
if (!Array.isArray(patch.
|
|
2688
|
+
if (!Array.isArray(patch.value)) return {
|
|
2659
2689
|
patchIndex: index,
|
|
2660
|
-
message: `Invalid set_string_list patch for field "${field.id}":
|
|
2690
|
+
message: `Invalid set_string_list patch for field "${field.id}": value must be an array of strings`,
|
|
2661
2691
|
fieldId: field.id,
|
|
2662
2692
|
fieldKind: field.kind
|
|
2663
2693
|
};
|
|
2664
2694
|
} else if (patch.op === "set_single_select" && field.kind === "single_select") {
|
|
2665
|
-
if (patch.
|
|
2666
|
-
if (!new Set(field.options.map((o) => o.id)).has(patch.
|
|
2695
|
+
if (patch.value !== null) {
|
|
2696
|
+
if (!new Set(field.options.map((o) => o.id)).has(patch.value)) return {
|
|
2667
2697
|
patchIndex: index,
|
|
2668
|
-
message: `Invalid option "${patch.
|
|
2698
|
+
message: `Invalid option "${patch.value}" for field "${field.id}"`
|
|
2669
2699
|
};
|
|
2670
2700
|
}
|
|
2671
2701
|
} else if (patch.op === "set_multi_select" && field.kind === "multi_select") {
|
|
2672
|
-
if (!Array.isArray(patch.
|
|
2702
|
+
if (!Array.isArray(patch.value)) return {
|
|
2673
2703
|
patchIndex: index,
|
|
2674
|
-
message: `Invalid set_multi_select patch for field "${field.id}":
|
|
2704
|
+
message: `Invalid set_multi_select patch for field "${field.id}": value must be an array of option IDs`,
|
|
2675
2705
|
fieldId: field.id,
|
|
2676
2706
|
fieldKind: field.kind
|
|
2677
2707
|
};
|
|
2678
2708
|
const validOptions = new Set(field.options.map((o) => o.id));
|
|
2679
|
-
for (const optId of patch.
|
|
2709
|
+
for (const optId of patch.value) if (!validOptions.has(optId)) return {
|
|
2680
2710
|
patchIndex: index,
|
|
2681
2711
|
message: `Invalid option "${optId}" for field "${field.id}"`
|
|
2682
2712
|
};
|
|
2683
2713
|
} else if (patch.op === "set_checkboxes" && field.kind === "checkboxes") {
|
|
2684
|
-
if (patch.
|
|
2714
|
+
if (patch.value == null || typeof patch.value !== "object" || Array.isArray(patch.value)) return {
|
|
2685
2715
|
patchIndex: index,
|
|
2686
|
-
message: `Invalid set_checkboxes patch for field "${field.id}":
|
|
2716
|
+
message: `Invalid set_checkboxes patch for field "${field.id}": value must be an object mapping option IDs to checkbox state strings (e.g. "todo", "done", "yes", "no")`,
|
|
2687
2717
|
fieldId: field.id,
|
|
2688
2718
|
fieldKind: field.kind
|
|
2689
2719
|
};
|
|
2690
2720
|
const validOptions = new Set(field.options.map((o) => o.id));
|
|
2691
|
-
for (const optId of Object.keys(patch.
|
|
2721
|
+
for (const optId of Object.keys(patch.value)) if (!validOptions.has(optId)) return {
|
|
2692
2722
|
patchIndex: index,
|
|
2693
2723
|
message: `Invalid option "${optId}" for field "${field.id}"`
|
|
2694
2724
|
};
|
|
2695
2725
|
} else if (patch.op === "set_url_list" && field.kind === "url_list") {
|
|
2696
|
-
if (!Array.isArray(patch.
|
|
2726
|
+
if (!Array.isArray(patch.value)) return {
|
|
2697
2727
|
patchIndex: index,
|
|
2698
|
-
message: `Invalid set_url_list patch for field "${field.id}":
|
|
2728
|
+
message: `Invalid set_url_list patch for field "${field.id}": value must be an array of URLs`,
|
|
2699
2729
|
fieldId: field.id,
|
|
2700
2730
|
fieldKind: field.kind
|
|
2701
2731
|
};
|
|
2702
2732
|
} else if (patch.op === "set_table" && field.kind === "table") {
|
|
2703
|
-
|
|
2733
|
+
const columnIds = field.columns.map((c) => c.id);
|
|
2734
|
+
if (!Array.isArray(patch.value)) return {
|
|
2704
2735
|
patchIndex: index,
|
|
2705
|
-
message: `Invalid set_table patch for field "${field.id}":
|
|
2736
|
+
message: `Invalid set_table patch for field "${field.id}": value must be an array of row objects. Each row should map column IDs to values. Columns: [${columnIds.join(", ")}]`,
|
|
2706
2737
|
fieldId: field.id,
|
|
2707
2738
|
fieldKind: field.kind,
|
|
2708
|
-
columnIds
|
|
2739
|
+
columnIds
|
|
2709
2740
|
};
|
|
2710
|
-
const validColumns = new Set(
|
|
2711
|
-
for (const row of patch.
|
|
2741
|
+
const validColumns = new Set(columnIds);
|
|
2742
|
+
for (const row of patch.value) if (row != null) {
|
|
2712
2743
|
for (const colId of Object.keys(row)) if (!validColumns.has(colId)) return {
|
|
2713
2744
|
patchIndex: index,
|
|
2714
2745
|
message: `Invalid column "${colId}" for table field "${field.id}"`
|
|
@@ -2839,16 +2870,16 @@ function applyPatch(form, responses, patch) {
|
|
|
2839
2870
|
setSimpleValue(responses, patch.fieldId, "year", patch.value);
|
|
2840
2871
|
break;
|
|
2841
2872
|
case "set_string_list":
|
|
2842
|
-
setListValue(responses, patch.fieldId, "string_list", patch.
|
|
2873
|
+
setListValue(responses, patch.fieldId, "string_list", patch.value);
|
|
2843
2874
|
break;
|
|
2844
2875
|
case "set_url_list":
|
|
2845
|
-
setListValue(responses, patch.fieldId, "url_list", patch.
|
|
2876
|
+
setListValue(responses, patch.fieldId, "url_list", patch.value);
|
|
2846
2877
|
break;
|
|
2847
2878
|
case "set_single_select":
|
|
2848
|
-
setSingleSelectValue(responses, patch.fieldId, patch.
|
|
2879
|
+
setSingleSelectValue(responses, patch.fieldId, patch.value);
|
|
2849
2880
|
break;
|
|
2850
2881
|
case "set_multi_select":
|
|
2851
|
-
setMultiSelectValue(responses, patch.fieldId, patch.
|
|
2882
|
+
setMultiSelectValue(responses, patch.fieldId, patch.value);
|
|
2852
2883
|
break;
|
|
2853
2884
|
case "set_checkboxes": {
|
|
2854
2885
|
const existing = (responses[patch.fieldId]?.value)?.values ?? {};
|
|
@@ -2858,16 +2889,16 @@ function applyPatch(form, responses, patch) {
|
|
|
2858
2889
|
kind: "checkboxes",
|
|
2859
2890
|
values: {
|
|
2860
2891
|
...existing,
|
|
2861
|
-
...patch.
|
|
2892
|
+
...patch.value
|
|
2862
2893
|
}
|
|
2863
2894
|
}
|
|
2864
2895
|
};
|
|
2865
2896
|
break;
|
|
2866
2897
|
}
|
|
2867
2898
|
case "set_table": {
|
|
2868
|
-
const rows = (patch.
|
|
2899
|
+
const rows = (patch.value ?? []).map((patchRow) => {
|
|
2869
2900
|
const row = {};
|
|
2870
|
-
if (patchRow != null) for (const [colId,
|
|
2901
|
+
if (patchRow != null) for (const [colId, cellValue] of Object.entries(patchRow)) row[colId] = patchValueToCell(cellValue);
|
|
2871
2902
|
return row;
|
|
2872
2903
|
});
|
|
2873
2904
|
responses[patch.fieldId] = {
|
|
@@ -2938,7 +2969,8 @@ function convertToInspectIssues(form) {
|
|
|
2938
2969
|
* @returns Apply result with new summaries and status
|
|
2939
2970
|
*/
|
|
2940
2971
|
function applyPatches(form, patches) {
|
|
2941
|
-
const
|
|
2972
|
+
const normalizedPatches = patches.map((p) => normalizePatch(form, p));
|
|
2973
|
+
const errors = validatePatches(form, normalizedPatches);
|
|
2942
2974
|
if (errors.length > 0) {
|
|
2943
2975
|
const issues$1 = convertToInspectIssues(form);
|
|
2944
2976
|
const summaries$1 = computeAllSummaries(form.schema, form.responsesByFieldId, form.notes, issues$1);
|
|
@@ -2956,7 +2988,7 @@ function applyPatches(form, patches) {
|
|
|
2956
2988
|
const newNotes = [...form.notes];
|
|
2957
2989
|
form.notes;
|
|
2958
2990
|
form.notes = newNotes;
|
|
2959
|
-
for (const patch of
|
|
2991
|
+
for (const patch of normalizedPatches) applyPatch(form, newResponses, patch);
|
|
2960
2992
|
form.responsesByFieldId = newResponses;
|
|
2961
2993
|
const issues = convertToInspectIssues(form);
|
|
2962
2994
|
const summaries = computeAllSummaries(form.schema, newResponses, newNotes, issues);
|
|
@@ -2972,4 +3004,4 @@ function applyPatches(form, patches) {
|
|
|
2972
3004
|
}
|
|
2973
3005
|
|
|
2974
3006
|
//#endregion
|
|
2975
|
-
export { isPatchError as $, deriveReportPath as A, MarkformAbortError as B, DEFAULT_RESEARCH_MAX_PATCHES_PER_TURN as C, REPORT_EXTENSION as D, MAX_FORMS_IN_MENU as E, WEB_SEARCH_CONFIG as F, MarkformPatchError as G, MarkformError as H, formatSuggestedLlms as I, isAbortError as J, MarkformValidationError as K, getWebSearchConfig as L, detectFileType as M, parseRolesFlag as N, USER_ROLE as O, SUGGESTED_LLMS as P, isParseError as Q, hasWebSearchSupport as R, DEFAULT_RESEARCH_MAX_ISSUES_PER_TURN as S, DEFAULT_ROLE_INSTRUCTIONS as T, MarkformLlmError as U, MarkformConfigError as V, MarkformParseError as W, isLlmError as X, isConfigError as Y, isMarkformError as Z, DEFAULT_MAX_ISSUES_PER_TURN as _, validate as a, DEFAULT_PORT as b, computeProgressSummary as c,
|
|
3007
|
+
export { isPatchError as $, deriveReportPath as A, MarkformAbortError as B, DEFAULT_RESEARCH_MAX_PATCHES_PER_TURN as C, REPORT_EXTENSION as D, MAX_FORMS_IN_MENU as E, WEB_SEARCH_CONFIG as F, MarkformPatchError as G, MarkformError as H, formatSuggestedLlms as I, isAbortError as J, MarkformValidationError as K, getWebSearchConfig as L, detectFileType as M, parseRolesFlag as N, USER_ROLE as O, SUGGESTED_LLMS as P, isParseError as Q, hasWebSearchSupport as R, DEFAULT_RESEARCH_MAX_ISSUES_PER_TURN as S, DEFAULT_ROLE_INSTRUCTIONS as T, MarkformLlmError as U, MarkformConfigError as V, MarkformParseError as W, isLlmError as X, isConfigError as Y, isMarkformError as Z, DEFAULT_MAX_ISSUES_PER_TURN as _, validate as a, DEFAULT_PORT as b, computeProgressSummary as c, serializeForm as d, isRetryableError as et, serializeRawMarkdown as f, DEFAULT_FORMS_DIR as g, ALL_EXTENSIONS as h, inspect as i, deriveSchemaPath as j, deriveExportPath as k, computeStructureSummary as l, AGENT_ROLE as m, getAllFields as n, computeAllSummaries as o, serializeReport as p, ParseError as q, getFieldsForRoles as r, computeFormState as s, applyPatches as t, isValidationError as tt, isFormComplete as u, DEFAULT_MAX_PATCHES_PER_TURN as v, DEFAULT_ROLES as w, DEFAULT_PRIORITY as x, DEFAULT_MAX_TURNS as y, parseModelIdForDisplay as z };
|
package/dist/bin.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import { L as PatchSchema } from "./coreTypes-
|
|
3
|
-
import { A as deriveReportPath, C as DEFAULT_RESEARCH_MAX_PATCHES_PER_TURN, D as REPORT_EXTENSION, E as MAX_FORMS_IN_MENU, F as WEB_SEARCH_CONFIG, I as formatSuggestedLlms, M as detectFileType, N as parseRolesFlag, O as USER_ROLE, P as SUGGESTED_LLMS, R as hasWebSearchSupport, S as DEFAULT_RESEARCH_MAX_ISSUES_PER_TURN, _ as DEFAULT_MAX_ISSUES_PER_TURN, b as DEFAULT_PORT, d as
|
|
4
|
-
import { D as parseForm, E as formToJsonSchema, a as resolveHarnessConfig, c as getProviderNames, d as createLiveAgent, h as createHarness, i as runResearch, l as resolveModel, n as isResearchForm, o as fillForm, p as createMockAgent, s as getProviderInfo, t as VERSION, u as buildMockWireFormat } from "./src-
|
|
5
|
-
import { n as serializeSession } from "./session-
|
|
2
|
+
import { L as PatchSchema } from "./coreTypes-Z8SvQyoL.mjs";
|
|
3
|
+
import { A as deriveReportPath, C as DEFAULT_RESEARCH_MAX_PATCHES_PER_TURN, D as REPORT_EXTENSION, E as MAX_FORMS_IN_MENU, F as WEB_SEARCH_CONFIG, I as formatSuggestedLlms, M as detectFileType, N as parseRolesFlag, O as USER_ROLE, P as SUGGESTED_LLMS, R as hasWebSearchSupport, S as DEFAULT_RESEARCH_MAX_ISSUES_PER_TURN, _ as DEFAULT_MAX_ISSUES_PER_TURN, b as DEFAULT_PORT, d as serializeForm, f as serializeRawMarkdown, g as DEFAULT_FORMS_DIR, h as ALL_EXTENSIONS, i as inspect, j as deriveSchemaPath, k as deriveExportPath, m as AGENT_ROLE, n as getAllFields, p as serializeReport, t as applyPatches, v as DEFAULT_MAX_PATCHES_PER_TURN, y as DEFAULT_MAX_TURNS, z as parseModelIdForDisplay } from "./apply-WeeBXwXg.mjs";
|
|
4
|
+
import { D as parseForm, E as formToJsonSchema, a as resolveHarnessConfig, c as getProviderNames, d as createLiveAgent, h as createHarness, i as runResearch, l as resolveModel, n as isResearchForm, o as fillForm, p as createMockAgent, s as getProviderInfo, t as VERSION, u as buildMockWireFormat } from "./src-DMQCFp2l.mjs";
|
|
5
|
+
import { n as serializeSession } from "./session-DX-DvjRP.mjs";
|
|
6
6
|
import { a as formatPath, c as logError, d as logTiming, f as logVerbose, g as writeFile, i as formatOutput, l as logInfo, m as readFile$1, n as createSpinner, o as getCommandContext, p as logWarn, r as ensureFormsDir, s as logDryRun, t as OUTPUT_FORMATS, u as logSuccess } from "./shared-D3dNi-Gn.mjs";
|
|
7
7
|
import Markdoc from "@markdoc/markdoc";
|
|
8
8
|
import YAML from "yaml";
|
|
@@ -293,7 +293,7 @@ function registerApplyCommand(program) {
|
|
|
293
293
|
logSuccess(ctx, `Report written to ${options.output}`);
|
|
294
294
|
} else console.log(output);
|
|
295
295
|
} else {
|
|
296
|
-
const output =
|
|
296
|
+
const output = serializeForm(form);
|
|
297
297
|
if (options.output) {
|
|
298
298
|
await writeFile(options.output, output);
|
|
299
299
|
logSuccess(ctx, `Modified form written to ${options.output}`);
|
|
@@ -898,7 +898,7 @@ function deriveExportPaths(basePath) {
|
|
|
898
898
|
*/
|
|
899
899
|
async function exportMultiFormat(form, basePath) {
|
|
900
900
|
const paths = deriveExportPaths(basePath);
|
|
901
|
-
const reportContent =
|
|
901
|
+
const reportContent = serializeReport(form);
|
|
902
902
|
await writeFile(paths.reportPath, reportContent);
|
|
903
903
|
const values = toStructuredValues(form);
|
|
904
904
|
const notes = toNotesArray(form);
|
|
@@ -908,7 +908,7 @@ async function exportMultiFormat(form, basePath) {
|
|
|
908
908
|
};
|
|
909
909
|
const yamlContent = YAML.stringify(exportData);
|
|
910
910
|
await writeFile(paths.yamlPath, yamlContent);
|
|
911
|
-
const formContent =
|
|
911
|
+
const formContent = serializeForm(form);
|
|
912
912
|
await writeFile(paths.formPath, formContent);
|
|
913
913
|
const schemaResult = formToJsonSchema(form);
|
|
914
914
|
const schemaContent = JSON.stringify(schemaResult.schema, null, 2) + "\n";
|
|
@@ -1530,7 +1530,7 @@ async function promptForStringList(ctx) {
|
|
|
1530
1530
|
return {
|
|
1531
1531
|
op: "set_string_list",
|
|
1532
1532
|
fieldId: field.id,
|
|
1533
|
-
items
|
|
1533
|
+
value: items
|
|
1534
1534
|
};
|
|
1535
1535
|
}
|
|
1536
1536
|
/**
|
|
@@ -1552,7 +1552,7 @@ async function promptForSingleSelect(ctx) {
|
|
|
1552
1552
|
return {
|
|
1553
1553
|
op: "set_single_select",
|
|
1554
1554
|
fieldId: field.id,
|
|
1555
|
-
|
|
1555
|
+
value: result
|
|
1556
1556
|
};
|
|
1557
1557
|
}
|
|
1558
1558
|
/**
|
|
@@ -1575,7 +1575,7 @@ async function promptForMultiSelect(ctx) {
|
|
|
1575
1575
|
return {
|
|
1576
1576
|
op: "set_multi_select",
|
|
1577
1577
|
fieldId: field.id,
|
|
1578
|
-
|
|
1578
|
+
value: result
|
|
1579
1579
|
};
|
|
1580
1580
|
}
|
|
1581
1581
|
/**
|
|
@@ -1608,7 +1608,7 @@ async function promptForCheckboxes(ctx) {
|
|
|
1608
1608
|
return {
|
|
1609
1609
|
op: "set_checkboxes",
|
|
1610
1610
|
fieldId: field.id,
|
|
1611
|
-
|
|
1611
|
+
value: values$1
|
|
1612
1612
|
};
|
|
1613
1613
|
}
|
|
1614
1614
|
if (field.checkboxMode === "explicit") {
|
|
@@ -1639,7 +1639,7 @@ async function promptForCheckboxes(ctx) {
|
|
|
1639
1639
|
return {
|
|
1640
1640
|
op: "set_checkboxes",
|
|
1641
1641
|
fieldId: field.id,
|
|
1642
|
-
|
|
1642
|
+
value: values$1
|
|
1643
1643
|
};
|
|
1644
1644
|
}
|
|
1645
1645
|
const values = {};
|
|
@@ -1677,7 +1677,7 @@ async function promptForCheckboxes(ctx) {
|
|
|
1677
1677
|
return {
|
|
1678
1678
|
op: "set_checkboxes",
|
|
1679
1679
|
fieldId: field.id,
|
|
1680
|
-
values
|
|
1680
|
+
value: values
|
|
1681
1681
|
};
|
|
1682
1682
|
}
|
|
1683
1683
|
/**
|
|
@@ -1813,7 +1813,7 @@ async function promptForUrlList(ctx) {
|
|
|
1813
1813
|
return {
|
|
1814
1814
|
op: "set_url_list",
|
|
1815
1815
|
fieldId: field.id,
|
|
1816
|
-
items
|
|
1816
|
+
value: items
|
|
1817
1817
|
};
|
|
1818
1818
|
}
|
|
1819
1819
|
/**
|
|
@@ -1942,19 +1942,19 @@ function formatPatchValue(patch) {
|
|
|
1942
1942
|
switch (patch.op) {
|
|
1943
1943
|
case "set_string": return patch.value ? truncate(`"${patch.value}"`) : "(empty)";
|
|
1944
1944
|
case "set_number": return patch.value !== null ? String(patch.value) : "(empty)";
|
|
1945
|
-
case "set_string_list": return patch.
|
|
1946
|
-
case "set_single_select": return patch.
|
|
1947
|
-
case "set_multi_select": return patch.
|
|
1948
|
-
case "set_checkboxes": return truncate(Object.entries(patch.
|
|
1945
|
+
case "set_string_list": return patch.value.length > 0 ? truncate(`[${patch.value.join(", ")}]`) : "(empty)";
|
|
1946
|
+
case "set_single_select": return patch.value ?? "(none)";
|
|
1947
|
+
case "set_multi_select": return patch.value.length > 0 ? truncate(`[${patch.value.join(", ")}]`) : "(none)";
|
|
1948
|
+
case "set_checkboxes": return truncate(Object.entries(patch.value).map(([k, v]) => `${k}:${v}`).join(", "));
|
|
1949
1949
|
case "clear_field": return "(cleared)";
|
|
1950
1950
|
case "skip_field": return patch.reason ? truncate(`(skipped: ${patch.reason})`) : "(skipped)";
|
|
1951
1951
|
case "abort_field": return patch.reason ? truncate(`(aborted: ${patch.reason})`) : "(aborted)";
|
|
1952
1952
|
case "set_url": return patch.value ? truncate(`"${patch.value}"`) : "(empty)";
|
|
1953
|
-
case "set_url_list": return patch.
|
|
1953
|
+
case "set_url_list": return patch.value.length > 0 ? truncate(`[${patch.value.join(", ")}]`) : "(empty)";
|
|
1954
1954
|
case "set_date": return patch.value ? truncate(`"${patch.value}"`) : "(empty)";
|
|
1955
1955
|
case "set_year": return patch.value !== null ? String(patch.value) : "(empty)";
|
|
1956
1956
|
case "set_table": {
|
|
1957
|
-
const rowCount = patch.
|
|
1957
|
+
const rowCount = patch.value?.length ?? 0;
|
|
1958
1958
|
return rowCount > 0 ? truncate(`[${rowCount} rows]`) : "(empty)";
|
|
1959
1959
|
}
|
|
1960
1960
|
case "add_note": return truncate(`note: ${patch.text}`);
|
|
@@ -2253,7 +2253,7 @@ async function runAgentFillWorkflow(form, modelId, formsDir, filePath, isResearc
|
|
|
2253
2253
|
const result = await fillForm({
|
|
2254
2254
|
form,
|
|
2255
2255
|
model: modelId,
|
|
2256
|
-
maxTurns,
|
|
2256
|
+
maxTurnsTotal: maxTurns,
|
|
2257
2257
|
maxPatchesPerTurn,
|
|
2258
2258
|
maxIssuesPerTurn,
|
|
2259
2259
|
targetRoles: [AGENT_ROLE],
|
|
@@ -2632,7 +2632,7 @@ function registerExportCommand(program) {
|
|
|
2632
2632
|
logVerbose(ctx, "Parsing form...");
|
|
2633
2633
|
const form = parseForm(content);
|
|
2634
2634
|
if (format === "markform") {
|
|
2635
|
-
console.log(
|
|
2635
|
+
console.log(serializeForm(form));
|
|
2636
2636
|
return;
|
|
2637
2637
|
}
|
|
2638
2638
|
if (format === "markdown") {
|
|
@@ -2665,7 +2665,7 @@ function registerExportCommand(program) {
|
|
|
2665
2665
|
schema,
|
|
2666
2666
|
values,
|
|
2667
2667
|
notes: form.notes,
|
|
2668
|
-
markdown:
|
|
2668
|
+
markdown: serializeForm(form)
|
|
2669
2669
|
};
|
|
2670
2670
|
if (format === "json") if (options.compact) console.log(JSON.stringify(output));
|
|
2671
2671
|
else console.log(JSON.stringify(output, null, 2));
|
|
@@ -2988,7 +2988,7 @@ function registerFillCommand(program) {
|
|
|
2988
2988
|
await ensureFormsDir(formsDir);
|
|
2989
2989
|
outputPath = generateVersionedPathInFormsDir(filePath, formsDir);
|
|
2990
2990
|
}
|
|
2991
|
-
const formMarkdown =
|
|
2991
|
+
const formMarkdown = serializeForm(harness.getForm());
|
|
2992
2992
|
if (ctx.dryRun) logInfo(ctx, `[DRY RUN] Would write form to: ${outputPath}`);
|
|
2993
2993
|
else {
|
|
2994
2994
|
await writeFile(outputPath, formMarkdown);
|
|
@@ -3356,7 +3356,7 @@ function registerReportCommand(program) {
|
|
|
3356
3356
|
logVerbose(ctx, "Parsing form...");
|
|
3357
3357
|
const form = parseForm(content);
|
|
3358
3358
|
logVerbose(ctx, "Generating report...");
|
|
3359
|
-
const reportContent =
|
|
3359
|
+
const reportContent = serializeReport(form);
|
|
3360
3360
|
if (options.output) {
|
|
3361
3361
|
let outputPath = options.output;
|
|
3362
3362
|
if (!outputPath.endsWith(REPORT_EXTENSION) && !outputPath.endsWith(".md")) outputPath = outputPath + REPORT_EXTENSION;
|
|
@@ -3747,7 +3747,7 @@ function formDataToPatches(formData, form) {
|
|
|
3747
3747
|
if (items.length > 0) patches.push({
|
|
3748
3748
|
op: "set_string_list",
|
|
3749
3749
|
fieldId,
|
|
3750
|
-
items
|
|
3750
|
+
value: items
|
|
3751
3751
|
});
|
|
3752
3752
|
else patches.push({
|
|
3753
3753
|
op: "clear_field",
|
|
@@ -3764,7 +3764,7 @@ function formDataToPatches(formData, form) {
|
|
|
3764
3764
|
if (typeof value === "string" && value !== "") patches.push({
|
|
3765
3765
|
op: "set_single_select",
|
|
3766
3766
|
fieldId,
|
|
3767
|
-
|
|
3767
|
+
value
|
|
3768
3768
|
});
|
|
3769
3769
|
else patches.push({
|
|
3770
3770
|
op: "clear_field",
|
|
@@ -3778,7 +3778,7 @@ function formDataToPatches(formData, form) {
|
|
|
3778
3778
|
if (selected.length > 0 && selected[0] !== "") patches.push({
|
|
3779
3779
|
op: "set_multi_select",
|
|
3780
3780
|
fieldId,
|
|
3781
|
-
selected
|
|
3781
|
+
value: selected
|
|
3782
3782
|
});
|
|
3783
3783
|
else patches.push({
|
|
3784
3784
|
op: "clear_field",
|
|
@@ -3790,12 +3790,12 @@ function formDataToPatches(formData, form) {
|
|
|
3790
3790
|
if ((field.checkboxMode ?? "multi") === "simple") {
|
|
3791
3791
|
const value = formData[fieldId];
|
|
3792
3792
|
const checked = Array.isArray(value) ? value : value ? [value] : [];
|
|
3793
|
-
const
|
|
3794
|
-
for (const opt of field.options)
|
|
3793
|
+
const checkboxValues = {};
|
|
3794
|
+
for (const opt of field.options) checkboxValues[opt.id] = checked.includes(opt.id) ? "done" : "todo";
|
|
3795
3795
|
patches.push({
|
|
3796
3796
|
op: "set_checkboxes",
|
|
3797
3797
|
fieldId,
|
|
3798
|
-
|
|
3798
|
+
value: checkboxValues
|
|
3799
3799
|
});
|
|
3800
3800
|
} else {
|
|
3801
3801
|
const values = {};
|
|
@@ -3806,7 +3806,7 @@ function formDataToPatches(formData, form) {
|
|
|
3806
3806
|
if (Object.keys(values).length > 0) patches.push({
|
|
3807
3807
|
op: "set_checkboxes",
|
|
3808
3808
|
fieldId,
|
|
3809
|
-
values
|
|
3809
|
+
value: values
|
|
3810
3810
|
});
|
|
3811
3811
|
}
|
|
3812
3812
|
break;
|
|
@@ -3830,7 +3830,7 @@ function formDataToPatches(formData, form) {
|
|
|
3830
3830
|
if (items.length > 0) patches.push({
|
|
3831
3831
|
op: "set_url_list",
|
|
3832
3832
|
fieldId,
|
|
3833
|
-
items
|
|
3833
|
+
value: items
|
|
3834
3834
|
});
|
|
3835
3835
|
else patches.push({
|
|
3836
3836
|
op: "clear_field",
|
|
@@ -3889,7 +3889,7 @@ async function handleSave(req, res, form, filePath, ctx, updateForm) {
|
|
|
3889
3889
|
applyPatches(form, formDataToPatches(parseFormBody(Buffer.concat(chunks).toString("utf-8")), form));
|
|
3890
3890
|
updateForm(form);
|
|
3891
3891
|
const newPath = generateVersionedPath(filePath);
|
|
3892
|
-
const content =
|
|
3892
|
+
const content = serializeForm(form);
|
|
3893
3893
|
if (ctx.dryRun) {
|
|
3894
3894
|
logInfo(ctx, `[DRY RUN] Would save to: ${newPath}`);
|
|
3895
3895
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
@@ -4999,7 +4999,7 @@ function parseInitialValues(inputs) {
|
|
|
4999
4999
|
patches.push({
|
|
5000
5000
|
op: "set_string_list",
|
|
5001
5001
|
fieldId,
|
|
5002
|
-
items
|
|
5002
|
+
value: items
|
|
5003
5003
|
});
|
|
5004
5004
|
} else patches.push({
|
|
5005
5005
|
op: "set_string",
|
|
@@ -5089,7 +5089,7 @@ function registerResearchCommand(program) {
|
|
|
5089
5089
|
model: modelId,
|
|
5090
5090
|
enableWebSearch: true,
|
|
5091
5091
|
captureWireFormat: false,
|
|
5092
|
-
maxTurns,
|
|
5092
|
+
maxTurnsTotal: maxTurns,
|
|
5093
5093
|
maxPatchesPerTurn,
|
|
5094
5094
|
maxIssuesPerTurn,
|
|
5095
5095
|
targetRoles: [AGENT_ROLE],
|
|
@@ -5111,7 +5111,7 @@ function registerResearchCommand(program) {
|
|
|
5111
5111
|
console.log(` ${formPath} ${pc.dim("(filled markform source)")}`);
|
|
5112
5112
|
console.log(` ${schemaPath} ${pc.dim("(JSON Schema)")}`);
|
|
5113
5113
|
if (options.transcript && result.transcript) {
|
|
5114
|
-
const { serializeSession: serializeSession$1 } = await import("./session-
|
|
5114
|
+
const { serializeSession: serializeSession$1 } = await import("./session-BJe-hei3.mjs");
|
|
5115
5115
|
const transcriptPath = outputPath.replace(/\.form\.md$/, ".session.yaml");
|
|
5116
5116
|
const { writeFile: writeFile$1 } = await import("./shared-CNqwaxUt.mjs");
|
|
5117
5117
|
await writeFile$1(transcriptPath, serializeSession$1(result.transcript));
|
package/dist/cli.mjs
CHANGED