markform 0.1.17 → 0.1.18
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 +2 -2
- package/dist/ai-sdk.d.mts +1 -1
- package/dist/ai-sdk.mjs +2 -2
- package/dist/{apply-DgDJBscb.mjs → apply-BYgtU64w.mjs} +29 -3
- package/dist/apply-BYgtU64w.mjs.map +1 -0
- package/dist/bin.mjs +1 -1
- package/dist/{cli-DAl8LQzI.mjs → cli-D9w0Bp4J.mjs} +192 -6
- package/dist/cli-D9w0Bp4J.mjs.map +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/{coreTypes-CnEea7Kh.d.mts → coreTypes-BMEs8h_2.d.mts} +125 -2
- package/dist/{coreTypes-DiCddBKu.mjs → coreTypes-SDB3KRRJ.mjs} +9 -4
- package/dist/coreTypes-SDB3KRRJ.mjs.map +1 -0
- package/dist/index.d.mts +129 -2
- package/dist/index.mjs +5 -5
- package/dist/{session-B7aR6hno.mjs → session-CW9AQw6i.mjs} +1 -1
- package/dist/{session-XDrocA3j.mjs → session-Ci4B0Pna.mjs} +2 -2
- package/dist/{session-XDrocA3j.mjs.map → session-Ci4B0Pna.mjs.map} +1 -1
- package/dist/{src-CHVJLGKt.mjs → src-DDxi-2ne.mjs} +495 -14
- package/dist/src-DDxi-2ne.mjs.map +1 -0
- package/docs/markform-apis.md +31 -0
- package/docs/markform-reference.md +27 -0
- package/docs/markform-spec.md +115 -0
- package/examples/movie-research/movie-deep-research-mock-filled.form.md +1 -1
- package/examples/movie-research/movie-deep-research.form.md +1 -1
- package/examples/parallel/parallel-research.form.md +57 -0
- package/examples/startup-deep-research/startup-deep-research.form.md +1 -1
- package/package.json +1 -1
- package/dist/apply-DgDJBscb.mjs.map +0 -1
- package/dist/cli-DAl8LQzI.mjs.map +0 -1
- package/dist/coreTypes-DiCddBKu.mjs.map +0 -1
- package/dist/src-CHVJLGKt.mjs.map +0 -1
package/dist/bin.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import { L as PatchSchema } from "./coreTypes-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as serializeSession } from "./session-
|
|
2
|
+
import { L as PatchSchema } from "./coreTypes-SDB3KRRJ.mjs";
|
|
3
|
+
import { B as WEB_SEARCH_CONFIG, D as DEFAULT_RESEARCH_MAX_ISSUES_PER_TURN, F as deriveReportPath, I as deriveSchemaPath, L as detectFileType, M as REPORT_EXTENSION, N as USER_ROLE, O as DEFAULT_RESEARCH_MAX_PATCHES_PER_TURN, P as deriveExportPath, R as parseRolesFlag, S as DEFAULT_MAX_PATCHES_PER_TURN, T as DEFAULT_PORT, U as hasWebSearchSupport, V as formatSuggestedLlms, W as parseModelIdForDisplay, _ as validateSyntaxConsistency, b as DEFAULT_MAX_ISSUES_PER_TURN, d as serializeForm, f as serializeRawMarkdown, i as inspect, j as MAX_FORMS_IN_MENU, m as friendlyUrlAbbrev, n as getAllFields, p as serializeReport, t as applyPatches, v as AGENT_ROLE, w as DEFAULT_MAX_TURNS, y as DEFAULT_FORMS_DIR, z as SUGGESTED_LLMS } from "./apply-BYgtU64w.mjs";
|
|
4
|
+
import { A as formToJsonSchema, _ as createMockAgent, a as resolveHarnessConfig, d as getProviderNames, f as resolveModel, h as computeExecutionPlan, i as runResearch, j as parseForm, m as createLiveAgent, n as isResearchForm, o as fillForm, p as buildMockWireFormat, t as VERSION, u as getProviderInfo, y as createHarness } from "./src-DDxi-2ne.mjs";
|
|
5
|
+
import { n as serializeSession } from "./session-Ci4B0Pna.mjs";
|
|
6
6
|
import { _ as writeFile, a as formatPath, c as logError, d as logTiming, f as logVerbose, g as stripHtmlComments, h as shouldUseColors, 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-CCq4haEV.mjs";
|
|
7
7
|
import Markdoc from "@markdoc/markdoc";
|
|
8
8
|
import YAML from "yaml";
|
|
@@ -3535,6 +3535,191 @@ function registerModelsCommand(program) {
|
|
|
3535
3535
|
});
|
|
3536
3536
|
}
|
|
3537
3537
|
|
|
3538
|
+
//#endregion
|
|
3539
|
+
//#region src/cli/commands/plan.ts
|
|
3540
|
+
/**
|
|
3541
|
+
* Get the response status string for a field.
|
|
3542
|
+
*/
|
|
3543
|
+
function getFieldStatus(form, fieldId) {
|
|
3544
|
+
const response = form.responsesByFieldId[fieldId];
|
|
3545
|
+
if (!response) return "unanswered";
|
|
3546
|
+
return response.state;
|
|
3547
|
+
}
|
|
3548
|
+
/**
|
|
3549
|
+
* Check if a field still needs work (not yet answered).
|
|
3550
|
+
*/
|
|
3551
|
+
function fieldNeedsWork(form, fieldId) {
|
|
3552
|
+
const response = form.responsesByFieldId[fieldId];
|
|
3553
|
+
if (!response) return true;
|
|
3554
|
+
return response.state !== "answered";
|
|
3555
|
+
}
|
|
3556
|
+
/**
|
|
3557
|
+
* Get all field IDs for an execution plan item.
|
|
3558
|
+
*/
|
|
3559
|
+
function getFieldIdsForItem(form, item) {
|
|
3560
|
+
if (item.itemType === "field") return [item.itemId];
|
|
3561
|
+
const group = form.schema.groups.find((g) => g.id === item.itemId);
|
|
3562
|
+
if (!group) return [];
|
|
3563
|
+
return group.children.map((f) => f.id);
|
|
3564
|
+
}
|
|
3565
|
+
/**
|
|
3566
|
+
* Get field metadata from the form schema.
|
|
3567
|
+
*/
|
|
3568
|
+
function getFieldMeta(form, fieldId) {
|
|
3569
|
+
for (const group of form.schema.groups) {
|
|
3570
|
+
const field = group.children.find((f) => f.id === fieldId);
|
|
3571
|
+
if (field) return field;
|
|
3572
|
+
}
|
|
3573
|
+
}
|
|
3574
|
+
/**
|
|
3575
|
+
* Build a PlanItemJson, including only fields that need work.
|
|
3576
|
+
* Returns undefined if no fields need work.
|
|
3577
|
+
*/
|
|
3578
|
+
function buildPlanItem(form, item) {
|
|
3579
|
+
const remainingFieldIds = getFieldIdsForItem(form, item).filter((id) => fieldNeedsWork(form, id));
|
|
3580
|
+
if (remainingFieldIds.length === 0) return;
|
|
3581
|
+
const planItem = {
|
|
3582
|
+
itemId: item.itemId,
|
|
3583
|
+
itemType: item.itemType
|
|
3584
|
+
};
|
|
3585
|
+
if (item.itemType === "group") planItem.fields = remainingFieldIds.map((id) => {
|
|
3586
|
+
const meta = getFieldMeta(form, id);
|
|
3587
|
+
return {
|
|
3588
|
+
fieldId: id,
|
|
3589
|
+
label: meta?.label,
|
|
3590
|
+
status: getFieldStatus(form, id),
|
|
3591
|
+
required: meta?.required ?? false
|
|
3592
|
+
};
|
|
3593
|
+
});
|
|
3594
|
+
return planItem;
|
|
3595
|
+
}
|
|
3596
|
+
function formatConsolePlan(report, useColors) {
|
|
3597
|
+
const lines = [];
|
|
3598
|
+
const bold = useColors ? pc.bold : (s$1) => s$1;
|
|
3599
|
+
const dim = useColors ? pc.dim : (s$1) => s$1;
|
|
3600
|
+
const cyan = useColors ? pc.cyan : (s$1) => s$1;
|
|
3601
|
+
const yellow = useColors ? pc.yellow : (s$1) => s$1;
|
|
3602
|
+
const titlePart = report.title ? ` (${report.title})` : "";
|
|
3603
|
+
lines.push(bold(cyan(`Plan: ${report.formId}${titlePart}`)));
|
|
3604
|
+
lines.push("");
|
|
3605
|
+
if (report.orderLevels.length === 0) {
|
|
3606
|
+
lines.push(dim("No remaining work — all fields are complete."));
|
|
3607
|
+
return lines.join("\n");
|
|
3608
|
+
}
|
|
3609
|
+
for (const level of report.orderLevels) {
|
|
3610
|
+
const itemCount = level.looseSerial.length + level.parallelBatches.reduce((sum, b) => sum + b.items.length, 0);
|
|
3611
|
+
lines.push(bold(`Order level ${level.order} (${itemCount} items):`));
|
|
3612
|
+
if (level.looseSerial.length > 0) {
|
|
3613
|
+
lines.push(` Loose serial (primary agent):`);
|
|
3614
|
+
for (const item of level.looseSerial) formatItem(lines, item, dim, yellow, " ");
|
|
3615
|
+
}
|
|
3616
|
+
for (const batch of level.parallelBatches) {
|
|
3617
|
+
lines.push(` Parallel batch "${batch.batchId}" (${batch.items.length} items, ${batch.items.length} agents):`);
|
|
3618
|
+
for (const item of batch.items) formatItem(lines, item, dim, yellow, " ");
|
|
3619
|
+
}
|
|
3620
|
+
lines.push("");
|
|
3621
|
+
}
|
|
3622
|
+
const s = report.summary;
|
|
3623
|
+
lines.push(dim(`Summary: ${s.orderLevelCount} order level${s.orderLevelCount !== 1 ? "s" : ""}, ${s.parallelBatchCount} parallel batch${s.parallelBatchCount !== 1 ? "es" : ""}, ${s.remainingFields} remaining field${s.remainingFields !== 1 ? "s" : ""}`));
|
|
3624
|
+
return lines.join("\n");
|
|
3625
|
+
}
|
|
3626
|
+
function formatItem(lines, item, dim, yellow, indent) {
|
|
3627
|
+
if (item.itemType === "group" && item.fields) {
|
|
3628
|
+
lines.push(`${indent}- ${item.itemId} [group]`);
|
|
3629
|
+
for (const f of item.fields) {
|
|
3630
|
+
const label = f.label ? ` (${f.label})` : "";
|
|
3631
|
+
const req = f.required ? yellow("required") + ", " : "";
|
|
3632
|
+
lines.push(`${indent} ${f.fieldId}${label} — ${req}${dim(f.status)}`);
|
|
3633
|
+
}
|
|
3634
|
+
} else {
|
|
3635
|
+
const meta = item;
|
|
3636
|
+
lines.push(`${indent}- ${meta.itemId}`);
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
/**
|
|
3640
|
+
* Register the plan command.
|
|
3641
|
+
*/
|
|
3642
|
+
function registerPlanCommand(program) {
|
|
3643
|
+
program.command("plan <file>").description("Show the idealized execution plan for a form (parallel batches, order levels)").action(async (file, _options, cmd) => {
|
|
3644
|
+
const ctx = getCommandContext(cmd);
|
|
3645
|
+
try {
|
|
3646
|
+
logVerbose(ctx, `Reading file: ${file}`);
|
|
3647
|
+
const content = await readFile$1(file);
|
|
3648
|
+
logVerbose(ctx, "Parsing and validating form...");
|
|
3649
|
+
const form = parseForm(content);
|
|
3650
|
+
const parseErrors = inspect(form).issues.filter((i) => i.reason === "validation_error");
|
|
3651
|
+
if (parseErrors.length > 0) {
|
|
3652
|
+
logError(`Form has validation errors. Fix them before planning:\n` + parseErrors.map((e) => ` - ${e.message}`).join("\n"));
|
|
3653
|
+
process.exit(1);
|
|
3654
|
+
}
|
|
3655
|
+
logVerbose(ctx, "Computing execution plan...");
|
|
3656
|
+
const executionPlan = computeExecutionPlan(form);
|
|
3657
|
+
const orderLevels = [];
|
|
3658
|
+
let totalItems = 0;
|
|
3659
|
+
let totalRemainingFields = 0;
|
|
3660
|
+
let totalBatches = 0;
|
|
3661
|
+
for (const order of executionPlan.orderLevels) {
|
|
3662
|
+
const looseItems = [];
|
|
3663
|
+
for (const item of executionPlan.looseSerial) {
|
|
3664
|
+
if (item.order !== order) continue;
|
|
3665
|
+
const planItem = buildPlanItem(form, item);
|
|
3666
|
+
if (planItem) {
|
|
3667
|
+
looseItems.push(planItem);
|
|
3668
|
+
totalItems++;
|
|
3669
|
+
totalRemainingFields += countRemainingFields(form, item);
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3672
|
+
const batches = [];
|
|
3673
|
+
for (const batch of executionPlan.parallelBatches) {
|
|
3674
|
+
const batchItems = [];
|
|
3675
|
+
for (const item of batch.items) {
|
|
3676
|
+
if (item.order !== order) continue;
|
|
3677
|
+
const planItem = buildPlanItem(form, item);
|
|
3678
|
+
if (planItem) {
|
|
3679
|
+
batchItems.push(planItem);
|
|
3680
|
+
totalItems++;
|
|
3681
|
+
totalRemainingFields += countRemainingFields(form, item);
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
if (batchItems.length > 0) {
|
|
3685
|
+
batches.push({
|
|
3686
|
+
batchId: batch.batchId,
|
|
3687
|
+
items: batchItems
|
|
3688
|
+
});
|
|
3689
|
+
totalBatches++;
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
if (looseItems.length > 0 || batches.length > 0) orderLevels.push({
|
|
3693
|
+
order,
|
|
3694
|
+
looseSerial: looseItems,
|
|
3695
|
+
parallelBatches: batches
|
|
3696
|
+
});
|
|
3697
|
+
}
|
|
3698
|
+
const output = formatOutput(ctx, {
|
|
3699
|
+
formId: form.schema.id,
|
|
3700
|
+
title: form.schema.title,
|
|
3701
|
+
orderLevels,
|
|
3702
|
+
summary: {
|
|
3703
|
+
orderLevelCount: orderLevels.length,
|
|
3704
|
+
parallelBatchCount: totalBatches,
|
|
3705
|
+
totalItems,
|
|
3706
|
+
remainingFields: totalRemainingFields
|
|
3707
|
+
}
|
|
3708
|
+
}, (data, useColors) => formatConsolePlan(data, useColors));
|
|
3709
|
+
console.log(output);
|
|
3710
|
+
} catch (error) {
|
|
3711
|
+
logError(error instanceof Error ? error.message : String(error));
|
|
3712
|
+
process.exit(1);
|
|
3713
|
+
}
|
|
3714
|
+
});
|
|
3715
|
+
}
|
|
3716
|
+
/**
|
|
3717
|
+
* Count remaining fields for an execution plan item.
|
|
3718
|
+
*/
|
|
3719
|
+
function countRemainingFields(form, item) {
|
|
3720
|
+
return getFieldIdsForItem(form, item).filter((id) => fieldNeedsWork(form, id)).length;
|
|
3721
|
+
}
|
|
3722
|
+
|
|
3538
3723
|
//#endregion
|
|
3539
3724
|
//#region src/cli/commands/serve.ts
|
|
3540
3725
|
/**
|
|
@@ -5664,7 +5849,7 @@ function registerResearchCommand(program) {
|
|
|
5664
5849
|
console.log(` ${formPath} ${pc.dim("(filled markform source)")}`);
|
|
5665
5850
|
console.log(` ${schemaPath} ${pc.dim("(JSON Schema)")}`);
|
|
5666
5851
|
if (options.transcript && result.transcript) {
|
|
5667
|
-
const { serializeSession: serializeSession$1 } = await import("./session-
|
|
5852
|
+
const { serializeSession: serializeSession$1 } = await import("./session-CW9AQw6i.mjs");
|
|
5668
5853
|
const transcriptPath = outputPath.replace(/\.form\.md$/, ".session.yaml");
|
|
5669
5854
|
const { writeFile: writeFile$1 } = await import("./shared-fUKfJ1UA.mjs");
|
|
5670
5855
|
await writeFile$1(transcriptPath, serializeSession$1(result.transcript));
|
|
@@ -6053,6 +6238,7 @@ function createProgram() {
|
|
|
6053
6238
|
registerFillCommand(program);
|
|
6054
6239
|
registerInspectCommand(program);
|
|
6055
6240
|
registerModelsCommand(program);
|
|
6241
|
+
registerPlanCommand(program);
|
|
6056
6242
|
registerRenderCommand(program);
|
|
6057
6243
|
registerReportCommand(program);
|
|
6058
6244
|
registerResearchCommand(program);
|
|
@@ -6072,4 +6258,4 @@ async function runCli() {
|
|
|
6072
6258
|
|
|
6073
6259
|
//#endregion
|
|
6074
6260
|
export { runCli as t };
|
|
6075
|
-
//# sourceMappingURL=cli-
|
|
6261
|
+
//# sourceMappingURL=cli-D9w0Bp4J.mjs.map
|