[feature] 新增 /context 命令:查看上下文各部分组成与占比

Offen
#161 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@li-xiu-qi arbeitet bereits daran.

Seit 26.10.2026.

  • #309 von @li-xiu-qi — offen

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
65/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
typescript

Rechercherichtung

Look for existing CLI command handlers in the codebase, likely in a src/commands/ or similar directory. Find where context usage data is calculated or exposed. The new /context command needs to aggregate token counts by category (system prompt, tools, messages, etc.) and format a visual representation. Check for existing utilities for token counting and UI rendering. Test by running the command and verifying the output matches the described structure.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

功能请求

希望新增 /context 命令,用来快速查看当前上下文窗口里各部分的组成和占比。

期望行为

运行 /context 后,展示类似截图的 Context Usage 视图,例如:

  • 当前模型与总用量(如 48.3k/1m tokens (5%))
  • 可视化网格,按类别着色区分已用 / 空闲 / autocompact buffer
  • 按类别列出 token 数与占比,例如:
    • System prompt
    • System tools
    • MCP tools
    • Custom agents
    • Memory files
    • Skills
    • Messages
    • Free space
    • Autocompact buffer
  • 对 MCP tools、agents、memory、skills 等可再展开明细(数量、路径、合计 tokens)
  • 支持类似 /context all 的展开查看
参考

参考交互示意见评论区截图(或 issue 附件)。期望效果类似常见的 Context Usage 面板:上方为按类别着色的上下文占用网格,右侧/下方为各类别 token 数与占比明细,并可展开 MCP tools / agents / memory / skills 等子项。

动机

上下文占用不透明时,很难判断是工具、技能、记忆还是对话历史占了大头。有一个一眼能看懂的分解视图,排查上下文膨胀会轻松很多。

Vorherrschende Sprache
TypeScript
Sterne
1k
Forks
68
Ø Merge
13 Std. 14 Min.
Gemergte PRs (30 T.)
66

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus stepfun-ai/Step-Code

Alle Issues in stepfun-ai/Step-Code

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.