Feature: HANDLES edges and per-registration data for generic router.add(method, path, handler) registrations (TypeScript)

未關閉
#3,089 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
typescript

研究方向

Start by tracing TypeScript route extraction and the framework-specific registration patterns that create Route nodes and HANDLES edges; the issue does not name source files or tests. Reproduce the reported generic router.add(method, path, handler) case and inspect how call-site arguments are stored on CALLS edges. Done means each method and path produces a route with its registration location and a HANDLES edge to the relevant handler target.

由索引模型根據 Issue 內容生成。

描述

enhancement parsing/quality

Feature request: HANDLES edges for generic router.add(method, path, handler) registrations

Version: codebase-memory-mcp v0.12.1 (linux-amd64-portable), TypeScript project.

What happens

A hand-written router registers routes with a plain method call. The indexer creates the Route nodes
(path parameters normalised to {}), but no HANDLES edge from the route to the handler function, and the
Route node carries no method, file or line. Only framework-specific registrations (Express, Fastify, ...)
get HANDLES.

Minimal example

// router.ts
export class Router {
  add(method: string, path: string, handler: (req: Request, ctx: { params: Record<string, string> }) => Promise<Response>) { /* ... */ }
}

// routes.ts
import { Router } from './router'
export async function replaceCredential(providerId: string, req: Request): Promise<Response> { /* ... */ }
export async function clearCredential(providerId: string, req: Request): Promise<Response> { /* ... */ }

export function registerRoutes(router: Router) {
  router.add('PUT', '/v1/connections/:providerId/credential', async (req, ctx) => {
    if (!authorize(req)) return unauthorized()
    return replaceCredential(ctx.params.providerId, req)
  })
  router.add('DELETE', '/v1/connections/:providerId/credential', (req, ctx) => clearCredential(ctx.params.providerId, req))
}

Observed after index_repository(mode=full):

  • MATCH (r:Route) RETURN r.name, r.method → /v1/connections/{}/credential, method "" (one node for PUT and DELETE)
  • MATCH (r:Route)-[:HANDLES]->(f) RETURN f.name → 0 rows
  • MATCH (f)-[r:CALLS]->(g) WHERE f.name='registerRoutes' AND g.name='add' RETURN r.args, r.line → one edge
    (one CALLS edge per caller/callee pair), carrying the args of a single registration although the function
    registers two routes (in the real project: 81 registrations in one function, one edge).

Expected

  • Route nodes per (method, path) with method, file_path, start_line set.
  • HANDLES edge from the route to the call target(s) in return position of the inline handler (here
    replaceCredential / clearCredential), or to the referenced function when the handler argument is an
    identifier.
  • Optionally the guard calls inside if conditions that lead to an early return (authorize) as a separate
    edge/property, since they are the authorisation preconditions of the route.

Suggestion

A generic registration pattern in service_patterns keyed by callee name and argument positions
(callee: "router.add", method: 0, path: 1, handler: 2), configurable per project, would cover hand-written
routers without framework detection. The call-site arguments are already captured on the CALLS edge, so the data
exists; only the per-call-site linking is missing.

主要語言
C
星號
45.8k
分支
3.8k
平均合併
2 天 18 小時
30 天內合併 PR
108

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

DeusData/codebase-memory-mcp 的其他 Issue

查看 DeusData/codebase-memory-mcp 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。