mirror of
https://github.com/Gmaker689/ai-diff-preview.git
synced 2026-09-27 03:21:52 +08:00
feat: 初始化 AI Code Diff Preview 插件项目
- 核心架构搭建:四层架构设计(触发层、隔离层、Diff引擎、UI层) - 快照管理器:管理 Base/Suggest 双版本,隔离 AI 生成代码 - Diff 引擎:基于 Myers 算法计算差异,生成变更块 - 内联装饰器:红绿高亮显示删除/新增行 - CodeLens 提供器:提供 Accept/Reject 按钮 - 事务处理:Accept/Reject 原子化操作 - Claude Hooks 集成:支持 after_code_edit/after_write_file 事件 - 状态栏显示:实时显示变更状态 - 基础测试用例:7 个测试全部通过 技术栈:TypeScript + VSCode Extension API + diff 库 + esbuild
This commit is contained in:
+122
@@ -0,0 +1,122 @@
|
||||
{
|
||||
"name": "ai-diff-preview",
|
||||
"displayName": "AI Code Diff Preview",
|
||||
"description": "类 Cursor 的 AI 代码差异预览插件,支持 Accept/Reject 操作",
|
||||
"version": "0.1.0",
|
||||
"publisher": "your-publisher-name",
|
||||
"engines": {
|
||||
"vscode": "^1.85.0"
|
||||
},
|
||||
"categories": [
|
||||
"Linters",
|
||||
"Programming Languages",
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [],
|
||||
"main": "./dist/extension.js",
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"command": "aiDiffPreview.acceptChunk",
|
||||
"title": "AI Diff: 接受当前变更块",
|
||||
"icon": "$(check)"
|
||||
},
|
||||
{
|
||||
"command": "aiDiffPreview.rejectChunk",
|
||||
"title": "AI Diff: 拒绝当前变更块",
|
||||
"icon": "$(close)"
|
||||
},
|
||||
{
|
||||
"command": "aiDiffPreview.acceptAll",
|
||||
"title": "AI Diff: 接受所有变更",
|
||||
"icon": "$(check-all)"
|
||||
},
|
||||
{
|
||||
"command": "aiDiffPreview.rejectAll",
|
||||
"title": "AI Diff: 拒绝所有变更",
|
||||
"icon": "$(trash)"
|
||||
},
|
||||
{
|
||||
"command": "aiDiffPreview.showDiffPanel",
|
||||
"title": "AI Diff: 显示 Diff 面板",
|
||||
"icon": "$(diff)"
|
||||
}
|
||||
],
|
||||
"keybindings": [
|
||||
{
|
||||
"command": "aiDiffPreview.acceptChunk",
|
||||
"key": "tab",
|
||||
"when": "aiDiffPreview.isActive"
|
||||
},
|
||||
{
|
||||
"command": "aiDiffPreview.rejectAll",
|
||||
"key": "escape",
|
||||
"when": "aiDiffPreview.isActive"
|
||||
},
|
||||
{
|
||||
"command": "aiDiffPreview.acceptAll",
|
||||
"key": "ctrl+shift+a",
|
||||
"mac": "cmd+shift+a",
|
||||
"when": "aiDiffPreview.isActive"
|
||||
},
|
||||
{
|
||||
"command": "aiDiffPreview.rejectAll",
|
||||
"key": "ctrl+shift+r",
|
||||
"mac": "cmd+shift+r",
|
||||
"when": "aiDiffPreview.isActive"
|
||||
}
|
||||
],
|
||||
"configuration": {
|
||||
"title": "AI Diff Preview",
|
||||
"properties": {
|
||||
"aiDiffPreview.enableAutoTrigger": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "启用 Claude Hooks 自动触发"
|
||||
},
|
||||
"aiDiffPreview.showInlineButtons": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "显示内联 Accept/Reject 按钮"
|
||||
},
|
||||
"aiDiffPreview.autoLint": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Diff 预览时自动运行 Lint 检查"
|
||||
},
|
||||
"aiDiffPreview.maxFileSize": {
|
||||
"type": "number",
|
||||
"default": 100000,
|
||||
"description": "最大处理文件大小(字符数)"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run build",
|
||||
"build": "esbuild ./src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node --minify",
|
||||
"watch": "esbuild ./src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --format=cjs --platform=node --sourcemap --watch",
|
||||
"lint": "eslint src --ext ts",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"package": "vsce package"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/diff": "^5.0.0",
|
||||
"@types/node": "^20.0.0",
|
||||
"@types/uuid": "^9.0.0",
|
||||
"@types/vscode": "^1.85.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||
"@typescript-eslint/parser": "^6.0.0",
|
||||
"@vscode/test-electron": "^2.3.0",
|
||||
"esbuild": "^0.19.0",
|
||||
"eslint": "^8.0.0",
|
||||
"prettier": "^3.0.0",
|
||||
"typescript": "^5.3.0",
|
||||
"vitest": "^1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"diff": "^5.0.0",
|
||||
"uuid": "^9.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user