跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    中文English
    gotgenes

    Session Context

    v1.4.0智能体编排
    @gotgenes/opencode-session-context

    OpenCode plugin for cross-session context access in subagent workflows

    GitHub 星标

    0

    月装机量

    22

    近 7 天 1

    综合评分SCORE

    22.2

    生态多维模型

    最近提交

    3 个月前

    2026-04-24

    快速安装与配置

    opencode.json

    写入当前项目的 opencode.json,只对这个仓库生效。

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["@gotgenes/opencode-session-context@1.4.0"]
    }

    opencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。

    npm version CI License: MIT TypeScript Bun OpenCode Plugin

    OpenCode plugin for cross-session context access in subagent workflows.

    What it does

    This package provides a plugin that exposes parent_session_messages, session_messages, and session_messages_batch tools for reading conversation history across sessions.

    When OpenCode dispatches a subagent via the Task tool, the subagent runs in a fresh child session with no access to the parent's conversation history. This plugin bridges that gap by fetching the parent session's messages through the OpenCode SDK.

    Installation

    Add the plugin to your opencode.json:

    {
      "plugin": ["@gotgenes/opencode-session-context"]
    }
    

    How it works

    The plugin registers these tools:

    Tool Description
    parent_session_messages Reads the current session's parentID via the SDK and fetches all messages from the parent session.
    session_messages(sessionId) Fetches all messages from any session by ID.
    session_messages_batch(sessionIds) Fetches all messages from multiple sessions by ID and concatenates them with === Session: <id> === delimiters.

    Both return structured text with agent attribution, full message text, and one-line summaries for tool invocations (using the title computed by OpenCode).

    Output format

    1. user
    How do I fix the login bug?
    
    ---
    
    2. assistant (tdd) [anthropic/claude-opus-4 (high)]
    Let me check the existing test helpers.
    
      [tool] Read file: web/app/auth/routes/sign-in.test.ts → completed
      [tool] bun test verify.test.ts → error: Process exited with code 1
    
    I see the test is failing because...
    

    Use cases

    Retro-stage analysis

    A retro-stage subagent can analyze the parent session's conversation to capture retrospective observations (friction, wins, user-side feedback) without requiring a human to invoke a command or switch agents.

    Parent-orchestrated TDD session reconstruction

    In parent-orchestrator workflows, task_id values returned by the Task tool are session IDs. A reviewer agent can reconstruct full TDD phase ordering by:

    1. Calling parent_session_messages to read the orchestrator thread and extract task_id values
    2. Calling session_messages_batch([taskId, ...]) for the tdd-red, tdd-green, and tdd-refactor subagent sessions
    3. Reviewing full per-phase detail, including file writes, test runs, and checkpoint calls