Skip to content

feat(webui): 市场 World 卡片显示前缀与工具定义的 token 占用 - #284

Merged
Phantivia merged 2 commits into
mainfrom
feat/market-prefix-size
Oct 19, 2026
Merged

Phantivia merged 2 commits into
mainfrom
feat/market-prefix-size

Conversation

@Phantivia

Copy link
Copy Markdown
Member

中文

扩展市场的 World 卡片能力摘要读 catalog 的 toolTokens 与 envPromptTokens(索引仓 Pal-AI-Lab/cortico-extensions#146 生成):

  • 「N 个工具」悬停显示「包含 N 个工具,工具定义占用了约 X token」
  • 新增「前缀 ≈N」,悬停显示「环境提示词占用了约 X token」
  • 档位在 SPEC_LEVELS:工具个数 10 / 20、工具定义 2500 / 6000 token、环境提示词 1000 / 2500 token,超过前一个数标黄、超过后一个数标红;工具数取个数与工具定义 token 两档里较严的一档。颜色用提示与警示标签的 --extension-caution / --extension-alert
  • catalog 还没有新字段时卡片照旧只显示工具与事件数

按索引仓现有 53 个 World:前缀 45 白 / 6 黄 / 3 红;工具 minecraft、pvz 因定义 token 标红,QQ 全家桶因工具个数标红。

check:extension 增加一项:干装载的 World 实例在默认配置下改写了 describe.tools 里某个工具的 description 或 parameters 时给 warning,列出工具名与字段。只警告不失败,因为实例可以按配置改写;市场的数按声明算。

English

World cards in the extension market read toolTokens and envPromptTokens from the catalog (produced by Pal-AI-Lab/cortico-extensions#146). The tool count shows the tool definitions' token estimate on hover; a new "Prefix ≈N" item shows the environment prompt's estimate. Both are tinted yellow or red past the thresholds in SPEC_LEVELS, using the notice and warning tag colors. Cards render as before when the catalog lacks these fields.

check:extension now warns, without failing, when a dry-mounted World's tools() under the default config returns a description or parameters that differ from describe.tools.

Checks

  • pnpm test
  • pnpm run typecheck
  • pnpm typecheck:web (browser code changed / 改了浏览器代码)
  • A bug fix carries a test that fails before the fix / 修 bug 附带修复前会失败的测试(不是修 bug)

pnpm dev:webui 里核对过白、黄、红三张卡的着色与悬停文字;check:extension 对 cortico-world-buckshot 输出新的一行 ✓。

🤖 Generated with Claude Code

Phantivia and others added 2 commits October 19, 2026 10:08
- 干装载的 World 实例在默认配置下改写了 describe.tools 里某个工具的 description 或 parameters 时给 warning,列出工具名与字段
- 只警告不失败:实例可以按配置改写,市场按声明显示工具与工具定义的 token 数
- 测试覆盖:声明与实例一致时没有 warning,改写 parameters 时 warning 点名且不进 failures

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 能力摘要读 catalog 的 toolTokens 与 envPromptTokens:工具数悬停显示工具定义占用,新增「前缀 ≈N」显示环境提示词占用
- 档位在 SPEC_LEVELS:工具个数 10/20、工具定义 2500/6000、环境提示词 1000/2500,超过前一个数标黄、后一个数标红;工具数取个数与 token 里较严的一档
- 颜色用提示与警示标签的 --extension-caution / --extension-alert;catalog 还没有新字段时只显示原来的工具与事件数
- dev:webui 假数据补上新字段,白黄红各一张

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/web/server.ts
tools?: number;
events?: number;
/** 全部声明工具的定义估算的 token 数。 */
toolTokens?: number;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

文档所有权未对齐。

AGENTS.md §8:「The commit that changes the owner changes the page.」docs/webui.md 与 src/web/README.md 的首行都将 src/web/server.ts 列为 owner。

本 PR 在 src/web/server.ts 第 258–261 行为 ExtensionSummary 增加了 toolTokens 与 envPromptTokens,这两页未改。请把变更收进规则,或把偏离的理由写进 PR 描述。

— Cortico PR Gate via Cursor Cloud Agent

toolCount: (n: number) => `${n} 个工具`,
eventCount: (n: number) => `${n} 种事件`,
toolsHint: (n: number, tokens: number) => `包含 ${n} 个工具,工具定义占用了约 ${tokens} token`,
prefixSize: (tokens: string) => `前缀 ≈${tokens}`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

界面把环境提示词的 token 数标成了「前缀」。

AGENTS.md §4 AI slop checklist:Accuracy after editing。本仓库里 prefix 是 Persona 总装模板,envPrompt 是 World 环境模板。

  • src/web/client/features/extensions/strings.ts:前缀 ≈${tokens} / Prefix ≈${tokens}
  • PR 描述:「新增「前缀 ≈N」」「前缀 45 白 / 6 黄 / 3 红」;English:「a new "Prefix ≈N" item」
  • commit fbcd934:「新增「前缀 ≈N」显示环境提示词占用」

按清单核对准了边界再留。

— Cortico PR Gate via Cursor Cloud Agent

promptsTabBot: '提示词模板',
toolCount: (n: number) => `${n} 个工具`,
eventCount: (n: number) => `${n} 种事件`,
toolsHint: (n: number, tokens: number) => `包含 ${n} 个工具,工具定义占用了约 ${tokens} token`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

悬停文案的前半句是卡片上已经写着的工具数。

AGENTS.md §4 AI slop checklist:Obvious information(Remove common knowledge and instructions evident from the UI)。

  • src/web/client/features/extensions/strings.ts:包含 ${n} 个工具,工具定义占用了约 ${tokens} token
  • 同文件英文:Includes ${n} tools; their definitions take about ${tokens} tokens

按清单删除界面上已有的部分。

— Cortico PR Gate via Cursor Cloud Agent

@Phantivia
Phantivia merged commit bc56cce into main Oct 19, 2026
4 checks passed
@Phantivia
Phantivia deleted the feat/market-prefix-size branch October 19, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant