20 KiB
Executable File
Scene: Contract / Agreement
Goal
Generate a complete, formal, well-structured legal document with clear clauses, rigorous logic, and proper formatting. Must simultaneously meet:
- Complete structure, clear clauses, formal language, explicit responsibilities
- Identifiable risk boundaries, proper Word formatting
- Ready for review, revision, circulation, or signing preparation
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
Contract Type Routing
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
}
5 Contract Types
| 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 |
Standard Template Structures
Template A: Bilateral Commercial Contract
- Header (title, contract number, date, location)
- Party Information (Party A, Party B)
- Recitals ("Whereas" clauses)
- Definitions & Interpretation
- Subject Matter & Scope of Services/Delivery
- Contract Price & Payment Terms
- Rights & Obligations of Both Parties
- Timeline, Delivery & Acceptance
- Invoicing, Tax & Settlement
- Intellectual Property & Confidentiality
- Representations & Warranties (if applicable)
- Liability for Breach
- Force Majeure
- Termination & Dissolution
- Notices & Service
- Dispute Resolution
- Miscellaneous
- Signature Block
Template B: Rights Transfer Agreement
- Header & Parties
- Recitals
- Definitions & Interpretation
- Subject of Transfer
- Consideration & Payment Arrangement
- Closing & Registration/Transfer
- Representations & Warranties
- Tax Allocation
- Liability for Breach
- Dispute Resolution
- Miscellaneous
- Signature Block
Template C: Non-Disclosure Agreement (NDA)
- Header & Parties
- Recitals
- Definition of Confidential Information
- Confidentiality Obligations
- Use Restrictions
- Return, Deletion & Destruction of Information
- Exceptions
- Confidentiality Period
- Liability for Breach
- Dispute Resolution
- Miscellaneous
- Signature Block
Template D: Framework / Cooperation Agreement
- Header & Parties
- Recitals
- Purpose & Principles
- Scope of Cooperation
- Division of Work & Responsibilities
- Project Advancement Mechanism
- Commercial Arrangements / Subsequent Agreements
- Confidentiality, IP & Compliance
- Term, Amendment & Termination
- Liability for Breach
- Dispute Resolution
- Miscellaneous
- Signature Block
Template E: Unilateral Terms / Platform Rules
- Document Title
- Definitions & Scope
- Service/Rule Content
- User Rights & Obligations / Platform Rights & Obligations
- Liability Limitations & Disclaimers
- Fees & Payment (if applicable)
- Intellectual Property
- Termination, Suspension & Amendment
- Notices & Service
- Dispute Resolution
- Miscellaneous
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.
Input Recognition & Completion
Processing Rules
- If user provides a template, historical agreement, or company standard → always follow it first
- If information is incomplete, fill conservatively — must be restrained, natural, professional, consistent with transaction logic
- Never fabricate unrealistic commercial terms, regulatory requirements, approval conclusions, qualification status, tax treatment results, payment facts, or performance facts
- If critical info is missing → use standardized placeholders
- If user does not specify jurisdiction → default to PRC commercial writing conventions, but avoid making specific legal conclusions
Legal Writing Standards
Register
- Use formal legal document register
- Use clear party designations: "Party A", "Party B", "both parties", "either party", "non-breaching party", "breaching party"
- Forbidden: Colloquial expressions ("you", "me", "they", "pay up", "cancel the contract", "handle ASAP")
- Preferred terms: "pay consideration", "perform obligations", "constitute a breach", "terminate the contract", "assume liability for damages", "written notice", "deliver and accept", "representations and warranties"
Precision
- Eliminate vague adjectives: avoid "quality", "reasonable", "enormous", "appropriate", "ASAP" unless necessary for legal flexibility
- Each obligation must specify: who, when, how, what
- Consistent legal phrasing:
- Mandatory obligation → "shall"
- Right authorization → "has the right to"
- Prohibition → "shall not"
- Discretionary → "may"
- Amounts, dates, percentages, deadlines, business days vs. calendar days must be as specific as possible
Clear Subjects
- Every clause must have an explicit responsible party — avoid vague subjects ("relevant parties", "relevant personnel", "when necessary")
- Joint obligations: explicitly write "both parties agree" or "both parties shall"
- Unilateral obligations: explicitly write "Party A shall" or "Party B shall"
Transaction Closure & Risk Control
A contract must not only describe the transaction — it must ensure logical closure. Check the following:
- If a performance deadline is specified → specify consequences of delay
- If payment milestones are specified → specify payment conditions, method, invoice requirements
- If a delivery obligation exists → specify delivery standards, method, acceptance rules, objection period
- If termination rights exist → specify conditions, notice, effective date, post-termination settlement
- If breach liability exists → must correspond to main obligations in preceding clauses
- If IP/technology/data/trade secrets are involved → separately address ownership, license scope, use restrictions
- If confidentiality obligations exist → define scope, exceptions, duration, breach consequences
- If force majeure clause exists → specify notice obligation, mitigation duty, subsequent negotiation mechanism
- If notice/service arrangements exist → specify address, contact person, email, or other delivery method
- If user requests significantly one-sided adhesion/disclaimer clauses → add a note near the clause:
[Note: This clause may involve adhesion terms or liability limitations. Manual review recommended for the specific transaction.]
Truthfulness & Legal Caution
- Never fabricate specific statute article numbers, judicial interpretation numbers, or regulatory document numbers
- Legal bases should use general references, e.g.: "In accordance with the Civil Code of the PRC and relevant laws and regulations..."
- Never pretend to provide formal legal opinions, litigation success predictions, or definitive validity/invalidity conclusions
- Never state definitive legality conclusions for high-risk clauses (adhesion terms, penalty clauses, disclaimers, non-compete, exclusivity, unilateral interpretation rights)
- Never fabricate that regulatory approvals are obtained, title is unencumbered, tax compliance is assured, or third-party consent is secured
- When critical info is insufficient → use placeholders, never present as confirmed fact
- For high-risk areas (equity, debt, licenses, data compliance, labor, personal information, cross-border) → maintain restrained language, do not add rigid commitments without user confirmation
Special Clause Requirements
Definitions Clause
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.
Dispute Resolution
- Must be explicit
- Choose between litigation OR arbitration — never mix both
- Litigation → specify jurisdictional connection point
- Arbitration → specify arbitration institution
- If user hasn't specified → use placeholder for confirmation
Tax Clause
- If the transaction involves taxes → specify which party bears them, whether price includes tax, invoice type and conditions
- Avoid vague "taxes borne as required by law" without transaction-specific detail
Breach Liability
- Must correspond to main obligations in preceding clauses
- Penalty amounts should be restrained — avoid obviously exaggerated or severely imbalanced figures
- If fundamental breach exists → consider corresponding termination rights and damages
Appendices
- For complex subjects/pricing/technical requirements/deliverables → use "Appendix 1, Appendix 2..." format
- Explicitly state appendix-contract relationship (typically: "Appendices form an integral part of this contract")
- If appendix content is unknown → use placeholder
Palette
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:
- Contract title (SimHei, black, NOT accent color)
- Contract number (black)
- Clause headings (black)
- Body text (black)
- Party information (black)
- Signature block text (black)
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")
Scene-Specific Font Overrides
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 |
Document Structure
- Title: "XXX Contract" or "XXX Agreement" — Er Hao SimHei, centered
- Contract number: right-aligned, Wu Hao
- Preamble: Party information with placeholders
- Recitals (summarize transaction background and purpose)
- Definitions (if specialized terms recur)
- Substantive clauses (per selected template)
- Signature block
- Appendices (if any)
Clause Numbering System
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:
- No level-skipping
- Forbidden: Using Markdown list markers (
-*1.) for clause hierarchy - No switching from "Article X" to
-or*or auto-list mid-document - Numbering style must be consistent throughout the entire document
- Clause headings should be clean and simple
Party Information Layout (Table-Based Alignment — Mandatory)
Party 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:
- Party A and Party B info blocks must use the same table column widths — labels align across both blocks
- Use
safeText()for all field values — never outputundefined - Label column width should accommodate the longest label (e.g., "统一社会信用代码")
- The indent (
margins.left: 420) simulates sub-level nesting under the party name
Signature Block
Left-right symmetric, structured, easy to adjust in Word. Never write as scattered paragraphs.
Required fields for each party:
- Party name (seal)
- Legal representative / Authorized representative
- Contact person
- Contact information
- Signing location
- Date: 【//____】
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" })] })] }),
],
});
}),
});
}
Monetary Amount Format
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)
Style Rules
- NO cover page — title page is the first page (title + contract number at top)
- NO TOC unless >20 clauses
- NO decorative elements — contracts must be formal and clean
- Line spacing: 1.5x (line: 360) — ⚠️ scene override (Profile A default is 1.3x/312; contracts use 1.5x for readability and annotation space)
- Body: Justified, first-line indent 480 twips
- Color: pure black "000000" throughout — no colored text
Scene-Specific Quality Checks
In addition to universal checks (see references/common-rules.md):
Format
- Party information complete (full name / address / legal representative / contact)
- Signature block properly formatted, symmetrical, all fields present
- Monetary amounts shown in both uppercase and numeric format
- Clause numbering sequential with no gaps
- No cover page (title page is first page)
- No Markdown list markers mixed into clause hierarchy
Content
- Clause numbering system consistent, no mixing
- Transaction closure complete (subject → consideration → performance → acceptance → breach → dispute)
- Breach liability corresponds to main obligations
- Dispute resolution explicitly stated (or placeholder for confirmation)
- All unconfirmed variables use
【】placeholders consistently - Language is formal, restrained, subjects are explicit
- No fabricated statute numbers or overreaching legal conclusions
- High-risk clauses include manual review notes
- Terminology consistent throughout
- Appendix-contract relationship explicitly stated
Closure
- Performance deadline → delay consequences specified
- Payment milestones → conditions and invoice requirements specified
- Delivery obligation → acceptance rules and objection period specified
- Termination right → conditions and post-termination handling specified
- Confidentiality obligation → scope, exceptions, duration, breach consequences specified
- Force majeure → notice and mitigation duties specified