markform 0.1.18 → 0.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.
Files changed (32) hide show
  1. package/README.md +27 -2
  2. package/dist/ai-sdk.d.mts +1 -2
  3. package/dist/ai-sdk.mjs +2 -2
  4. package/dist/ai-sdk.mjs.map +1 -1
  5. package/dist/{apply-BYgtU64w.mjs → apply-DIvm1b1s.mjs} +430 -31
  6. package/dist/apply-DIvm1b1s.mjs.map +1 -0
  7. package/dist/bin.mjs +20 -2
  8. package/dist/bin.mjs.map +1 -1
  9. package/dist/{cli-D9w0Bp4J.mjs → cli-FFMoEhFS.mjs} +1039 -89
  10. package/dist/cli-FFMoEhFS.mjs.map +1 -0
  11. package/dist/cli.mjs +1 -1
  12. package/dist/{coreTypes-SDB3KRRJ.mjs → coreTypes-CPKXf2dc.mjs} +1 -1
  13. package/dist/{coreTypes-SDB3KRRJ.mjs.map → coreTypes-CPKXf2dc.mjs.map} +1 -1
  14. package/dist/{coreTypes-BMEs8h_2.d.mts → coreTypes-CkxML8g2.d.mts} +4 -9
  15. package/dist/index.d.mts +515 -22
  16. package/dist/index.mjs +5 -5
  17. package/dist/{session-Ci4B0Pna.mjs → session-CK0x28RO.mjs} +2 -2
  18. package/dist/session-CK0x28RO.mjs.map +1 -0
  19. package/dist/{session-CW9AQw6i.mjs → session-ZHBi3LVQ.mjs} +1 -1
  20. package/dist/{shared-fUKfJ1UA.mjs → shared-BTR35aMz.mjs} +1 -1
  21. package/dist/{shared-CCq4haEV.mjs → shared-DwdyWmvE.mjs} +1 -3
  22. package/dist/shared-DwdyWmvE.mjs.map +1 -0
  23. package/dist/{src-DDxi-2ne.mjs → src-wR7GoftB.mjs} +1707 -645
  24. package/dist/src-wR7GoftB.mjs.map +1 -0
  25. package/docs/markform-apis.md +81 -0
  26. package/docs/markform-reference.md +15 -1
  27. package/package.json +17 -15
  28. package/dist/apply-BYgtU64w.mjs.map +0 -1
  29. package/dist/cli-D9w0Bp4J.mjs.map +0 -1
  30. package/dist/session-Ci4B0Pna.mjs.map +0 -1
  31. package/dist/shared-CCq4haEV.mjs.map +0 -1
  32. package/dist/src-DDxi-2ne.mjs.map +0 -1
@@ -207,6 +207,7 @@ const result = await fillForm({
207
207
  | `callbacks` | `FillCallbacks` | `undefined` | Progress callbacks |
208
208
  | `signal` | `AbortSignal` | `undefined` | Cancellation signal |
209
209
  | `additionalTools` | `Record<string, Tool>` | `undefined` | Custom tools for agent |
210
+ | `recordFill` | `boolean` | (required) | Collect detailed FillRecord with timeline and stats |
210
211
 
211
212
  ### Parallel Execution
212
213
 
@@ -343,6 +344,7 @@ await fillForm({
343
344
  | `onToolEnd` | `{ name, output, durationMs, error? }` | Called after a tool completes |
344
345
  | `onLlmCallStart` | `{ model }` | Called before an LLM request |
345
346
  | `onLlmCallEnd` | `{ model, inputTokens, outputTokens }` | Called after an LLM response |
347
+ | `onWebSearch` | `{ query, resultCount, provider }` | Called when a web search is performed |
346
348
 
347
349
  **TurnProgress fields:**
348
350
 
@@ -366,6 +368,85 @@ interface PatchRejection {
366
368
  }
367
369
  ```
368
370
 
371
+ ### FillRecord
372
+
373
+ When `recordFill: true`, the `FillResult.record` contains a complete record of everything
374
+ that happened during the fill operation. Useful for cost analysis, debugging, and auditing.
375
+
376
+ ```typescript
377
+ const result = await fillForm({
378
+ form: formMarkdown,
379
+ model: 'anthropic/claude-sonnet-4-5',
380
+ enableWebSearch: true,
381
+ captureWireFormat: false,
382
+ recordFill: true,
383
+ });
384
+
385
+ if (result.record) {
386
+ console.log(`Session: ${result.record.sessionId}`);
387
+ console.log(`Duration: ${result.record.durationMs}ms`);
388
+ console.log(`Tokens: ${result.record.llm.inputTokens} in, ${result.record.llm.outputTokens} out`);
389
+ console.log(`Tool calls: ${result.record.toolSummary.totalCalls}`);
390
+ }
391
+ ```
392
+
393
+ **FillRecord fields:**
394
+
395
+ | Field | Type | Description |
396
+ | --- | --- | --- |
397
+ | `sessionId` | `string` | Unique session identifier (UUID) |
398
+ | `startedAt` | `string` | ISO datetime when fill started |
399
+ | `completedAt` | `string` | ISO datetime when fill completed |
400
+ | `durationMs` | `number` | Total duration in milliseconds |
401
+ | `form` | `object` | Form metadata (id, title, structure) |
402
+ | `status` | `string` | `'completed'`, `'partial'`, `'failed'`, `'cancelled'` |
403
+ | `formProgress` | `ProgressCounts` | Final form progress counts |
404
+ | `llm` | `object` | LLM usage (provider, model, tokens) |
405
+ | `toolSummary` | `ToolSummary` | Aggregated tool statistics |
406
+ | `timingBreakdown` | `TimingBreakdown` | Time spent in LLM, tools, overhead |
407
+ | `timeline` | `TimelineEntry[]` | Turn-by-turn execution history |
408
+ | `execution` | `ExecutionMetadata` | Parallel execution details |
409
+ | `customData` | `object` | Optional client-defined data |
410
+
411
+ ### formatFillRecordSummary(record, options?): string
412
+
413
+ Format a FillRecord as a human-readable text summary.
414
+
415
+ ```typescript
416
+ import { formatFillRecordSummary } from 'markform';
417
+
418
+ const summary = formatFillRecordSummary(result.record, { verbose: true });
419
+ console.log(summary);
420
+ ```
421
+
422
+ **Output example:**
423
+
424
+ ```
425
+ Fill completed in 12.4s (5 turns)
426
+
427
+ Tokens: 2,450 input / 890 output (anthropic/claude-sonnet-4-5)
428
+ Tools: 12 calls (11 succeeded, 1 failed)
429
+ - web_search: 5 calls, avg 1.2s, p95 2.1s
430
+ - fill_form: 7 calls, avg 45ms
431
+
432
+ Timing: 55% LLM (6.8s) | 41% tools (5.1s) | 4% overhead (0.5s)
433
+
434
+ Progress: 18/20 fields filled (90%)
435
+ ```
436
+
437
+ **CLI usage:**
438
+
439
+ The CLI provides `--record-fill` to write a sidecar `.fill.json` file:
440
+
441
+ ```bash
442
+ markform fill input.form.md -o output.form.md --record-fill
443
+ # Creates: output.form.md (filled form)
444
+ # output.fill.json (FillRecord JSON)
445
+ ```
446
+
447
+ The CLI always prints a summary to stderr (use `--quiet` to suppress, `--verbose` for
448
+ more detail).
449
+
369
450
  ### createHarness(form, config?): FormHarness
370
451
 
371
452
  Create a harness for manual control over the fill loop.
@@ -61,7 +61,21 @@ markform:
61
61
 
62
62
  ## Conventions
63
63
 
64
- Use `.form.md` for Markform files.
64
+ ### File Extensions
65
+
66
+ | File Type | Extension | Description |
67
+ |-----------|-----------|-------------|
68
+ | Form | `.form.md` | Markform source and filled forms |
69
+ | Fill Record | `.fill.json` | Execution metadata (sidecar file) |
70
+ | Report | `.report.md` | Filtered human-readable output |
71
+ | Schema | `.schema.json` | JSON Schema for form structure |
72
+ | Values | `.yml` or `.json` | Exported field values |
73
+
74
+ **Recommended:** Use `.form.md` for all Markform files. This enables:
75
+ - Auto-discovery of fill records by `markform serve`
76
+ - Consistent tooling behavior across CLI commands
77
+ - Clear distinction from regular markdown files
78
+
65
79
  Markform uses HTML comment syntax for structure tags, which render invisibly on GitHub.
66
80
 
67
81
  ### Syntax
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markform",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Markdown forms for token-friendly workflows",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "author": "Joshua Levy",
@@ -55,35 +55,37 @@
55
55
  "node": ">=20"
56
56
  },
57
57
  "dependencies": {
58
- "@ai-sdk/deepseek": "^2.0.1",
59
- "@ai-sdk/google": "^3.0.1",
60
- "@ai-sdk/openai": "^3.0.1",
61
- "@ai-sdk/xai": "^3.0.2",
62
- "@clack/prompts": "^0.11.0",
58
+ "@ai-sdk/deepseek": "^2.0.16",
59
+ "@ai-sdk/google": "^3.0.19",
60
+ "@ai-sdk/openai": "^3.0.24",
61
+ "@ai-sdk/xai": "^3.0.45",
62
+ "@clack/prompts": "^1.0.0",
63
63
  "@markdoc/markdoc": "^0.5.4",
64
- "ai": "^6.0.3",
64
+ "ai": "^6.0.66",
65
65
  "atomically": "^2.1.0",
66
- "commander": "^14.0.2",
66
+ "commander": "^14.0.3",
67
67
  "dotenv": "^17.2.3",
68
68
  "jiti": "^2.6.1",
69
69
  "js-sha256": "^0.11.1",
70
70
  "picocolors": "^1.1.1",
71
+ "ulid": "^3.0.2",
72
+ "undici": "^7.19.2",
71
73
  "yaml": "^2.8.2",
72
- "zod": "^4.2.1"
74
+ "zod": "^4.3.6"
73
75
  },
74
76
  "devDependencies": {
75
- "@ai-sdk/anthropic": "^3.0.1",
76
- "@types/node": "^22.15.30",
77
- "@vitest/coverage-v8": "^4.0.16",
77
+ "@ai-sdk/anthropic": "^3.0.34",
78
+ "@types/node": "^25.1.0",
79
+ "@vitest/coverage-v8": "^4.0.18",
78
80
  "ajv": "^8.17.1",
79
81
  "ajv-formats": "^3.0.1",
80
82
  "c8": "^10.1.3",
81
83
  "monocart-coverage-reports": "^2.12.9",
82
- "publint": "^0.3.16",
84
+ "publint": "^0.3.17",
83
85
  "tryscript": "^0.1.6",
84
- "tsdown": "^0.18.3",
86
+ "tsdown": "^0.20.1",
85
87
  "typescript": "^5.9.3",
86
- "vitest": "^4.0.16"
88
+ "vitest": "^4.0.18"
87
89
  },
88
90
  "scripts": {
89
91
  "copy-docs": "cp ../../README.md . && mkdir -p docs && cp ../../docs/markform-spec.md docs/ && cp ../../docs/markform-reference.md docs/ && cp ../../docs/markform-apis.md docs/",