refactor(schema): getTableSchema 返回类型化行,移除 mermaid ER 图 - #14
Merged
Conversation
候选 5:getTableSchema 此前把 MySQL information_schema 裸行原样
导出,COLUMN_NAME / COLUMN_TYPE 的知识散布在 4+ 命令层站点,cast
遍地。在 driver 边界一次收窄为 SchemaColumn[]/SchemaIndex[]。
- types.ts 新增 SchemaColumn(nullable 布尔化)/ SchemaIndex(按
INDEX_NAME 聚合)/ TableSchema;裸行不再出边界
- formatSchemaMarkdown 改收类型化参数,cast 与 idxMap 分组逻辑消失
- 移除 mermaid ER 图(pi 不渲染图,用户只能看到源码文本):
- 删 /db relations er-diagram 命令及 completions
- discover 的 AI 消息改为分表小节结构化文本(### 表 + 列列表),
更直接、更省 token、无 mermaid 语法噪音
- commands/relations.ts / schema.ts / db-tools.ts 消费点 cast 全部封口
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
候选 5:getTableSchema 返回类型化行,挡住 information_schema 泄漏
变更内容
types.ts新增SchemaColumn(name/type/nullable 布尔/key/default/extra/comment)、SchemaIndex(按 INDEX_NAME 聚合:name/columns/unique)、TableSchemaconnection/db-manager.ts:getTableSchema在 driver 边界一次映射(IS_NULLABLE === "YES"→ nullable、索引分组聚合),裸行不再出边界formatting/schema-table.ts:formatSchemaMarkdown改收类型化参数,6+3 处 cast 与 idxMap 分组逻辑消失/db relations er-diagram命令及 completions、utils 注释### 表+- 列 (类型)列表),更直接省 token、无 mermaid 语法噪音;MAX_TABLES 截断保留commands/relations.ts/schema.ts/workspace.ts/db-tools.ts消费点 cast 全部封口为什么
裸 information_schema 行此前漏到 4+ 消费点,COLUMN_NAME 知识散布、cast 遍地、ER builder(命令层最逻辑密集代码)无法纯函数化且不可测。收窄后一个概念一个形状,加字段只改边界。
验证
npm run check(tsc)通过npm test229 通过(删 er-diagram completion 用例,schema-table 构造改类型化行)npm run lint0 errors(12 warnings 存量)npm run fmt+fmt:check通过