@fastcar/cli 0.1.2 → 0.1.4
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.
- package/bin/cli.js +239 -226
- package/package.json +1 -1
- package/skills/AGENTS.md +251 -0
- package/skills/fastcar-database/SKILL.md +436 -337
- package/skills/fastcar-framework/SKILL.md +577 -856
- package/skills/fastcar-rpc-microservices/SKILL.md +19 -69
- package/skills/fastcar-serverless/SKILL.md +48 -48
- package/skills/fastcar-toolkit/SKILL.md +22 -31
- package/skills/typescript-coding-style/SKILL.md +144 -0
- package/src/init.js +708 -700
- package/src/pack.js +7 -7
- package/src/skill.js +493 -364
- package/src/update.js +301 -0
- package/src/utils.js +2 -2
package/bin/cli.js
CHANGED
|
@@ -1,226 +1,239 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const init = require("../src/init");
|
|
4
|
-
const setModules = require("../src/setModules");
|
|
5
|
-
const { reverseGenerate, initReverseConfig } = require("../src/reverse");
|
|
6
|
-
const { packProject } = require("../src/pack");
|
|
7
|
-
const {
|
|
8
|
-
installSkill,
|
|
9
|
-
uninstallSkill,
|
|
10
|
-
listSkills,
|
|
11
|
-
listTargets,
|
|
12
|
-
initSkill,
|
|
13
|
-
} = require("../src/skill");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
reverse
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
$ fastcar-cli init
|
|
52
|
-
$ fastcar-cli init
|
|
53
|
-
$ fastcar-cli init
|
|
54
|
-
$ fastcar-cli init
|
|
55
|
-
$ fastcar-cli
|
|
56
|
-
$ fastcar-cli
|
|
57
|
-
$ fastcar-cli
|
|
58
|
-
$ fastcar-cli
|
|
59
|
-
$ fastcar-cli
|
|
60
|
-
$ fastcar-cli
|
|
61
|
-
|
|
62
|
-
$ fastcar-cli
|
|
63
|
-
$ fastcar-cli
|
|
64
|
-
$ fastcar-cli
|
|
65
|
-
|
|
66
|
-
$ fastcar-cli
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
},
|
|
91
|
-
"
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
case "
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
case "
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
//
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const init = require("../src/init");
|
|
4
|
+
const setModules = require("../src/setModules");
|
|
5
|
+
const { reverseGenerate, initReverseConfig } = require("../src/reverse");
|
|
6
|
+
const { packProject } = require("../src/pack");
|
|
7
|
+
const {
|
|
8
|
+
installSkill,
|
|
9
|
+
uninstallSkill,
|
|
10
|
+
listSkills,
|
|
11
|
+
listTargets,
|
|
12
|
+
initSkill,
|
|
13
|
+
} = require("../src/skill");
|
|
14
|
+
const { updateCosTemplate } = require("../src/update");
|
|
15
|
+
const packageINFO = require("../package.json");
|
|
16
|
+
const templates = require("../src/templates.json");
|
|
17
|
+
|
|
18
|
+
function showHelp() {
|
|
19
|
+
console.log(`
|
|
20
|
+
Usage: fastcar-cli [command] [options]
|
|
21
|
+
|
|
22
|
+
Commands:
|
|
23
|
+
init [template] [name] 初始化项目
|
|
24
|
+
template: 模板名称 (${Object.keys(templates).join(", ")})
|
|
25
|
+
name: 项目名称(可选,默认使用当前目录名)
|
|
26
|
+
|
|
27
|
+
clean node_modules 删除冗余的 node_modules 目录
|
|
28
|
+
compress node_modules 压缩 node_modules 目录
|
|
29
|
+
reverse 数据库表逆向生成
|
|
30
|
+
reverse:init 生成 reverse.config.yml/json 配置文件
|
|
31
|
+
pack [pm] 打包项目(排除 devDependencies)
|
|
32
|
+
pm: 包管理器 (npm/yarn/pnpm),可选,默认自动检测
|
|
33
|
+
|
|
34
|
+
update:cos 更新 @fastcar/template-cos 的 target 文件夹
|
|
35
|
+
|
|
36
|
+
skill install <name> 安装 FastCar skill 到本地 AI Agent
|
|
37
|
+
使用 all 或 --all 安装全部 skills
|
|
38
|
+
-g, --global 安装到全局(默认)
|
|
39
|
+
-l, --local 安装到项目级
|
|
40
|
+
-t, --target 目标 agent (kimi/claude/cursor)
|
|
41
|
+
skill uninstall <name> 卸载 FastCar skill
|
|
42
|
+
skill list 列出可用的 skills
|
|
43
|
+
skill targets 列出支持的 AI Agents
|
|
44
|
+
skill init 初始化项目级 agent 配置
|
|
45
|
+
|
|
46
|
+
Options:
|
|
47
|
+
-v, --version 显示版本号
|
|
48
|
+
-h, --help 显示帮助信息
|
|
49
|
+
|
|
50
|
+
Examples:
|
|
51
|
+
$ fastcar-cli init # 交互式选择模板
|
|
52
|
+
$ fastcar-cli init web # 使用 web 模板
|
|
53
|
+
$ fastcar-cli init rpc # 使用 rpc 模板
|
|
54
|
+
$ fastcar-cli init micro # 使用 microservices 模板
|
|
55
|
+
$ fastcar-cli init cos # 使用 cos 模板
|
|
56
|
+
$ fastcar-cli init static # 使用 static 模板
|
|
57
|
+
$ fastcar-cli init my-project # 创建 my-project 目录
|
|
58
|
+
$ fastcar-cli init web my-project # 使用 web 模板创建 my-project
|
|
59
|
+
$ fastcar-cli clean node_modules
|
|
60
|
+
$ fastcar-cli reverse # 数据库表逆向生成
|
|
61
|
+
$ fastcar-cli reverse:init # 生成默认配置文件(默认 YAML 格式)
|
|
62
|
+
$ fastcar-cli pack # 打包项目(自动检测包管理器)
|
|
63
|
+
$ fastcar-cli pack yarn # 使用 yarn 安装依赖
|
|
64
|
+
$ fastcar-cli pack pnpm # 使用 pnpm 安装依赖
|
|
65
|
+
|
|
66
|
+
$ fastcar-cli update:cos # 更新 cos 模板的 target 文件夹
|
|
67
|
+
|
|
68
|
+
$ fastcar-cli skill install fastcar-framework # 交互式安装
|
|
69
|
+
$ fastcar-cli skill install fastcar-framework -g # 全局安装
|
|
70
|
+
$ fastcar-cli skill install fastcar-framework -l # 本地安装
|
|
71
|
+
$ fastcar-cli skill install fastcar-framework -t kimi # 安装到 Kimi
|
|
72
|
+
$ fastcar-cli skill install all # 安装全部 skills
|
|
73
|
+
$ fastcar-cli skill install --all -g # 全局安装全部 skills
|
|
74
|
+
$ fastcar-cli skill list # 列出可用 skills
|
|
75
|
+
$ fastcar-cli skill targets # 列出支持的 agents
|
|
76
|
+
|
|
77
|
+
Reverse 命令参数说明:
|
|
78
|
+
通过配置文件传入参数,在项目根目录创建 reverse.config.yml 或 reverse.config.json:
|
|
79
|
+
|
|
80
|
+
{
|
|
81
|
+
"tables": ["test"], // 要逆向生成的表名数组(必填)
|
|
82
|
+
"modelDir": "/path/to/models", // Model 文件输出目录绝对路径(必填)
|
|
83
|
+
"mapperDir": "/path/to/mappers", // Mapper 文件输出目录绝对路径(必填)
|
|
84
|
+
"dbConfig": { // MySQL 数据库配置(必填)
|
|
85
|
+
"host": "localhost",
|
|
86
|
+
"port": 3306,
|
|
87
|
+
"user": "root",
|
|
88
|
+
"password": "password",
|
|
89
|
+
"database": "test_db"
|
|
90
|
+
},
|
|
91
|
+
"style": { // Prettier 格式化配置(可选)
|
|
92
|
+
"tabWidth": 4,
|
|
93
|
+
"printWidth": 200,
|
|
94
|
+
"trailingComma": "es5",
|
|
95
|
+
"useTabs": true,
|
|
96
|
+
"parser": "typescript",
|
|
97
|
+
"endOfLine": "crlf"
|
|
98
|
+
},
|
|
99
|
+
"ignoreCamelcase": false // 是否忽略驼峰命名转换(可选,默认 false)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
也可以使用 reverse:init 命令生成默认配置文件:
|
|
103
|
+
$ fastcar-cli reverse:init
|
|
104
|
+
`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function showVersion() {
|
|
108
|
+
console.log(`fastcar-cli version ${packageINFO.version}`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function run(argv) {
|
|
112
|
+
// 命令入口
|
|
113
|
+
if (!argv || argv.length === 0) {
|
|
114
|
+
showHelp();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const head = argv[0];
|
|
119
|
+
const body = argv.slice(1);
|
|
120
|
+
|
|
121
|
+
switch (head) {
|
|
122
|
+
case "-v":
|
|
123
|
+
case "--version": {
|
|
124
|
+
showVersion();
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
case "-h":
|
|
128
|
+
case "--help": {
|
|
129
|
+
showHelp();
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case "init": {
|
|
133
|
+
await init(body);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case "clean":
|
|
137
|
+
case "compress": {
|
|
138
|
+
if (!body[0]) {
|
|
139
|
+
body[0] = "node_modules";
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (body[0] === "node_modules") {
|
|
143
|
+
setModules(body[0], head === "compress");
|
|
144
|
+
} else {
|
|
145
|
+
console.log("❌ 缺少文件路径");
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case "reverse": {
|
|
150
|
+
await reverseGenerate(body);
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case "reverse:init": {
|
|
154
|
+
await initReverseConfig();
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
case "pack": {
|
|
158
|
+
const pm = body[0]; // 可选的包管理器参数
|
|
159
|
+
packProject(null, null, pm);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case "update:cos": {
|
|
163
|
+
await updateCosTemplate(body);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
case "skill": {
|
|
167
|
+
const subCmd = body[0];
|
|
168
|
+
const args = body.slice(1);
|
|
169
|
+
|
|
170
|
+
// 解析参数
|
|
171
|
+
const options = {
|
|
172
|
+
global: args.includes("-g") || args.includes("--global"),
|
|
173
|
+
local: args.includes("-l") || args.includes("--local"),
|
|
174
|
+
all: args.includes("--all"),
|
|
175
|
+
target: null,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// 解析 --target 或 -t
|
|
179
|
+
const targetIdx = args.findIndex((a) => a === "-t" || a === "--target");
|
|
180
|
+
if (targetIdx !== -1 && args[targetIdx + 1]) {
|
|
181
|
+
options.target = args[targetIdx + 1];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// 移除参数,保留 skill name
|
|
185
|
+
const skillName = args.find((a) => !a.startsWith("-"));
|
|
186
|
+
|
|
187
|
+
switch (subCmd) {
|
|
188
|
+
case "install": {
|
|
189
|
+
if (!skillName && !options.all) {
|
|
190
|
+
console.log("❌ 请指定 skill 名称,或使用 all/--all 安装全部");
|
|
191
|
+
console.log(
|
|
192
|
+
"用法: fastcar-cli skill install <skill-name> [options]",
|
|
193
|
+
);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
await installSkill(skillName || 'all', options);
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
case "uninstall": {
|
|
200
|
+
if (!skillName) {
|
|
201
|
+
console.log("❌ 请指定 skill 名称");
|
|
202
|
+
console.log(
|
|
203
|
+
"用法: fastcar-cli skill uninstall <skill-name> [options]",
|
|
204
|
+
);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
await uninstallSkill(skillName, options);
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
case "list": {
|
|
211
|
+
await listSkills();
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
case "targets": {
|
|
215
|
+
listTargets();
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
case "init": {
|
|
219
|
+
await initSkill(options);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
default: {
|
|
223
|
+
console.log("❌ 未知的 skill 命令");
|
|
224
|
+
console.log("可用的子命令: install, uninstall, list, targets, init");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
default: {
|
|
230
|
+
console.log(`❌ 未知命令: ${head}\n`);
|
|
231
|
+
showHelp();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
run(process.argv.slice(2)).catch((err) => {
|
|
237
|
+
console.error(err);
|
|
238
|
+
process.exit(1);
|
|
239
|
+
});
|