Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions todo/t1305-opencode-streaming-hooks-issue.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
# t1305: OpenCode Upstream Issue Draft

**Upstream issue created:** https://github.com/anomalyco/opencode/issues/14691
## Status

- **Original issue:** [#14691](https://github.com/anomalyco/opencode/issues/14691) -- CLOSED (superseded)
- **Active issue:** [#14740](https://github.com/anomalyco/opencode/issues/14740) -- OPEN (cleaner description)
- **Active PR:** [#14741](https://github.com/anomalyco/opencode/pull/14741) -- OPEN, MERGEABLE
- Branch: `feature/stream-hooks-v2`
- CI: 6/8 pass (2 failures are unrelated Windows Playwright flake)
- Includes unit tests
- Awaiting maintainer review/merge
- **Internal PR:** [#2152](https://github.com/marcusquinn/aidevops/pull/2152) -- MERGED (issue draft)

### Timeline

1. Issue #14691 created (2026-02-22) with full research, benchmark data, code sketch
2. PR #14727 submitted with initial implementation

Choose a reason for hiding this comment

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

medium

For consistency with the other items in the timeline, please add the date for when PR #14727 was submitted.

3. Issue #14740 created (2026-02-23) as cleaner re-submission
4. PR #14741 submitted (2026-02-23) with unit tests, superseding #14727
5. Issue #14691 closed to consolidate discussion at #14740

## Target Repository

`anomalyco/opencode` (108k+ stars)
`anomalyco/opencode` (109k+ stars, TypeScript, v1.2.10)

## Issue Title

`[FEATURE]: Plugin hooks for streaming token observation (stream.delta) and abort handling (stream.aborted)`
`[FEATURE]: Plugin hooks for real-time stream observation and abort control`

## Research Summary

Expand Down Expand Up @@ -217,3 +234,16 @@ if (abortReason) {
4. **Complements #12472**: Claude Code's `PreToolUse`/`PostToolUse` map to `tool.execute.before/after`. These new hooks cover the streaming phase that Claude Code doesn't expose at all -- making OpenCode's plugin system strictly more capable.

5. **Complements #13524**: The centralized hook dispatch from #13524 would naturally include these new hooks.

## Architecture Verification (2026-02-23)

Re-checked per task note about v1.2.7 Bun->Filesystem migration:

- **`processor.ts` location**: Confirmed still in `packages/opencode/src/session/` (TypeScript codebase)
- **Plugin system**: `packages/plugin/src/index.ts` -- `Plugin.trigger()` pattern unchanged
- **Streaming loop**: `for await (const value of stream.fullStream)` switch statement in processor.ts
- **v1.2.1 PartDelta SDK events**: `text-delta`, `reasoning-delta`, `tool-input-delta` events from AI SDK
- **v1.2.7 migration**: Bun.file() -> Filesystem module (file I/O layer), does NOT affect streaming/plugin architecture
- **Current version**: v1.2.10 (released 2026-02-20)
Comment on lines +242 to +247

Choose a reason for hiding this comment

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

medium

The architecture verification section is a great addition. I have a few suggestions for improvement:

  1. Formatting Consistency: Use backticks for file paths (e.g., packages/plugin/src/index.ts), method names (Plugin.trigger()), and event identifiers (text-delta) to match the style in line 242.
  2. Implementation Gap: You've identified reasoning-delta as an available event in line 245, and it's included in the stream.delta hook definition (line 95). However, it is currently missing from the processor.ts code sketch. Consider adding a case for it in the sketch to ensure completeness.


**Note:** There is a separate Go project `opencode-ai/opencode` (11k stars) which is a different product entirely. The target for this task is `anomalyco/opencode` (109k stars, TypeScript).

Choose a reason for hiding this comment

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

medium

Repository names should be wrapped in backticks to match the formatting used in the 'Target Repository' section (line 24). Also, consider using 109k+ for the star count to remain consistent with the earlier mention.

Loading