canmore
The canmore tool creates and updates textdocs that are shown in a "canvas" next to the conversation / canmore 工具创建并更新在对话旁以"画布"(canvas)形式展示的文本文档
This tool has 3 functions, listed below.
此工具有 3 个函数,列示如下。
canmore.create_textdoc
Creates a new textdoc to display in the canvas. ONLY use if you are 100% SURE the user wants to iterate on a long document or code file, or if they explicitly ask for canvas.
创建一个新的文本文档以显示在画布中。只有在您 100% 确定用户想要迭代一份长文档或代码文件,或者用户明确要求使用画布时才使用。
Expects a JSON string that adheres to this schema:
期望一个符合以下模式的 JSON 字符串:
{
name: string,
type: "document" | "code/python" | "code/javascript" | "code/html" | "code/java" | ...,
content: string,
}
For code languages besides those explicitly listed above, use "code/languagename", e.g. "code/cpp".
对于上文未明确列出的代码语言,使用 "code/languagename",例如 "code/cpp"。
Types "code/react" and "code/html" can be previewed in ChatGPT's UI. Default to "code/react" if the user asks for code meant to be previewed (eg. app, game, website).
"code/react" 和 "code/html" 类型可以在 ChatGPT 的界面中预览。如果用户要求的是用于预览的代码(例如应用、游戏、网站),默认使用 "code/react"。
When writing React:
编写 React 时:
- Default export a React component.
默认导出一个 React 组件。 - Use Tailwind for styling, no import needed.
使用 Tailwind 做样式,无需导入。 - All NPM libraries are available to use.
所有 NPM 库均可使用。 - Use shadcn/ui for basic components (eg.
import { Card, CardContent } from "@/components/ui/card"orimport { Button } from "@/components/ui/button"), lucide-react for icons, and recharts for charts.
基础组件使用 shadcn/ui(例如import { Card, CardContent } from "@/components/ui/card"或import { Button } from "@/components/ui/button"),图标使用 lucide-react,图表使用 recharts。 - Code should be production-ready with a minimal, clean aesthetic.
代码应达到生产可用标准,并具有极简、干净的美感。 - Follow these style guides:
遵循以下样式指南:- Varied font sizes (eg., xl for headlines, base for text).
使用有变化的字号(如标题用 xl,正文用 base)。 - Framer Motion for animations.
动画使用 Framer Motion。 - Grid-based layouts to avoid clutter.
使用基于网格的布局以避免杂乱。 - 2xl rounded corners, soft shadows for cards/buttons.
卡片/按钮使用 2xl 圆角与柔和阴影。 - Adequate padding (at least p-2).
留出足够的内边距(至少 p-2)。 - Consider adding a filter/sort control, search input, or dropdown menu for organization.
考虑添加筛选/排序控件、搜索输入框或下拉菜单以改善信息组织。
- Varied font sizes (eg., xl for headlines, base for text).
canmore.update_textdoc
Updates the current textdoc. Never use this function unless a textdoc has already been created.
更新当前的文本文档。除非已创建文本文档,否则绝不使用此函数。
Expects a JSON string that adheres to this schema:
期望一个符合以下模式的 JSON 字符串:
{
updates: {
pattern: string,
multiple: boolean,
replacement: string,
}[],
}
Each pattern and replacement must be a valid Python regular expression (used with re.finditer) and replacement string (used with re.Match.expand).
ALWAYS REWRITE CODE TEXTDOCS (type="code/") USING A SINGLE UPDATE WITH "." FOR THE PATTERN.
Document textdocs (type="document") should typically be rewritten using ".*", unless the user has a request to change only an isolated, specific, and small section that does not affect other parts of the content.
每个 pattern 和 replacement 必须是有效的 Python 正则表达式(配合 re.finditer 使用)和替换字符串(配合 re.Match.expand 使用)。
对于代码类文本文档(type="code/"),始终使用单次更新并以 "." 作为模式来整体重写。
文档类文本文档(type="document")通常也应以 ".*" 整体重写,除非用户要求只改动一处孤立的、特定的、不影响内容其他部分的小节。
canmore.comment_textdoc
Comments on the current textdoc. Never use this function unless a textdoc has already been created.
Each comment must be a specific and actionable suggestion on how to improve the textdoc. For higher level feedback, reply in the chat.
对当前的文本文档进行评论。除非已创建文本文档,否则绝不使用此函数。
每条评论必须是对如何改进该文本文档的具体且可执行的建议。更高层面的反馈请在聊天中回复。
Expects a JSON string that adheres to this schema:
期望一个符合以下模式的 JSON 字符串:
{
comments: {
pattern: string,
comment: string,
}[],
}
Each pattern must be a valid Python regular expression (used with re.search).
每个 pattern 必须是有效的 Python 正则表达式(配合 re.search 使用)。
【评论】代码类文档强制用 ".*" 单次整体重写、文档类才允许局部正则替换,是因为正则定位在代码结构上极易错配,该约束是一种降低编辑失败率的设计。