open-agreements 0.7.4 → 0.7.6

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 (391) hide show
  1. package/README.de.md +300 -255
  2. package/README.es.md +301 -254
  3. package/README.md +391 -90
  4. package/README.pt-br.md +301 -254
  5. package/README.template.md +333 -0
  6. package/README.zh.md +300 -253
  7. package/SECURITY.md +34 -0
  8. package/content/recipes/nvca-stock-purchase-agreement/README.md +39 -0
  9. package/content/recipes/nvca-voting-agreement/README.md +43 -0
  10. package/content/templates/bonterms-mutual-nda/README.md +2 -2
  11. package/content/templates/bonterms-mutual-nda/metadata.yaml +5 -11
  12. package/content/templates/bonterms-professional-services-agreement/README.md +2 -2
  13. package/content/templates/bonterms-professional-services-agreement/metadata.yaml +2 -2
  14. package/content/templates/closing-checklist/template.docx +0 -0
  15. package/content/templates/closing-checklist/template.md +30 -0
  16. package/content/templates/common-paper-ai-addendum/template.docx +0 -0
  17. package/content/templates/common-paper-ai-addendum-in-app/template.docx +0 -0
  18. package/content/templates/common-paper-csa-with-ai/template.docx +0 -0
  19. package/content/templates/common-paper-independent-contractor-agreement/template.docx +0 -0
  20. package/content/templates/common-paper-mutual-nda/README.md +28 -0
  21. package/content/templates/common-paper-one-way-nda/metadata.yaml +1 -1
  22. package/content/templates/common-paper-term-sheet/template.docx +0 -0
  23. package/content/templates/openagreements-board-consent-safe/.template.generated.json +74 -0
  24. package/content/templates/openagreements-board-consent-safe/README.md +61 -0
  25. package/content/templates/openagreements-board-consent-safe/metadata.yaml +53 -0
  26. package/content/templates/openagreements-board-consent-safe/reference-source.docx +0 -0
  27. package/content/templates/openagreements-board-consent-safe/template.docx +0 -0
  28. package/content/templates/openagreements-board-consent-safe/template.md +66 -0
  29. package/content/templates/openagreements-due-diligence-request-list/README.md +68 -0
  30. package/content/templates/openagreements-due-diligence-request-list/metadata.yaml +300 -0
  31. package/content/templates/openagreements-due-diligence-request-list/template.docx +0 -0
  32. package/content/templates/openagreements-due-diligence-request-list/template.md +318 -0
  33. package/content/templates/openagreements-employee-ip-inventions-assignment/.template.generated.json +230 -0
  34. package/content/templates/openagreements-employee-ip-inventions-assignment/metadata.yaml +1 -1
  35. package/content/templates/openagreements-employee-ip-inventions-assignment/template.docx +0 -0
  36. package/content/templates/openagreements-employee-ip-inventions-assignment/template.md +96 -35
  37. package/content/templates/openagreements-employment-confidentiality-acknowledgement/README.md +1 -1
  38. package/content/templates/openagreements-employment-confidentiality-acknowledgement/metadata.yaml +2 -2
  39. package/content/templates/openagreements-employment-confidentiality-acknowledgement/template.docx +0 -0
  40. package/content/templates/openagreements-employment-confidentiality-acknowledgement/template.json +75 -0
  41. package/content/templates/openagreements-employment-confidentiality-acknowledgement/template.md +8 -4
  42. package/content/templates/openagreements-employment-offer-letter/.template.generated.json +224 -0
  43. package/content/templates/openagreements-employment-offer-letter/README.md +65 -1
  44. package/content/templates/openagreements-employment-offer-letter/metadata.yaml +1 -1
  45. package/content/templates/openagreements-employment-offer-letter/template.docx +0 -0
  46. package/content/templates/openagreements-employment-offer-letter/template.md +70 -30
  47. package/content/templates/openagreements-restrictive-covenant-florida/.template.generated.json +456 -0
  48. package/content/templates/openagreements-restrictive-covenant-florida/README.md +141 -0
  49. package/content/templates/openagreements-restrictive-covenant-florida/metadata.yaml +419 -0
  50. package/content/templates/openagreements-restrictive-covenant-florida/template.docx +0 -0
  51. package/content/templates/openagreements-restrictive-covenant-florida/template.md +233 -0
  52. package/content/templates/openagreements-restrictive-covenant-wyoming/.template.generated.json +399 -0
  53. package/content/templates/openagreements-restrictive-covenant-wyoming/metadata.yaml +69 -12
  54. package/content/templates/openagreements-restrictive-covenant-wyoming/template.docx +0 -0
  55. package/content/templates/openagreements-restrictive-covenant-wyoming/template.md +110 -59
  56. package/content/templates/openagreements-stockholder-consent-safe/.template.generated.json +74 -0
  57. package/content/templates/openagreements-stockholder-consent-safe/README.md +62 -0
  58. package/content/templates/openagreements-stockholder-consent-safe/metadata.yaml +53 -0
  59. package/content/templates/openagreements-stockholder-consent-safe/reference-source.docx +0 -0
  60. package/content/templates/openagreements-stockholder-consent-safe/template.docx +0 -0
  61. package/content/templates/openagreements-stockholder-consent-safe/template.md +62 -0
  62. package/content/templates/working-group-list/template.docx +0 -0
  63. package/content/templates/working-group-list/template.md +18 -0
  64. package/dist/cli/index.js.map +1 -1
  65. package/dist/commands/fill.d.ts +1 -1
  66. package/dist/commands/fill.d.ts.map +1 -1
  67. package/dist/commands/fill.js +4 -1
  68. package/dist/commands/fill.js.map +1 -1
  69. package/dist/commands/list.js +11 -1
  70. package/dist/commands/list.js.map +1 -1
  71. package/dist/commands/recipe.js.map +1 -1
  72. package/dist/core/checklist/docx-import.d.ts.map +1 -1
  73. package/dist/core/employment/jurisdiction-rules.js +2 -2
  74. package/dist/core/employment/jurisdiction-rules.js.map +1 -1
  75. package/dist/core/employment/memo.d.ts +1 -1
  76. package/dist/core/employment/memo.d.ts.map +1 -1
  77. package/dist/core/employment/memo.js +14 -6
  78. package/dist/core/employment/memo.js.map +1 -1
  79. package/dist/core/engine.d.ts.map +1 -1
  80. package/dist/core/engine.js +28 -0
  81. package/dist/core/engine.js.map +1 -1
  82. package/dist/core/fill-pipeline.d.ts +30 -5
  83. package/dist/core/fill-pipeline.d.ts.map +1 -1
  84. package/dist/core/fill-pipeline.js +173 -9
  85. package/dist/core/fill-pipeline.js.map +1 -1
  86. package/dist/core/humanize-docx.d.ts +21 -0
  87. package/dist/core/humanize-docx.d.ts.map +1 -0
  88. package/dist/core/humanize-docx.js +492 -0
  89. package/dist/core/humanize-docx.js.map +1 -0
  90. package/dist/core/metadata.d.ts +119 -65
  91. package/dist/core/metadata.d.ts.map +1 -1
  92. package/dist/core/metadata.js +269 -13
  93. package/dist/core/metadata.js.map +1 -1
  94. package/dist/core/recipe/bracket-normalizer.d.ts +1 -1
  95. package/dist/core/recipe/bracket-normalizer.d.ts.map +1 -1
  96. package/dist/core/recipe/bracket-normalizer.js +3 -0
  97. package/dist/core/recipe/bracket-normalizer.js.map +1 -1
  98. package/dist/core/recipe/computed.d.ts +1 -1
  99. package/dist/core/recipe/computed.d.ts.map +1 -1
  100. package/dist/core/recipe/index.d.ts.map +1 -1
  101. package/dist/core/recipe/index.js +22 -4
  102. package/dist/core/recipe/index.js.map +1 -1
  103. package/dist/core/recipe/patcher.js +0 -24
  104. package/dist/core/recipe/patcher.js.map +1 -1
  105. package/dist/core/recipe/types.d.ts +1 -1
  106. package/dist/core/recipe/types.d.ts.map +1 -1
  107. package/dist/core/recipe/verifier.js.map +1 -1
  108. package/dist/core/selector.js +0 -1
  109. package/dist/core/selector.js.map +1 -1
  110. package/dist/core/template-listing.d.ts +6 -8
  111. package/dist/core/template-listing.d.ts.map +1 -1
  112. package/dist/core/template-listing.js +24 -0
  113. package/dist/core/template-listing.js.map +1 -1
  114. package/dist/core/template-search.d.ts +36 -0
  115. package/dist/core/template-search.d.ts.map +1 -0
  116. package/dist/core/template-search.js +84 -0
  117. package/dist/core/template-search.js.map +1 -0
  118. package/dist/core/unified-pipeline.d.ts +2 -0
  119. package/dist/core/unified-pipeline.d.ts.map +1 -1
  120. package/dist/core/unified-pipeline.js +19 -1
  121. package/dist/core/unified-pipeline.js.map +1 -1
  122. package/dist/core/validation/template.d.ts +32 -0
  123. package/dist/core/validation/template.d.ts.map +1 -1
  124. package/dist/core/validation/template.js +163 -3
  125. package/dist/core/validation/template.js.map +1 -1
  126. package/dist/index.d.ts +1 -0
  127. package/dist/index.d.ts.map +1 -1
  128. package/dist/index.js +2 -0
  129. package/dist/index.js.map +1 -1
  130. package/gemini-extension.json +1 -1
  131. package/node_modules/@usejunior/docx-core/dist/.tsbuildinfo +1 -1
  132. package/node_modules/@usejunior/docx-core/dist/atomizer.d.ts.map +1 -1
  133. package/node_modules/@usejunior/docx-core/dist/atomizer.js +12 -4
  134. package/node_modules/@usejunior/docx-core/dist/atomizer.js.map +1 -1
  135. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/atomLcs.d.ts +0 -14
  136. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/atomLcs.d.ts.map +1 -1
  137. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/atomLcs.js +31 -2
  138. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/atomLcs.js.map +1 -1
  139. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/documentReconstructor.d.ts +11 -0
  140. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/documentReconstructor.d.ts.map +1 -1
  141. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/documentReconstructor.js +180 -6
  142. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/documentReconstructor.js.map +1 -1
  143. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/hierarchicalLcs.d.ts +14 -4
  144. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/hierarchicalLcs.d.ts.map +1 -1
  145. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/hierarchicalLcs.js +344 -60
  146. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/hierarchicalLcs.js.map +1 -1
  147. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/inPlaceModifier.d.ts +35 -1
  148. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/inPlaceModifier.d.ts.map +1 -1
  149. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/inPlaceModifier.js +186 -12
  150. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/inPlaceModifier.js.map +1 -1
  151. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/pipeline.d.ts.map +1 -1
  152. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/pipeline.js +31 -13
  153. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/pipeline.js.map +1 -1
  154. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/xmlToWmlElement.d.ts.map +1 -1
  155. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/xmlToWmlElement.js +3 -2
  156. package/node_modules/@usejunior/docx-core/dist/baselines/atomizer/xmlToWmlElement.js.map +1 -1
  157. package/node_modules/@usejunior/docx-core/dist/format-detection.d.ts.map +1 -1
  158. package/node_modules/@usejunior/docx-core/dist/format-detection.js +2 -1
  159. package/node_modules/@usejunior/docx-core/dist/format-detection.js.map +1 -1
  160. package/node_modules/@usejunior/docx-core/dist/move-detection.d.ts.map +1 -1
  161. package/node_modules/@usejunior/docx-core/dist/move-detection.js +3 -4
  162. package/node_modules/@usejunior/docx-core/dist/move-detection.js.map +1 -1
  163. package/node_modules/@usejunior/docx-core/dist/primitives/comments.d.ts +2 -2
  164. package/node_modules/@usejunior/docx-core/dist/primitives/comments.d.ts.map +1 -1
  165. package/node_modules/@usejunior/docx-core/dist/primitives/comments.js +7 -2
  166. package/node_modules/@usejunior/docx-core/dist/primitives/comments.js.map +1 -1
  167. package/node_modules/@usejunior/docx-core/dist/primitives/document.d.ts +2 -2
  168. package/node_modules/@usejunior/docx-core/dist/primitives/document.d.ts.map +1 -1
  169. package/node_modules/@usejunior/docx-core/dist/primitives/dom-helpers.d.ts +1 -5
  170. package/node_modules/@usejunior/docx-core/dist/primitives/dom-helpers.d.ts.map +1 -1
  171. package/node_modules/@usejunior/docx-core/dist/primitives/dom-helpers.js +12 -25
  172. package/node_modules/@usejunior/docx-core/dist/primitives/dom-helpers.js.map +1 -1
  173. package/node_modules/@usejunior/docx-core/dist/primitives/layout.d.ts.map +1 -1
  174. package/node_modules/@usejunior/docx-core/dist/primitives/layout.js +4 -6
  175. package/node_modules/@usejunior/docx-core/dist/primitives/layout.js.map +1 -1
  176. package/node_modules/@usejunior/docx-core/dist/primitives/xml.d.ts.map +1 -1
  177. package/node_modules/@usejunior/docx-core/dist/primitives/xml.js +2 -0
  178. package/node_modules/@usejunior/docx-core/dist/primitives/xml.js.map +1 -1
  179. package/node_modules/@usejunior/docx-core/package.json +3 -3
  180. package/package.json +29 -15
  181. package/skills/canonical-markdown-authoring/CONNECTORS.md +67 -0
  182. package/skills/canonical-markdown-authoring/SKILL.md +565 -0
  183. package/skills/client-email/SKILL.md +2 -0
  184. package/skills/cloud-service-agreement/CONNECTORS.md +2 -2
  185. package/skills/cloud-service-agreement/SKILL.md +39 -2
  186. package/skills/cloud-service-agreement/template-filling-execution.md +92 -0
  187. package/skills/data-privacy-agreement/CONNECTORS.md +2 -2
  188. package/skills/data-privacy-agreement/SKILL.md +2 -0
  189. package/skills/delaware-franchise-tax/SKILL.md +2 -0
  190. package/skills/edit-docx-agreement/SKILL.md +2 -0
  191. package/skills/employment-contract/CONNECTORS.md +2 -2
  192. package/skills/employment-contract/SKILL.md +2 -0
  193. package/skills/iso-27001-evidence-collection/SKILL.md +2 -0
  194. package/skills/iso-27001-internal-audit/SKILL.md +2 -0
  195. package/skills/nda/CONNECTORS.md +2 -2
  196. package/skills/nda/SKILL.md +46 -2
  197. package/skills/nda/template-filling-execution.md +98 -0
  198. package/skills/non-compete-contract-explainer/SKILL.md +107 -0
  199. package/skills/non-compete-contract-explainer/content/wyoming.md +286 -0
  200. package/skills/non-compete-contract-explainer/manifest.json +18 -0
  201. package/skills/open-agreements/CONNECTORS.md +2 -2
  202. package/skills/open-agreements/SKILL.md +165 -67
  203. package/skills/open-agreements/template-filling-execution.md +92 -0
  204. package/skills/recipe-quality-audit/SKILL.md +2 -0
  205. package/skills/safe/CONNECTORS.md +2 -2
  206. package/skills/safe/SKILL.md +39 -2
  207. package/skills/safe/template-filling-execution.md +92 -0
  208. package/skills/services-agreement/CONNECTORS.md +2 -2
  209. package/skills/services-agreement/SKILL.md +40 -1
  210. package/skills/services-agreement/template-filling-execution.md +81 -0
  211. package/skills/shared/template-filling-execution.md +2 -2
  212. package/skills/soc2-readiness/SKILL.md +2 -0
  213. package/skills/unit-test-philosophy/SKILL.md +3 -0
  214. package/skills/venture-financing/CONNECTORS.md +2 -2
  215. package/skills/venture-financing/SKILL.md +2 -0
  216. package/content/templates/openagreements-restrictive-covenant-wyoming/practice-note.md +0 -103
  217. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/CHANGELOG.md +0 -468
  218. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/LICENSE +0 -8
  219. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/SECURITY.md +0 -50
  220. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/index.d.ts +0 -43
  221. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/lib/.eslintrc.yml +0 -2
  222. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/lib/conventions.js +0 -203
  223. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/lib/dom-parser.js +0 -322
  224. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/lib/dom.js +0 -1879
  225. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/lib/entities.js +0 -2166
  226. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/lib/index.js +0 -4
  227. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/lib/sax.js +0 -662
  228. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/package.json +0 -71
  229. package/node_modules/@usejunior/docx-core/node_modules/@xmldom/xmldom/readme.md +0 -356
  230. package/node_modules/core-util-is/LICENSE +0 -19
  231. package/node_modules/core-util-is/README.md +0 -3
  232. package/node_modules/core-util-is/lib/util.js +0 -107
  233. package/node_modules/core-util-is/package.json +0 -38
  234. package/node_modules/immediate/LICENSE.txt +0 -20
  235. package/node_modules/immediate/README.md +0 -93
  236. package/node_modules/immediate/dist/immediate.js +0 -75
  237. package/node_modules/immediate/dist/immediate.min.js +0 -1
  238. package/node_modules/immediate/lib/browser.js +0 -69
  239. package/node_modules/immediate/lib/index.js +0 -73
  240. package/node_modules/immediate/package.json +0 -42
  241. package/node_modules/inherits/LICENSE +0 -16
  242. package/node_modules/inherits/README.md +0 -42
  243. package/node_modules/inherits/inherits.js +0 -9
  244. package/node_modules/inherits/inherits_browser.js +0 -27
  245. package/node_modules/inherits/package.json +0 -29
  246. package/node_modules/isarray/.npmignore +0 -1
  247. package/node_modules/isarray/.travis.yml +0 -4
  248. package/node_modules/isarray/Makefile +0 -6
  249. package/node_modules/isarray/README.md +0 -60
  250. package/node_modules/isarray/component.json +0 -19
  251. package/node_modules/isarray/index.js +0 -5
  252. package/node_modules/isarray/package.json +0 -45
  253. package/node_modules/isarray/test.js +0 -20
  254. package/node_modules/jszip/.codeclimate.yml +0 -16
  255. package/node_modules/jszip/.editorconfig +0 -8
  256. package/node_modules/jszip/.eslintrc.js +0 -43
  257. package/node_modules/jszip/.github/workflows/pr.yaml +0 -58
  258. package/node_modules/jszip/.jekyll-metadata +0 -0
  259. package/node_modules/jszip/.travis.yml +0 -17
  260. package/node_modules/jszip/CHANGES.md +0 -204
  261. package/node_modules/jszip/LICENSE.markdown +0 -651
  262. package/node_modules/jszip/README.markdown +0 -33
  263. package/node_modules/jszip/deps.js +0 -37
  264. package/node_modules/jszip/dist/jszip.js +0 -11577
  265. package/node_modules/jszip/dist/jszip.min.js +0 -13
  266. package/node_modules/jszip/graph.svg +0 -601
  267. package/node_modules/jszip/index.d.ts +0 -330
  268. package/node_modules/jszip/lib/base64.js +0 -106
  269. package/node_modules/jszip/lib/compressedObject.js +0 -74
  270. package/node_modules/jszip/lib/compressions.js +0 -14
  271. package/node_modules/jszip/lib/crc32.js +0 -77
  272. package/node_modules/jszip/lib/defaults.js +0 -11
  273. package/node_modules/jszip/lib/external.js +0 -18
  274. package/node_modules/jszip/lib/flate.js +0 -85
  275. package/node_modules/jszip/lib/generate/ZipFileWorker.js +0 -539
  276. package/node_modules/jszip/lib/generate/index.js +0 -57
  277. package/node_modules/jszip/lib/index.js +0 -55
  278. package/node_modules/jszip/lib/license_header.js +0 -11
  279. package/node_modules/jszip/lib/load.js +0 -88
  280. package/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +0 -74
  281. package/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +0 -42
  282. package/node_modules/jszip/lib/nodejsUtils.js +0 -57
  283. package/node_modules/jszip/lib/object.js +0 -384
  284. package/node_modules/jszip/lib/readable-stream-browser.js +0 -10
  285. package/node_modules/jszip/lib/reader/ArrayReader.js +0 -57
  286. package/node_modules/jszip/lib/reader/DataReader.js +0 -116
  287. package/node_modules/jszip/lib/reader/NodeBufferReader.js +0 -19
  288. package/node_modules/jszip/lib/reader/StringReader.js +0 -38
  289. package/node_modules/jszip/lib/reader/Uint8ArrayReader.js +0 -22
  290. package/node_modules/jszip/lib/reader/readerFor.js +0 -28
  291. package/node_modules/jszip/lib/signature.js +0 -7
  292. package/node_modules/jszip/lib/stream/ConvertWorker.js +0 -26
  293. package/node_modules/jszip/lib/stream/Crc32Probe.js +0 -24
  294. package/node_modules/jszip/lib/stream/DataLengthProbe.js +0 -29
  295. package/node_modules/jszip/lib/stream/DataWorker.js +0 -116
  296. package/node_modules/jszip/lib/stream/GenericWorker.js +0 -263
  297. package/node_modules/jszip/lib/stream/StreamHelper.js +0 -214
  298. package/node_modules/jszip/lib/support.js +0 -38
  299. package/node_modules/jszip/lib/utf8.js +0 -275
  300. package/node_modules/jszip/lib/utils.js +0 -501
  301. package/node_modules/jszip/lib/zipEntries.js +0 -261
  302. package/node_modules/jszip/lib/zipEntry.js +0 -293
  303. package/node_modules/jszip/lib/zipObject.js +0 -133
  304. package/node_modules/jszip/package.json +0 -67
  305. package/node_modules/jszip/sponsors.md +0 -21
  306. package/node_modules/jszip/tsconfig.json +0 -101
  307. package/node_modules/jszip/vendor/FileSaver.js +0 -247
  308. package/node_modules/lie/README.md +0 -62
  309. package/node_modules/lie/dist/lie.js +0 -350
  310. package/node_modules/lie/dist/lie.min.js +0 -1
  311. package/node_modules/lie/dist/lie.polyfill.js +0 -358
  312. package/node_modules/lie/dist/lie.polyfill.min.js +0 -1
  313. package/node_modules/lie/lib/browser.js +0 -273
  314. package/node_modules/lie/lib/index.js +0 -298
  315. package/node_modules/lie/license.md +0 -7
  316. package/node_modules/lie/lie.d.ts +0 -244
  317. package/node_modules/lie/package.json +0 -69
  318. package/node_modules/lie/polyfill.js +0 -4
  319. package/node_modules/pako/LICENSE +0 -21
  320. package/node_modules/pako/README.md +0 -191
  321. package/node_modules/pako/dist/pako.js +0 -6818
  322. package/node_modules/pako/dist/pako.min.js +0 -1
  323. package/node_modules/pako/dist/pako_deflate.js +0 -3997
  324. package/node_modules/pako/dist/pako_deflate.min.js +0 -1
  325. package/node_modules/pako/dist/pako_inflate.js +0 -3300
  326. package/node_modules/pako/dist/pako_inflate.min.js +0 -1
  327. package/node_modules/pako/index.js +0 -14
  328. package/node_modules/pako/lib/deflate.js +0 -400
  329. package/node_modules/pako/lib/inflate.js +0 -423
  330. package/node_modules/pako/lib/utils/common.js +0 -105
  331. package/node_modules/pako/lib/utils/strings.js +0 -187
  332. package/node_modules/pako/lib/zlib/README +0 -59
  333. package/node_modules/pako/lib/zlib/adler32.js +0 -51
  334. package/node_modules/pako/lib/zlib/constants.js +0 -68
  335. package/node_modules/pako/lib/zlib/crc32.js +0 -59
  336. package/node_modules/pako/lib/zlib/deflate.js +0 -1874
  337. package/node_modules/pako/lib/zlib/gzheader.js +0 -58
  338. package/node_modules/pako/lib/zlib/inffast.js +0 -345
  339. package/node_modules/pako/lib/zlib/inflate.js +0 -1556
  340. package/node_modules/pako/lib/zlib/inftrees.js +0 -343
  341. package/node_modules/pako/lib/zlib/messages.js +0 -32
  342. package/node_modules/pako/lib/zlib/trees.js +0 -1222
  343. package/node_modules/pako/lib/zlib/zstream.js +0 -47
  344. package/node_modules/pako/package.json +0 -44
  345. package/node_modules/process-nextick-args/index.js +0 -45
  346. package/node_modules/process-nextick-args/license.md +0 -19
  347. package/node_modules/process-nextick-args/package.json +0 -25
  348. package/node_modules/process-nextick-args/readme.md +0 -18
  349. package/node_modules/readable-stream/.travis.yml +0 -34
  350. package/node_modules/readable-stream/CONTRIBUTING.md +0 -38
  351. package/node_modules/readable-stream/GOVERNANCE.md +0 -136
  352. package/node_modules/readable-stream/LICENSE +0 -47
  353. package/node_modules/readable-stream/README.md +0 -58
  354. package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
  355. package/node_modules/readable-stream/duplex-browser.js +0 -1
  356. package/node_modules/readable-stream/duplex.js +0 -1
  357. package/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
  358. package/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
  359. package/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
  360. package/node_modules/readable-stream/lib/_stream_transform.js +0 -214
  361. package/node_modules/readable-stream/lib/_stream_writable.js +0 -685
  362. package/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -78
  363. package/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -84
  364. package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
  365. package/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
  366. package/node_modules/readable-stream/package.json +0 -52
  367. package/node_modules/readable-stream/passthrough.js +0 -1
  368. package/node_modules/readable-stream/readable-browser.js +0 -7
  369. package/node_modules/readable-stream/readable.js +0 -19
  370. package/node_modules/readable-stream/transform.js +0 -1
  371. package/node_modules/readable-stream/writable-browser.js +0 -1
  372. package/node_modules/readable-stream/writable.js +0 -8
  373. package/node_modules/safe-buffer/LICENSE +0 -21
  374. package/node_modules/safe-buffer/README.md +0 -584
  375. package/node_modules/safe-buffer/index.d.ts +0 -187
  376. package/node_modules/safe-buffer/index.js +0 -62
  377. package/node_modules/safe-buffer/package.json +0 -37
  378. package/node_modules/setimmediate/LICENSE.txt +0 -20
  379. package/node_modules/setimmediate/package.json +0 -30
  380. package/node_modules/setimmediate/setImmediate.js +0 -186
  381. package/node_modules/string_decoder/.travis.yml +0 -50
  382. package/node_modules/string_decoder/LICENSE +0 -48
  383. package/node_modules/string_decoder/README.md +0 -47
  384. package/node_modules/string_decoder/lib/string_decoder.js +0 -296
  385. package/node_modules/string_decoder/package.json +0 -31
  386. package/node_modules/util-deprecate/History.md +0 -16
  387. package/node_modules/util-deprecate/LICENSE +0 -24
  388. package/node_modules/util-deprecate/README.md +0 -53
  389. package/node_modules/util-deprecate/browser.js +0 -67
  390. package/node_modules/util-deprecate/node.js +0 -6
  391. package/node_modules/util-deprecate/package.json +0 -27
@@ -1 +1 @@
1
- {"version":3,"file":"template-listing.d.ts","sourceRoot":"","sources":["../../src/core/template-listing.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B;AAMD,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAKjD;AAED,sDAAsD;AACtD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4BrD;AAED,wBAAgB,SAAS,CACvB,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC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,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgDrD;AAED,wBAAgB,SAAS,CACvB,MAAM,EAAE,eAAe,EAAE,EACzB,cAAc,EAAE,MAAM,EAAE,GACvB,iBAAiB,EAAE,CAgBrB;AAMD,wBAAgB,iBAAiB,IAAI,gBAAgB,EAAE,CAyBtD"}
@@ -26,6 +26,9 @@ export function sourceName(url) {
26
26
  if (host === 'github.com' && pathname.startsWith('/open-agreements/')) {
27
27
  return 'OpenAgreements';
28
28
  }
29
+ if (host === 'github.com' && pathname.startsWith('/cooleyLLP/seriesseed')) {
30
+ return 'Series Seed';
31
+ }
29
32
  if (host === 'github.com' && pathname.startsWith('/papertrail/legal-docs')) {
30
33
  return 'Papertrail';
31
34
  }
@@ -38,8 +41,23 @@ export function sourceName(url) {
38
41
  'ycombinator.com': 'Y Combinator',
39
42
  'bookface-static.ycombinator.com': 'Y Combinator',
40
43
  'nvca.org': 'NVCA',
44
+ 'openagreements.org': 'OpenAgreements',
41
45
  'openagreements.ai': 'OpenAgreements',
42
46
  };
47
+ // For github.com URLs without a special-cased path, surface the
48
+ // org/owner segment as the source — that's the publishing entity for
49
+ // CC-BY-style attribution (e.g. github.com/Bonterms/Mutual-NDA → Bonterms).
50
+ // A small org map normalizes display names where the github handle
51
+ // differs from the conventional brand (CommonPaper → Common Paper).
52
+ if (host === 'github.com') {
53
+ const org = pathname.split('/').filter(Boolean)[0];
54
+ if (org) {
55
+ const orgMap = {
56
+ CommonPaper: 'Common Paper',
57
+ };
58
+ return orgMap[org] ?? org;
59
+ }
60
+ }
43
61
  return map[host] ?? host;
44
62
  }
45
63
  catch {
@@ -54,8 +72,13 @@ export function mapFields(fields, priorityFields) {
54
72
  required: required.has(f.name),
55
73
  section: f.section ?? null,
56
74
  description: f.description,
75
+ ...(f.display_label !== undefined ? { display_label: f.display_label } : {}),
57
76
  default: f.default ?? null,
58
77
  default_value_rationale: f.default_value_rationale ?? null,
78
+ ...((f.type === 'enum' || f.type === 'multiselect') && f.options
79
+ ? { options: [...f.options] }
80
+ : {}),
81
+ ...(f.items ? { items: mapFields(f.items, []) } : {}),
59
82
  }));
60
83
  }
61
84
  // ---------------------------------------------------------------------------
@@ -75,6 +98,7 @@ export function listTemplateItems() {
75
98
  source_url: meta.source_url,
76
99
  source: sourceName(meta.source_url),
77
100
  attribution_text: meta.attribution_text,
101
+ allow_derivatives: meta.allow_derivatives,
78
102
  fields: mapFields(meta.fields, meta.priority_fields),
79
103
  });
80
104
  }
@@ -1 +1 @@
1
- {"version":3,"file":"template-listing.js","sourceRoot":"","sources":["../../src/core/template-listing.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AA4BxD,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,IAAI,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAC9G,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAEjC,IAAI,IAAI,KAAK,YAAY,IAAI,QAAQ,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACtE,OAAO,gBAAgB,CAAC;QAC1B,CAAC;QACD,IAAI,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CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * BM25 template search via MiniSearch.
3
+ *
4
+ * Builds an in-memory index from the template list on each call (sub-millisecond
5
+ * at 100+ templates). No caching, no persistence — stateless and serverless-safe.
6
+ */
7
+ export interface TemplateSearchResult {
8
+ template_id: string;
9
+ display_name: string;
10
+ category: string;
11
+ description: string;
12
+ source: string | null;
13
+ field_count: number;
14
+ score: number;
15
+ }
16
+ export interface TemplateSearchOptions {
17
+ query: string;
18
+ category?: string;
19
+ source?: string;
20
+ max_results?: number;
21
+ }
22
+ /** Minimal shape required from TemplateItem — avoids coupling to _shared.ts types. */
23
+ interface TemplateItemLike {
24
+ name: string;
25
+ display_name: string;
26
+ category: string;
27
+ description: string;
28
+ source: string | null;
29
+ fields: {
30
+ name: string;
31
+ section: string | null;
32
+ }[];
33
+ }
34
+ export declare function searchTemplates(templates: TemplateItemLike[], options: TemplateSearchOptions): TemplateSearchResult[];
35
+ export {};
36
+ //# sourceMappingURL=template-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-search.d.ts","sourceRoot":"","sources":["../../src/core/template-search.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,sFAAsF;AACtF,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,CAAC;CACpD;AA+BD,wBAAgB,eAAe,CAC7B,SAAS,EAAE,gBAAgB,EAAE,EAC7B,OAAO,EAAE,qBAAqB,GAC7B,oBAAoB,EAAE,CAuDxB"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * BM25 template search via MiniSearch.
3
+ *
4
+ * Builds an in-memory index from the template list on each call (sub-millisecond
5
+ * at 100+ templates). No caching, no persistence — stateless and serverless-safe.
6
+ */
7
+ import MiniSearch from 'minisearch';
8
+ // ---------------------------------------------------------------------------
9
+ // Index construction
10
+ // ---------------------------------------------------------------------------
11
+ function toSearchDocument(template) {
12
+ const sections = new Set();
13
+ const fieldNames = [];
14
+ for (const field of template.fields) {
15
+ fieldNames.push(field.name.replace(/_/g, ' '));
16
+ if (field.section)
17
+ sections.add(field.section);
18
+ }
19
+ return {
20
+ id: template.name,
21
+ display_name: template.display_name,
22
+ description: template.description,
23
+ // Hyphens → spaces for tokenization (MiniSearch splits on whitespace)
24
+ category: template.category.replace(/-/g, ' '),
25
+ source: template.source ?? '',
26
+ field_names: fieldNames.join(' '),
27
+ section_names: [...sections].join(' '),
28
+ };
29
+ }
30
+ // ---------------------------------------------------------------------------
31
+ // Search
32
+ // ---------------------------------------------------------------------------
33
+ export function searchTemplates(templates, options) {
34
+ const maxResults = options.max_results ?? 10;
35
+ const index = new MiniSearch({
36
+ fields: ['display_name', 'description', 'category', 'source', 'field_names', 'section_names'],
37
+ storeFields: ['id'],
38
+ searchOptions: {
39
+ boost: {
40
+ display_name: 3,
41
+ description: 2,
42
+ category: 1.5,
43
+ source: 1.5,
44
+ field_names: 1,
45
+ section_names: 0.5,
46
+ },
47
+ prefix: true,
48
+ fuzzy: (term) => (term.length <= 3 ? false : 0.2),
49
+ },
50
+ });
51
+ // Build lookup map for original template data (preserves original category/source values)
52
+ const templateMap = new Map();
53
+ for (const t of templates) {
54
+ index.add(toSearchDocument(t));
55
+ templateMap.set(t.name, t);
56
+ }
57
+ const raw = index.search(options.query);
58
+ // Map hits back to original template data (not MiniSearch stored fields)
59
+ let results = raw.flatMap((hit) => {
60
+ const t = templateMap.get(hit.id);
61
+ if (!t)
62
+ return [];
63
+ return [{
64
+ template_id: t.name,
65
+ display_name: t.display_name,
66
+ category: t.category,
67
+ description: t.description,
68
+ source: t.source,
69
+ field_count: t.fields.length,
70
+ score: hit.score,
71
+ }];
72
+ });
73
+ // Exact case-insensitive post-filters
74
+ if (options.category) {
75
+ const cat = options.category.toLowerCase();
76
+ results = results.filter((r) => r.category.toLowerCase() === cat);
77
+ }
78
+ if (options.source) {
79
+ const src = options.source.toLowerCase();
80
+ results = results.filter((r) => r.source?.toLowerCase() === src);
81
+ }
82
+ return results.slice(0, maxResults);
83
+ }
84
+ //# sourceMappingURL=template-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-search.js","sourceRoot":"","sources":["../../src/core/template-search.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AA2CpC,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E,SAAS,gBAAgB,CAAC,QAA0B;IAClD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC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AAM,EAAE,CAAC;QACnB,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACzC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACtC,CAAC"}
@@ -7,6 +7,7 @@
7
7
  * this module handles the surrounding orchestration: temp dir, copy, clean→patch,
8
8
  * selections, fill, verify, cleanup.
9
9
  */
10
+ import { type ConfirmClauseDescriptor } from './fill-pipeline.js';
10
11
  import type { FieldDefinition, CleanConfig } from './metadata.js';
11
12
  import type { SelectionsConfig } from './selector.js';
12
13
  import type { VerifyResult } from './recipe/types.js';
@@ -27,6 +28,7 @@ export interface PipelineOptions {
27
28
  coerceBooleans?: boolean;
28
29
  computeDisplayFields?: (data: Record<string, unknown>) => void;
29
30
  signingTagDefaults?: Record<string, string>;
31
+ confirmClauses?: ConfirmClauseDescriptor[];
30
32
  fixSmartQuotes?: boolean;
31
33
  verify: (outputPath: string) => VerifyResult | Promise<VerifyResult>;
32
34
  postProcess?: (outputPath: string) => void | Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"unified-pipeline.d.ts","sourceRoot":"","sources":["../../src/core/unified-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OA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IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAG3D,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CA8IvF"}
@@ -34,6 +34,15 @@ const W_NS = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
34
34
  export async function runFillPipeline(options) {
35
35
  const { inputPath, outputPath, values, fields, priorityFieldNames = [], cleanPatch, selectionsConfig, coerceBooleans = false, computeDisplayFields, fixSmartQuotes = false, verify, postProcess, keepIntermediate = false, } = options;
36
36
  const tempDir = mkdtempSync(join(tmpdir(), 'fill-pipeline-'));
37
+ const syntheticFieldKeys = new Set(fields
38
+ .filter((field) => field.type === 'multiselect' && field.derive_booleans === true)
39
+ .flatMap((field) => (field.options ?? []).map((option) => `${option}_enabled`)));
40
+ // The cover-notice derived boolean is synthetic — always exclude it from
41
+ // fieldsUsed. prepareFillData now defines `any_confirmation_pending`
42
+ // unconditionally (so a template carrying the `{IF any_confirmation_pending}`
43
+ // tag can't crash a consumer that supplies no confirm clauses), so the
44
+ // exclusion must be unconditional too — otherwise it leaks into fieldsUsed.
45
+ syntheticFieldKeys.add('any_confirmation_pending');
37
46
  let stages;
38
47
  try {
39
48
  // Step 2: Copy source to temp dir
@@ -76,6 +85,7 @@ export async function runFillPipeline(options) {
76
85
  coerceBooleans,
77
86
  computeDisplayFields,
78
87
  signingTagDefaults: options.signingTagDefaults,
88
+ confirmClauses: options.confirmClauses,
79
89
  });
80
90
  // Step 5: Read current buffer; apply selections if configured
81
91
  let templateBuf = readFileSync(currentPath);
@@ -119,7 +129,7 @@ export async function runFillPipeline(options) {
119
129
  }
120
130
  return {
121
131
  outputPath,
122
- fieldsUsed: Object.keys(data),
132
+ fieldsUsed: Object.keys(data).filter((key) => !syntheticFieldKeys.has(key)),
123
133
  stages,
124
134
  };
125
135
  }
@@ -134,6 +144,11 @@ export async function runFillPipeline(options) {
134
144
  * Collapse runs of 2+ spaces into a single space within all text paragraphs.
135
145
  * Fixes double spaces left when empty field substitutions (e.g. {initial_word_lower} → "")
136
146
  * leave adjacent spaces in the DOCX.
147
+ *
148
+ * Paragraphs containing Word field characters (w:fldChar) are skipped because
149
+ * getParagraphText treats field-code runs as empty, so "Page " + PAGE field +
150
+ * " of " looks like "Page of " and the replacement would delete the field run
151
+ * that sits between the two space-bearing runs.
137
152
  */
138
153
  async function collapseDoubleSpacesInDocx(docxPath) {
139
154
  const zip = new AdmZip(docxPath);
@@ -151,6 +166,9 @@ async function collapseDoubleSpacesInDocx(docxPath) {
151
166
  let partModified = false;
152
167
  for (let i = 0; i < paragraphs.length; i++) {
153
168
  const para = paragraphs[i];
169
+ if (para.getElementsByTagNameNS(W_NS, 'fldChar').length > 0) {
170
+ continue;
171
+ }
154
172
  let text = getParagraphText(para);
155
173
  let match;
156
174
  while ((match = / {2,}/.exec(text)) !== null) {
@@ -1 +1 @@
1
- {"version":3,"file":"unified-pipeline.js","sourceRoot":"","sources":["../../src/core/unified-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,C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GAAG,IAAI,CAAC;gBACtB,CAAC;gBAAC,MAAM,CAAC;oBACP,MAAM;gBACR,CAAC;gBACD,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QAED,IAAI,YAAY,EAAE,CAAC;YACjB,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;YAClF,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;IAED,IAAI,WAAW,EAAE,CAAC;QAChB,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC"}
@@ -4,6 +4,38 @@ export interface TemplateValidationResult {
4
4
  errors: string[];
5
5
  warnings: string[];
6
6
  }
7
+ /**
8
+ * Enforce the `statutory_compliance_representation` contract against the rendered
9
+ * template text. This is the load-bearing guard that the decided `confirm=`
10
+ * behavior actually shipped — three checks per field:
11
+ *
12
+ * 1. The clause renders the highlighted `[CONFIRM before signing: …; see <url>]`
13
+ * bracket gated on `{IF !<field>}`. Presence of a bare `{IF !field}` is NOT
14
+ * sufficient (the legacy `when=field omitted="…"` mechanism also emits one),
15
+ * so the negated conditional MUST be immediately followed by the literal
16
+ * bracket.
17
+ * 2. The URL and note inside the bracket EQUAL the field's metadata
18
+ * `authority_url` / `confirm_note`. These now have a single authoring source
19
+ * (metadata.yaml — the directive no longer restates them), so this is no
20
+ * longer an author-drift check between two hand-edited files. It is an
21
+ * integrity check between metadata.yaml and the COMMITTED rendered artifact:
22
+ * `validateTemplate` scans the committed `template.docx`, so a stale DOCX (or
23
+ * `.template.generated.json`) — e.g. a metadata edit shipped without
24
+ * regenerating — is caught here, as are hand-authored JSON templates that
25
+ * carry `confirm`/`authority_url`/`confirm_note` directly. Equality, not
26
+ * substring: a value with an extra suffix must fail.
27
+ * 3. The clause body always renders — i.e. the affirmative `{IF <field>}` form
28
+ * is absent. A `confirm=` clause only ever emits `{IF !<field>}`; a legacy
29
+ * `when=<field>` clause wraps its body in `{IF <field>}`. Asserting the
30
+ * affirmative form is absent proves the body is unconditional and closes the
31
+ * spoof where an `omitted="[CONFIRM …]"` string mimics the bracket.
32
+ */
33
+ export declare function checkStatutoryComplianceReps(searchableText: string, fields: {
34
+ name: string;
35
+ statutory_compliance_representation?: boolean;
36
+ authority_url?: string;
37
+ confirm_note?: string;
38
+ }[], errors: string[]): void;
7
39
  /**
8
40
  * Validate that a template's metadata fields match the placeholders in its DOCX file.
9
41
  */
@@ -1 +1 @@
1
- {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../src/core/validation/template.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AA+BD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,wBAAwB,CAyLlG"}
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../src/core/validation/template.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AA2CD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,4BAA4B,CAC1C,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,mCAAmC,CAAC,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACxH,MAAM,EAAE,MAAM,EAAE,GACf,IAAI,CAkDN;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,wBAAwB,CAuSlG"}
@@ -31,6 +31,85 @@ function extractDocxText(docxPath) {
31
31
  }
32
32
  return paragraphs.join('\n');
33
33
  }
34
+ /** Decode the handful of XML entities that OOXML escaping can introduce into
35
+ * `<w:t>` text (notably `&amp;` for `&` in a URL), so a captured bracket URL
36
+ * compares equal to the raw `authority_url` from metadata.yaml. */
37
+ function decodeXmlEntities(value) {
38
+ return value
39
+ .replace(/&lt;/g, '<')
40
+ .replace(/&gt;/g, '>')
41
+ .replace(/&quot;/g, '"')
42
+ .replace(/&apos;/g, "'")
43
+ .replace(/&amp;/g, '&');
44
+ }
45
+ /**
46
+ * Enforce the `statutory_compliance_representation` contract against the rendered
47
+ * template text. This is the load-bearing guard that the decided `confirm=`
48
+ * behavior actually shipped — three checks per field:
49
+ *
50
+ * 1. The clause renders the highlighted `[CONFIRM before signing: …; see <url>]`
51
+ * bracket gated on `{IF !<field>}`. Presence of a bare `{IF !field}` is NOT
52
+ * sufficient (the legacy `when=field omitted="…"` mechanism also emits one),
53
+ * so the negated conditional MUST be immediately followed by the literal
54
+ * bracket.
55
+ * 2. The URL and note inside the bracket EQUAL the field's metadata
56
+ * `authority_url` / `confirm_note`. These now have a single authoring source
57
+ * (metadata.yaml — the directive no longer restates them), so this is no
58
+ * longer an author-drift check between two hand-edited files. It is an
59
+ * integrity check between metadata.yaml and the COMMITTED rendered artifact:
60
+ * `validateTemplate` scans the committed `template.docx`, so a stale DOCX (or
61
+ * `.template.generated.json`) — e.g. a metadata edit shipped without
62
+ * regenerating — is caught here, as are hand-authored JSON templates that
63
+ * carry `confirm`/`authority_url`/`confirm_note` directly. Equality, not
64
+ * substring: a value with an extra suffix must fail.
65
+ * 3. The clause body always renders — i.e. the affirmative `{IF <field>}` form
66
+ * is absent. A `confirm=` clause only ever emits `{IF !<field>}`; a legacy
67
+ * `when=<field>` clause wraps its body in `{IF <field>}`. Asserting the
68
+ * affirmative form is absent proves the body is unconditional and closes the
69
+ * spoof where an `omitted="[CONFIRM …]"` string mimics the bracket.
70
+ */
71
+ export function checkStatutoryComplianceReps(searchableText, fields, errors) {
72
+ const scrFields = fields.filter((f) => f.statutory_compliance_representation === true);
73
+ if (scrFields.length === 0)
74
+ return;
75
+ // Capture the field, the note, and the URL. The note uses a lazy `[\s\S]*?` so
76
+ // a literal `]` inside it does not truncate the match; the URL is the
77
+ // non-space, non-`]` run after "; see ".
78
+ const confirmRe = /\{IF !(\w+)\}\s*\[CONFIRM before signing: ([\s\S]*?); see ([^\]\s]+)\]/g;
79
+ const bracketByField = new Map();
80
+ let match;
81
+ while ((match = confirmRe.exec(searchableText)) !== null) {
82
+ bracketByField.set(match[1], {
83
+ note: decodeXmlEntities(match[2]),
84
+ url: decodeXmlEntities(match[3]),
85
+ });
86
+ }
87
+ for (const field of scrFields) {
88
+ const bracket = bracketByField.get(field.name);
89
+ if (bracket === undefined) {
90
+ errors.push(`statutory_compliance_representation field "${field.name}" must be gated by a clause confirm= — ` +
91
+ `no "{IF !${field.name}} [CONFIRM before signing: …; see <url>]" bracket found in the rendered template`);
92
+ continue;
93
+ }
94
+ const { note, url } = bracket;
95
+ if (field.authority_url && url !== field.authority_url) {
96
+ errors.push(`statutory_compliance_representation field "${field.name}" authority_url ` +
97
+ `("${field.authority_url}") does not match the URL in its rendered [CONFIRM …] bracket ` +
98
+ `("${url}") — metadata.yaml and the committed rendered template have drifted (regenerate the template)`);
99
+ }
100
+ if (field.confirm_note && note !== field.confirm_note) {
101
+ errors.push(`statutory_compliance_representation field "${field.name}" confirm_note ` +
102
+ `("${field.confirm_note}") does not match the note in its rendered [CONFIRM …] bracket ` +
103
+ `("${note}") — metadata.yaml and the committed rendered template have drifted (regenerate the template)`);
104
+ }
105
+ // The recital body must render unconditionally: a confirm= clause never
106
+ // wraps its body in an affirmative {IF <field>}.
107
+ if (searchableText.includes(`{IF ${field.name}}`)) {
108
+ errors.push(`statutory_compliance_representation field "${field.name}" must use confirm= (the recital body ` +
109
+ `always renders); found an affirmative "{IF ${field.name}}" indicating legacy when=/omitted gating`);
110
+ }
111
+ }
112
+ }
34
113
  /**
35
114
  * Validate that a template's metadata fields match the placeholders in its DOCX file.
36
115
  */
@@ -60,6 +139,29 @@ export function validateTemplate(templateDir, templateId) {
60
139
  }
61
140
  const metadataFieldNames = new Set(metadata.fields.map((f) => f.name));
62
141
  const priorityFieldNames = new Set(metadata.priority_fields);
142
+ const multiselectFieldNames = new Set(metadata.fields
143
+ .filter((field) => field.type === 'multiselect')
144
+ .map((field) => field.name));
145
+ const derivedBooleanMultiselects = metadata.fields.filter((field) => field.type === 'multiselect' && field.derive_booleans === true);
146
+ // Map from multiselect field name → set of derived `<option>_enabled` keys.
147
+ // Used below to suppress the "field not in DOCX" warning ONLY when at least
148
+ // one of the field's derived keys is actually referenced in the template.
149
+ // A derive_booleans multiselect with zero derived references is genuinely
150
+ // unused and should still warn (or error if priority-listed).
151
+ const derivedKeysByField = new Map(derivedBooleanMultiselects.map((field) => [
152
+ field.name,
153
+ new Set((field.options ?? []).map((option) => `${option}_enabled`)),
154
+ ]));
155
+ const rejectDirectMultiselectConditionals = (foundConditionalFields) => {
156
+ for (const fieldName of multiselectFieldNames) {
157
+ if (!foundConditionalFields.has(fieldName)) {
158
+ continue;
159
+ }
160
+ errors.push(`Multiselect field "${fieldName}" must not be referenced directly in {IF ${fieldName}} ` +
161
+ `(empty arrays are truthy); use derived <option>_enabled keys ` +
162
+ `(when derive_booleans: true) or restructure your template logic.`);
163
+ }
164
+ };
63
165
  // Check if this template uses declarative replacements
64
166
  const replacementsPath = join(templateDir, 'replacements.json');
65
167
  const hasReplacements = existsSync(replacementsPath);
@@ -115,8 +217,19 @@ export function validateTemplate(templateDir, templateId) {
115
217
  while ((docxCondMatch = docxConditionalRegex.exec(docxText)) !== null) {
116
218
  foundConditionalFields.add(docxCondMatch[1]);
117
219
  }
220
+ rejectDirectMultiselectConditionals(foundConditionalFields);
118
221
  // Check metadata fields are covered by tags
119
222
  for (const fieldName of metadataFieldNames) {
223
+ const derivedKeys = derivedKeysByField.get(fieldName);
224
+ if (derivedKeys) {
225
+ // Suppress coverage warning ONLY if at least one derived key is
226
+ // actually referenced. Otherwise the multiselect is dead weight and
227
+ // the warning/error should fire normally.
228
+ const anyDerivedReferenced = [...derivedKeys].some((key) => foundTags.has(key) || foundConditionalFields.has(key));
229
+ if (anyDerivedReferenced) {
230
+ continue;
231
+ }
232
+ }
120
233
  const inTags = foundTags.has(fieldName) || foundConditionalFields.has(fieldName);
121
234
  if (!inTags) {
122
235
  if (priorityFieldNames.has(fieldName)) {
@@ -142,6 +255,9 @@ export function validateTemplate(templateDir, templateId) {
142
255
  }
143
256
  }
144
257
  }
258
+ // Confirm brackets may be injected via replacement values, so search both
259
+ // the original DOCX text and the replacement values.
260
+ checkStatutoryComplianceReps(`${docxText}\n${Object.values(replacements).join('\n')}`, metadata.fields, errors);
145
261
  }
146
262
  else {
147
263
  // Original behavior: scan DOCX text directly for {tags}
@@ -158,11 +274,45 @@ export function validateTemplate(templateDir, templateId) {
158
274
  while ((condMatch = conditionalRegex.exec(text)) !== null) {
159
275
  foundConditionalFields.add(condMatch[1]);
160
276
  }
161
- // Extract array field names from FOR loop constructs
162
- const forLoopRegex = /\{FOR \w+ IN (\w+)\}/g;
277
+ rejectDirectMultiselectConditionals(foundConditionalFields);
278
+ // Extract array field names + item bindings from FOR loop constructs.
279
+ // Each loop has shape `{FOR <item> IN <field>}` and references look like
280
+ // `{$<item>.<rowField>}`. Validate that <field> is declared array-typed in
281
+ // metadata and that <rowField> references resolve through the field's items.
282
+ const forLoopRegex = /\{FOR (\w+) IN (\w+)\}/g;
283
+ const repeatItemBindings = new Map(); // item -> field
163
284
  let forMatch;
164
285
  while ((forMatch = forLoopRegex.exec(text)) !== null) {
165
- foundTags.add(forMatch[1]);
286
+ const itemName = forMatch[1];
287
+ const collectionName = forMatch[2];
288
+ foundTags.add(collectionName);
289
+ repeatItemBindings.set(itemName, collectionName);
290
+ const field = metadata.fields.find((f) => f.name === collectionName);
291
+ if (!field) {
292
+ errors.push(`{FOR ${itemName} IN ${collectionName}} references "${collectionName}" but it is not defined in metadata fields`);
293
+ }
294
+ else if (field.type !== 'array') {
295
+ errors.push(`{FOR ${itemName} IN ${collectionName}} requires "${collectionName}" to be type=array in metadata; declared type=${field.type}`);
296
+ }
297
+ }
298
+ // Validate {$item.rowField} references against metadata items shape.
299
+ const itemRefRegex = /\{\$(\w+)\.(\w+)\}/g;
300
+ let itemRefMatch;
301
+ while ((itemRefMatch = itemRefRegex.exec(text)) !== null) {
302
+ const itemName = itemRefMatch[1];
303
+ const rowFieldName = itemRefMatch[2];
304
+ const collectionName = repeatItemBindings.get(itemName);
305
+ if (!collectionName) {
306
+ errors.push(`{$${itemName}.${rowFieldName}} references item "${itemName}" but no enclosing {FOR ${itemName} IN ...} was found`);
307
+ continue;
308
+ }
309
+ const field = metadata.fields.find((f) => f.name === collectionName);
310
+ if (!field || !field.items)
311
+ continue; // already errored above, or no shape declared
312
+ const itemField = field.items.find((sub) => sub.name === rowFieldName);
313
+ if (!itemField) {
314
+ errors.push(`{$${itemName}.${rowFieldName}} references "${rowFieldName}" but "${collectionName}.items" does not declare it`);
315
+ }
166
316
  }
167
317
  // Security: scan for docx-templates control/code tags that should not exist
168
318
  // in open-source templates. Only simple {identifier} tags are allowed.
@@ -172,6 +322,15 @@ export function validateTemplate(templateDir, templateId) {
172
322
  }
173
323
  // Check for fields in metadata but not in DOCX
174
324
  for (const fieldName of metadataFieldNames) {
325
+ const derivedKeys = derivedKeysByField.get(fieldName);
326
+ if (derivedKeys) {
327
+ // See the parallel branch above: only suppress when at least one
328
+ // derived key is actually referenced.
329
+ const anyDerivedReferenced = [...derivedKeys].some((key) => foundTags.has(key) || foundConditionalFields.has(key));
330
+ if (anyDerivedReferenced) {
331
+ continue;
332
+ }
333
+ }
175
334
  const inDocx = foundTags.has(fieldName) || foundConditionalFields.has(fieldName);
176
335
  if (!inDocx) {
177
336
  if (priorityFieldNames.has(fieldName)) {
@@ -191,6 +350,7 @@ export function validateTemplate(templateDir, templateId) {
191
350
  warnings.push(`Placeholder {${tag}} found in template.docx but not defined in metadata fields`);
192
351
  }
193
352
  }
353
+ checkStatutoryComplianceReps(text, metadata.fields, errors);
194
354
  }
195
355
  return { templateId, valid: errors.length === 0, errors, warnings };
196
356
  }