diff --git a/src/generate_skills.rs b/src/generate_skills.rs index 121d4c79..c3915e9c 100644 --- a/src/generate_skills.rs +++ b/src/generate_skills.rs @@ -474,6 +474,40 @@ metadata: } } + // Gmail-specific: explain how to create properly formatted drafts + if alias == "gmail" { + out.push_str("## Creating Drafts\n\n"); + out.push_str("**Always use HTML when creating drafts** to prevent email clients from wrapping long lines. Build the raw RFC 2822 message with `Content-Type: text/html` and convert the plain text body to HTML:\n\n"); + out.push_str("- Double newlines → paragraph breaks (`
...
` separated by `

`)\n"); + out.push_str("- Single newlines → `
`\n"); + out.push_str("- Wrap in `
...
`\n\n"); + out.push_str("```bash\n"); + out.push_str("python3 - <<'PYEOF'\n"); + out.push_str("import base64\n\n"); + out.push_str("to = \"recipient@example.com\"\n"); + out.push_str("subject = \"Your Subject\"\n"); + out.push_str("body = \"\"\"Paragraph one line one.\\nStill paragraph one.\\n\\nParagraph two.\"\"\"\n\n"); + out.push_str("paragraphs = body.split('\\n\\n')\n"); + out.push_str("html_parts = ['
' + p.replace('\\n', '
').strip() + '
' for p in paragraphs]\n"); + out.push_str("html_body = '
' + '

'.join(html_parts) + '
'\n\n"); + out.push_str("raw = '\\r\\n'.join([\n"); + out.push_str(" f'To: {to}',\n"); + out.push_str(" f'Subject: {subject}',\n"); + out.push_str(" 'MIME-Version: 1.0',\n"); + out.push_str(" 'Content-Type: text/html; charset=utf-8',\n"); + out.push_str(" '',\n"); + out.push_str(" html_body,\n"); + out.push_str("])\n"); + out.push_str("encoded = base64.urlsafe_b64encode(raw.encode('utf-8')).decode('ascii').rstrip('=')\n"); + out.push_str("print(encoded)\n"); + out.push_str("PYEOF\n"); + out.push_str("```\n\n"); + out.push_str("Then create the draft:\n\n"); + out.push_str("```bash\n"); + out.push_str("gws gmail users drafts create --json '{\"message\":{\"raw\":\"ENCODED_OUTPUT_FROM_ABOVE\"}}'\n"); + out.push_str("```\n\n"); + out.push_str("To reply in-thread, add `\"threadId\"` to the message object and include `In-Reply-To` / `References` headers.\n\n"); + } // Discovering commands section out.push_str("## Discovering Commands\n\n"); out.push_str("Before calling any API method, inspect it:\n\n");