@lazyingart/agintiflow 0.20.232 → 0.20.233

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyingart/agintiflow",
3
- "version": "0.20.232",
3
+ "version": "0.20.233",
4
4
  "type": "module",
5
5
  "description": "AgInTiFlow is a project-aware agent workspace for hybrid wet-dry R&D, hardware-aware intelligence, software automation, and industrial workflows.",
6
6
  "license": "Apache-2.0",
@@ -42,14 +42,19 @@ const currentDocument = evaluateCurrentStateText({
42
42
  });
43
43
  assert.equal(currentDocument.ok, true, "authoritative current-state prose was rejected");
44
44
 
45
- function page(words, { height = 842, startY = 60, endY = 700, heading = "Section" } = {}) {
45
+ function page(
46
+ words,
47
+ { height = 842, startY = 60, endY = 700, heading = "Section", wordHeight = 10 } = {}
48
+ ) {
46
49
  const items = [];
47
50
  const count = Math.max(1, words);
48
51
  for (let index = 0; index < count; index += 1) {
49
52
  const ratio = count === 1 ? 0 : index / (count - 1);
50
53
  const y = startY + (endY - startY) * ratio;
51
54
  const text = index === 0 ? heading : `word${index}`;
52
- items.push(`<word xMin="60" yMin="${y.toFixed(2)}" xMax="100" yMax="${(y + 10).toFixed(2)}">${text}</word>`);
55
+ items.push(
56
+ `<word xMin="60" yMin="${y.toFixed(2)}" xMax="100" yMax="${(y + wordHeight).toFixed(2)}">${text}</word>`
57
+ );
53
58
  }
54
59
  items.push(`<word xMin="250" yMin="810" xMax="300" yMax="820">footer</word>`);
55
60
  return `<page width="595" height="${height}">${items.join("")}</page>`;
@@ -67,4 +72,18 @@ const intentionalAppendix = evaluatePdfPageBalance(
67
72
  );
68
73
  assert.equal(intentionalAppendix.ok, true, "an intentional sparse appendix page was rejected");
69
74
 
75
+ const undersizedOnePage = evaluatePdfPageBalance(
76
+ `<doc>${page(340, { wordHeight: 8.3 })}</doc>`
77
+ );
78
+ assert.equal(undersizedOnePage.ok, false, "undersized one-page typography was accepted");
79
+ assert(
80
+ undersizedOnePage.defects.some((item) => item.code === "undersized-document-text"),
81
+ "undersized typography did not produce a reader-facing defect"
82
+ );
83
+
84
+ const readableOnePage = evaluatePdfPageBalance(
85
+ `<doc>${page(260, { wordHeight: 9.4 })}</doc>`
86
+ );
87
+ assert.equal(readableOnePage.ok, true, "readable one-page typography was rejected");
88
+
70
89
  console.log("document artifact quality smoke test passed");
@@ -29,6 +29,7 @@ const INTENTIONAL_SPARSE_PAGE_PATTERN =
29
29
  /^(?:appendix|approval|approvals|acknowledgements?|back cover|contact|notes|references|sign[- ]?off|signatures?)\b/i;
30
30
  const HISTORICAL_TRANSITION_PATTERN =
31
31
  /\b(?:formerly|no longer|previously|replac(?:ed|ing)|superseded|used to be)\b/i;
32
+ const MIN_READABLE_MEDIAN_WORD_HEIGHT_PT = 8.8;
32
33
 
33
34
  function portablePath(value = "") {
34
35
  return String(value || "").replace(/\\/g, "/");
@@ -175,14 +176,27 @@ export function evaluatePdfPageBalance(bboxXml = "") {
175
176
  const yValues = contentWords.flatMap((word) => [word.yMin, word.yMax]).filter(Number.isFinite);
176
177
  const usableHeight = Math.max(1, Number(page.height || 0) - 120);
177
178
  const occupiedHeight = yValues.length ? Math.max(...yValues) - Math.min(...yValues) : 0;
179
+ const wordHeights = contentWords
180
+ .map((word) => word.yMax - word.yMin)
181
+ .filter((value) => Number.isFinite(value) && value > 0);
178
182
  return {
179
183
  page: index + 1,
180
184
  wordCount: contentWords.length,
181
185
  occupiedRatio: occupiedHeight / usableHeight,
186
+ medianWordHeight: median(wordHeights),
182
187
  leadingText: contentWords.slice(0, 16).map((word) => word.text).join(" ").trim(),
183
188
  };
184
189
  });
185
190
  const defects = [];
191
+ const documentMedianWordHeight = median(
192
+ metrics.flatMap((item) => Array(item.wordCount).fill(item.medianWordHeight))
193
+ );
194
+ if (documentMedianWordHeight > 0 && documentMedianWordHeight < MIN_READABLE_MEDIAN_WORD_HEIGHT_PT) {
195
+ defects.push({
196
+ code: "undersized-document-text",
197
+ message: `The document's median rendered word height is ${documentMedianWordHeight.toFixed(1)} pt, below the ${MIN_READABLE_MEDIAN_WORD_HEIGHT_PT.toFixed(1)} pt readability floor. Keep normal body type and rebalance coherent sections across pages instead of shrinking text to force a page count.`,
198
+ });
199
+ }
186
200
  if (metrics.length > 1) {
187
201
  const priorWordCounts = metrics.slice(0, -1).map((item) => item.wordCount).filter((value) => value > 0);
188
202
  const last = metrics.at(-1);
@@ -204,6 +218,7 @@ export function evaluatePdfPageBalance(bboxXml = "") {
204
218
  ok: pages.length > 0 && defects.length === 0,
205
219
  checked: pages.length > 0,
206
220
  pages: metrics,
221
+ documentMedianWordHeight,
207
222
  defects,
208
223
  };
209
224
  }
@@ -276,7 +276,7 @@ export const TASK_PROFILES = {
276
276
  id: "word",
277
277
  label: "Word documents",
278
278
  prompt:
279
- "Bias toward Word/docx/document workflows while still using writing, conversion, LaTeX, or scripts when useful. Preserve source material byte-for-byte and synthesize a reader-facing document from the authoritative current facts instead of concatenating notes, logs, schemas, task IDs, private paths, or delivery instructions. Reconcile conflicting or superseded source facts before drafting: values labeled corrected, replaced, earlier, old, prior, cancelled, or no longer selected identify what to discard, and those discarded literals must not appear in the final document unless the user explicitly requests history or the history is necessary to explain a live decision. Keep the reconciliation history private: a current-state handoff should say who owns the work, which value is approved, and which option is selected, not narrate who was replaced or which preliminary value is no longer used. Before finishing, extract the final text and search for every superseded literal found in the sources. Prefer mature editable-document tooling already available in the workspace, such as python-docx, pandoc, or LibreOffice, over hand-written OOXML; when direct OOXML is genuinely necessary, validate its package parts and openability. Keep one maintainable source of truth and a reproducible project-local build command. Verify the DOCX is structurally editable, compile the PDF, run pdftotext or an equivalent extraction check that rejects replacement characters and unexpected control glyphs, and verify PDF text bounding boxes remain inside a readable page margin. Render every PDF page to a separate image under an ignored build/verification directory. Inspect one rendered page per read_image call, never batch pages into one vision call, and repair orphaned headings, near-empty spill pages, awkward table or paragraph breaks, overlaps, clipping, excessive whitespace, weak hierarchy, and inconsistent number formatting before finishing. Prefer one balanced readable page over pushing one short section onto a mostly empty trailing page; preserve an intentionally sparse appendix, approval, signature, reference, or back-matter page when it serves a real purpose. Retain ignored verification renders as evidence; optional cleanup must never block completion. Use clear descriptive filenames, exclude caches and generated debris from commits, inspect git status/diff before committing, and report success only after the editable source, reader-facing current-state content, visual layout, searchable text, and requested artifacts all pass.",
279
+ "Bias toward Word/docx/document workflows while still using writing, conversion, LaTeX, or scripts when useful. Preserve source material byte-for-byte and synthesize a reader-facing document from the authoritative current facts instead of concatenating notes, logs, schemas, task IDs, private paths, or delivery instructions. Reconcile conflicting or superseded source facts before drafting: values labeled corrected, replaced, earlier, old, prior, cancelled, or no longer selected identify what to discard, and those discarded literals must not appear in the final document unless the user explicitly requests history or the history is necessary to explain a live decision. Keep the reconciliation history private: a current-state handoff should say who owns the work, which value is approved, and which option is selected, not narrate who was replaced or which preliminary value is no longer used. Before finishing, extract the final text and search for every superseded literal found in the sources. Prefer mature editable-document tooling already available in the workspace, such as python-docx, pandoc, or LibreOffice, over hand-written OOXML; when direct OOXML is genuinely necessary, validate its package parts and openability. Keep one maintainable source of truth and a reproducible project-local build command. Verify the DOCX is structurally editable, compile the PDF, run pdftotext or an equivalent extraction check that rejects replacement characters and unexpected control glyphs, and verify PDF text bounding boxes remain inside a readable page margin. Render every PDF page to a separate image under an ignored build/verification directory. Inspect one rendered page per read_image call, never batch pages into one vision call, and repair orphaned headings, near-empty spill pages, awkward table or paragraph breaks, overlaps, clipping, excessive whitespace, weak hierarchy, and inconsistent number formatting before finishing. Keep normal readable body type, line spacing, and margins; never shrink typography merely to force the document onto one page. When content spans pages, move or redistribute coherent sections so each page is useful instead of leaving a short spill page. Preserve an intentionally sparse appendix, approval, signature, reference, or back-matter page when it serves a real purpose. Retain ignored verification renders as evidence; optional cleanup must never block completion. Use clear descriptive filenames, exclude caches and generated debris from commits, inspect git status/diff before committing, and report success only after the editable source, reader-facing current-state content, visual layout, searchable text, and requested artifacts all pass.",
280
280
  tools: ["files", "shell", "canvas", "sandbox"],
281
281
  },
282
282
  latex: {