Skip to content

feat: messages to the heavens#410

Merged
gewenyu99 merged 9 commits intomainfrom
messages-to-the-heavens
Apr 27, 2026
Merged

feat: messages to the heavens#410
gewenyu99 merged 9 commits intomainfrom
messages-to-the-heavens

Conversation

@gewenyu99
Copy link
Copy Markdown
Collaborator

@gewenyu99 gewenyu99 commented Apr 22, 2026

Problem

We want to send messages to the heavens (posthog cloud). See our game plan

Changes

Adds a interface to hook into event plan updates made by the agent.

  • Adds a destination for debugging which is just to a local file
  • Leaves an empty destination for hook up later to PostHog Cloud

See comments in this PR <3

Test plan

readonly name = 'posthog';

send(_event: StreamEvent, _payload: TaskStreamUpdate): Promise<void> {
// TODO: implement when the PostHog API surface is defined.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Wire this up to send to where ever in the heavens (posthog app)

try {
appendFileSync(
TASK_STREAM_LOG,
`[${event}] ${JSON.stringify(payload)}\n`,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This will print to /tmp/posthog-task-stream.log for easy debugging and for us to tweak what this looks like

started_at: this.startedAt,
run_phase: session.runPhase,
tasks: buildTasks(tasks),
event_plan: eventPlan.length > 0 ? eventPlan : undefined,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We will also send the event plan up so we can display them

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Image

equiv to this screen in wizard

Copy link
Copy Markdown
Collaborator Author

@gewenyu99 gewenyu99 Apr 23, 2026

Choose a reason for hiding this comment

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

[CREATE] {
  "session_id": "onboarding-posthog_integration-2026-04-23T15:16:21.919Z",
  "workflow_id": "onboarding",
  "skill_id": "posthog_integration",
  "started_at": "2026-04-23T15:16:21.919Z",
  "run_phase": "idle",
  "tasks": [],
  "timestamp": "2026-04-23T15:16:21.920Z"
}
[UPDATE] {
  "session_id": "onboarding-posthog_integration-2026-04-23T15:16:21.919Z",
  "workflow_id": "onboarding",
  "skill_id": "posthog_integration",
  "started_at": "2026-04-23T15:16:21.919Z",
  "run_phase": "running",
  "tasks": [
    {
      "id": "0",
      "title": "Analyze project structure and plan event tracking",
      "status": "in_progress"
    },
    {
      "id": "1",
      "title": "Set up PostHog dependencies and environment variables",
      "status": "pending"
    },
    {
      "id": "2",
      "title": "Insert event tracking code",
      "status": "pending"
    },
    {
      "id": "3",
      "title": "Revise and validate tracking implementation",
      "status": "pending"
    },
    {
      "id": "4",
      "title": "Wrap up integration",
      "status": "pending"
    }
  ],
  "timestamp": "2026-04-23T15:17:12.484Z"
}
[UPDATE] {
  "session_id": "onboarding-posthog_integration-2026-04-23T15:16:21.919Z",
  "workflow_id": "onboarding",
  "skill_id": "posthog_integration",
  "started_at": "2026-04-23T15:16:21.919Z",
  "run_phase": "running",
  "tasks": [
    {
      "id": "0",
      "title": "Analyze project structure and plan event tracking",
      "status": "in_progress"
    },
    {
      "id": "1",
      "title": "Set up PostHog dependencies and environment variables",
      "status": "pending"
    },
    {
      "id": "2",
      "title": "Insert event tracking code",
      "status": "pending"
    },
    {
      "id": "3",
      "title": "Revise and validate tracking implementation",
      "status": "pending"
    },
    {
      "id": "4",
      "title": "Wrap up integration",
      "status": "pending"
    }
  ],
  "event_plan": [
    {
      "name": "start_free_trial_clicked",
      "description": "User clicks a 'Start Free Trial' CTA button"
    },
    {
      "name": "contact_sales_clicked",
      "description": "User clicks the 'Contact Sales' button on the homepage hero"
    },
    {
      "name": "pricing_plan_clicked",
      "description": "User clicks a CTA on the pricing page (Starter, Pro, or Enterprise)"
    },
    {
      "name": "contact_form_submitted",
      "description": "User successfully submits the contact form (client-side success)"
    },
    {
      "name": "contact_form_errored",
      "description": "Contact form submission fails with a validation or network error (client-side)"
    },
    {
      "name": "contact_form_submission_received",
      "description": "Server successfully processes a contact form submission (server-side)"
    }
  ],
  "timestamp": "2026-04-23T15:18:01.764Z"
}
...
[UPDATE] {
  "session_id": "onboarding-posthog_integration-2026-04-23T15:16:21.919Z",
  "workflow_id": "onboarding",
  "skill_id": "posthog_integration",
  "started_at": "2026-04-23T15:16:21.919Z",
  "run_phase": "running",
  "tasks": [
    {
      "id": "0",
      "title": "Analyze project structure and plan event tracking",
      "status": "completed"
    },
    {
      "id": "1",
      "title": "Set up PostHog dependencies and environment variables",
      "status": "completed"
    },
    {
      "id": "2",
      "title": "Insert event tracking code",
      "status": "completed"
    },
    {
      "id": "3",
      "title": "Revise and validate tracking implementation",
      "status": "completed"
    },
    {
      "id": "4",
      "title": "Wrap up integration",
      "status": "in_progress"
    }
  ],
  "event_plan": [
    {
      "name": "start_free_trial_clicked",
      "description": "User clicks a 'Start Free Trial' CTA button"
    },
    {
      "name": "contact_sales_clicked",
      "description": "User clicks the 'Contact Sales' button on the homepage hero"
    },
    {
      "name": "pricing_plan_clicked",
      "description": "User clicks a CTA on the pricing page (Starter, Pro, or Enterprise)"
    },
    {
      "name": "contact_form_submitted",
      "description": "User successfully submits the contact form (client-side success)"
    },
    {
      "name": "contact_form_errored",
      "description": "Contact form submission fails with a validation or network error (client-side)"
    },
    {
      "name": "contact_form_submission_received",
      "description": "Server successfully processes a contact form submission (server-side)"
    }
  ],
  "timestamp": "2026-04-23T15:19:58.268Z"
}
[UPDATE] {
  "session_id": "onboarding-posthog_integration-2026-04-23T15:16:21.919Z",
  "workflow_id": "onboarding",
  "skill_id": "posthog_integration",
  "started_at": "2026-04-23T15:16:21.919Z",
  "run_phase": "running",
  "tasks": [
    {
      "id": "0",
      "title": "Analyze project structure and plan event tracking",
      "status": "completed"
    },
    {
      "id": "1",
      "title": "Set up PostHog dependencies and environment variables",
      "status": "completed"
    },
    {
      "id": "2",
      "title": "Insert event tracking code",
      "status": "completed"
    },
    {
      "id": "3",
      "title": "Revise and validate tracking implementation",
      "status": "completed"
    },
    {
      "id": "4",
      "title": "Wrap up integration",
      "status": "completed"
    }
  ],
  "event_plan": [
    {
      "name": "start_free_trial_clicked",
      "description": "User clicks a 'Start Free Trial' CTA button"
    },
    {
      "name": "contact_sales_clicked",
      "description": "User clicks the 'Contact Sales' button on the homepage hero"
    },
    {
      "name": "pricing_plan_clicked",
      "description": "User clicks a CTA on the pricing page (Starter, Pro, or Enterprise)"
    },
    {
      "name": "contact_form_submitted",
      "description": "User successfully submits the contact form (client-side success)"
    },
    {
      "name": "contact_form_errored",
      "description": "Contact form submission fails with a validation or network error (client-side)"
    },
    {
      "name": "contact_form_submission_received",
      "description": "Server successfully processes a contact form submission (server-side)"
    }
  ],
  "timestamp": "2026-04-23T15:21:25.405Z"
}

Copy link
Copy Markdown
Contributor

@MattBro MattBro left a comment

Choose a reason for hiding this comment

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

A few things worth looking at before this lands. The big one is that COMPLETE events don't actually fire - details inline.

Comment thread src/lib/task-stream/task-stream-push.ts Outdated
Comment thread src/ui/tui/start-tui.ts Outdated
StreamEvent,
} from '../types';

const TASK_STREAM_LOG = '/tmp/posthog-task-stream.log';
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.

/tmp doesn't exist on Windows, and the log grows unbounded across runs. Use os.tmpdir() and either truncate on construction or include a timestamp in the filename so concurrent/repeat runs don't collide.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is a generally good piece of advice for all of our logging! Thanks :D

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh this actually explains why our skills don't install properly on windows 😬 we unzip in tmp!

Copy link
Copy Markdown
Collaborator Author

@gewenyu99 gewenyu99 Apr 23, 2026

Choose a reason for hiding this comment

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

#417

This should fix both for windows

Comment thread src/ui/tui/start-tui.ts Outdated
Comment thread src/lib/task-stream/task-stream-push.ts Outdated
Comment thread src/lib/task-stream/task-stream-push.ts Outdated
Comment thread src/ui/tui/start-tui.ts Outdated
Comment thread src/lib/task-stream/task-stream-push.ts
@gewenyu99
Copy link
Copy Markdown
Collaborator Author

Oooo this is a great review @MattBro! On it

@gewenyu99 gewenyu99 requested a review from a team April 23, 2026 20:30
@gewenyu99 gewenyu99 marked this pull request as ready for review April 23, 2026 20:30
@gewenyu99 gewenyu99 requested a review from MattBro April 23, 2026 20:30
Copy link
Copy Markdown
Contributor

@MattBro MattBro left a comment

Choose a reason for hiding this comment

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

Looks good - everything substantive got handled, tests cover the lifecycle, and dispose in bin.ts closes the COMPLETE gap cleanly. Nice work.

Two small non-blockers:

  • Typo in the test describe block: Coorect order of events.
  • onTasksChanged only fires from syncTodos, so mid-run setEventPlan / setRunPhase changes won't push until the next todo sync. Terminal phase is caught by dispose() so it's fine in practice, but worth a thought if the plan gets edited independently.

Windows /tmp is tracked in #417, good to split.

@gewenyu99
Copy link
Copy Markdown
Collaborator Author

Thanks for the review @MattBro <3

I learned a lot. Looking forward to working together on this.

@gewenyu99 gewenyu99 merged commit fe1114a into main Apr 27, 2026
17 checks passed
@gewenyu99 gewenyu99 deleted the messages-to-the-heavens branch April 27, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants