Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

http: ToolContracts arm duplicates HttpInput inline — named references now expand on the wire

オープン
#100 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
66/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
tooling

調査の方向性

Start in plugins/http/src/index.ts: move the HttpInput interface above the declare module block and point the http arm at it. Before editing, record the params text from ToolTypeIndex.wireContracts(), then confirm it matches after the change. Read expandNamed in plugins/tool-types/src/build-dts.ts to see how a named reference is expanded. Done means the wire text is unchanged and the inline copy is gone; the sweep of other arms is a separate step.

索引モデルが issue の本文から書いたものです。

説明

future-enhancement

plugins/http/src/index.ts declares the http contract with its params written inline, and describes the same shape again in a local HttpInput interface, which the executor casts its input to:

// params are inlined structurally (not a `HttpInput` reference) so the derived wire text shows real fields.
declare module '@matatbread/matbot-plugin-api' {
  interface ToolContracts {
    http: ToolContract<unknown, { url: string; method?: string; headers?: Record<string, string>; body?: string; responseType?: 'text' | 'json' }>;
  }
}

interface HttpInput { url: string; method?: string; headers?: Record<string, string>; body?: string; responseType?: 'text' | 'json' }

The comment's reason no longer applies. When this was written (360b7cc), wire text was the arm's source text verbatim, so a named reference would have reached the model as params: HttpInput. Since c6685bc both consumers handle a reference:

  • Wire text: expandNamed (plugins/tool-types/src/build-dts.ts) expands workspace interfaces and aliases into their fields, up to WIRE_DEPTH (2).
  • Generated dts: a referenced plugin-local interface or alias is bundled next to the reference (classify → bundle), exported or not.

The inline literal is therefore a second copy of the shape. That goes against the single-source rule for tool contracts, and a field added to only one copy goes unnoticed.

Fix

Move HttpInput above the declare module block, declare http: ToolContract<unknown, HttpInput>, and drop the comment. Check that ToolTypeIndex.wireContracts() produces the same params text for http before and after.

Sweep the other tools for the same case

27 source files declare at least one arm with inline object-literal params. An inline literal isn't a problem in itself. Look for an arm whose inline shape is also described by a local interface/type, or by an input as { … } cast in the executor, and point the arm at that one declaration.

Out of scope: plugins/tool-store/src/index.ts (~L280). That contract is a runtime toolContract string, resolved by a second Program that holds only plugin-api, so a plugin-local name cannot resolve there. Inlining is still required in that case.

主要言語
TypeScript
スター
5
フォーク
2
平均マージ
9時間 5分
マージ済み PR(30日)
11

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

MatAtBread/matbot のほかの issue

MatAtBread/matbot の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。