cfix 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/.env.example +69 -0
  2. package/README.md +1590 -0
  3. package/bin/cfix +14 -0
  4. package/bin/cfix.cmd +6 -0
  5. package/cli/commands/config.js +58 -0
  6. package/cli/commands/doctor.js +240 -0
  7. package/cli/commands/fix.js +211 -0
  8. package/cli/commands/help.js +62 -0
  9. package/cli/commands/init.js +226 -0
  10. package/cli/commands/logs.js +161 -0
  11. package/cli/commands/monitor.js +151 -0
  12. package/cli/commands/project.js +331 -0
  13. package/cli/commands/service.js +133 -0
  14. package/cli/commands/status.js +115 -0
  15. package/cli/commands/task.js +412 -0
  16. package/cli/commands/version.js +19 -0
  17. package/cli/index.js +269 -0
  18. package/cli/lib/config-manager.js +612 -0
  19. package/cli/lib/formatter.js +224 -0
  20. package/cli/lib/process-manager.js +233 -0
  21. package/cli/lib/service-client.js +271 -0
  22. package/cli/scripts/install-completion.js +133 -0
  23. package/package.json +85 -0
  24. package/public/monitor.html +1096 -0
  25. package/scripts/completion.bash +87 -0
  26. package/scripts/completion.zsh +102 -0
  27. package/src/assets/README.md +32 -0
  28. package/src/assets/error.png +0 -0
  29. package/src/assets/icon.png +0 -0
  30. package/src/assets/success.png +0 -0
  31. package/src/claude-cli-service.js +216 -0
  32. package/src/config/index.js +69 -0
  33. package/src/database/manager.js +391 -0
  34. package/src/database/migration.js +252 -0
  35. package/src/git-service.js +1278 -0
  36. package/src/index.js +1658 -0
  37. package/src/logger.js +139 -0
  38. package/src/metrics/collector.js +184 -0
  39. package/src/middleware/auth.js +86 -0
  40. package/src/middleware/rate-limit.js +85 -0
  41. package/src/queue/integration-example.js +283 -0
  42. package/src/queue/task-queue.js +333 -0
  43. package/src/services/notification-limiter.js +48 -0
  44. package/src/services/notification-service.js +115 -0
  45. package/src/services/system-notifier.js +130 -0
  46. package/src/task-manager.js +289 -0
  47. package/src/utils/exec.js +87 -0
  48. package/src/utils/project-lock.js +246 -0
  49. package/src/utils/retry.js +110 -0
  50. package/src/utils/sanitizer.js +174 -0
  51. package/src/websocket/notifier.js +363 -0
  52. package/src/wechat-notifier.js +97 -0
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 安装命令自动补全脚本
4
+ */
5
+
6
+ const path = require('path');
7
+ const fs = require('fs');
8
+ const os = require('os');
9
+ const { execSync } = require('child_process');
10
+
11
+ const ROOT_DIR = process.env.CFIX_ROOT || path.resolve(__dirname, '../..');
12
+
13
+ /**
14
+ * 获取 shell 类型
15
+ */
16
+ function getShell() {
17
+ const shell = process.env.SHELL || '';
18
+ if (shell.includes('zsh')) return 'zsh';
19
+ if (shell.includes('bash')) return 'bash';
20
+ return 'bash'; // 默认
21
+ }
22
+
23
+ /**
24
+ * 获取配置文件路径
25
+ */
26
+ function getConfigFile(shell) {
27
+ const homeDir = os.homedir();
28
+
29
+ if (shell === 'zsh') {
30
+ return path.join(homeDir, '.zshrc');
31
+ }
32
+
33
+ // bash
34
+ if (process.platform === 'darwin') {
35
+ return path.join(homeDir, '.bash_profile');
36
+ }
37
+ return path.join(homeDir, '.bashrc');
38
+ }
39
+
40
+ /**
41
+ * 安装 bash 补全
42
+ */
43
+ function installBashCompletion() {
44
+ const completionFile = path.join(ROOT_DIR, 'scripts', 'completion.bash');
45
+ const configFile = getConfigFile('bash');
46
+ const sourceLine = `\n# cfix completion\nsource "${completionFile}"\n`;
47
+
48
+ console.log('📦 安装 Bash 自动补全');
49
+ console.log(`配置文件: ${configFile}`);
50
+ console.log('');
51
+
52
+ try {
53
+ let configContent = '';
54
+ if (fs.existsSync(configFile)) {
55
+ configContent = fs.readFileSync(configFile, 'utf-8');
56
+ }
57
+
58
+ // 检查是否已安装
59
+ if (configContent.includes('cfix completion')) {
60
+ console.log('✅ 自动补全已安装');
61
+ return;
62
+ }
63
+
64
+ // 添加补全配置
65
+ fs.appendFileSync(configFile, sourceLine);
66
+ console.log('✅ 自动补全已安装');
67
+ console.log('');
68
+ console.log('请运行以下命令使补全生效:');
69
+ console.log(` source ${configFile}`);
70
+
71
+ } catch (error) {
72
+ console.error(`❌ 安装失败: ${error.message}`);
73
+ }
74
+ }
75
+
76
+ /**
77
+ * 安装 zsh 补全
78
+ */
79
+ function installZshCompletion() {
80
+ const completionFile = path.join(ROOT_DIR, 'scripts', 'completion.zsh');
81
+ const zshCompletionDir = path.join(os.homedir(), '.zsh', 'completions');
82
+ const targetFile = path.join(zshCompletionDir, '_cfix');
83
+
84
+ console.log('📦 安装 Zsh 自动补全');
85
+ console.log('');
86
+
87
+ try {
88
+ // 创建补全目录
89
+ if (!fs.existsSync(zshCompletionDir)) {
90
+ fs.mkdirSync(zshCompletionDir, { recursive: true });
91
+ }
92
+
93
+ // 复制补全文件
94
+ fs.copyFileSync(completionFile, targetFile);
95
+ console.log(`✅ 补全文件已安装: ${targetFile}`);
96
+ console.log('');
97
+ console.log('请确保 ~/.zshrc 中有以下配置:');
98
+ console.log(' autoload -U compinit && compinit');
99
+
100
+ } catch (error) {
101
+ console.error(`❌ 安装失败: ${error.message}`);
102
+ }
103
+ }
104
+
105
+ /**
106
+ * 主函数
107
+ */
108
+ function main() {
109
+ console.log('🔧 安装 cfix 命令自动补全');
110
+ console.log('');
111
+ console.log('======================================');
112
+ console.log('');
113
+
114
+ const shell = getShell();
115
+ console.log(`检测到 Shell: ${shell}`);
116
+ console.log('');
117
+
118
+ if (shell === 'zsh') {
119
+ installZshCompletion();
120
+ } else {
121
+ installBashCompletion();
122
+ }
123
+
124
+ console.log('');
125
+ console.log('======================================');
126
+ console.log('');
127
+ console.log('安装完成后,重新打开终端或运行:');
128
+ console.log(' exec $SHELL');
129
+ console.log('');
130
+ console.log('然后输入 cfix 并按 Tab 键测试补全功能');
131
+ }
132
+
133
+ main();
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "cfix",
3
+ "version": "1.0.0",
4
+ "description": "AI 自动代码修复 CLI 工具",
5
+ "main": "src/index.js",
6
+ "bin": {
7
+ "cfix": "./bin/cfix"
8
+ },
9
+ "scripts": {
10
+ "start": "node src/index.js",
11
+ "dev": "nodemon src/index.js",
12
+ "cli": "node cli/index.js",
13
+ "install:global": "node cli/scripts/install-global.js",
14
+ "install:completion": "node cli/scripts/install-completion.js",
15
+ "install:redis": "npm install ioredis bull",
16
+ "install:db": "npm install sqlite3 sqlite",
17
+ "install:ws": "npm install ws",
18
+ "migrate": "node src/database/migration.js",
19
+ "test": "echo \"Error: no test specified\" && exit 1"
20
+ },
21
+ "keywords": [
22
+ "cfix",
23
+ "codefix",
24
+ "ai",
25
+ "auto-fix",
26
+ "claude",
27
+ "zhipu",
28
+ "glm",
29
+ "automation",
30
+ "task-queue",
31
+ "cli"
32
+ ],
33
+ "author": "aiwa <1348844909@qq.com>",
34
+ "license": "MIT",
35
+ "dependencies": {
36
+ "@anthropic-ai/sdk": "^0.32.1",
37
+ "@koa/cors": "^5.0.0",
38
+ "axios": "^1.7.9",
39
+ "chalk": "^5.3.0",
40
+ "commander": "^11.1.0",
41
+ "conf": "^12.0.0",
42
+ "dotenv": "^16.4.7",
43
+ "inquirer": "^9.2.12",
44
+ "koa": "^2.15.3",
45
+ "koa-bodyparser": "^4.4.1",
46
+ "koa-ratelimit": "^5.1.0",
47
+ "koa-router": "^13.1.0",
48
+ "koa-static": "^5.0.0",
49
+ "node-notifier": "^10.0.1",
50
+ "ora": "^7.0.1",
51
+ "winston": "^3.11.0",
52
+ "winston-daily-rotate-file": "^4.7.1"
53
+ },
54
+ "optionalDependencies": {
55
+ "bull": "^4.12.0",
56
+ "cli-table3": "^0.6.3",
57
+ "ioredis": "^5.3.2",
58
+ "sqlite": "^5.0.1",
59
+ "sqlite3": "^5.1.6",
60
+ "ws": "^8.18.3"
61
+ },
62
+ "devDependencies": {
63
+ "nodemon": "^3.1.9"
64
+ },
65
+ "engines": {
66
+ "node": ">=16.0.0"
67
+ },
68
+ "files": [
69
+ "bin/",
70
+ "cli/",
71
+ "src/",
72
+ "public/",
73
+ "scripts/",
74
+ "README.md",
75
+ ".env.example"
76
+ ],
77
+ "repository": {
78
+ "type": "git",
79
+ "url": ""
80
+ },
81
+ "homepage": "",
82
+ "bugs": {
83
+ "url": ""
84
+ }
85
+ }