Skip to content

[Priority: Low] [Feature] 暴露文件检索与运行时观测只读能力 #337

@liujuanjuan1984

Description

@liujuanjuan1984

🔍 发现的问题 / 原始需求描述

上游 opencode 还提供了一批只读但高可观测性的接口:find.textfind.filesfile.read/list/statuspath.getvcs.getcommand.listapp.agentsapp.skillslsp.statusformatter.status。这些接口不直接属于 A2A 主聊天路径,但对 IDE 集成、调试面板、诊断客户端很有价值。当前 opencode-a2a 完全没有暴露这部分能力,导致消费方很难把它当成 OpenCode 的远程控制面来使用。

🛠️ 详细实施方案 (必须包含涉及的文件路径和核心逻辑/伪代码)

  1. 新增只读 runtime inspection 扩展。
    涉及文件:
  • src/opencode_a2a/contracts/extensions.py
  • src/opencode_a2a/server/agent_card.py
  • docs/guide.md

建议方法集合:

  • opencode.find.text
  • opencode.find.files
  • opencode.file.read
  • opencode.file.list
  • opencode.file.status
  • opencode.path.get
  • opencode.vcs.get
  • opencode.commands.list
  • opencode.agents.list
  • opencode.skills.list
  • opencode.lsp.status
  • opencode.formatter.status
  1. 在上游 client 中补齐对应 GET 调用,并统一目录/工作区透传。
    涉及文件:
  • src/opencode_a2a/opencode_upstream_client.py
  1. 在 JSON-RPC 层新增只读 handler,并对结果做最小标准化。
    涉及文件:
  • src/opencode_a2a/jsonrpc/dispatch.py
  • src/opencode_a2a/jsonrpc/handlers/runtime_inspection.py (new)
  • src/opencode_a2a/jsonrpc/handlers/common.py

伪代码:

switch method:
  opencode.find.text -> GET /find
  opencode.file.read -> GET /file/content
  opencode.vcs.get -> GET /vcs
  opencode.agents.list -> GET /agent
  ...
return provider-private result with stable field names
  1. 约束范围:本 issue 只做只读观测面,不包含 pty.*tui.*global.dispose/upgradeauth.* 这类高风险或 UI 私有接口。

🧪 回归测试建议

  • 为每类只读方法补齐成功、404、payload mismatch、目录边界校验测试。
  • 为 Agent Card 契约增加方法声明与 capability snapshot 测试。
  • 补充文档示例,验证消费方能基于这些方法实现简单诊断面板。
  • 运行 ./scripts/doctor.sh

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:todoPlanned but not started

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions