open-agreements 0.2.1 → 0.3.0

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 (193) hide show
  1. package/README.de.md +371 -0
  2. package/README.es.md +371 -0
  3. package/README.md +40 -2
  4. package/README.pt-br.md +371 -0
  5. package/README.zh.md +371 -0
  6. package/content/templates/closing-checklist/metadata.yaml +6 -13
  7. package/content/templates/closing-checklist/template.docx +0 -0
  8. package/content/templates/common-paper-ai-addendum/README.md +18 -0
  9. package/content/templates/common-paper-ai-addendum/metadata.yaml +136 -0
  10. package/content/templates/common-paper-ai-addendum/replacements.json +5 -0
  11. package/content/templates/common-paper-ai-addendum/selections.json +62 -0
  12. package/content/templates/common-paper-ai-addendum/template.docx +0 -0
  13. package/content/templates/common-paper-ai-addendum-in-app/metadata.yaml +88 -0
  14. package/content/templates/common-paper-ai-addendum-in-app/replacements.json +5 -0
  15. package/content/templates/common-paper-ai-addendum-in-app/selections.json +62 -0
  16. package/content/templates/common-paper-amendment/README.md +18 -0
  17. package/content/templates/common-paper-amendment/metadata.yaml +48 -0
  18. package/content/templates/common-paper-amendment/template.docx +0 -0
  19. package/content/templates/common-paper-business-associate-agreement/README.md +20 -1
  20. package/content/templates/common-paper-business-associate-agreement/metadata.yaml +111 -3
  21. package/content/templates/common-paper-business-associate-agreement/replacements.json +2 -1
  22. package/content/templates/common-paper-business-associate-agreement/selections.json +38 -0
  23. package/content/templates/common-paper-business-associate-agreement/template.docx +0 -0
  24. package/content/templates/common-paper-cloud-service-agreement/README.md +18 -0
  25. package/content/templates/common-paper-cloud-service-agreement/metadata.yaml +48 -0
  26. package/content/templates/common-paper-cloud-service-agreement/template.docx +0 -0
  27. package/content/templates/common-paper-csa-with-ai/README.md +18 -0
  28. package/content/templates/common-paper-csa-with-ai/metadata.yaml +462 -2
  29. package/content/templates/common-paper-csa-with-ai/replacements.json +5 -2
  30. package/content/templates/common-paper-csa-with-ai/selections.json +291 -0
  31. package/content/templates/common-paper-csa-with-ai/template.docx +0 -0
  32. package/content/templates/common-paper-csa-with-sla/README.md +18 -0
  33. package/content/templates/common-paper-csa-with-sla/metadata.yaml +387 -2
  34. package/content/templates/common-paper-csa-with-sla/replacements.json +4 -2
  35. package/content/templates/common-paper-csa-with-sla/selections.json +257 -0
  36. package/content/templates/common-paper-csa-with-sla/template.docx +0 -0
  37. package/content/templates/common-paper-csa-without-sla/README.md +18 -0
  38. package/content/templates/common-paper-csa-without-sla/metadata.yaml +380 -2
  39. package/content/templates/common-paper-csa-without-sla/replacements.json +5 -2
  40. package/content/templates/common-paper-csa-without-sla/selections.json +250 -0
  41. package/content/templates/common-paper-csa-without-sla/template.docx +0 -0
  42. package/content/templates/common-paper-data-processing-agreement/README.md +16 -0
  43. package/content/templates/common-paper-data-processing-agreement/metadata.yaml +397 -3
  44. package/content/templates/common-paper-data-processing-agreement/replacements.json +2 -1
  45. package/content/templates/common-paper-data-processing-agreement/selections.json +211 -0
  46. package/content/templates/common-paper-data-processing-agreement/template.docx +0 -0
  47. package/content/templates/common-paper-design-partner-agreement/README.md +18 -0
  48. package/content/templates/common-paper-design-partner-agreement/metadata.yaml +99 -3
  49. package/content/templates/common-paper-design-partner-agreement/selections.json +27 -0
  50. package/content/templates/common-paper-design-partner-agreement/template.docx +0 -0
  51. package/content/templates/common-paper-independent-contractor-agreement/README.md +18 -0
  52. package/content/templates/common-paper-independent-contractor-agreement/clean.json +8 -0
  53. package/content/templates/common-paper-independent-contractor-agreement/metadata.yaml +52 -0
  54. package/content/templates/common-paper-independent-contractor-agreement/replacements.json +3 -0
  55. package/content/templates/common-paper-independent-contractor-agreement/template.docx +0 -0
  56. package/content/templates/common-paper-letter-of-intent/README.md +18 -0
  57. package/content/templates/common-paper-letter-of-intent/metadata.yaml +48 -0
  58. package/content/templates/common-paper-letter-of-intent/template.docx +0 -0
  59. package/content/templates/common-paper-mutual-nda/README.md +29 -7
  60. package/content/templates/common-paper-mutual-nda/metadata.yaml +48 -0
  61. package/content/templates/common-paper-mutual-nda/template.docx +0 -0
  62. package/content/templates/common-paper-one-way-nda/README.md +13 -0
  63. package/content/templates/common-paper-one-way-nda/metadata.yaml +24 -0
  64. package/content/templates/common-paper-one-way-nda/selections.json +38 -0
  65. package/content/templates/common-paper-one-way-nda/template.docx +0 -0
  66. package/content/templates/common-paper-order-form/README.md +18 -0
  67. package/content/templates/common-paper-order-form/metadata.yaml +115 -3
  68. package/content/templates/common-paper-order-form/replacements.json +5 -2
  69. package/content/templates/common-paper-order-form/selections.json +56 -0
  70. package/content/templates/common-paper-order-form/template.docx +0 -0
  71. package/content/templates/common-paper-order-form-with-sla/README.md +18 -0
  72. package/content/templates/common-paper-order-form-with-sla/metadata.yaml +149 -3
  73. package/content/templates/common-paper-order-form-with-sla/replacements.json +6 -2
  74. package/content/templates/common-paper-order-form-with-sla/selections.json +64 -0
  75. package/content/templates/common-paper-order-form-with-sla/template.docx +0 -0
  76. package/content/templates/common-paper-partnership-agreement/README.md +18 -0
  77. package/content/templates/common-paper-partnership-agreement/metadata.yaml +293 -4
  78. package/content/templates/common-paper-partnership-agreement/replacements.json +5 -2
  79. package/content/templates/common-paper-partnership-agreement/selections.json +138 -0
  80. package/content/templates/common-paper-partnership-agreement/template.docx +0 -0
  81. package/content/templates/common-paper-pilot-agreement/README.md +18 -0
  82. package/content/templates/common-paper-pilot-agreement/metadata.yaml +48 -0
  83. package/content/templates/common-paper-pilot-agreement/template.docx +0 -0
  84. package/content/templates/common-paper-professional-services-agreement/README.md +18 -0
  85. package/content/templates/common-paper-professional-services-agreement/metadata.yaml +338 -4
  86. package/content/templates/common-paper-professional-services-agreement/replacements.json +7 -4
  87. package/content/templates/common-paper-professional-services-agreement/selections.json +207 -0
  88. package/content/templates/common-paper-professional-services-agreement/template.docx +0 -0
  89. package/content/templates/common-paper-statement-of-work/README.md +18 -0
  90. package/content/templates/common-paper-statement-of-work/metadata.yaml +110 -2
  91. package/content/templates/common-paper-statement-of-work/replacements.json +4 -1
  92. package/content/templates/common-paper-statement-of-work/selections.json +55 -0
  93. package/content/templates/common-paper-statement-of-work/template.docx +0 -0
  94. package/content/templates/common-paper-term-sheet/README.md +18 -0
  95. package/content/templates/common-paper-term-sheet/metadata.yaml +48 -0
  96. package/content/templates/common-paper-term-sheet/template.docx +0 -0
  97. package/content/templates/working-group-list/template.docx +0 -0
  98. package/dist/cli/index.d.ts.map +1 -1
  99. package/dist/cli/index.js +47 -10
  100. package/dist/cli/index.js.map +1 -1
  101. package/dist/commands/checklist.d.ts +21 -1
  102. package/dist/commands/checklist.d.ts.map +1 -1
  103. package/dist/commands/checklist.js +176 -44
  104. package/dist/commands/checklist.js.map +1 -1
  105. package/dist/commands/list.d.ts.map +1 -1
  106. package/dist/commands/list.js +1 -46
  107. package/dist/commands/list.js.map +1 -1
  108. package/dist/commands/recipe.js +3 -11
  109. package/dist/commands/recipe.js.map +1 -1
  110. package/dist/core/checklist/format-checklist-docx.d.ts +10 -0
  111. package/dist/core/checklist/format-checklist-docx.d.ts.map +1 -0
  112. package/dist/core/checklist/format-checklist-docx.js +321 -0
  113. package/dist/core/checklist/format-checklist-docx.js.map +1 -0
  114. package/dist/core/checklist/index.d.ts +23 -14
  115. package/dist/core/checklist/index.d.ts.map +1 -1
  116. package/dist/core/checklist/index.js +83 -39
  117. package/dist/core/checklist/index.js.map +1 -1
  118. package/dist/core/checklist/jsonl-stores.d.ts +3 -0
  119. package/dist/core/checklist/jsonl-stores.d.ts.map +1 -0
  120. package/dist/core/checklist/jsonl-stores.js +16 -0
  121. package/dist/core/checklist/jsonl-stores.js.map +1 -0
  122. package/dist/core/checklist/schemas.d.ts +2 -2
  123. package/dist/core/checklist/schemas.js +1 -1
  124. package/dist/core/checklist/schemas.js.map +1 -1
  125. package/dist/core/checklist/state-manager.d.ts +146 -0
  126. package/dist/core/checklist/state-manager.d.ts.map +1 -0
  127. package/dist/core/checklist/state-manager.js +147 -0
  128. package/dist/core/checklist/state-manager.js.map +1 -0
  129. package/dist/core/checklist/status-labels.d.ts +6 -0
  130. package/dist/core/checklist/status-labels.d.ts.map +1 -0
  131. package/dist/core/checklist/status-labels.js +29 -0
  132. package/dist/core/checklist/status-labels.js.map +1 -0
  133. package/dist/core/engine.d.ts +1 -0
  134. package/dist/core/engine.d.ts.map +1 -1
  135. package/dist/core/engine.js +72 -11
  136. package/dist/core/engine.js.map +1 -1
  137. package/dist/core/selector.d.ts +2 -0
  138. package/dist/core/selector.d.ts.map +1 -1
  139. package/dist/core/selector.js +181 -39
  140. package/dist/core/selector.js.map +1 -1
  141. package/dist/core/template-listing.d.ts +40 -0
  142. package/dist/core/template-listing.d.ts.map +1 -0
  143. package/dist/core/template-listing.js +91 -0
  144. package/dist/core/template-listing.js.map +1 -0
  145. package/dist/core/validation/recipe.d.ts.map +1 -1
  146. package/dist/core/validation/recipe.js +47 -61
  147. package/dist/core/validation/recipe.js.map +1 -1
  148. package/dist/core/validation/template.d.ts.map +1 -1
  149. package/dist/core/validation/template.js +10 -2
  150. package/dist/core/validation/template.js.map +1 -1
  151. package/dist/index.d.ts +2 -0
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +4 -0
  154. package/dist/index.js.map +1 -1
  155. package/package.json +8 -2
  156. package/skills/cloud-service-agreement/SKILL.md +9 -0
  157. package/skills/data-privacy-agreement/SKILL.md +9 -0
  158. package/skills/edit-docx-agreement/CONNECTORS.md +20 -0
  159. package/skills/edit-docx-agreement/SKILL.md +77 -0
  160. package/skills/employment-contract/SKILL.md +9 -0
  161. package/skills/iso-27001-evidence-collection/CONNECTORS.md +39 -0
  162. package/skills/iso-27001-evidence-collection/SKILL.md +304 -0
  163. package/skills/iso-27001-evidence-collection/rules/api-exports.md +191 -0
  164. package/skills/iso-27001-evidence-collection/rules/evidence-types.md +107 -0
  165. package/skills/iso-27001-evidence-collection/rules/screenshot-guide.md +77 -0
  166. package/skills/iso-27001-internal-audit/CONNECTORS.md +39 -0
  167. package/skills/iso-27001-internal-audit/SKILL.md +275 -0
  168. package/skills/iso-27001-internal-audit/rules/access-control.md +191 -0
  169. package/skills/iso-27001-internal-audit/rules/business-continuity.md +94 -0
  170. package/skills/iso-27001-internal-audit/rules/change-management.md +211 -0
  171. package/skills/iso-27001-internal-audit/rules/encryption.md +93 -0
  172. package/skills/iso-27001-internal-audit/rules/incident-response.md +127 -0
  173. package/skills/iso-27001-internal-audit/rules/isms-management.md +164 -0
  174. package/skills/iso-27001-internal-audit/rules/logging-monitoring.md +96 -0
  175. package/skills/iso-27001-internal-audit/rules/people-controls.md +161 -0
  176. package/skills/iso-27001-internal-audit/rules/supplier-management.md +92 -0
  177. package/skills/nda/SKILL.md +9 -0
  178. package/skills/open-agreements/SKILL.md +9 -0
  179. package/skills/safe/SKILL.md +9 -0
  180. package/skills/services-agreement/SKILL.md +9 -0
  181. package/skills/soc2-readiness/CONNECTORS.md +39 -0
  182. package/skills/soc2-readiness/SKILL.md +301 -0
  183. package/skills/soc2-readiness/rules/change-vendor-management.md +104 -0
  184. package/skills/soc2-readiness/rules/communication-info.md +85 -0
  185. package/skills/soc2-readiness/rules/control-activities.md +95 -0
  186. package/skills/soc2-readiness/rules/control-environment.md +126 -0
  187. package/skills/soc2-readiness/rules/logical-access.md +264 -0
  188. package/skills/soc2-readiness/rules/monitoring-activities.md +66 -0
  189. package/skills/soc2-readiness/rules/optional-categories.md +264 -0
  190. package/skills/soc2-readiness/rules/privacy-criteria.md +359 -0
  191. package/skills/soc2-readiness/rules/risk-assessment.md +100 -0
  192. package/skills/soc2-readiness/rules/system-operations.md +170 -0
  193. package/skills/venture-financing/SKILL.md +9 -0
@@ -0,0 +1,321 @@
1
+ /**
2
+ * Post-fill formatter for closing-checklist DOCX files.
3
+ *
4
+ * After docx-templates fills the template, every row looks identical.
5
+ * This formatter opens the DOCX, finds the Documents table, classifies
6
+ * each row (stage heading, main entry, citation, signatory, action, issue),
7
+ * and applies semantic XML formatting: bold, italic, color, indentation.
8
+ */
9
+ import AdmZip from 'adm-zip';
10
+ import { DOMParser, XMLSerializer } from '@xmldom/xmldom';
11
+ const W_NS = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
12
+ const DOCUMENTS_HEADERS = ['No.', 'Title', 'Status', 'Responsible Party'];
13
+ function classifyRow(numberText, titleText) {
14
+ // Stage heading: number cell empty, title matches roman numeral pattern
15
+ if (!numberText.trim() && /^[IVX]+\.\s/.test(titleText.trim())) {
16
+ return 'stage_heading';
17
+ }
18
+ // Main entry: number cell non-empty
19
+ if (numberText.trim()) {
20
+ return 'main_entry';
21
+ }
22
+ // Sub-rows: number cell empty, classify by title content
23
+ const stripped = titleText.replace(/^\u00A0+/, '').trim();
24
+ if (stripped.startsWith('Ref:'))
25
+ return 'citation';
26
+ if (/^\u2610\s+Signatory:|^\u2611\s+Signatory:|^Signatory:/.test(stripped))
27
+ return 'signatory';
28
+ if (/^\u2610\s+Action\s|^\u2611\s+Action\s|^Action\s/.test(stripped))
29
+ return 'action';
30
+ if (/^\u2610\s+Issue\s|^\u2611\s+Issue\s|^Issue\s/.test(stripped))
31
+ return 'issue';
32
+ return 'unknown';
33
+ }
34
+ // ---------------------------------------------------------------------------
35
+ // XML helpers (same patterns as recipe/patcher.ts)
36
+ // ---------------------------------------------------------------------------
37
+ function ensureRunProperties(run) {
38
+ const doc = run.ownerDocument;
39
+ const children = run.childNodes;
40
+ for (let i = 0; i < children.length; i++) {
41
+ const child = children[i];
42
+ if (child.localName === 'rPr' && child.namespaceURI === W_NS) {
43
+ return child;
44
+ }
45
+ }
46
+ const rPr = doc.createElementNS(W_NS, 'w:rPr');
47
+ run.insertBefore(rPr, run.firstChild);
48
+ return rPr;
49
+ }
50
+ function setRunBold(run) {
51
+ const rPr = ensureRunProperties(run);
52
+ // Check if <w:b/> already exists
53
+ const children = rPr.childNodes;
54
+ for (let i = 0; i < children.length; i++) {
55
+ const child = children[i];
56
+ if (child.localName === 'b' && child.namespaceURI === W_NS)
57
+ return;
58
+ }
59
+ const doc = run.ownerDocument;
60
+ const b = doc.createElementNS(W_NS, 'w:b');
61
+ rPr.appendChild(b);
62
+ }
63
+ function setRunItalic(run) {
64
+ const rPr = ensureRunProperties(run);
65
+ const children = rPr.childNodes;
66
+ for (let i = 0; i < children.length; i++) {
67
+ const child = children[i];
68
+ if (child.localName === 'i' && child.namespaceURI === W_NS)
69
+ return;
70
+ }
71
+ const doc = run.ownerDocument;
72
+ const iEl = doc.createElementNS(W_NS, 'w:i');
73
+ rPr.appendChild(iEl);
74
+ }
75
+ function setRunColor(run, colorHex) {
76
+ const rPr = ensureRunProperties(run);
77
+ const doc = run.ownerDocument;
78
+ const children = rPr.childNodes;
79
+ for (let i = 0; i < children.length; i++) {
80
+ const child = children[i];
81
+ if (child.localName === 'color' && child.namespaceURI === W_NS) {
82
+ child.setAttributeNS(W_NS, 'w:val', colorHex);
83
+ return;
84
+ }
85
+ }
86
+ const color = doc.createElementNS(W_NS, 'w:color');
87
+ color.setAttributeNS(W_NS, 'w:val', colorHex);
88
+ rPr.appendChild(color);
89
+ }
90
+ function ensureParagraphProperties(para) {
91
+ const doc = para.ownerDocument;
92
+ const children = para.childNodes;
93
+ for (let i = 0; i < children.length; i++) {
94
+ const child = children[i];
95
+ if (child.localName === 'pPr' && child.namespaceURI === W_NS) {
96
+ return child;
97
+ }
98
+ }
99
+ const pPr = doc.createElementNS(W_NS, 'w:pPr');
100
+ para.insertBefore(pPr, para.firstChild);
101
+ return pPr;
102
+ }
103
+ function setParagraphIndent(para, leftDxa) {
104
+ const pPr = ensureParagraphProperties(para);
105
+ const doc = para.ownerDocument;
106
+ // Find or create <w:ind>
107
+ const children = pPr.childNodes;
108
+ for (let i = 0; i < children.length; i++) {
109
+ const child = children[i];
110
+ if (child.localName === 'ind' && child.namespaceURI === W_NS) {
111
+ child.setAttributeNS(W_NS, 'w:left', String(leftDxa));
112
+ return;
113
+ }
114
+ }
115
+ const ind = doc.createElementNS(W_NS, 'w:ind');
116
+ ind.setAttributeNS(W_NS, 'w:left', String(leftDxa));
117
+ pPr.appendChild(ind);
118
+ }
119
+ // ---------------------------------------------------------------------------
120
+ // NBSP indent handling
121
+ // ---------------------------------------------------------------------------
122
+ const NBSP = '\u00A0';
123
+ const DXA_PER_LEVEL = 360;
124
+ /**
125
+ * Count leading NBSP pairs in all text nodes of a table cell,
126
+ * strip them from the text content, and return the indent level.
127
+ */
128
+ function countAndStripNbspIndent(tc) {
129
+ const paragraphs = tc.getElementsByTagNameNS(W_NS, 'p');
130
+ let maxLevel = 0;
131
+ for (let p = 0; p < paragraphs.length; p++) {
132
+ const runs = paragraphs[p].getElementsByTagNameNS(W_NS, 'r');
133
+ if (runs.length === 0)
134
+ continue;
135
+ // Collect full text to count leading NBSPs
136
+ let fullText = '';
137
+ for (let r = 0; r < runs.length; r++) {
138
+ const tEls = runs[r].getElementsByTagNameNS(W_NS, 't');
139
+ for (let t = 0; t < tEls.length; t++) {
140
+ fullText += tEls[t].textContent ?? '';
141
+ }
142
+ }
143
+ // Count leading NBSP pairs
144
+ let nbspCount = 0;
145
+ for (let i = 0; i < fullText.length; i++) {
146
+ if (fullText[i] === NBSP) {
147
+ nbspCount++;
148
+ }
149
+ else {
150
+ break;
151
+ }
152
+ }
153
+ const level = Math.floor(nbspCount / 2);
154
+ if (level > maxLevel)
155
+ maxLevel = level;
156
+ if (nbspCount > 0) {
157
+ // Strip leading NBSPs from text runs
158
+ let remaining = nbspCount;
159
+ for (let r = 0; r < runs.length && remaining > 0; r++) {
160
+ const tEls = runs[r].getElementsByTagNameNS(W_NS, 't');
161
+ for (let t = 0; t < tEls.length && remaining > 0; t++) {
162
+ const text = tEls[t].textContent ?? '';
163
+ let stripCount = 0;
164
+ for (let c = 0; c < text.length && remaining > 0; c++) {
165
+ if (text[c] === NBSP) {
166
+ stripCount++;
167
+ remaining--;
168
+ }
169
+ else {
170
+ break;
171
+ }
172
+ }
173
+ if (stripCount > 0) {
174
+ const newText = text.slice(stripCount);
175
+ tEls[t].textContent = newText;
176
+ if (newText.startsWith(' ') || newText.endsWith(' ') || newText === '') {
177
+ tEls[t].setAttribute('xml:space', 'preserve');
178
+ }
179
+ }
180
+ }
181
+ }
182
+ // Set paragraph indent
183
+ if (level > 0) {
184
+ setParagraphIndent(paragraphs[p], level * DXA_PER_LEVEL);
185
+ }
186
+ }
187
+ }
188
+ return maxLevel;
189
+ }
190
+ // ---------------------------------------------------------------------------
191
+ // Cell text extraction
192
+ // ---------------------------------------------------------------------------
193
+ function getCellText(tc) {
194
+ const tNodes = tc.getElementsByTagNameNS(W_NS, 't');
195
+ const parts = [];
196
+ for (let i = 0; i < tNodes.length; i++) {
197
+ parts.push(tNodes[i].textContent ?? '');
198
+ }
199
+ return parts.join('');
200
+ }
201
+ // ---------------------------------------------------------------------------
202
+ // Apply formatting to all runs in a cell
203
+ // ---------------------------------------------------------------------------
204
+ function getAllRunsInCell(tc) {
205
+ const runs = [];
206
+ const rNodes = tc.getElementsByTagNameNS(W_NS, 'r');
207
+ for (let i = 0; i < rNodes.length; i++) {
208
+ runs.push(rNodes[i]);
209
+ }
210
+ return runs;
211
+ }
212
+ function formatCellRuns(tc, format) {
213
+ const runs = getAllRunsInCell(tc);
214
+ for (const run of runs) {
215
+ if (format.bold)
216
+ setRunBold(run);
217
+ if (format.italic)
218
+ setRunItalic(run);
219
+ if (format.color)
220
+ setRunColor(run, format.color);
221
+ }
222
+ }
223
+ // ---------------------------------------------------------------------------
224
+ // Find Documents table by matching header row
225
+ // ---------------------------------------------------------------------------
226
+ function findDocumentsTable(xmlDoc) {
227
+ const tables = xmlDoc.getElementsByTagNameNS(W_NS, 'tbl');
228
+ for (let t = 0; t < tables.length; t++) {
229
+ const table = tables[t];
230
+ const rows = getDirectChildRows(table);
231
+ if (rows.length === 0)
232
+ continue;
233
+ const headerRow = rows[0];
234
+ const cells = getDirectChildCells(headerRow);
235
+ const headerTexts = cells.map((c) => getCellText(c).trim());
236
+ if (headerTexts.length === DOCUMENTS_HEADERS.length &&
237
+ headerTexts.every((text, i) => text === DOCUMENTS_HEADERS[i])) {
238
+ return table;
239
+ }
240
+ }
241
+ return null;
242
+ }
243
+ function getDirectChildRows(table) {
244
+ const rows = [];
245
+ const children = table.childNodes;
246
+ for (let i = 0; i < children.length; i++) {
247
+ const child = children[i];
248
+ if (child.nodeType === 1) {
249
+ const el = child;
250
+ if (el.localName === 'tr' && el.namespaceURI === W_NS) {
251
+ rows.push(el);
252
+ }
253
+ }
254
+ }
255
+ return rows;
256
+ }
257
+ function getDirectChildCells(row) {
258
+ const cells = [];
259
+ const children = row.childNodes;
260
+ for (let i = 0; i < children.length; i++) {
261
+ const child = children[i];
262
+ if (child.nodeType === 1) {
263
+ const el = child;
264
+ if (el.localName === 'tc' && el.namespaceURI === W_NS) {
265
+ cells.push(el);
266
+ }
267
+ }
268
+ }
269
+ return cells;
270
+ }
271
+ // ---------------------------------------------------------------------------
272
+ // Main formatter
273
+ // ---------------------------------------------------------------------------
274
+ export async function formatChecklistDocx(docxPath) {
275
+ const zip = new AdmZip(docxPath);
276
+ const entry = zip.getEntry('word/document.xml');
277
+ if (!entry)
278
+ return;
279
+ const xmlStr = entry.getData().toString('utf-8');
280
+ const xmlDoc = new DOMParser().parseFromString(xmlStr, 'text/xml');
281
+ const docsTable = findDocumentsTable(xmlDoc);
282
+ if (!docsTable)
283
+ return;
284
+ const rows = getDirectChildRows(docsTable);
285
+ // Skip header row (index 0)
286
+ for (let r = 1; r < rows.length; r++) {
287
+ const cells = getDirectChildCells(rows[r]);
288
+ if (cells.length < 2)
289
+ continue;
290
+ const numberText = getCellText(cells[0]);
291
+ const titleText = getCellText(cells[1]);
292
+ const rowType = classifyRow(numberText, titleText);
293
+ // Convert NBSP indentation to OOXML indent on title cell
294
+ countAndStripNbspIndent(cells[1]);
295
+ const titleCell = cells[1];
296
+ switch (rowType) {
297
+ case 'stage_heading':
298
+ formatCellRuns(titleCell, { italic: true, color: '8C8D8E' });
299
+ break;
300
+ case 'main_entry':
301
+ formatCellRuns(titleCell, { bold: true });
302
+ break;
303
+ case 'citation':
304
+ formatCellRuns(titleCell, { italic: true, color: '494A4B' });
305
+ break;
306
+ case 'signatory':
307
+ case 'action':
308
+ case 'issue':
309
+ // Normal formatting; checkboxes already in text
310
+ break;
311
+ case 'unknown':
312
+ break;
313
+ }
314
+ }
315
+ // Serialize and write back
316
+ const serializer = new XMLSerializer();
317
+ const updatedXml = serializer.serializeToString(xmlDoc);
318
+ zip.updateFile('word/document.xml', Buffer.from(updatedXml, 'utf-8'));
319
+ zip.writeZip(docxPath);
320
+ }
321
+ //# sourceMappingURL=format-checklist-docx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-checklist-docx.js","sourceRoot":"","sources":["../../../src/core/checklist/format-checklist-docx.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG1D,MAAM,IAAI,GAAG,8DAA8D,CAAC;AAE5E,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,CAAC,CAAC;AAQ1E,SAAS,WAAW,CAAC,UAAkB,EAAE,SAAiB;IACxD,wEAAwE;IACxE,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAC/D,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,oCAAoC;IACpC,IAAI,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;QACtB,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,yDAAyD;IACzD,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1D,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,UAAU,CAAC;IACnD,IAAI,uDAAuD,CAAC,IAAI,CAAC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M,UAAU,GAAG,IAAI,aAAa,EAAE,CAAC;IACvC,MAAM,UAAU,GAAG,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACxD,GAAG,CAAC,UAAU,CAAC,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;IACtE,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC"}
@@ -2,37 +2,46 @@ export { ClosingChecklistSchema, type ClosingChecklist } from './schemas.js';
2
2
  export { ChecklistPatchModeEnum, JsonPointerSchema, PatchCitationSchema, ChecklistPatchSourceEventSchema, ChecklistPatchOperationSchema, ChecklistPatchEnvelopeSchema, ChecklistPatchApplyRequestSchema, type ChecklistPatchMode, type JsonPointer, type PatchCitation, type ChecklistPatchSourceEvent, type ChecklistPatchOperation, type ChecklistPatchEnvelope, type ChecklistPatchApplyRequest, } from './patch-schemas.js';
3
3
  export { CHECKLIST_PATCH_VALIDATION_TTL_MS, DANGEROUS_KEYS, applyChecklistPatchOperations, computeChecklistPatchHash, validateChecklistPatch, getChecklistPatchValidationArtifact, setChecklistPatchValidationStore, getChecklistPatchValidationStore, type ChecklistPatchValidationErrorCode, type ChecklistPatchValidationDiagnostic, type ResolvedChecklistPatchOperation, type ChecklistPatchValidationArtifact, type ChecklistPatchValidationStore, type ValidateChecklistPatchInput, type ChecklistPatchValidationSuccess, type ChecklistPatchValidationFailure, type ChecklistPatchValidationResult, } from './patch-validator.js';
4
4
  export { applyChecklistPatch, setChecklistAppliedPatchStore, getChecklistAppliedPatchStore, setChecklistProposedPatchStore, getChecklistProposedPatchStore, type ChecklistAppliedPatchRecord, type ChecklistAppliedPatchStore, type ChecklistProposedPatchRecord, type ChecklistProposedPatchStore, type ChecklistPatchApplyErrorCode, type ChecklistPatchApplyFailure, type ChecklistPatchApplySuccess, type ChecklistPatchApplyResult, type ApplyChecklistPatchInput, } from './patch-apply.js';
5
- interface LegacyTemplateDocumentRow {
6
- document_name: string;
5
+ export { humanStatus, STATUS_LABELS } from './status-labels.js';
6
+ export { createChecklist, listChecklists, resolveChecklist, getChecklistState, saveChecklistState, appendHistory, getHistory, ChecklistStateSchema, type ChecklistState, type ChecklistMeta, type ChecklistSummary, type HistoryRecord, } from './state-manager.js';
7
+ export { appendJsonl, readJsonl } from './jsonl-stores.js';
8
+ export { formatChecklistDocx } from './format-checklist-docx.js';
9
+ interface TemplateDocumentRow {
10
+ number: string;
11
+ title: string;
7
12
  status: string;
13
+ responsible_party: string;
8
14
  }
9
- interface LegacyTemplateActionRow {
15
+ interface TemplateActionRow {
10
16
  item_id: string;
11
17
  description: string;
12
18
  status: string;
13
- assigned_to: {
14
- organization: string;
15
- };
19
+ assigned_to: string;
16
20
  due_date: string;
17
21
  }
18
- interface LegacyTemplateIssueRow {
22
+ interface TemplateIssueRow {
19
23
  issue_id: string;
20
24
  title: string;
21
25
  status: string;
22
- escalation_tier: string;
23
- resolution: string;
26
+ summary: string;
24
27
  }
25
28
  export interface ChecklistTemplateContext {
26
29
  deal_name: string;
27
30
  updated_at: string;
28
- working_group: Array<Record<string, unknown>>;
29
- documents: LegacyTemplateDocumentRow[];
30
- action_items: LegacyTemplateActionRow[];
31
- open_issues: LegacyTemplateIssueRow[];
31
+ documents: TemplateDocumentRow[];
32
+ action_items: TemplateActionRow[];
33
+ open_issues: TemplateIssueRow[];
32
34
  }
33
35
  /**
34
- * Build template values for the legacy closing-checklist DOCX template from
36
+ * Build template values for the closing-checklist DOCX template from
35
37
  * document-first v2 checklist input.
38
+ *
39
+ * Layout:
40
+ * - Stage headers as bold section rows
41
+ * - Entry rows: Number | Title | Status | Responsible Party
42
+ * - Citations as indented sub-rows under their entry
43
+ * - Signatories as indented sub-rows
44
+ * - Linked actions/issues as indented sub-rows
36
45
  */
37
46
  export declare function buildChecklistTemplateContext(data: unknown): ChecklistTemplateContext;
38
47
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"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UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,mBAAmB,EAAE,CAAC;IACjC,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAClC,WAAW,EAAE,gBAAgB,EAAE,CAAC;CACjC;AAkLD;;;;;;;;;;GAUG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,GAAG,wBAAwB,CAiGrF"}
@@ -1,8 +1,13 @@
1
1
  import { ClosingChecklistSchema, } from './schemas.js';
2
+ import { humanStatus } from './status-labels.js';
2
3
  export { ClosingChecklistSchema } from './schemas.js';
3
4
  export { ChecklistPatchModeEnum, JsonPointerSchema, PatchCitationSchema, ChecklistPatchSourceEventSchema, ChecklistPatchOperationSchema, ChecklistPatchEnvelopeSchema, ChecklistPatchApplyRequestSchema, } from './patch-schemas.js';
4
5
  export { CHECKLIST_PATCH_VALIDATION_TTL_MS, DANGEROUS_KEYS, applyChecklistPatchOperations, computeChecklistPatchHash, validateChecklistPatch, getChecklistPatchValidationArtifact, setChecklistPatchValidationStore, getChecklistPatchValidationStore, } from './patch-validator.js';
5
6
  export { applyChecklistPatch, setChecklistAppliedPatchStore, getChecklistAppliedPatchStore, setChecklistProposedPatchStore, getChecklistProposedPatchStore, } from './patch-apply.js';
7
+ export { humanStatus, STATUS_LABELS } from './status-labels.js';
8
+ export { createChecklist, listChecklists, resolveChecklist, getChecklistState, saveChecklistState, appendHistory, getHistory, ChecklistStateSchema, } from './state-manager.js';
9
+ export { appendJsonl, readJsonl } from './jsonl-stores.js';
10
+ export { formatChecklistDocx } from './format-checklist-docx.js';
6
11
  const STAGE_ORDER = ['PRE_SIGNING', 'SIGNING', 'CLOSING', 'POST_CLOSING'];
7
12
  const STAGE_HEADINGS = {
8
13
  PRE_SIGNING: 'PRE-SIGNING',
@@ -12,9 +17,13 @@ const STAGE_HEADINGS = {
12
17
  };
13
18
  const STAGE_ROMANS = ['I', 'II', 'III', 'IV'];
14
19
  function compareBySortKey(a, b) {
15
- const keyCompare = a.sort_key.localeCompare(b.sort_key, undefined, { numeric: true, sensitivity: 'base' });
16
- if (keyCompare !== 0)
17
- return keyCompare;
20
+ const aKey = a.sort_key ?? '';
21
+ const bKey = b.sort_key ?? '';
22
+ if (aKey || bKey) {
23
+ const keyCompare = aKey.localeCompare(bKey, undefined, { numeric: true, sensitivity: 'base' });
24
+ if (keyCompare !== 0)
25
+ return keyCompare;
26
+ }
18
27
  return a.entry_id.localeCompare(b.entry_id);
19
28
  }
20
29
  function nonEmpty(values) {
@@ -45,23 +54,33 @@ function latestCitationLabel(citations) {
45
54
  }
46
55
  function signatoryLabel(signatory) {
47
56
  const who = nonEmpty([signatory.party, signatory.name ?? '', signatory.title ?? '']).join(' ');
48
- const artifacts = signatory.signature_artifacts
49
- .map((artifact) => artifact.uri ?? artifact.path ?? '')
50
- .filter((value) => value.length > 0);
51
- if (artifacts.length === 0) {
52
- return `${who} [${signatory.status}]`;
53
- }
54
- return `${who} [${signatory.status}] (${artifacts.join(', ')})`;
57
+ return `${who}: ${humanStatus(signatory.status)}`;
55
58
  }
56
59
  function toArray(collection) {
57
60
  return Array.isArray(collection) ? collection : Object.values(collection);
58
61
  }
62
+ function assignAutoSortKeys(entries) {
63
+ const byStage = new Map();
64
+ for (const entry of entries) {
65
+ if (entry.sort_key)
66
+ continue;
67
+ const group = byStage.get(entry.stage) ?? [];
68
+ group.push(entry);
69
+ byStage.set(entry.stage, group);
70
+ }
71
+ for (const group of byStage.values()) {
72
+ group.forEach((entry, index) => {
73
+ entry.sort_key = String((index + 1) * 100);
74
+ });
75
+ }
76
+ }
59
77
  function buildRenderModel(data) {
60
78
  const checklist = ClosingChecklistSchema.parse(data);
61
79
  const documents = toArray(checklist.documents);
62
80
  const entries = toArray(checklist.checklist_entries);
63
81
  const actions = toArray(checklist.action_items);
64
82
  const issues = toArray(checklist.issues);
83
+ assignAutoSortKeys(entries);
65
84
  const documentsById = new Map(documents.map((document) => [document.document_id, document]));
66
85
  const entryDocumentIds = new Set(entries
67
86
  .map((entry) => entry.document_id)
@@ -121,9 +140,8 @@ function buildRenderModel(data) {
121
140
  }
122
141
  }
123
142
  roots.sort(compareBySortKey);
124
- for (const [parentId, children] of childrenByParent.entries()) {
143
+ for (const [, children] of childrenByParent.entries()) {
125
144
  children.sort(compareBySortKey);
126
- childrenByParent.set(parentId, children);
127
145
  }
128
146
  const stageRows = [];
129
147
  const visit = (entry, depth, number) => {
@@ -154,8 +172,15 @@ function buildRenderModel(data) {
154
172
  };
155
173
  }
156
174
  /**
157
- * Build template values for the legacy closing-checklist DOCX template from
175
+ * Build template values for the closing-checklist DOCX template from
158
176
  * document-first v2 checklist input.
177
+ *
178
+ * Layout:
179
+ * - Stage headers as bold section rows
180
+ * - Entry rows: Number | Title | Status | Responsible Party
181
+ * - Citations as indented sub-rows under their entry
182
+ * - Signatories as indented sub-rows
183
+ * - Linked actions/issues as indented sub-rows
159
184
  */
160
185
  export function buildChecklistTemplateContext(data) {
161
186
  const model = buildRenderModel(data);
@@ -164,39 +189,62 @@ export function buildChecklistTemplateContext(data) {
164
189
  const stageRows = model.rowsByStage.get(stage) ?? [];
165
190
  if (stageRows.length === 0)
166
191
  return;
192
+ // Stage heading row
167
193
  documentRows.push({
168
- document_name: `${STAGE_ROMANS[index]}. ${STAGE_HEADINGS[stage]}`,
194
+ number: '',
195
+ title: `${STAGE_ROMANS[index]}. ${STAGE_HEADINGS[stage]}`,
169
196
  status: '',
197
+ responsible_party: '',
170
198
  });
171
199
  for (const row of stageRows) {
172
200
  const indent = '\u00A0\u00A0'.repeat(row.depth);
173
- const citationText = row.entry.citations.map(citationLabel).join('; ');
174
- const linkText = row.document?.primary_link ? ` (${row.document.primary_link})` : '';
175
- const documentName = `${row.number} ${indent}${row.entry.title}${citationText ? ` [${citationText}]` : ''}${linkText}`;
176
- const statusParts = [row.entry.status];
177
- if (row.entry.signatories.length > 0) {
178
- statusParts.push(row.entry.signatories.map(signatoryLabel).join('; '));
179
- }
180
- const responsibility = responsibilityLabel(row.entry.responsible_party);
181
- if (responsibility) {
182
- statusParts.push(`Resp: ${responsibility}`);
183
- }
201
+ const linkSuffix = row.document?.primary_link ? ` (${row.document.primary_link})` : '';
202
+ // Main entry row
184
203
  documentRows.push({
185
- document_name: documentName,
186
- status: statusParts.join(' | '),
204
+ number: row.number,
205
+ title: `${indent}${row.entry.title}${linkSuffix}`,
206
+ status: humanStatus(row.entry.status),
207
+ responsible_party: responsibilityLabel(row.entry.responsible_party),
187
208
  });
209
+ // Citation sub-rows
210
+ for (const citation of row.entry.citations) {
211
+ documentRows.push({
212
+ number: '',
213
+ title: `${indent}\u00A0\u00A0Ref: ${citationLabel(citation)}`,
214
+ status: '',
215
+ responsible_party: '',
216
+ });
217
+ }
218
+ // Signatory sub-rows
219
+ for (const signatory of row.entry.signatories) {
220
+ const sigCheckbox = signatory.status === 'RECEIVED' ? '\u2611' : '\u2610';
221
+ documentRows.push({
222
+ number: '',
223
+ title: `${indent}\u00A0\u00A0${sigCheckbox} Signatory: ${signatoryLabel(signatory)}`,
224
+ status: '',
225
+ responsible_party: '',
226
+ });
227
+ }
228
+ // Linked action sub-rows
188
229
  for (const action of row.linkedActions) {
230
+ const actCheckbox = action.status === 'COMPLETED' ? '\u2611' : '\u2610';
189
231
  const latestCitation = latestCitationLabel(action.citations);
190
232
  documentRows.push({
191
- document_name: `\u00A0\u00A0${indent}\u21B3 Action ${action.action_id}: ${action.description}`,
192
- status: latestCitation ? `${action.status} | Evidence: ${latestCitation}` : action.status,
233
+ number: '',
234
+ title: `${indent}\u00A0\u00A0${actCheckbox} Action ${action.action_id}: ${action.description}`,
235
+ status: latestCitation ? `${humanStatus(action.status)} | ${latestCitation}` : humanStatus(action.status),
236
+ responsible_party: responsibilityLabel(action.assigned_to),
193
237
  });
194
238
  }
239
+ // Linked issue sub-rows
195
240
  for (const issue of row.linkedIssues) {
241
+ const issCheckbox = issue.status === 'CLOSED' ? '\u2611' : '\u2610';
196
242
  const latestCitation = latestCitationLabel(issue.citations);
197
243
  documentRows.push({
198
- document_name: `\u00A0\u00A0${indent}\u21B3 Issue ${issue.issue_id}: ${issue.title}`,
199
- status: latestCitation ? `${issue.status} | Evidence: ${latestCitation}` : issue.status,
244
+ number: '',
245
+ title: `${indent}\u00A0\u00A0${issCheckbox} Issue ${issue.issue_id}: ${issue.title}`,
246
+ status: latestCitation ? `${humanStatus(issue.status)} | ${latestCitation}` : humanStatus(issue.status),
247
+ responsible_party: '',
200
248
  });
201
249
  }
202
250
  }
@@ -204,23 +252,19 @@ export function buildChecklistTemplateContext(data) {
204
252
  const fallbackActions = model.unlinkedActions.map((action) => ({
205
253
  item_id: action.action_id,
206
254
  description: action.description,
207
- status: latestCitationLabel(action.citations) ? `${action.status} | ${latestCitationLabel(action.citations)}` : action.status,
208
- assigned_to: {
209
- organization: responsibilityLabel(action.assigned_to) || '',
210
- },
255
+ status: humanStatus(action.status),
256
+ assigned_to: responsibilityLabel(action.assigned_to),
211
257
  due_date: action.due_date ?? '',
212
258
  }));
213
259
  const fallbackIssues = model.unlinkedIssues.map((issue) => ({
214
260
  issue_id: issue.issue_id,
215
261
  title: issue.title,
216
- status: issue.status,
217
- escalation_tier: '',
218
- resolution: nonEmpty([issue.summary ?? '', latestCitationLabel(issue.citations)]).join(' | '),
262
+ status: humanStatus(issue.status),
263
+ summary: nonEmpty([issue.summary ?? '', latestCitationLabel(issue.citations)]).join(' | '),
219
264
  }));
220
265
  return {
221
266
  deal_name: model.checklist.deal_name,
222
267
  updated_at: model.checklist.updated_at,
223
- working_group: [],
224
268
  documents: documentRows,
225
269
  action_items: fallbackActions,
226
270
  open_issues: fallbackIssues,