Skip to content

feat: Add MoU Drafter — AI-powered MoU & vendor-contract drafting with LaTeX/PDF output agentkit-challenge#174

Merged
akshatvirmani merged 41 commits into
Lamatic:mainfrom
rohith0110:main
Jun 7, 2026
Merged

feat: Add MoU Drafter — AI-powered MoU & vendor-contract drafting with LaTeX/PDF output agentkit-challenge#174
akshatvirmani merged 41 commits into
Lamatic:mainfrom
rohith0110:main

Conversation

@rohith0110

@rohith0110 rohith0110 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Problem

Drafting a Memorandum of Understanding or a small-vendor service contract is one of those tasks where the typing is fast but the thinking is expensive. A founder, event organiser, or operations lead has to:

  • remember which protective clauses matter (indemnity caps, force-majeure carve-outs, IP assignment, cancellation tiers, late-fee anchors, food-safety / allergen language for catering, …),
  • decide which ones actually apply to this engagement type and this governing law,
  • keep the numbers internally consistent (payment deadlines that don't contradict each other, cleanup times that match the event-end time, liability caps tied to the actual fee), and
  • format the whole thing into a document that looks like it came out of a law firm, not a Google Doc.

Most people end up either copy-pasting a stale template they don't fully understand, or paying a lawyer for a first draft that was always going to be a first draft anyway.

Solution

MoU Drafter is an AgentKit kit that turns a structured 30-field form into a professionally-typeset PDF contract, automatically applying a curated set of 21 protective clause patterns based on the engagement context. It is explicitly a first-draft generator for human review, not legal advice.

The flow runs entirely on Lamatic:

  1. A Next.js form collects the engagement parameters (parties, scope, deliverables, fees, payment timing, event logistics, tax treatment, cancellation policy, catering specifics, IP / confidentiality / insurance / data-protection toggles, governing law).
  2. A Validate Input code node normalises every field, expands payment / termination presets into concrete day-counts, derives the jurisdictionFamily from the free-text governing-law field, and surfaces upstream warnings (lump-sum risk, missing event dates, signatory-role collisions).
  3. An LLM clause generator (Gemini 3 Flash, with Claude Sonnet 4.6 as fallback) emits structured JSON — recitals, definitions, and clauses keyed by anchor strings — under a hardened system prompt with prompt-injection defences, double-escape rules, and a per-pattern gating checklist.
  4. An Assemble LaTeX code node parses the JSON tolerantly, LaTeX-escapes every user scalar, selectively escapes model prose while preserving LaTeX commands, scrubs dangerous primitives (\write18, \input, \loop, …), verifies that every expected pattern anchor is present via % PATTERN:<anchor> markers, and renders into a hand-maintained article-class template with a real signature block and a confidential footer.
  5. The Next.js app shows a live in-browser PDF preview (server-side pdflatex on the dev host, with download-only fallback in production), a drafting-notes panel for warnings, a pattern report, and one-click download .tex / .pdf plus Open in Overleaf for further negotiation.

The result is a single page where a non-lawyer can produce a clean, protective, jurisdiction-aware MoU draft in under a minute — and a reviewer can verify why each clause is there by reading the patternReport returned alongside the document.

Project Links

Source Code

https://github.com/rohith0110/AgentKit/tree/feat/mou-drafter
Branch: feat/mou-drafter
Kit path: kits/mou-drafter/

Live Demo

https://mou.itsrohith.dev

Video Walkthrough

https://youtu.be/rqpECF_buuI

Tech Stack

  • Lamatic — flow orchestration (API trigger → code node → LLM node → code node → response)
  • Next.js 15 (App Router) + React 18 + TypeScript — the kit app
  • Tailwind CSS v4 + shadcn/ui + lucide-react — UI
  • react-hook-form + zod — form schema and validation
  • DeepSeek v4 Pro — primary clause-generator model
  • LaTeX (article class) — deterministic typesetting
  • Server-side pdflatex (dev) via apps/app/api/compile-latex/route.ts — live PDF preview only on local builds with MiKTeX installed
  • Overleaf POST Integration — one-click "open in Overleaf" for negotiation
  • lamatic npm SDK — server-action client (apps/lib/lamatic-client.ts)
  • Vercel — hosting

Features

  • 30-field structured form with grouped sections (Parties, Engagement, Commercial, Event, Cancellation, Catering, Clause Toggles, Governing Law) and inline info-icon tooltips that explain each field.
  • 21 gated protective clause patterns — applied only when their gating condition is satisfied (e.g. liquidated-damages only for US/Canada governing law; no-publicity only when explicitly required; guest-count-adjustments only for catering engagements with a finalisation date).
  • Prompt-injection-resistant LLM call — every free-text field is wrapped in <<<USER_INPUT>>> delimiters; the system prompt treats anything inside as data, never instructions.
  • Deterministic LaTeX assembly — the model produces only JSON; the LaTeX template is hand-maintained in the code node and never touched by the model. User scalars are escaped through a dedicated texEscape; model prose passes through a selective escaper that preserves intended LaTeX commands but neutralises stray & $ _ # %.
  • Pattern verification — the assembler computes the expected set of clause anchors from the gating rules, then verifies the LLM emitted every one. Missing / unexpected patterns are surfaced as warnings in the API response and in the UI's drafting-notes panel.
  • Live PDF preview, .tex / .pdf download, and Overleaf hand-off — all from one page.
  • ShinyText loader, signatory-name-vs-role collision detection, and form-level validation to catch upstream data issues before they reach the LLM.

Impact

  • A founder, ops lead, or event organiser can produce a defensible first-draft MoU in under a minute instead of an hour of template surgery.
  • A reviewer can audit why each clause appears (patternReport + the % PATTERN:<anchor> markers in the rendered LaTeX), instead of trusting the document blindly.
  • Because the template, gating rules, and protective patterns are version-controlled in the kit, any improvement (e.g. a better cancellation clause, a new jurisdiction family) propagates to every future draft.

PR Checklist

1. Select Contribution Type

  • Kit (kits/mou-drafter/)
  • Bundle (bundles/<bundle-name>/)
  • Template (templates/<template-name>/)

2. General Requirements

  • PR is for one project only (no unrelated changes)
  • No secrets, API keys, or real credentials are committed
  • Folder name uses kebab-case and matches the flow ID (mou-drafter)
  • All changes are documented in README.md (purpose, setup, usage)

3. File Structure

  • lamatic.config.ts present with valid metadata (name, description, tags, steps, author, env keys, links)
  • agent.md present (LLM-generated agent identity & capability doc)
  • Flow file flows/mou-drafter.ts present, self-contained (meta + inputs + references + nodes + edges)
  • Externalised resources present and @referenced from the flow:
    • prompts/mou-drafter_llmnode-842_system_0.md (system prompt)
    • prompts/mou-drafter_llmnode-842_user_1.md (user prompt)
    • scripts/mou-drafter_code-node-316_code.ts (validate-input)
    • scripts/mou-drafter_code-node-138_code.ts (assemble-latex)
    • model-configs/mou-drafter_llmnode-842_generative-model-name.ts
    • constitutions/default.md
  • apps/.env.example present with placeholder values only (no real keys)
  • No hand-edited node graphs (flow exported from Lamatic Studio; only @reference targets edited in this repo)

4. Validation

  • npm install && npm run dev works locally (run from kits/mou-drafter/apps/)
  • PR title is clear ([kit] Add MoU Drafter — AI-powered MoU & vendor-contract drafting with LaTeX/PDF output)
  • No unrelated files or projects are modified
  • GitHub Actions workflows pass (all checks green)
  • All CodeRabbit or other PR review comments are addressed and resolved
  • PR labelled agentkit-challenge

Disclaimer

This kit generates a first-draft document using software. It is not legal advice and does not substitute for review by a licensed attorney in the relevant jurisdiction. Every generated draft includes a verbatim disclaimer footer and a drafting-notes panel listing any caveats the validator surfaced.

  • Flow overview (kits/mou-drafter/flows/mou-drafter.ts)

    • Node types present: triggerNode (API Request / GraphQL trigger w/ advance_schema), dynamic code node (validate-input: codeNode_316), dynamic LLM node (clause-generator: LLMNode_842), dynamic code node (assemble-latex: codeNode_138), responseNode (API Response). A responseEdge from trigger → response is present.
    • High-level pipeline: GraphQL/API trigger accepts a 30-field form → validate-input normalizes/coerces fields, derives defaults and warnings → clause-generator LLM (configured with system + user prompts and model-config) must emit strict clause JSON (gated by 21 pattern anchors) → assemble-latex tolerantly parses/repairs JSON, escapes/scrubs user and model content, verifies/appends % PATTERN: markers, and deterministically produces LaTeX plus clauseJson/warnings/patternReport → response returns { latex, clauseJson, warnings, patternReport } (app supports PDF compile/preview and Overleaf export).
  • Files added (grouped, concise)

    • Documentation & kit metadata
      • kits/mou-drafter/README.md
      • kits/mou-drafter/agent.md
      • kits/mou-drafter/lamatic.config.ts
      • kits/mou-drafter/constitutions/default.md
    • Flow, scripts, prompts, model-config
      • kits/mou-drafter/flows/mou-drafter.ts
      • kits/mou-drafter/scripts/mou-drafter_code-node-316_code.ts (validate-input)
      • kits/mou-drafter/scripts/mou-drafter_code-node-138_code.ts (assemble-latex)
      • kits/mou-drafter/prompts/mou-drafter_clause-generator_system.md (system spec)
      • kits/mou-drafter/prompts/mou-drafter_llmnode-842_user_1.md (user template)
      • kits/mou-drafter/prompts/mou-drafter_llmnode-842_system_0.md (pointer)
      • kits/mou-drafter/model-configs/mou-drafter_llmnode-842_generative-model-name.ts
    • Next.js app scaffold & config
      • kits/mou-drafter/apps/package.json
      • kits/mou-drafter/apps/tsconfig.json
      • kits/mou-drafter/apps/next.config.mjs
      • kits/mou-drafter/apps/postcss.config.mjs
      • kits/mou-drafter/.env.example
      • kits/mou-drafter/apps/.env.example
      • kits/mou-drafter/apps/.gitignore
      • kits/mou-drafter/apps/next-env.d.ts
      • kits/mou-drafter/apps/global.d.ts
    • App pages, API, orchestration
      • kits/mou-drafter/apps/app/layout.tsx
      • kits/mou-drafter/apps/app/globals.css
      • kits/mou-drafter/apps/app/page.tsx
      • kits/mou-drafter/apps/app/api/compile-latex/route.ts (dev-gated pdflatex endpoint, size/time limits, condensed logs)
      • kits/mou-drafter/apps/actions/orchestrate.ts (flatten inputs, call Lamatic.executeFlow with timeout, normalize errors)
    • React components & UI primitives
      • kits/mou-drafter/apps/components/MoUForm.tsx (30-field form, react-hook-form + zod)
      • kits/mou-drafter/apps/components/LatexPreview.tsx
      • kits/mou-drafter/apps/components/ShinyText.tsx
      • kits/mou-drafter/apps/components/components.json
      • UI primitives: kits/mou-drafter/apps/components/ui/{accordion,alert,badge,button,card,collapsible,dialog,form,input,label,select,separator,switch,tabs,textarea,toast,toaster,tooltip}.tsx
    • Libraries, hooks, utilities, integrations
      • kits/mou-drafter/apps/lib/schema.ts (Zod mouFormSchema, MoUFormData, PatternReport, MoUFlowResult)
      • kits/mou-drafter/apps/lib/lamatic-client.ts (env-validated lamaticClient)
      • kits/mou-drafter/apps/lib/overleaf.ts (openInOverleaf, downloadTexFile)
      • kits/mou-drafter/apps/lib/utils.ts (cn wrapper)
      • kits/mou-drafter/apps/hooks/use-toast.ts
      • kits/mou-drafter/apps/global.d.ts (CSS module declaration)
    • Tests & example output
      • kits/mou-drafter/apps/test-e2e.js (E2E script exercising the flow)
      • kits/mou-drafter/apps/test-output-catering.tex (sample generated LaTeX)
    • Other
      • registry.json (end-of-file structure adjustment)
  • Key functional highlights (condensed)

    • Input validation: extensive normalization, derived fields (depositPct, paymentDays, termination windows, jurisdictionFamily), pre-rendered deliverables/warnings blocks.
    • LLM constraints: system/user prompts require structured JSON (clauses as object keyed by anchors), metadata.disclaimer exactness, % PATTERN: markers, and gating of 21 protective clause patterns.
    • LaTeX assembly: tolerant JSON parsing/repair, whitelist fixes for backslashes, escape/sanitize user scalars, scrub dangerous LaTeX macros, selective prose escaping while preserving verification comment lines, deterministic signature/disclaimer insertion, patternReport of expected vs found anchors.
    • App UX & integration: Next.js UI for form → generating → result/error, dev-only server-side PDF compile with logs, Overleaf hand-off, .tex/.pdf download, and drafting-warnings panel.
    • Safety/defenses: prompt-injection refusal rules in system prompt, surfaced validation warnings, compile endpoint enforces limits and returns structured errors/logs.
  • Outstanding / PR notes

    • Checklist mostly complete; GitHub Actions and reviewer-comment resolution remain outstanding. Outputs are first-draft only and explicitly not legal advice.

rohith0110 and others added 18 commits June 1, 2026 17:11
…-default select boxes with Radix custom Select components
…to slate-950/deep-obsidian with 1.2% opacity grid lines
…ss background for a refined minimal aesthetic
… POST + UX polish

In-browser PDF rendering via SwiftLaTeX no longer works — their texlive2
CDN went offline and the wasm engine can't fetch its .fmt or packages.
Replace it with a real pdflatex compile route used only in development,
since Vercel serverless functions can't run pdflatex. In production the
preview card is tree-shaken out and users go straight to Overleaf or .tex
download.

- Add /api/compile-latex route: spawns pdflatex in a mkdtemp dir, returns
  PDF bytes on success or the extracted error blocks from the log on
  failure. 45s timeout, 512KB body cap, ENOENT-aware error message,
  configurable via PDFLATEX_BIN. Guarded by NODE_ENV so it returns 503
  in prod unless ENABLE_PDF_COMPILE=1.
- Rewrite LatexPreview to POST to that route and show the returned PDF in
  an iframe via blob URL, with a structured error card + collapsible
  pdflatex log + Overleaf/.tex fallbacks.
- Gate the preview card in page.tsx on NODE_ENV === "development" so the
  prod bundle ships no preview code at all.
- Fix Overleaf 414 by switching from ?snip_uri=data:base64,... GET to a
  hidden-form POST with the snip field — no URL length cap.
- Add cursor: pointer globally to buttons, links, Radix Select triggers,
  switches, tabs, role-based interactive elements, and date-picker icons.
- Bump generation timeout from 3 to 4 minutes (orchestrate.ts + page.tsx).
- Leave swiftlatex.ts in place but unused (in case the CDN ever revives);
  it's no longer imported anywhere.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ance cleanup-time conflict, and section 19 sub-numbering

- prompts/system_0: rewrite commercialTerms schema description to enforce a
  single payment-deadline anchor and forbid the "within N days of invoice
  receipt" restatement that was conflicting with the "N days before Event
  Date" deadline.
- prompts/system_0: extend pattern #2 (acceptance-window) guidance — event-day
  on-site / clean-up Deliverables must adopt the same clean-up time used in
  event-logistics (24-hour notation), not invent an earlier cutoff.
- scripts/assemble-latex: post-process the governing-law-venue-severability
  clause to force \begin{enumerate}[label=\thesection.\arabic*.] so the
  General Provisions subclauses render as 19.1, 19.2 ... instead of restarting
  at 1.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
[kit] Add MoU Drafter — AI-powered MoU & vendor-contract drafting with LaTeX/PDF output
@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a complete “MoU Drafter” kit: Next.js form UI, Zod validation, Lamatic flow/prompt wiring, deterministic LaTeX assembly scripts, sandboxed pdflatex API, Overleaf/.tex helpers, E2E test/sample output, and kit documentation/registry entries.

Changes

MoU Drafter end-to-end kit

Layer / File(s) Summary
Documentation, environment setup, and kit registration
kits/mou-drafter/README.md, kits/mou-drafter/agent.md, kits/mou-drafter/.env.example, kits/mou-drafter/apps/.env.example, kits/mou-drafter/apps/.gitignore, kits/mou-drafter/constitutions/default.md, kits/mou-drafter/lamatic.config.ts
Adds kit README documenting intake flow, 55 agreement fields, 21 gated protective patterns, and LaTeX→PDF/Overleaf output; agent.md with integration details and troubleshooting; environment variable placeholders for Lamatic credentials; gitignore for Node artifacts and env files; constitution prompt with safety/data handling rules; kit metadata configuration.
Next.js app foundation: layout, theming, and configuration
kits/mou-drafter/apps/app/layout.tsx, kits/mou-drafter/apps/app/globals.css, kits/mou-drafter/apps/components.json, kits/mou-drafter/apps/postcss.config.mjs, kits/mou-drafter/apps/tsconfig.json, kits/mou-drafter/apps/next.config.mjs, kits/mou-drafter/apps/package.json, kits/mou-drafter/apps/next-env.d.ts
Root layout with metadata, Geist fonts, and Toaster/Analytics; global CSS with Tailwind directives, design-token palette (:root + .dark override), @theme inline mappings, glass-card styling, input/select/switch/deliverable styling, and cursor behavior; Shadcn UI config; PostCSS/Tailwind pipeline; TypeScript config and Next type refs; package.json with app deps.
Radix UI component library with styling and variants
kits/mou-drafter/apps/components/ui/*, kits/mou-drafter/apps/lib/utils.ts
Accordion, Alert, Badge, Button, Card, Collapsible, Dialog, Input, Label, Select, Separator, Switch, Tabs, Toast, Tooltip components wrapping Radix primitives with Tailwind styling, data-slot attributes, variant utilities, form primitives, and cn() utility.
Form schema validation and toast state management
kits/mou-drafter/apps/lib/schema.ts, kits/mou-drafter/apps/hooks/use-toast.ts, kits/mou-drafter/apps/components/ui/toaster.tsx
Zod schema defining MoUFormData and export types (PatternReport, MoUFlowResult); use-toast reducer/pubsub and hook with timeout-based removal; Toaster component mapping state to toast UI.
MoU drafting form and multi-phase page state machine
kits/mou-drafter/apps/components/MoUForm.tsx, kits/mou-drafter/apps/app/page.tsx
MoUForm with field helpers, conditional sections (events/catering/cancellation/risk), deliverables array, and Page implementing form→generating→result/error phases with progress, copy fallback, pattern report, and download/Overleaf actions.
LaTeX preview component and browser helpers
kits/mou-drafter/apps/components/LatexPreview.tsx, kits/mou-drafter/apps/components/ShinyText.tsx, kits/mou-drafter/apps/lib/overleaf.ts
LatexPreview POSTs to /api/compile-latex and previews returned PDF blob; ShinyText provides animated loading text; openInOverleaf() and downloadTexFile() helpers for exports.
Server action orchestration and Lamatic client
kits/mou-drafter/apps/actions/orchestrate.ts, kits/mou-drafter/apps/lib/lamatic-client.ts
generateMoU server action with withTimeout helper and flattenFormToTrigger (JSON-stringify deliverables, uppercase currency), executes Lamatic flow, extracts latex/clauseJson/warnings/patternReport, normalizes errors; lamaticClient validates required LAMATIC env vars at import.
LaTeX-to-PDF compilation API endpoint
kits/mou-drafter/apps/app/api/compile-latex/route.ts
POST endpoint that validates env gating (ENABLE_PDF_COMPILE), enforces UTF-8 512KB cap, writes main.tex, runs pdflatex in sandboxed runtime with mounts and a 45s kill timeout, returns application/pdf on success or structured JSON error with condensed pdflatex log.
Lamatic flow graph: nodes, edges, and model config
kits/mou-drafter/flows/mou-drafter.ts, kits/mou-drafter/model-configs/mou-drafter_llmnode-842_generative-model-name.ts
Flow definition exporting meta/inputs/references/nodes/edges; trigger node with advance_schema, validation node, LLM clause-generator node wired to prompts and model config, LaTeX assembly node, API response node; model config sets a generator with temperature 0.4.
System prompt, user prompt template, and LLM output contracts
kits/mou-drafter/prompts/mou-drafter_clause-generator_system.md, kits/mou-drafter/prompts/mou-drafter_llmnode-842_user_1.md, kits/mou-drafter/prompts/mou-drafter_llmnode-842_system_0.md
System prompt mandates JSON-only clause object keyed by anchors, exact disclaimer, and 21 gated patterns with self-checks; user prompt template supplies structured placeholders and upstream warnings; system prompt file references the clause-generator spec.
Input normalization and LaTeX assembly scripts
kits/mou-drafter/scripts/mou-drafter_code-node-316_code.ts, kits/mou-drafter/scripts/mou-drafter_code-node-138_code.ts
Validation script normalizes/coerces inputs, derives deposit/payment/termination/jurisdiction fields, tolerates stringified deliverables, and emits warnings; assembly script tolerant-parses LLM JSON, repairs under-escaped LaTeX, scrubs dangerous macros, escapes user tokens, sanitizes clause prose while preserving pattern comments, verifies anchors, builds recitals/definitions/commercial terms, substitutes deterministic signature, and returns latex+clauseJson+warnings+patternReport.
E2E test, sample LaTeX output, and registry fix
kits/mou-drafter/apps/test-e2e.js, kits/mou-drafter/apps/test-output-catering.tex, registry.json
Adds an executable E2E script that triggers the flow with realistic catering data and sanity-checks returned LaTeX, writes a sample test-output-catering.tex, logs warnings/patternReport, and adjusts registry.json termination.

Suggested reviewers

  • amanintech
  • d-pamneja
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

@rohith0110 rohith0110 changed the title [kit] Add MoU Drafter — AI-powered MoU & vendor-contract drafting with LaTeX/PDF output [kit] Add MoU Drafter — AI-powered MoU & vendor-contract drafting with LaTeX/PDF output agentkit-challenge Jun 6, 2026
@rohith0110 rohith0110 changed the title [kit] Add MoU Drafter — AI-powered MoU & vendor-contract drafting with LaTeX/PDF output agentkit-challenge feat: Add MoU Drafter — AI-powered MoU & vendor-contract drafting with LaTeX/PDF output agentkit-challenge Jun 6, 2026
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

:robot_face: AgentKit Structural Validation

New Contributions Detected

  • Kit: kits/mou-drafter

Check Results

Check Status
No edits to existing kits ✅ Pass
Required root files present ✅ Pass
Flow .ts files present ✅ Pass
lamatic.config.ts valid ✅ Pass
No changes outside kits/ ✅ Pass

🎉 All checks passed! This contribution follows the AgentKit structure.

@rohith0110 rohith0110 marked this pull request as draft June 6, 2026 10:02
Suggested improvements by github actions bot

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (7)
kits/mou-drafter/apps/components/MoUForm.tsx (1)

303-303: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Mission briefing: Tighten type safety in form helper signatures.

The any types for control, register, and errors parameters bypass TypeScript's type checking. This reduces IDE autocomplete and compile-time safety for consumers of these helpers.

🎯 Recommended type improvements
+import type { Control, FieldErrors, UseFormRegister } from "react-hook-form";

 function FormSelect({
   id,
   label,
   options,
   labels,
   control,
   error,
   required,
   info,
 }: {
   id: string;
   label: string;
   options: readonly string[];
   labels: Record<string, string>;
-  control: any;
+  control: Control<MoUFormData>;
   error?: string;
   required?: boolean;
   info?: ReactNode;
 }) {

 function PartyFields({
   prefix,
   title,
   register,
   control,
   errors,
 }: {
   prefix: "partyA" | "partyB";
   title: string;
-  register: any;
-  control: any;
-  errors: any;
+  register: UseFormRegister<MoUFormData>;
+  control: Control<MoUFormData>;
+  errors: FieldErrors<MoUFormData>;
 }) {

Also applies to: 433-433

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/mou-drafter/apps/components/MoUForm.tsx` at line 303, Replace the unsafe
any types on form helper parameters with concrete react-hook-form types: import
and use Control<T>, UseFormRegister<T>, and FieldErrors<T> (from
'react-hook-form') instead of any for the parameters named control, register,
and errors; apply the generic using your form data interface (e.g.,
MoUFormValues) so signatures become Control<MoUFormValues>,
UseFormRegister<MoUFormValues>, FieldErrors<MoUFormValues> for the helpers
referenced around the symbols control/register/errors at lines ~303 and ~433 and
update the helper function/type declarations to accept those typed parameters.
kits/mou-drafter/apps/components/ui/form.tsx (1)

45-75: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Mission critical: Guards must fire before accessing context values.

Agent, lines 48-49 access formContext and fieldContext?.name before the validation guards at lines 51-61 confirm these contexts exist. This creates a temporal dead zone where useFormState({ name: undefined }) executes when fieldContext is missing, and the error only fires afterward. Additionally, useFormContext() throws its own error if used outside <Form>, creating duplicate error paths.

Reorder the guards to execute immediately after reading contexts, before any property access or dependent hook calls.

🎯 Proposed tactical adjustment
 const useFormField = () => {
   const fieldContext = React.useContext(FormFieldContext)
   const itemContext = React.useContext(FormItemContext)
-  const formContext = useFormContext()
-  const formState = useFormState({ name: fieldContext?.name })
 
   if (!fieldContext) {
     throw new Error('useFormField should be used within <FormField>')
   }
 
   if (!itemContext) {
     throw new Error('useFormField should be used within <FormItem>')
   }
 
+  const formContext = useFormContext()
+
   if (!formContext) {
     throw new Error('useFormField should be used within <Form>')
   }
 
+  const formState = useFormState({ name: fieldContext.name })
   const fieldState = formContext.getFieldState(fieldContext.name, formState)
 
   const { id } = itemContext
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/mou-drafter/apps/components/ui/form.tsx` around lines 45 - 75, The bug
is that useFormState is called and fieldContext?.name is accessed before the
null-check guards run in useFormField; reorder so you read contexts
(React.useContext(FormFieldContext), React.useContext(FormItemContext)) and call
useFormContext() as now, then immediately run the three guards that throw if
fieldContext, itemContext or formContext are missing, and only after those
guards call useFormState({ name: fieldContext.name }) and then call
formContext.getFieldState(fieldContext.name, formState); this ensures no
property access or dependent hook logic runs before the existence checks while
preserving hook call order in useFormField.
registry.json (1)

2738-2773: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Agent, the registry entry is critically incomplete. Mission metadata is missing.

The mou-drafter entry has multiple empty required fields that prevent users from discovering and deploying this kit:

Critical missing fields:

  1. description (line 2740): Empty string. Should describe the kit's purpose.

    Suggested value (based on PR description):

    "description": "AI-powered MoU & vendor-contract drafting with LaTeX/PDF output. Converts 30-field structured form into LaTeX-typeset Memorandum of Understanding / small-vendor contract first draft (explicitly not legal advice)."
  2. tags (line 2743): Empty array. Reduces discoverability.

    Suggested values (based on PR context and similar kits):

    "tags": ["legal", "documents", "generative", "LaTeX", "contracts"]
  3. author.name (line 2745): Empty. Missing attribution.

    Suggested value (PR author):

    "author": {
      "name": "rohith0110"
    }
  4. steps (line 2747): Empty array. Should define flow steps.

    Suggested value (based on PR description and lamatic.config.ts):

    "steps": [
      {
        "id": "mou-drafter",
        "type": "mandatory",
        "envKey": "MOU_DRAFTER_FLOW_ID"
      }
    ]
  5. links (line 2748): Empty object. Should include deployment/demo/docs links.

    Suggested value (based on PR description):

    "links": {
      "github": "https://github.com/Lamatic/AgentKit/tree/main/kits/mou-drafter",
      "deploy": "https://vercel.com/new/clone?repository-url=https://github.com/Lamatic/AgentKit&root-directory=kits%2Fmou-drafter%2Fapps&env=MOU_DRAFTER_FLOW_ID,LAMATIC_API_URL,LAMATIC_PROJECT_ID,LAMATIC_API_KEY"
    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@registry.json` around lines 2738 - 2773, The registry entry for slug
"mou-drafter" is missing required metadata; update the object to fill
description, tags, author.name, steps, and links: set description to the
provided MoU/contract drafting summary, add tags
["legal","documents","generative","LaTeX","contracts"], set author.name to
"rohith0110", populate steps with a single step object { id: "mou-drafter",
type: "mandatory", envKey: "MOU_DRAFTER_FLOW_ID" }, and add links including the
GitHub and deploy URLs shown in the review so the kit is discoverable and
deployable.
kits/mou-drafter/apps/test-e2e.js (3)

199-208: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Critical: Flow execution lacks timeout protection.

Agent, the production code wraps executeFlow in a timeout guard (per orchestrate.ts context snippet 3), but this test doesn't. If the flow hangs or the LLM is overloaded, the test will block indefinitely, potentially stalling CI/CD pipelines.

Add a timeout wrapper or use a test framework timeout. Example:

const TIMEOUT_MS = 120_000; // 2 minutes

function withTimeout(promise, ms, message) {
  return Promise.race([
    promise,
    new Promise((_, reject) =>
      setTimeout(() => reject(new Error(message)), ms)
    )
  ]);
}

// Then in main():
try {
  resData = await withTimeout(
    client.executeFlow(FLOW_ID, flatInputs),
    TIMEOUT_MS,
    "Flow execution timed out after 2 minutes"
  );
} catch (err) {
  console.error("[FAIL] Flow call threw:", err.message);
  process.exit(1);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/mou-drafter/apps/test-e2e.js` around lines 199 - 208, The test currently
awaits client.executeFlow(FLOW_ID, flatInputs) with no timeout, which can hang
CI; add a timeout wrapper function (e.g., withTimeout) that races the
executeFlow promise against a setTimeout rejection (suggested TIMEOUT_MS =
120_000) and replace the direct await with awaiting the timed promise; ensure
the catch block for the timed await still logs the error via the existing
console.error("[FAIL] Flow call threw:", ...) and exits, and reference the same
client.executeFlow and FLOW_ID when invoking the timeout wrapper.

115-173: 🧹 Nitpick | 🔵 Trivial | ⚖️ Poor tradeoff

Agent, the duplicated flattenFormToTrigger logic presents a maintenance hazard.

This function duplicates the production logic from orchestrate.ts. While this decoupling is intentional for E2E testing, it creates a synchronization risk: if the production implementation changes (e.g., new fields, different defaults), this test won't detect the divergence unless manually updated.

Consider one of these strategies:

  1. Add a comment referencing the source implementation with a warning to keep them synchronized
  2. Extract the flattening logic to a shared utility that both production and test can import
  3. Add a separate unit test that validates the flattening contract, so this E2E test can focus on flow execution

For now, at minimum, add a comment:

// IMPORTANT: Keep synchronized with apps/actions/orchestrate.ts flattenFormToTrigger
// Any changes to the production flattening logic must be mirrored here
function flattenFormToTrigger(form) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/mou-drafter/apps/test-e2e.js` around lines 115 - 173, The test defines a
local duplicate of the production flattening logic (flattenFormToTrigger) which
can drift from the implementation in orchestrate.ts; add a clear top-of-function
comment warning to keep it synchronized (e.g., "IMPORTANT: Keep synchronized
with apps/actions/orchestrate.ts flattenFormToTrigger — mirror any changes to
production logic or move to a shared util"), and as follow-ups consider
extracting the flattening into a shared utility used by both the production code
and this test or add a unit test to assert the flattening contract so E2E stays
focused on flow execution.

29-112: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Mission briefing: Test coverage scope is limited to catering engagement.

Agent, this test only validates the catering engagement path. The mou-drafter flow supports multiple engagement types (consulting, creative, etc.), but this E2E test won't catch regressions in those alternate paths.

Consider adding test cases for other engagement types to ensure full coverage of the flow's capabilities.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/mou-drafter/apps/test-e2e.js` around lines 29 - 112, The E2E test only
exercises the catering path by using the formData object with engagementType:
"catering", so add additional test cases that submit formData variants for other
engagement types (e.g., "consulting", "creative", "events") to cover alternate
flows; duplicate the existing formData template in test-e2e.js and modify the
engagementType and any type-specific fields (e.g., deliverables, paymentPreset,
event* fields) for each variant, then call the same submission/assertion logic
used for the catering case so the test suite validates all engagementType
branches.
kits/mou-drafter/apps/actions/orchestrate.ts (1)

130-135: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Mission: keep contract titles out of server logs.

agreementTitle is still raw user-supplied legal-document metadata. In this kit it can easily contain party names or matter identifiers, so this log statement is still leaking sensitive content.

🔧 Minimal redaction patch
     console.log("[mou-drafter] Sending flat inputs to flow:", {
-      agreementTitle: flatInputs.agreementTitle,
+      agreementTitle_present: Boolean(flatInputs.agreementTitle),
       deliverables_type: typeof flatInputs.deliverables,
       deliverables_is_string: typeof flatInputs.deliverables === "string",
       partyAName: "[redacted]",
       partyBName: "[redacted]",
     });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/mou-drafter/apps/actions/orchestrate.ts` around lines 130 - 135, The
console.log in orchestrate.ts is printing raw user-supplied agreementTitle
(sensitive) — change the logging in the block that prints flatInputs (the
console.log that includes agreementTitle, deliverables_type,
deliverables_is_string, partyAName, partyBName) to avoid logging the raw title:
instead log a redacted placeholder or a non-sensitive derivative (e.g.,
"REDACTED_AGREEMENT_TITLE" or a hash/length) for agreementTitle, keeping the
rest of the diagnostics (deliverables_type, deliverables_is_string, partyAName,
partyBName) unchanged; update the message to clearly indicate the title was
redacted so future readers know it was intentional.
♻️ Duplicate comments (1)
kits/mou-drafter/apps/actions/orchestrate.ts (1)

124-139: ⚠️ Potential issue | 🟠 Major

Mission: route this action through the parent lamatic.config.ts contract, not an env-only flow id.

generateMoU still calls executeFlow with process.env.MOU_DRAFTER_FLOW_ID, so the app can drift away from the kit’s declared step definitions. Import the parent config and resolve the MoU drafter step from there, with env only as deployment wiring if you truly need an override.

As per coding guidelines, kits/*/apps/actions/orchestrate.ts must “import and use ../../lamatic.config to read step definitions from the parent kit.” Based on learnings, the same contract applies here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/mou-drafter/apps/actions/orchestrate.ts` around lines 124 - 139, The
current generateMoU path directly uses process.env.MOU_DRAFTER_FLOW_ID when
calling lamaticClient.executeFlow, which bypasses the parent kit's step
definitions; update orchestrate.ts to import the parent lamatic.config
(../../lamatic.config) and resolve the MoU drafter step ID from that config
(falling back to process.env.MOU_DRAFTER_FLOW_ID only as an override), then pass
the resolved step ID into lamaticClient.executeFlow along with the flattened
inputs from flattenFormToTrigger; ensure references to generateMoU and the call
site of lamaticClient.executeFlow are updated to use the config-derived ID so
the app follows the kit’s declared contract.

Sources: Coding guidelines, Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@kits/mou-drafter/apps/app/api/compile-latex/route.ts`:
- Around line 85-95: The current route swallows chmod failures on outputDir
which hides when the sandbox output mount isn’t writable; change the
chmod(outputDir, 0o777).catch(() => undefined) to propagate the error (remove
the catch) or explicitly throw a descriptive error if chmod fails so the request
fails fast; adjust the code around inputDir/outputDir setup (where chmod is
called) to log/throw a clear permission error before calling runPdflatex so
runPdflatex(inputDir, outputDir) isn’t invoked when /output isn’t writable.

In `@kits/mou-drafter/apps/lib/lamatic-client.ts`:
- Around line 19-23: The top-level instantiation export "lamaticClient = new
Lamatic(...)" causes Lamatic to validate env at module import time and can crash
imports; change to lazy initialization so env validation happens inside the call
path (e.g., create a getLamaticClient or initLamaticClient function used by
generateMoU) instead of at module scope. Specifically, remove the module-scope
"new Lamatic(...)" usage and implement a factory that checks
process.env.LAMATIC_API_URL / LAMATIC_PROJECT_ID / LAMATIC_API_KEY and either
returns a constructed Lamatic instance or throws/returns an error that
generateMoU can catch and convert into the { success: false, error } response;
update generateMoU to call this factory (not the exported lamaticClient) so
missing secrets produce a controlled failure rather than an import-time crash.

In `@kits/mou-drafter/prompts/mou-drafter_clause-generator_system.md`:
- Line 168: Update the "Numbered or bulleted lists" style example in
mou-drafter_clause-generator_system.md so the LaTeX commands in the example (the
begin{itemize}, item and end{itemize} fragments) use JSON-escaped backslashes to
match the double-escaped backslash contract described at line 16; replace the
current single-backslash example with the double-escaped form used in JSON
values, keep the one-level-only/no-nesting requirement, and ensure the change is
applied to the example text referenced in the "Numbered or bulleted lists" rule.

---

Outside diff comments:
In `@kits/mou-drafter/apps/actions/orchestrate.ts`:
- Around line 130-135: The console.log in orchestrate.ts is printing raw
user-supplied agreementTitle (sensitive) — change the logging in the block that
prints flatInputs (the console.log that includes agreementTitle,
deliverables_type, deliverables_is_string, partyAName, partyBName) to avoid
logging the raw title: instead log a redacted placeholder or a non-sensitive
derivative (e.g., "REDACTED_AGREEMENT_TITLE" or a hash/length) for
agreementTitle, keeping the rest of the diagnostics (deliverables_type,
deliverables_is_string, partyAName, partyBName) unchanged; update the message to
clearly indicate the title was redacted so future readers know it was
intentional.

In `@kits/mou-drafter/apps/components/MoUForm.tsx`:
- Line 303: Replace the unsafe any types on form helper parameters with concrete
react-hook-form types: import and use Control<T>, UseFormRegister<T>, and
FieldErrors<T> (from 'react-hook-form') instead of any for the parameters named
control, register, and errors; apply the generic using your form data interface
(e.g., MoUFormValues) so signatures become Control<MoUFormValues>,
UseFormRegister<MoUFormValues>, FieldErrors<MoUFormValues> for the helpers
referenced around the symbols control/register/errors at lines ~303 and ~433 and
update the helper function/type declarations to accept those typed parameters.

In `@kits/mou-drafter/apps/components/ui/form.tsx`:
- Around line 45-75: The bug is that useFormState is called and
fieldContext?.name is accessed before the null-check guards run in useFormField;
reorder so you read contexts (React.useContext(FormFieldContext),
React.useContext(FormItemContext)) and call useFormContext() as now, then
immediately run the three guards that throw if fieldContext, itemContext or
formContext are missing, and only after those guards call useFormState({ name:
fieldContext.name }) and then call formContext.getFieldState(fieldContext.name,
formState); this ensures no property access or dependent hook logic runs before
the existence checks while preserving hook call order in useFormField.

In `@kits/mou-drafter/apps/test-e2e.js`:
- Around line 199-208: The test currently awaits client.executeFlow(FLOW_ID,
flatInputs) with no timeout, which can hang CI; add a timeout wrapper function
(e.g., withTimeout) that races the executeFlow promise against a setTimeout
rejection (suggested TIMEOUT_MS = 120_000) and replace the direct await with
awaiting the timed promise; ensure the catch block for the timed await still
logs the error via the existing console.error("[FAIL] Flow call threw:", ...)
and exits, and reference the same client.executeFlow and FLOW_ID when invoking
the timeout wrapper.
- Around line 115-173: The test defines a local duplicate of the production
flattening logic (flattenFormToTrigger) which can drift from the implementation
in orchestrate.ts; add a clear top-of-function comment warning to keep it
synchronized (e.g., "IMPORTANT: Keep synchronized with
apps/actions/orchestrate.ts flattenFormToTrigger — mirror any changes to
production logic or move to a shared util"), and as follow-ups consider
extracting the flattening into a shared utility used by both the production code
and this test or add a unit test to assert the flattening contract so E2E stays
focused on flow execution.
- Around line 29-112: The E2E test only exercises the catering path by using the
formData object with engagementType: "catering", so add additional test cases
that submit formData variants for other engagement types (e.g., "consulting",
"creative", "events") to cover alternate flows; duplicate the existing formData
template in test-e2e.js and modify the engagementType and any type-specific
fields (e.g., deliverables, paymentPreset, event* fields) for each variant, then
call the same submission/assertion logic used for the catering case so the test
suite validates all engagementType branches.

In `@registry.json`:
- Around line 2738-2773: The registry entry for slug "mou-drafter" is missing
required metadata; update the object to fill description, tags, author.name,
steps, and links: set description to the provided MoU/contract drafting summary,
add tags ["legal","documents","generative","LaTeX","contracts"], set author.name
to "rohith0110", populate steps with a single step object { id: "mou-drafter",
type: "mandatory", envKey: "MOU_DRAFTER_FLOW_ID" }, and add links including the
GitHub and deploy URLs shown in the review so the kit is discoverable and
deployable.

---

Duplicate comments:
In `@kits/mou-drafter/apps/actions/orchestrate.ts`:
- Around line 124-139: The current generateMoU path directly uses
process.env.MOU_DRAFTER_FLOW_ID when calling lamaticClient.executeFlow, which
bypasses the parent kit's step definitions; update orchestrate.ts to import the
parent lamatic.config (../../lamatic.config) and resolve the MoU drafter step ID
from that config (falling back to process.env.MOU_DRAFTER_FLOW_ID only as an
override), then pass the resolved step ID into lamaticClient.executeFlow along
with the flattened inputs from flattenFormToTrigger; ensure references to
generateMoU and the call site of lamaticClient.executeFlow are updated to use
the config-derived ID so the app follows the kit’s declared contract.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: df946695-eddd-4d45-8dae-28d548e85e4e

📥 Commits

Reviewing files that changed from the base of the PR and between 4346122 and 7bb9eb0.

⛔ Files ignored due to path filters (1)
  • kits/mou-drafter/apps/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (21)
  • kits/mou-drafter/README.md
  • kits/mou-drafter/agent.md
  • kits/mou-drafter/apps/.gitignore
  • kits/mou-drafter/apps/actions/orchestrate.ts
  • kits/mou-drafter/apps/app/api/compile-latex/route.ts
  • kits/mou-drafter/apps/app/page.tsx
  • kits/mou-drafter/apps/components/LatexPreview.tsx
  • kits/mou-drafter/apps/components/MoUForm.tsx
  • kits/mou-drafter/apps/components/ui/button.tsx
  • kits/mou-drafter/apps/components/ui/form.tsx
  • kits/mou-drafter/apps/components/ui/textarea.tsx
  • kits/mou-drafter/apps/hooks/use-toast.ts
  • kits/mou-drafter/apps/lib/lamatic-client.ts
  • kits/mou-drafter/apps/next-env.d.ts
  • kits/mou-drafter/apps/next.config.mjs
  • kits/mou-drafter/apps/package.json
  • kits/mou-drafter/apps/test-e2e.js
  • kits/mou-drafter/apps/tsconfig.json
  • kits/mou-drafter/prompts/mou-drafter_clause-generator_system.md
  • kits/mou-drafter/prompts/mou-drafter_llmnode-842_system_0.md
  • registry.json
💤 Files with no reviewable changes (1)
  • kits/mou-drafter/apps/tsconfig.json

Comment thread kits/mou-drafter/apps/app/api/compile-latex/route.ts
Comment thread kits/mou-drafter/apps/lib/lamatic-client.ts Outdated
Comment thread kits/mou-drafter/prompts/mou-drafter_clause-generator_system.md Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
kits/mou-drafter/apps/package.json (2)

37-37: ⚠️ Potential issue | 🟠 Major

Mission accepted: align this kit’s dependencies to the documented stack (or justify the deviation).

  • next is pinned to 16.2.6 (present on npm; latest dist-tag 16.2.7), but kit guidance calls for Next.js 14–15.
  • react/react-dom are pinned to 19.2.6 (present on npm; latest dist-tag 19.2.7), but kit guidance calls for React 18.

Update the versions to match the kit spec, or add a clear rationale for using Next 16 + React 19.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/mou-drafter/apps/package.json` at line 37, The package.json currently
pins dependencies to unsupported stack versions (next, react, react-dom); either
update the dependency entries for "next" to a supported 14.x or 15.x range and
set "react" and "react-dom" to React 18 (e.g., ^18.2.0) to match the kit
guidance, or add a short, explicit justification in the repo (package.json
comment is not allowed—add a clear rationale to the PR description or README)
explaining why you intentionally require Next 16 and React 19 and any
compatibility workarounds; target the "next", "react", and "react-dom"
identifiers when making the change so reviewers can verify alignment with the
kit spec.

Source: Learnings


39-40: ⚠️ Potential issue | 🟡 Minor

Agent handler directive: React 19.2.6 pin—compatibility OK; align with kit React 18 guidance

"react": "19.2.6",
"react-dom": "19.2.6",
  • react@19.2.6 and react-dom@19.2.6 exist on npm.
  • React 19.2.6 is compatible with Next.js (Next.js manages its own React wiring), so the compatibility verification concern is covered.
  • Next action: if the kit briefing/policy mandates React 18, switch these pins to React 18.x or add a documented justification for intentionally using React 19 in this kit.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/mou-drafter/apps/package.json` around lines 39 - 40, The package.json
currently pins "react" and "react-dom" to "19.2.6"; align with the kit policy by
either (A) changing these dependency entries in package.json to the approved
React 18.x pin (e.g., "react": "18.x", "react-dom": "18.x") or (B) add a short
documented justification in the repo (e.g., README or a new
DEPENDENCY_DECISIONS.md) explaining why React 19 is intentionally used for this
kit and noting compatibility with Next.js; update the package.json dependencies
(react/react-dom) or add the justification file accordingly and ensure the
change references the same dependency keys.

Source: Learnings

registry.json (1)

2738-2773: ⚠️ Potential issue | 🟠 Major

Fix mou-drafter metadata parsing so registry.json isn’t left blank.
registry.json entry for slug: "mou-drafter" is missing description, author, steps, links, and even reports type: "template"—but kits/mou-drafter/lamatic.config.ts does contain name, author, steps, and links.

Root cause: the registry update script parses lamatic.config.ts using regex that expects unquoted JS keys like name:, author: { name: ..., email: ... }, steps: [{ id: ..., type: ... }], and links: { github: ..., deploy: ... }. Your config uses JSON-style quoted keys everywhere ("name":, "id":, "type":, "github":), so the parser doesn’t match them—leaving registry fields empty (and deploy: "" can’t be captured either).

  • Update kits/mou-drafter/lamatic.config.ts to use unquoted keys (JS object syntax) and ensure links.deploy is a real URL (not "").
  • Fill description (currently "") and set non-empty tags if you want discoverability.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@registry.json` around lines 2738 - 2773, Update
kits/mou-drafter/lamatic.config.ts so the config uses unquoted JS object keys
(e.g., name:, author: { name:, email: }, steps: [{ id:, type:, ... }], links: {
github:, deploy: ... }) instead of JSON-style quoted keys so the registry parser
regex will match; populate description with a meaningful string, add non-empty
tags, ensure author has name/email, and set links.deploy to a real URL (not an
empty string) so registry.json will be written with description, author, steps,
links and tags populated.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@kits/mou-drafter/apps/package.json`:
- Line 37: The package.json currently pins dependencies to unsupported stack
versions (next, react, react-dom); either update the dependency entries for
"next" to a supported 14.x or 15.x range and set "react" and "react-dom" to
React 18 (e.g., ^18.2.0) to match the kit guidance, or add a short, explicit
justification in the repo (package.json comment is not allowed—add a clear
rationale to the PR description or README) explaining why you intentionally
require Next 16 and React 19 and any compatibility workarounds; target the
"next", "react", and "react-dom" identifiers when making the change so reviewers
can verify alignment with the kit spec.
- Around line 39-40: The package.json currently pins "react" and "react-dom" to
"19.2.6"; align with the kit policy by either (A) changing these dependency
entries in package.json to the approved React 18.x pin (e.g., "react": "18.x",
"react-dom": "18.x") or (B) add a short documented justification in the repo
(e.g., README or a new DEPENDENCY_DECISIONS.md) explaining why React 19 is
intentionally used for this kit and noting compatibility with Next.js; update
the package.json dependencies (react/react-dom) or add the justification file
accordingly and ensure the change references the same dependency keys.

In `@registry.json`:
- Around line 2738-2773: Update kits/mou-drafter/lamatic.config.ts so the config
uses unquoted JS object keys (e.g., name:, author: { name:, email: }, steps: [{
id:, type:, ... }], links: { github:, deploy: ... }) instead of JSON-style
quoted keys so the registry parser regex will match; populate description with a
meaningful string, add non-empty tags, ensure author has name/email, and set
links.deploy to a real URL (not an empty string) so registry.json will be
written with description, author, steps, links and tags populated.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: d9af7d8c-c2bf-4f10-b8de-54e2ba53083d

📥 Commits

Reviewing files that changed from the base of the PR and between 7bb9eb0 and 535eaff.

📒 Files selected for processing (3)
  • kits/mou-drafter/apps/next.config.mjs
  • kits/mou-drafter/apps/package.json
  • registry.json
💤 Files with no reviewable changes (1)
  • kits/mou-drafter/apps/next.config.mjs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
kits/mou-drafter/apps/tsconfig.json (2)

36-37: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Intel suggests redundant path entry.

Agent, you've included both forward-slash and backslash variants of the .next/dev/types path. Modern Node.js normalizes paths cross-platform—the backslash entry is redundant. Consider removing line 37 for cleaner config.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/mou-drafter/apps/tsconfig.json` around lines 36 - 37, Remove the
redundant Windows-style path entry ".next\\dev/types/**/*.ts" from tsconfig.json
since Node/TypeScript path resolution handles cross-platform separators; keep
the forward-slash entry ".next/dev/types/**/*.ts" and ensure any other similar
duplicated backslash entries are cleaned up so only normalized paths remain.

11-11: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Mission brief: Enable strict mode for enhanced type safety.

Agent, your TypeScript configuration has strict: false. For a new 2026 deployment, this disables critical type-checking safeguards (strict null checks, no implicit any, etc.). This mission requires stricter discipline.

🎯 Recommended upgrade
-    "strict": false,
+    "strict": true,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/mou-drafter/apps/tsconfig.json` at line 11, The project tsconfig.json
currently has "strict": false; change the TypeScript compiler option "strict" to
true in tsconfig.json to enable all strict checks (including strictNullChecks
and noImplicitAny), then run a full type-check (tsc --noEmit) and fix resultant
type errors (address implicit anys, nullable types, and incorrect function
signatures) in affected modules; ensure any per-folder or extends-based tsconfig
overrides do not re-disable strict and update those (or add local
compilerOptions) so strict mode is globally active.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@kits/mou-drafter/apps/tsconfig.json`:
- Around line 36-37: Remove the redundant Windows-style path entry
".next\\dev/types/**/*.ts" from tsconfig.json since Node/TypeScript path
resolution handles cross-platform separators; keep the forward-slash entry
".next/dev/types/**/*.ts" and ensure any other similar duplicated backslash
entries are cleaned up so only normalized paths remain.
- Line 11: The project tsconfig.json currently has "strict": false; change the
TypeScript compiler option "strict" to true in tsconfig.json to enable all
strict checks (including strictNullChecks and noImplicitAny), then run a full
type-check (tsc --noEmit) and fix resultant type errors (address implicit anys,
nullable types, and incorrect function signatures) in affected modules; ensure
any per-folder or extends-based tsconfig overrides do not re-disable strict and
update those (or add local compilerOptions) so strict mode is globally active.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: e13bd01e-2092-4e88-9e8f-64765e3bfb6e

📥 Commits

Reviewing files that changed from the base of the PR and between 535eaff and 6048aee.

⛔ Files ignored due to path filters (1)
  • kits/mou-drafter/apps/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • kits/mou-drafter/apps/global.d.ts
  • kits/mou-drafter/apps/next-env.d.ts
  • kits/mou-drafter/apps/package.json
  • kits/mou-drafter/apps/tsconfig.json

@akshatvirmani

Copy link
Copy Markdown
Contributor

/validate

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

📡 Running Studio validation — results will appear here shortly.

@akshatvirmani

Copy link
Copy Markdown
Contributor

@rohith0110 can you resolve the above coderabbit comments? also you can also remove the registry.json file too from the PR. This registry gets updated automatically via our GitHub actions checks.

@rohith0110

Copy link
Copy Markdown
Contributor Author

@rohith0110 can you resolve the above coderabbit comments? also you can also remove the registry.json file too from the PR. This registry gets updated automatically via our GitHub actions checks.

Hey, I made the minor fixes and removed the registry from the PR, but the issue was that when I opened a PR from my fork's feature branch to the main branch, it triggered the GitHub Action on my fork. The action is configured to auto-update the registry on merge, so when I merged feat/mou-drafter into my fork's main via PR, the bot ran and pushed registry changes. That's what caused the registry to show up as modified.

- lamatic-client: export singleton lamaticClient instead of factory function
- compile-latex route: fail fast on chmod errors rather than silently swallowing
  them; the sandbox user (65534:65534) requires a world-writable /output mount
- orchestrate: derive flow ID from lamatic.config step definition (falls back to
  MOU_DRAFTER_FLOW_ID env override); redact agreementTitle in diagnostic log
- MoUForm: replace any types on FormSelect.control and PartyFields
  (register/control/errors) with concrete react-hook-form generics
- form.tsx/useFormField: guard checks now run before useFormState so fieldContext
  is guaranteed non-null when its name is passed to the hook
- test-e2e: add withTimeout (120s) around executeFlow to prevent CI hangs; add
  sync warning comment on local flattenFormToTrigger; add services and design
  variants alongside catering so all three engagement-type branches are exercised
…actory

Switch orchestrate.ts from the removed lamaticClient singleton import to
the getLamaticClient() factory exported by the updated lamatic-client.ts.
…build

lamatic.config.ts:
- Switch from JSON-style quoted keys to unquoted JS object keys so the
  registry parser regex matches
- Add meaningful description and tags
- Add envKey: MOU_DRAFTER_FLOW_ID to the mandatory step so orchestrate.ts
  resolves the flow ID from config rather than always falling back to the env var
- Set a real Vercel deploy URL and a full GitHub link

apps/tsconfig.json:
- Add ../../lamatic.config.ts to the include array so TypeScript (and
  therefore Next.js/webpack) can resolve the ../../lamatic.config import
  in actions/orchestrate.ts; without this entry the file is outside the
  compilation scope and Vercel fails with "Module not found"
@rohith0110

Copy link
Copy Markdown
Contributor Author

Hey @akshatvirmani, I've made all the fixes CodeRabbit suggested. Let me know if there's anything else you'd like changed. Thanks!

@akshatvirmani

akshatvirmani commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Great! @rohith0110 just one thing can you remove the additional line change in the registry.json file. It is still showing in the PR. We can merge after that

image

@rohith0110

Copy link
Copy Markdown
Contributor Author

Hey @akshatvirmani, is it okay now? Let me know if there's anything else you'd like changed. Thanks!

@akshatvirmani

Copy link
Copy Markdown
Contributor

/validate

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

📡 Running Studio validation — results will appear here shortly.

@akshatvirmani akshatvirmani merged commit c9762dd into Lamatic:main Jun 7, 2026
2 checks passed
@akshatvirmani

Copy link
Copy Markdown
Contributor

Merged! @rohith0110 if you want you add add https://mou.itsrohith.dev/ in the "deploy" field in the lamatic.config.ts file

@rohith0110

Copy link
Copy Markdown
Contributor Author

Hey @akshatvirmani, got the merge notification and just wanted to say thanks. Building this kit was genuinely fun, and the challenge format made it worth doing properly. Glad to have been part of it. I will open a new PR with the link added to the deploy field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants