Skip to content

contrib: nightly launchd job for OpenCode day summaries - #24

Open
artcashin wants to merge 1 commit into
prime-radiant-inc:mainfrom
artcashin:feat/nightly-opencode-summary
Open

artcashin wants to merge 1 commit into
prime-radiant-inc:mainfrom
artcashin:feat/nightly-opencode-summary

Conversation

@artcashin

Copy link
Copy Markdown

Packaging for a workflow the CLI already supports. Nothing in src/ changes — this adds a script, a launchd plist template and setup notes under contrib/.

Why

Two things push toward one unattended run per day:

  • OpenCode sessions only reach the journal when ingest runs the staging adapter, so they lag until someone runs it.
  • A day summarized while you are still working in it is summarized incomplete, and stays that way.

Running once, just after the day is genuinely over, addresses both.

Depends on

Branched from main and touches no shared files, so it can merge in any order relative to those — it simply does nothing useful until both land.

Two details that are easy to get wrong

Sessions are selected by logical date, reading day_start_hour from config, because that is how summarize groups them. Selecting on the calendar date is wrong in both directions: it picks projects whose work belongs to the previous day, and misses projects whose work belongs to this one. I hit exactly this while testing — a project with sessions at 00:07 and 01:48 was selected for the wrong day and summarized nothing.

The job runs at 05:05, not midnight. With day_start_hour at 5 a logical day runs 05:00 to 05:00, so a midnight run summarizes a day with five hours still left in it — and, because the entry then exists, freezes it that way.

Scope

Entries are keyed by (date, project), so a project used with both OpenCode and Claude Code on the same day yields one entry covering both. The script selects projects that had OpenCode activity; summarizing OpenCode sessions in isolation would need source-aware grouping in the tool itself. The README says so plainly rather than implying a cleaner separation than exists.

Secrets stay out of the plist — the script sources the shell environment, so a key named by summary_provider.api_key_env is never copied into a file launchd reads.

Testing

Run end-to-end on macOS against a live corpus: a populated day (regenerating entries across five projects, with trivial ones correctly skipped), an empty day (clean no-op exit), and under env -i with a stripped PATH to mimic launchd's minimal environment rather than a login shell. The launchctl registration and recorded calendar interval were verified after install.

🤖 Generated with Claude Code

OpenCode sessions only reach the journal when `ingest` runs the staging
adapter, and a day summarized while it is still in progress cannot otherwise be
refreshed. Both point at wanting one unattended run per day, just after the day
is genuinely over.

Adds a script, a launchd plist template and setup notes under contrib/. Nothing
in src/ changes; this is packaging for a workflow the CLI already supports.

Two details that are easy to get wrong and are handled here:

- Sessions are selected by *logical* date, reading day_start_hour from config.
  Selecting on the calendar date both picks projects whose work belongs to the
  previous day and misses projects whose work belongs to this one.
- The job runs at 05:05 rather than midnight. With day_start_hour at 5 a logical
  day is not over until 05:00, so a midnight run would summarize a day with five
  hours still to go — and freeze it that way.

Secrets stay out of the plist: the script sources the shell environment, so a
key named by summary_provider.api_key_env is never copied into a file launchd
reads.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant