Summary
Allow users to attach Word documents (.docx) as context when generating requirements with the AI feature. Word documents (e.g. requirement specifications, meeting notes, business rules) would have their text extracted and sent alongside the prompt.
Background
Image attachment support has been implemented (vision-capable models). PDF support is tracked in #70. Word document support is the third document type to add.
Approach
LLM APIs (including OpenRouter) do not natively support .docx files. Text must be extracted before sending to the model.
Recommended: Server-side extraction with mammoth
Use the mammoth library to convert .docx to plain text or simplified HTML on the server (API route).
- Pros: Clean text extraction; handles styles, lists, tables; small dependency (~150 KB); well-maintained
- Cons: Adds a server-side dependency; complex formatting (charts, SmartArt, embedded objects) may be lost
Alternative: Browser-side extraction
Use mammoth in the browser to extract text before sending, similar to the PDF client-side approach.
- Pros: No server-side dependency
- Cons: Increases client bundle size; extraction happens on the user's device
Considerations
- Token consumption: Word documents can contain substantial text. Need a character/token limit with a warning.
- File size limit: Suggest max 20 MB per document.
- Max file count: Suggest max 2 documents (shared limit with PDFs).
- Supported formats:
.docx only (modern Office Open XML). Legacy .doc format is not supported by mammoth and should be rejected with a clear error message.
- Images in Word docs: Embedded images could optionally be extracted and sent as image content parts (if a vision-capable model is selected), but this adds complexity — defer to a follow-up.
- UI: Extend the existing file drop zone — add
.docx to accepted MIME types. Show a document icon instead of a thumbnail preview.
Acceptance Criteria
Summary
Allow users to attach Word documents (
.docx) as context when generating requirements with the AI feature. Word documents (e.g. requirement specifications, meeting notes, business rules) would have their text extracted and sent alongside the prompt.Background
Image attachment support has been implemented (vision-capable models). PDF support is tracked in #70. Word document support is the third document type to add.
Approach
LLM APIs (including OpenRouter) do not natively support
.docxfiles. Text must be extracted before sending to the model.Recommended: Server-side extraction with
mammothUse the
mammothlibrary to convert.docxto plain text or simplified HTML on the server (API route).Alternative: Browser-side extraction
Use
mammothin the browser to extract text before sending, similar to the PDF client-side approach.Considerations
.docxonly (modern Office Open XML). Legacy.docformat is not supported bymammothand should be rejected with a clear error message..docxto accepted MIME types. Show a document icon instead of a thumbnail preview.Acceptance Criteria
.docxfiles in the AI generation dialog.docfiles are rejected with a clear error messageenandsv