Skip to content

feat(plugin): session-recap injection — personalized onset greeting - #528

Merged
jeonghun-jj-lee merged 4 commits into
mainfrom
523-featplugin-session-recap-injection-smart-onset-greeting-from-session-history
Aug 23, 2026
Merged

feat(plugin): session-recap injection — personalized onset greeting#528
jeonghun-jj-lee merged 4 commits into
mainfrom
523-featplugin-session-recap-injection-smart-onset-greeting-from-session-history

Conversation

@jeonghun-jj-lee

@jeonghun-jj-lee jeonghun-jj-lee commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements #523 — injects a ## Recent sessions (last 7 days) block into the system prompt so the onset router can personalize its greeting from actual session history, rather than depending on vault files only populated by dream-cycle workflows.

What changed

File Role
opencode-plugin/session_recap.ts Core module: DB read (bun:sqlite), filtering, caching, mechanical recap extraction, markdown composition
opencode-plugin/amicode_context.ts Hook wiring: now async, passes sessionID from input, calls buildRecentSessionsBlock
test/session_recap.test.ts 26 unit tests covering all pure logic paths

Design pivot from issue

The issue assumed client.sessions.list() via a PluginInput SDK handle — investigation showed the plugin receives no client. Pivoted to reading the SQLite DB directly via bun:sqlite (Bun built-in, zero deps). Same outcome, simpler surface.

Deferred

  • LLM summarization — the mechanical extract (first user prompt + numerical outcomes) is good enough for v1. LLM recaps need provider config the plugin doesn't have access to; will follow up once the small-model hook is wired.
  • Latency AC (< 3s for 5 sessions) — mechanical extraction is ~instant; the latency criterion is satisfied trivially without parallelism.

Test results

  • 26 new tests pass (filtering, outcome extraction, composition, caching, graceful degradation)
  • Full fast suite: 106/106 files, 1505/1505 tests pass
  • 2 pre-existing flaky E2E failures (binary server timeout) — unrelated

Closes #523

Summary by CodeRabbit

  • New Features

    • Added recent session recaps to context, helping maintain continuity across conversations.
    • Onboarding now includes available profile scoring information.
    • Explicit onboarding requests can resume an existing profile or restart from Stage 1.
  • Improvements

    • Removed the “Design a new pulse” option from onboarding choices.
    • Session recap generation and storage now degrade gracefully when unavailable.
  • Tests

    • Added coverage for session filtering, recap formatting, caching, and onboarding routing.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 83248ee0-96e8-4e4d-b79d-2cea6edb1a92

📥 Commits

Reviewing files that changed from the base of the PR and between a8d33df and c953b46.

📒 Files selected for processing (7)
  • packages/extension/opencode-plugin/amicode_context.ts
  • packages/extension/opencode-plugin/session_recap.ts
  • packages/extension/src/opencode_config.ts
  • packages/extension/src/scores/router.ts
  • packages/extension/test/scores/entitlements_router.test.ts
  • packages/extension/test/scores/golden/router-section.md
  • packages/extension/test/session_recap.test.ts

📝 Walkthrough

Walkthrough

The plugin adds cached recent-session recaps to system prompts. Onboarding content now includes the overture score, handles completed profiles, and removes the pulse-designer option. Tests cover recap behavior and updated routing output.

Changes

Session recap injection

Layer / File(s) Summary
Session recap pipeline
packages/extension/opencode-plugin/session_recap.ts, packages/extension/test/session_recap.test.ts
The new pipeline filters recent sessions, extracts outcomes, reads and writes cached JSON recaps, renders Markdown, and degrades gracefully when SQLite or filesystem operations fail.
System prompt recap injection
packages/extension/opencode-plugin/amicode_context.ts
The asynchronous system transform builds a recap block for the current session and appends it when available. Recap failures are logged and suppressed.

Onboarding routing updates

Layer / File(s) Summary
Onboarding completion and choices
packages/extension/src/opencode_config.ts, packages/extension/src/scores/router.ts, packages/extension/test/scores/entitlements_router.test.ts, packages/extension/test/scores/golden/router-section.md
Post-onboarding content includes the compiled overture score. Completed onboarding offers profile retention or reset. The pulse-designer option is removed and routing expectations are updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested reviewers: aarontrowbridge

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 523-featplugin-session-recap-injection-smart-onset-greeting-from-session-history

Comment @coderabbitai help to get the list of available commands.

…rom session history

Reads recent sessions (last 7 days) from the opencode SQLite DB via
bun:sqlite, extracts mechanical recaps (user prompts + numerical outcomes),
caches them to ~/.amico/session-recaps/, and injects a '## Recent sessions'
block into the system prompt. The onset router naturally uses this to
personalize the greeting without any changes to its own text.

Key decisions:
- bun:sqlite (Bun built-in) for DB reads — no npm deps, no SDK client needed
- Mechanical extraction (not LLM) for v1 — captures topic + fidelity/iteration
  numbers; LLM summarization deferred to a follow-up
- Env-seam pattern (AMICODE_SESSION_RECAP_CACHE_DIR, OPENCODE_DB) for testability
- Graceful degradation: returns null under Node/vitest or on any error
- Pure logic functions exported for unit testing (26 tests)

Acceptance criteria addressed:
- Returning user sees ## Recent sessions in system prompt
- Current session excluded; subagent sessions excluded
- Noise sessions (Compaction, <2 assistant msgs) filtered
- Cache prevents re-summarization
- Graceful degradation on failure (never crashes prompt build)

Closes #523
The onset router unconditionally offered pulse design as a top-level option,
causing the model to recommend pulses even for users whose intent is general
coding or product development. The design-a-pulse skill remains invocable by
name — it's just no longer the first thing offered on every session.

The remaining default options (resume active problem, resume campaign, fleet
ops, bring your own problem, just explore) are all state-gated: they only
appear when the relevant state exists, so the model builds the greeting from
what's actually there rather than defaulting to quantum control.
…ng skills

When onboarding is already complete, the overture score is not compiled into
the session's AGENTS.md. Previously, the onset router said 'skip to the
overture' for onboarding requests — but the overture wasn't there. The model
then improvised by invoking design-a-pulse from the skill index (the closest
thing to an interview it could find).

Now the router explicitly handles the post-completion case: tell the user
their profile exists and offer keep/redo. No skill invocation, no improvised
interview. The overture only runs when it's actually compiled in
(shouldOnboard = true at boot time).
…d for re-onboarding

Previously, the overture was only compiled into the session's AGENTS.md when
shouldOnboard=true at boot. Post-completion, it was absent — so 'begin
onboarding' required a window reload to recompile it in. Bad UX.

Now the overture is always compiled in (as a section after the general-purpose
copilot stub), gated by the onset router's instructions rather than by
presence/absence. The router says 'run the overture if present' — and it
always is. No reload needed to re-run onboarding.

Cost: ~12KB added to prompts that already had the stub. The overture content
is inert unless the user explicitly triggers it via the onset router.
@jeonghun-jj-lee
jeonghun-jj-lee force-pushed the 523-featplugin-session-recap-injection-smart-onset-greeting-from-session-history branch from aadb607 to c953b46 Compare August 23, 2026 17:33
@jeonghun-jj-lee
jeonghun-jj-lee marked this pull request as ready for review August 23, 2026 17:51
@jeonghun-jj-lee
jeonghun-jj-lee merged commit 3e5ed1c into main Aug 23, 2026
8 checks passed
@jeonghun-jj-lee
jeonghun-jj-lee deleted the 523-featplugin-session-recap-injection-smart-onset-greeting-from-session-history branch August 23, 2026 17:51
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.

feat(plugin): session-recap injection — smart onset greeting from session history

1 participant