Generate a complete, formal, well-structured legal document with clear clauses, rigorous logic, and proper formatting. Must simultaneously meet:
Forbidden: Producing outlines-only / sample clauses / drafting advice / risk summaries; outputting chat-style explanations or filler phrases.
→ Font profile: A (Formal) — see references/common-rules.md
→ Default layout: standard margins — see references/common-rules.md
→ Placeholder convention & universal prohibitions — see references/common-rules.md
function selectContractType(keywords, topic) {
if (/confidential|NDA|non-disclosure/.test(keywords)) return "nda";
if (/transfer|equity|asset|rights/.test(keywords)) return "transfer";
if (/framework|strategic|cooperation agreement/.test(keywords)) return "framework";
if (/terms|platform rules|user agreement|privacy/.test(keywords)) return "terms";
return "bilateral"; // default: bilateral commercial contract
}
| Type | Use Case | Structure Focus |
|---|---|---|
| bilateral | Service/sale/development/procurement contracts | Subject → Consideration → Performance → Acceptance → Breach → Dispute |
| transfer | Equity/debt/asset/rights transfer | Subject → Consideration → Closing & Registration → Representations → Tax |
| nda | Non-disclosure agreements | Definition of Confidential Info → Obligations → Use Restrictions → Exceptions → Duration |
| framework | Cooperation framework / strategic alliance | Scope → Division of Work → Mechanism → Subsequent Agreements |
| terms | Platform rules / Terms of Service / User agreements | Definitions → Services → Rights & Obligations → Liability Limits → Amendments |
Note: Unilateral/boilerplate terms require special attention to adhesion clause risks — avoid creating extremely one-sided documents.
If the user provides an existing template, historical agreement, or company standard, always follow it first.
A contract must not only describe the transaction — it must ensure logical closure. Check the following:
[Note: This clause may involve adhesion terms or liability limitations. Manual review recommended for the specific transaction.]If the document repeatedly uses specialized terms ("deliverables", "service results", "confidential information", "source code", "project milestones", "acceptance criteria", "trade secrets"), include a "Definitions & Interpretation" clause near the beginning.
Legal Wood (Warm + Heavy + Calm) — for decorative elements only; body text must be pure black.
const palette = { primary:"#28201C", body:"#000000", secondary:"#6E6560", accent:"#7A5C3A", surface:"#FBF9F7" };
⚠️ ALL visible text in contracts must be pure black "000000". This includes:
The only exception is red-header official documents (红头文件), which follow their own GB/T 9704 color rules. For standard contracts, NO colored text is permitted — no red, no accent color, no dark-blue-grey.
// ✅ Contract title — always pure black
new Paragraph({ alignment: AlignmentType.CENTER,
spacing: { line: Math.ceil(22 * 23), lineRule: "atLeast" }, // ★ Rule 8: prevent clipping
children: [new TextRun({ text: "Training Cooperation Framework Agreement",
size: 44, bold: true, color: "000000", // ← MUST be "000000"
font: { eastAsia: "SimHei", ascii: "Times New Roman" } })]
})
// ❌ FORBIDDEN — accent/palette color on contract text
new TextRun({ text: "Training Cooperation Framework Agreement", color: palette.accent }) // ← WRONG
new TextRun({ text: "Contract No.:", color: palette.primary }) // ← WRONG (if primary ≠ "000000")
Beyond Profile A defaults:
| Element | Font | Size | Style |
|---|---|---|---|
| Contract title | SimHei | Er Hao 22pt (size: 44) | Bold, centered |
| Contract number | SimSun | Wu Hao 10.5pt (size: 21) | Right-aligned |
| Clause heading | SimHei | Xiao Si 12pt (size: 24) | Bold |
| Monetary amount | SimSun | Xiao Si 12pt (size: 24) | Bold |
Use stable, consistent, pure-text numbering suitable for Chinese legal documents.
Article 1 Subject Matter
1.1 xxxxxxxxxx
1.2 xxxxxxxxxx
(1) xxxxxxxxxx
(2) xxxxxxxxxx
① xxxxxxxxxx
② xxxxxxxxxx
Article 2 Price and Payment
2.1 ...
Numbering discipline:
- * 1.) for clause hierarchy- or * or auto-list mid-documentParty A and Party B information MUST be laid out using a borderless table so that labels align vertically. Never use plain paragraphs with indentation — this causes misalignment between parties.
// ✅ Correct — borderless table ensures "统一社会信用代码:", "地址:", "法定代表人:" align
function partyInfoBlock(partyLabel, partyName, fields) {
// fields: [["Unified Social Credit Code", value], ["Address", value], ["Legal Representative", value]]
const NB = { style: BorderStyle.NONE, size: 0, color: "FFFFFF" };
const noBorders = { top: NB, bottom: NB, left: NB, right: NB };
const headerPara = new Paragraph({ spacing: { before: 200, after: 120 },
children: [new TextRun({ text: `${partyLabel}: ${safeText(partyName, "【Company full name】")}`,
size: 24, font: { eastAsia: "SimSun", ascii: "Times New Roman" } })]
});
const infoTable = new Table({
width: { size: 90, type: WidthType.PERCENTAGE },
borders: { top: NB, bottom: NB, left: NB, right: NB, insideHorizontal: NB, insideVertical: NB },
rows: fields.map(([label, value]) => new TableRow({
children: [
new TableCell({
width: { size: 35, type: WidthType.PERCENTAGE },
borders: noBorders,
margins: { top: 40, bottom: 40, left: 420, right: 60 },
children: [new Paragraph({
children: [new TextRun({ text: `${label}:`, size: 24,
font: { eastAsia: "SimSun", ascii: "Times New Roman" } })],
})],
}),
new TableCell({
borders: noBorders,
margins: { top: 40, bottom: 40, left: 60, right: 120 },
children: [new Paragraph({
children: [new TextRun({ text: safeText(value, `【Please fill in: ${label}】`), size: 24,
font: { eastAsia: "SimSun", ascii: "Times New Roman" } })],
})],
}),
],
})),
});
return [headerPara, infoTable];
}
// Usage:
const partyAChildren = partyInfoBlock("Party A (甲方)", config.partyA?.name, [
["Unified Social Credit Code (统一社会信用代码)", config.partyA?.creditCode],
["Address (地址)", config.partyA?.address],
["Legal Representative (法定代表人/负责人)", config.partyA?.legalRep],
]);
Rules:
safeText() for all field values — never output undefinedmargins.left: 420) simulates sub-level nesting under the party nameLeft-right symmetric, structured, easy to adjust in Word. Never write as scattered paragraphs.
Required fields for each party:
Use a borderless 2-column table for symmetry. Every field value must use safeText() — never output undefined or empty string. If a field is not provided, use the appropriate 【Please fill in】 placeholder.
// ✅ Correct signature block — safeText for all values
function buildSignatureBlock(partyA, partyB) {
const fields = ["Party (Seal)", "Legal Rep / Authorized Rep (Signature)", "Contact Person", "Contact Info", "Signing Location", "Date"];
const NB = { style: BorderStyle.NONE, size: 0, color: "FFFFFF" };
const noBorders = { top: NB, bottom: NB, left: NB, right: NB };
return new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: { top: NB, bottom: NB, left: NB, right: NB, insideHorizontal: NB, insideVertical: NB },
rows: fields.map((label, i) => {
const aVal = i === fields.length - 1 ? "【____/____/____】" : safeText(partyA?.[i], "");
const bVal = i === fields.length - 1 ? "【____/____/____】" : safeText(partyB?.[i], "");
const displayA = i === 0 ? `Party A (甲方): ${aVal}` : `${label}: ${aVal}`;
const displayB = i === 0 ? `Party B (乙方): ${bVal}` : `${label}: ${bVal}`;
return new TableRow({
children: [
new TableCell({ width: { size: 50, type: WidthType.PERCENTAGE }, borders: noBorders,
margins: { top: 80, bottom: 80, left: 120, right: 60 },
children: [new Paragraph({ children: [new TextRun({ text: displayA, size: 24, color: "000000" })] })] }),
new TableCell({ width: { size: 50, type: WidthType.PERCENTAGE }, borders: noBorders,
margins: { top: 80, bottom: 80, left: 60, right: 120 },
children: [new Paragraph({ children: [new TextRun({ text: displayB, size: 24, color: "000000" })] })] }),
],
});
}),
});
}
Contracts must show amounts in both uppercase Chinese and numeric format:
Contract amount: RMB One Million Two Hundred Thirty-Four Thousand Five Hundred Sixty-Seven Yuan (¥1,234,567.00)
In addition to universal checks (see references/common-rules.md):
【】 placeholders consistently