Repository navigation
feat(webui): 市场 World 卡片显示前缀与工具定义的 token 占用 - #284
Conversation
- 干装载的 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>
| tools?: number; | ||
| events?: number; | ||
| /** 全部声明工具的定义估算的 token 数。 */ | ||
| toolTokens?: number; |
There was a problem hiding this comment.
文档所有权未对齐。
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}`, |
There was a problem hiding this comment.
界面把环境提示词的 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`, |
There was a problem hiding this comment.
悬停文案的前半句是卡片上已经写着的工具数。
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
中文
扩展市场的 World 卡片能力摘要读 catalog 的
toolTokens与envPromptTokens(索引仓 Pal-AI-Lab/cortico-extensions#146 生成):SPEC_LEVELS:工具个数 10 / 20、工具定义 2500 / 6000 token、环境提示词 1000 / 2500 token,超过前一个数标黄、超过后一个数标红;工具数取个数与工具定义 token 两档里较严的一档。颜色用提示与警示标签的--extension-caution/--extension-alert按索引仓现有 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
toolTokensandenvPromptTokensfrom 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 inSPEC_LEVELS, using the notice and warning tag colors. Cards render as before when the catalog lacks these fields.check:extensionnow warns, without failing, when a dry-mounted World'stools()under the default config returns a description or parameters that differ fromdescribe.tools.Checks
pnpm testpnpm run typecheckpnpm typecheck:web(browser code changed / 改了浏览器代码)pnpm dev:webui里核对过白、黄、红三张卡的着色与悬停文字;check:extension对 cortico-world-buckshot 输出新的一行 ✓。🤖 Generated with Claude Code