task icon Task

Analyze Email for Roast

Fetch Gmail data and compute roastable patterns - follow-ups, late nights, meeting spam

Requirements
Gmail connection must be established.
1

Check if Gmail is connected. If not, tell the user:
"I need access to your Gmail to roast you properly. Let's connect it first."
Then guide them through the Gmail OAuth connection.

2

Tell the user what's about to happen:
"Alright, I'm going to analyze your inbox for roastable material.
This includes your sent emails, follow-up patterns, late-night sins,
and who you're desperately emailing. Takes about 30 seconds.
Ready to face yourself?"

Wait for confirmation before proceeding.

3

Say 'Scanning your inbox for evidence...' then run the fetch code.

6

Check the fetch output. If count is 0 or very low (<20 emails):
"Your sent folder is suspiciously empty. Either you're new here, or you've been
deleting evidence. I need at least some emails to roast you properly."
STOP if insufficient data.

If count is reasonable, say:
"Found [X] sent emails. Now computing your sins..."

9

Check the stats output. Preview what you found to build anticipation:

"Analysis complete. Here's the damage:

  • follow-up emails sent
  • [Y]% of them were ignored
  • [Z] late-night emails (you ok?)
  • Your peak sending hour: [hour]
  • Thread abandonment rate: [X]%

This is... substantial material. Ready to pick your roaster?"

Save this preview - the main roast task will use the full metrics.

                    To run this task you must have the following required information:

> Gmail connection must be established.

If you don't have all of this information, exit here and respond asking for any extra information you require, and instructions to run this task again with ALL required information.

---

You MUST use a todo list to complete these steps in order. Never move on to one step if you haven't completed the previous step. If you have multiple read steps in a row, read them all at once (in parallel).

Add all steps to your todo list now and begin executing.

## Steps

1. Check if Gmail is connected. If not, tell the user:
"I need access to your Gmail to roast you properly. Let's connect it first."
Then guide them through the Gmail OAuth connection.


2. Tell the user what's about to happen:
"Alright, I'm going to analyze your inbox for roastable material.
This includes your sent emails, follow-up patterns, late-night sins,
and who you're desperately emailing. Takes about 30 seconds.
Ready to face yourself?"

Wait for confirmation before proceeding.


3. Say 'Scanning your inbox for evidence...' then run the fetch code.

4. [Read Email Analysis Session]: Read the file at `session/email-roast-analysis.json` into context (Get session path for email data)

5. [Gather Arguments: Fetch Gmail Messages] The next step has the following requirements for arguments, do not proceed until you have all the required information:
- `query`: in:sent newer_than:6m
- `maxResults` (default: "50"): 500
- `outputPath` (default: "session/emails.json"): ui:session.email.analysis path for emails

6. [Run Code: Fetch Gmail Messages]: Call `run_script` with:

```json
{
  "file": {
    "path": https://sk.ills.app/code/gmail.inbox.fetch/preview,
    "args": [
      "query",
      "maxResults",
      "outputPath"
    ]
  },
  "packages": null
}
```

7. Check the fetch output. If count is 0 or very low (<20 emails):
"Your sent folder is suspiciously empty. Either you're new here, or you've been
deleting evidence. I need at least some emails to roast you properly."
STOP if insufficient data.

If count is reasonable, say:
"Found [X] sent emails. Now computing your sins..."


8. [Read Roast Metrics]: Read the file at `session/roast-metrics.json` into context (Get session path for metrics output)

9. [Gather Arguments: Compute Email Roast Stats] The next step has the following requirements for arguments, do not proceed until you have all the required information:
- `inputPath` (default: "session/emails.json"): emails file path from previous step
- `outputPath` (default: "session/roast_metrics.json"): ui:session.roast.metrics path for metrics output

10. [Run Code: Compute Email Roast Stats]: Call `run_script` with:

```json
{
  "file": {
    "path": https://sk.ills.app/code/viral.email.stats/preview,
    "args": [
      "inputPath",
      "outputPath"
    ]
  },
  "packages": null
}
```

11. Check the stats output. Preview what you found to build anticipation:

"Analysis complete. Here's the damage:
- [X] follow-up emails sent
- [Y]% of them were ignored
- [Z] late-night emails (you ok?)
- Your peak sending hour: [hour]
- Thread abandonment rate: [X]%

This is... substantial material. Ready to pick your roaster?"

Save this preview - the main roast task will use the full metrics.