http: ToolContracts arm duplicates HttpInput inline — named references now expand on the wire
メンテナーはふだん 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 の本文から書いたものです。
説明
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 toWIRE_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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MatAtBread/matbot のほかの issue
-
future-enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
MatAtBread/matbot#65 ·
メンテナーはふだん 1 日以内に返信
MatAtBread/matbot の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
grafana/profiles-drilldown#1212 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
grafana/traces-drilldown#980 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
openremote/openremote#3487 · コメント 1 件 ·
-
triage:needs-human
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
garrytan/gbrain#7635 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
coollabsio/jean#867 ·
メンテナーはふだん 1 日以内に返信