@fastcar/cli 0.1.0 → 0.1.1
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/package.json +1 -1
- package/skills/fastcar-framework/SKILL.md +74 -251
- package/src/skill-targets.js +3 -3
- package/src/skill.js +5 -3
package/package.json
CHANGED
|
@@ -26,36 +26,23 @@ FastCar 是基于 TypeScript 的 Node.js 企业级应用开发框架,灵感来
|
|
|
26
26
|
import { FastCarApplication } from "@fastcar/core";
|
|
27
27
|
import { Application, Autowired, Component, Service } from "@fastcar/core/annotation";
|
|
28
28
|
|
|
29
|
-
// 服务层
|
|
30
29
|
@Service
|
|
31
30
|
class UserService {
|
|
32
|
-
getUsers() {
|
|
33
|
-
return [{ id: 1, name: "Alice" }];
|
|
34
|
-
}
|
|
31
|
+
getUsers() { return [{ id: 1, name: "Alice" }]; }
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
// 控制器层
|
|
38
34
|
@Controller
|
|
39
35
|
class UserController {
|
|
40
|
-
@Autowired
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
getUsers() {
|
|
44
|
-
return this.userService.getUsers();
|
|
45
|
-
}
|
|
36
|
+
@Autowired private userService!: UserService;
|
|
37
|
+
getUsers() { return this.userService.getUsers(); }
|
|
46
38
|
}
|
|
47
39
|
|
|
48
|
-
// 应用入口
|
|
49
40
|
@Application
|
|
50
41
|
class App {
|
|
51
42
|
app!: FastCarApplication;
|
|
52
|
-
|
|
53
|
-
async start() {
|
|
54
|
-
console.log("应用启动成功!");
|
|
55
|
-
}
|
|
43
|
+
async start() { console.log("应用启动成功!"); }
|
|
56
44
|
}
|
|
57
45
|
|
|
58
|
-
// 启动
|
|
59
46
|
const app = new App();
|
|
60
47
|
app.start();
|
|
61
48
|
```
|
|
@@ -67,23 +54,11 @@ app.start();
|
|
|
67
54
|
```typescript
|
|
68
55
|
import { GET, POST, REQUEST, Body, Param } from "@fastcar/koa/annotation";
|
|
69
56
|
|
|
70
|
-
@Controller
|
|
71
|
-
@REQUEST("/api/users")
|
|
57
|
+
@Controller @REQUEST("/api/users")
|
|
72
58
|
class UserController {
|
|
73
|
-
@GET
|
|
74
|
-
async
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
@GET("/:id")
|
|
79
|
-
async getById(@Param("id") id: string) {
|
|
80
|
-
return { id };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
@POST
|
|
84
|
-
async create(@Body user: UserDTO) {
|
|
85
|
-
return { created: true };
|
|
86
|
-
}
|
|
59
|
+
@GET async list() { return { data: [] }; }
|
|
60
|
+
@GET("/:id") async getById(@Param("id") id: string) { return { id }; }
|
|
61
|
+
@POST async create(@Body user: UserDTO) { return { created: true }; }
|
|
87
62
|
}
|
|
88
63
|
```
|
|
89
64
|
|
|
@@ -94,22 +69,14 @@ import { Repository, Table, Field, PrimaryKey, SqlSession } from "@fastcar/mysql
|
|
|
94
69
|
|
|
95
70
|
@Table("users")
|
|
96
71
|
class User {
|
|
97
|
-
@PrimaryKey
|
|
98
|
-
@Field("
|
|
99
|
-
id!: number;
|
|
100
|
-
|
|
101
|
-
@Field("name")
|
|
102
|
-
name!: string;
|
|
72
|
+
@PrimaryKey @Field("id") id!: number;
|
|
73
|
+
@Field("name") name!: string;
|
|
103
74
|
}
|
|
104
75
|
|
|
105
76
|
@Repository
|
|
106
77
|
class UserRepository {
|
|
107
|
-
@SqlSession
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
async findById(id: number) {
|
|
111
|
-
return this.session.findById(User, id);
|
|
112
|
-
}
|
|
78
|
+
@SqlSession private session!: SqlSession;
|
|
79
|
+
async findById(id: number) { return this.session.findById(User, id); }
|
|
113
80
|
}
|
|
114
81
|
```
|
|
115
82
|
|
|
@@ -120,13 +87,8 @@ import { RedisClient } from "@fastcar/redis/annotation";
|
|
|
120
87
|
|
|
121
88
|
@Service
|
|
122
89
|
class CacheService {
|
|
123
|
-
@RedisClient
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
async get(key: string) {
|
|
127
|
-
return this.redis.get(key);
|
|
128
|
-
}
|
|
129
|
-
|
|
90
|
+
@RedisClient private redis!: RedisClient;
|
|
91
|
+
async get(key: string) { return this.redis.get(key); }
|
|
130
92
|
async set(key: string, value: string, ttl?: number) {
|
|
131
93
|
await this.redis.set(key, value, ttl);
|
|
132
94
|
}
|
|
@@ -140,17 +102,8 @@ import { Scheduled, Cron } from "@fastcar/timer/annotation";
|
|
|
140
102
|
|
|
141
103
|
@Component
|
|
142
104
|
class TaskService {
|
|
143
|
-
|
|
144
|
-
@
|
|
145
|
-
async intervalTask() {
|
|
146
|
-
console.log("每分钟执行");
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Cron 表达式
|
|
150
|
-
@Cron("0 0 * * * *")
|
|
151
|
-
async hourlyTask() {
|
|
152
|
-
console.log("每小时执行");
|
|
153
|
-
}
|
|
105
|
+
@Scheduled(60000) async intervalTask() { console.log("每分钟执行"); }
|
|
106
|
+
@Cron("0 0 * * * *") async hourlyTask() { console.log("每小时执行"); }
|
|
154
107
|
}
|
|
155
108
|
```
|
|
156
109
|
|
|
@@ -161,12 +114,9 @@ import { WorkerPool, WorkerTask } from "@fastcar/workerpool/annotation";
|
|
|
161
114
|
|
|
162
115
|
@Component
|
|
163
116
|
class ComputeService {
|
|
164
|
-
@WorkerPool({ minWorkers: 2, maxWorkers: 4 })
|
|
165
|
-
private pool!: WorkerPool;
|
|
166
|
-
|
|
117
|
+
@WorkerPool({ minWorkers: 2, maxWorkers: 4 }) private pool!: WorkerPool;
|
|
167
118
|
@WorkerTask
|
|
168
119
|
heavyComputation(data: number[]): number {
|
|
169
|
-
// 在 worker 线程中执行
|
|
170
120
|
return data.reduce((a, b) => a + b, 0);
|
|
171
121
|
}
|
|
172
122
|
}
|
|
@@ -174,8 +124,6 @@ class ComputeService {
|
|
|
174
124
|
|
|
175
125
|
## 项目模板速查
|
|
176
126
|
|
|
177
|
-
FastCar CLI 提供 5 种项目模板,分别适用于不同的业务场景。
|
|
178
|
-
|
|
179
127
|
### 模板选择指南
|
|
180
128
|
|
|
181
129
|
| 模板 | 适用场景 | 核心依赖 | 关键注解 |
|
|
@@ -188,64 +136,56 @@ FastCar CLI 提供 5 种项目模板,分别适用于不同的业务场景。
|
|
|
188
136
|
|
|
189
137
|
### 各模板入口示例
|
|
190
138
|
|
|
191
|
-
|
|
139
|
+
**Web 模板**
|
|
192
140
|
```typescript
|
|
193
141
|
import { FastCarApplication } from "@fastcar/core";
|
|
194
142
|
import { Application } from "@fastcar/core/annotation";
|
|
195
143
|
import { EnableKoa, KoaMiddleware } from "@fastcar/koa/annotation";
|
|
196
144
|
import { ExceptionGlobalHandler, KoaBodyParser } from "@fastcar/koa";
|
|
197
145
|
|
|
198
|
-
@Application
|
|
199
|
-
@EnableKoa
|
|
146
|
+
@Application @EnableKoa
|
|
200
147
|
@KoaMiddleware(ExceptionGlobalHandler)
|
|
201
148
|
@KoaMiddleware(KoaBodyParser)
|
|
202
|
-
class APP {
|
|
203
|
-
app!: FastCarApplication;
|
|
204
|
-
}
|
|
149
|
+
class APP { app!: FastCarApplication; }
|
|
205
150
|
export default new APP();
|
|
206
151
|
```
|
|
207
152
|
|
|
208
|
-
|
|
153
|
+
**Static 模板**
|
|
209
154
|
```typescript
|
|
210
155
|
import { Application } from "@fastcar/core/annotation";
|
|
211
156
|
import { EnableKoa, KoaMiddleware } from "@fastcar/koa/annotation";
|
|
212
157
|
import { ExceptionGlobalHandler, KoaStatic } from "@fastcar/koa";
|
|
213
158
|
|
|
214
|
-
@Application
|
|
215
|
-
@EnableKoa
|
|
159
|
+
@Application @EnableKoa
|
|
216
160
|
@KoaMiddleware(ExceptionGlobalHandler)
|
|
217
161
|
@KoaMiddleware(KoaStatic)
|
|
218
|
-
class APP {
|
|
219
|
-
app!: any;
|
|
220
|
-
}
|
|
162
|
+
class APP { app!: any; }
|
|
221
163
|
export default new APP();
|
|
222
164
|
```
|
|
223
165
|
|
|
224
|
-
|
|
166
|
+
**RPC 模板**
|
|
225
167
|
```typescript
|
|
226
168
|
import { Application } from "@fastcar/core/annotation";
|
|
227
169
|
import { EnableRPC } from "@fastcar/rpc/annotation";
|
|
228
170
|
|
|
229
|
-
@Application
|
|
230
|
-
@EnableRPC
|
|
171
|
+
@Application @EnableRPC
|
|
231
172
|
class APP {}
|
|
232
173
|
export default new APP();
|
|
233
174
|
```
|
|
234
175
|
|
|
235
|
-
|
|
176
|
+
**COS 模板**
|
|
236
177
|
```typescript
|
|
237
178
|
import { Application } from "@fastcar/core/annotation";
|
|
238
179
|
import { EnableKoa, KoaMiddleware } from "@fastcar/koa/annotation";
|
|
239
180
|
import { ExceptionGlobalHandler, KoaBody, KoaBodyParser, KoaCors } from "@fastcar/koa";
|
|
240
181
|
|
|
241
|
-
@EnableKoa
|
|
242
|
-
@Application
|
|
182
|
+
@Application @EnableKoa
|
|
243
183
|
@KoaMiddleware(ExceptionGlobalHandler, KoaBody, KoaBodyParser, KoaCors)
|
|
244
184
|
class APP {}
|
|
245
185
|
export default new APP();
|
|
246
186
|
```
|
|
247
187
|
|
|
248
|
-
|
|
188
|
+
**Microservices 模板**
|
|
249
189
|
微服务模板采用多服务架构,包含 `app-node.ts`(子进程启动多服务)和 `app-pm2.ts`(PM2 启动入口)。服务模块分为:
|
|
250
190
|
- **center**:服务中心,提供服务注册与发现
|
|
251
191
|
- **connector**:连接器服务,处理客户端连接
|
|
@@ -280,15 +220,10 @@ template/
|
|
|
280
220
|
│ ├── annotation/ # 注解定义
|
|
281
221
|
│ ├── common/ # 公共代码
|
|
282
222
|
│ ├── middleware/ # 中间件
|
|
283
|
-
│ ├── servers/ #
|
|
284
|
-
│ │ ├── base/ # 基础服务
|
|
285
|
-
│ │ ├── center/ # 服务中心
|
|
286
|
-
│ │ ├── chat/ # 聊天服务
|
|
287
|
-
│ │ ├── connector/ # 连接器服务
|
|
288
|
-
│ │ └── web/ # Web 服务
|
|
223
|
+
│ ├── servers/ # 服务目录(base/center/chat/connector/web)
|
|
289
224
|
│ ├── types/ # 类型定义
|
|
290
225
|
│ ├── utils/ # 工具函数
|
|
291
|
-
│ ├── app-node.ts #
|
|
226
|
+
│ ├── app-node.ts # 单节点入口
|
|
292
227
|
│ └── app-pm2.ts # PM2 入口
|
|
293
228
|
├── resource/
|
|
294
229
|
│ ├── application.yml
|
|
@@ -346,17 +281,14 @@ import { Configure, Value } from "@fastcar/core/annotation";
|
|
|
346
281
|
|
|
347
282
|
@Configure
|
|
348
283
|
class AppConfig {
|
|
349
|
-
@Value("server.port")
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
@Value("mysql.host")
|
|
353
|
-
dbHost!: string;
|
|
284
|
+
@Value("server.port") port!: number;
|
|
285
|
+
@Value("mysql.host") dbHost!: string;
|
|
354
286
|
}
|
|
355
287
|
```
|
|
356
288
|
|
|
357
|
-
### 各模板 application.yml
|
|
289
|
+
### 各模板 application.yml 配置
|
|
358
290
|
|
|
359
|
-
#### Web / Static / COS
|
|
291
|
+
#### Web / Static / COS 通用配置
|
|
360
292
|
|
|
361
293
|
```yaml
|
|
362
294
|
application:
|
|
@@ -366,18 +298,16 @@ settings:
|
|
|
366
298
|
koa:
|
|
367
299
|
server:
|
|
368
300
|
- { port: 8080, host: "0.0.0.0" }
|
|
369
|
-
# HTTPS
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
{ "public": "public" } # 别名: 路径(相对 resource 目录或绝对路径)
|
|
373
|
-
koaBodyParser: # 请求体解析
|
|
301
|
+
# HTTPS: { port: 443, host: "0.0.0.0", protocol: https, ssl: { key: "./ssl/server.key", cert: "./ssl/server.pem" } }
|
|
302
|
+
koaStatic: { "public": "public" } # 静态资源映射
|
|
303
|
+
koaBodyParser:
|
|
374
304
|
enableTypes: ["json", "form", "text"]
|
|
375
305
|
extendTypes: { text: ["text/xml", "application/xml"] }
|
|
376
306
|
```
|
|
377
307
|
|
|
378
|
-
- `settings.koa.server
|
|
379
|
-
- `settings.koa.koaStatic
|
|
380
|
-
- `settings.koa.koaBodyParser
|
|
308
|
+
- `settings.koa.server`:服务器监听配置数组,支持 `http`/`https`/`http2`
|
|
309
|
+
- `settings.koa.koaStatic`:静态资源访问映射,格式 `{ "别名": "路径" }`
|
|
310
|
+
- `settings.koa.koaBodyParser`:请求体解析配置
|
|
381
311
|
|
|
382
312
|
#### RPC 模板配置
|
|
383
313
|
|
|
@@ -389,122 +319,53 @@ settings:
|
|
|
389
319
|
rpc:
|
|
390
320
|
list:
|
|
391
321
|
- id: "server-1"
|
|
392
|
-
type: "ws" #
|
|
322
|
+
type: "ws" # 协议:ws / http / grpc / mqtt
|
|
393
323
|
server: { port: 1235 }
|
|
394
|
-
extra: {}
|
|
395
324
|
serviceType: "base" # 服务类型分类
|
|
396
|
-
secure:
|
|
397
|
-
username: "user"
|
|
398
|
-
password: "123456"
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
- `settings.rpc.list`:RPC 服务端点数组。
|
|
402
|
-
- `id`:节点唯一标识。
|
|
403
|
-
- `type`:通信协议,常见取值 `ws`、`http`、`grpc`、`mqtt`。
|
|
404
|
-
- `server`:监听配置,通常只写 `{ port }`。
|
|
405
|
-
- `extra`:协议扩展参数。
|
|
406
|
-
- `serviceType`:服务类型,用于服务分组或路由。
|
|
407
|
-
- `secure`:安全认证信息,包含 `username` 和 `password`。
|
|
408
|
-
|
|
409
|
-
#### COS 模板特有配置
|
|
410
|
-
|
|
411
|
-
```yaml
|
|
412
|
-
application:
|
|
413
|
-
env: "prod"
|
|
414
|
-
|
|
415
|
-
settings:
|
|
416
|
-
hotterSysConfig: true # 启用系统配置热更新监听
|
|
325
|
+
secure: { username: "user", password: "123456" }
|
|
417
326
|
```
|
|
418
327
|
|
|
419
|
-
- `settings.
|
|
328
|
+
- `settings.rpc.list`:RPC 服务端点数组
|
|
329
|
+
- `type`:通信协议;`serviceType`:服务分组;`secure`:安全认证
|
|
420
330
|
|
|
421
331
|
#### Microservices 模板配置
|
|
422
332
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
```yaml
|
|
426
|
-
application:
|
|
427
|
-
env: "dev"
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
详细集群配置放在 `application-dev.yml`:
|
|
333
|
+
主配置声明环境,详细集群配置放在 `application-dev.yml`:
|
|
431
334
|
|
|
432
335
|
```yaml
|
|
433
336
|
settings:
|
|
434
|
-
hotterSysConfig: true
|
|
435
|
-
|
|
337
|
+
hotterSysConfig: true # 监听配置变更
|
|
436
338
|
microservices:
|
|
437
|
-
center:
|
|
438
|
-
token: "
|
|
339
|
+
center: # 服务中心
|
|
340
|
+
token: "xxx"
|
|
439
341
|
servers:
|
|
440
342
|
- host: "localhost"
|
|
441
|
-
clusters: 1
|
|
343
|
+
clusters: 1 # 实例数
|
|
442
344
|
list:
|
|
443
345
|
- type: "ws"
|
|
444
346
|
server: { port: 60000 }
|
|
445
|
-
timeout: 0
|
|
347
|
+
timeout: 0
|
|
446
348
|
connectionLimit: 1
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
timeout: 30000
|
|
452
|
-
maxMsgNum: 10000
|
|
453
|
-
increase: true
|
|
454
|
-
|
|
455
|
-
connector: # 连接器服务
|
|
456
|
-
token: "x3TGsWC9uloZu235LA07eAiJ61nQ1A5f"
|
|
349
|
+
retry: { retryCount: 3, retryInterval: 3000 }
|
|
350
|
+
|
|
351
|
+
connector: # 连接器服务
|
|
352
|
+
token: "xxx"
|
|
457
353
|
servers:
|
|
458
354
|
- host: "localhost"
|
|
459
355
|
clusters: 1
|
|
460
356
|
list:
|
|
461
|
-
- front: true
|
|
357
|
+
- front: true # 面向客户端的前置节点
|
|
462
358
|
type: "ws"
|
|
463
359
|
server: { port: 60100 }
|
|
464
360
|
|
|
465
|
-
chat: # 聊天服务
|
|
466
|
-
|
|
467
|
-
servers:
|
|
468
|
-
- host: "localhost"
|
|
469
|
-
clusters: 1
|
|
470
|
-
list:
|
|
471
|
-
- type: "ws"
|
|
472
|
-
server: { port: 60200 }
|
|
473
|
-
|
|
474
|
-
web: # Web 服务
|
|
475
|
-
token: "go0kbkNM3wQ4e2Vgo0kbkNM3wQ4e2V"
|
|
476
|
-
koa:
|
|
477
|
-
koaBodyParser:
|
|
478
|
-
enableTypes: ["json", "form", "text"]
|
|
479
|
-
extendTypes: { text: ["text/xml", "application/xml"] }
|
|
480
|
-
servers:
|
|
481
|
-
- host: "localhost"
|
|
482
|
-
clusters: 1
|
|
483
|
-
list:
|
|
484
|
-
- type: "http"
|
|
485
|
-
server: { port: 8080 }
|
|
486
|
-
- type: "ws"
|
|
487
|
-
server: { port: 60300 }
|
|
361
|
+
chat: { ... } # 聊天服务
|
|
362
|
+
web: { ... } # Web 服务(支持 http/ws 混合)
|
|
488
363
|
```
|
|
489
364
|
|
|
490
|
-
- `settings.microservices
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
- `clusters`:集群实例数量。若大于 1,框架会自动递增 `serviceId` 和端口号生成多个实例。
|
|
495
|
-
- `list`:该集群对外暴露的协议端点列表。
|
|
496
|
-
- `type`:协议类型,如 `ws`、`http`。
|
|
497
|
-
- `server`:端口配置 `{ port }`。
|
|
498
|
-
- `front: true`:仅 connector 等前置服务需要,表示该节点直接面向客户端。
|
|
499
|
-
- `timeout`:连接超时时间(毫秒),`0` 表示永不超时。
|
|
500
|
-
- `connectionLimit`:最大连接数限制。
|
|
501
|
-
- `disconnectInterval`:断线后重连间隔(毫秒)。
|
|
502
|
-
- `retry`:消息重试策略。
|
|
503
|
-
- `retryCount`:最大重试次数。
|
|
504
|
-
- `retryInterval`:重试间隔。
|
|
505
|
-
- `timeout`:重试总超时。
|
|
506
|
-
- `maxMsgNum`:消息队列最大长度。
|
|
507
|
-
- `increase`:是否递增重试间隔。
|
|
365
|
+
- `settings.microservices.<服务名>`:各微服务模块配置
|
|
366
|
+
- `token`:服务间通信鉴权令牌;`clusters`:集群实例数(自动递增端口号)
|
|
367
|
+
- `front: true`:标记为面向客户端的前置节点
|
|
368
|
+
- `retry`:消息重试策略(retryCount/retryInterval/timeout/maxMsgNum/increase)
|
|
508
369
|
|
|
509
370
|
## 生命周期钩子
|
|
510
371
|
|
|
@@ -513,23 +374,9 @@ import { ApplicationStart, ApplicationStop, ApplicationInit } from "@fastcar/cor
|
|
|
513
374
|
|
|
514
375
|
@Component
|
|
515
376
|
class LifecycleService {
|
|
516
|
-
|
|
517
|
-
@
|
|
518
|
-
async
|
|
519
|
-
console.log("应用启动");
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
// 应用停止前执行
|
|
523
|
-
@ApplicationStop
|
|
524
|
-
async onStop() {
|
|
525
|
-
console.log("应用停止");
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
// 初始化(配合 @ApplicationRunner)
|
|
529
|
-
@ApplicationInit
|
|
530
|
-
async init() {
|
|
531
|
-
console.log("初始化完成");
|
|
532
|
-
}
|
|
377
|
+
@ApplicationStart async onStart() { console.log("应用启动"); }
|
|
378
|
+
@ApplicationStop async onStop() { console.log("应用停止"); }
|
|
379
|
+
@ApplicationInit async init() { console.log("初始化完成"); }
|
|
533
380
|
}
|
|
534
381
|
```
|
|
535
382
|
|
|
@@ -539,18 +386,14 @@ class LifecycleService {
|
|
|
539
386
|
import { ValidForm, NotNull, Size, Rule } from "@fastcar/core/annotation";
|
|
540
387
|
|
|
541
388
|
class UserDTO {
|
|
542
|
-
@NotNull
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
@Size({ minSize: 1, maxSize: 150 })
|
|
546
|
-
age!: number;
|
|
389
|
+
@NotNull name!: string;
|
|
390
|
+
@Size({ minSize: 1, maxSize: 150 }) age!: number;
|
|
547
391
|
}
|
|
548
392
|
|
|
549
393
|
@Controller
|
|
550
394
|
class UserController {
|
|
551
395
|
@ValidForm
|
|
552
396
|
createUser(@Rule() @NotNull user: UserDTO) {
|
|
553
|
-
// 参数自动校验
|
|
554
397
|
return this.userService.create(user);
|
|
555
398
|
}
|
|
556
399
|
}
|
|
@@ -603,56 +446,36 @@ TypeUtil.isClass(MyClass); // true
|
|
|
603
446
|
```bash
|
|
604
447
|
# Web 项目
|
|
605
448
|
mkdir my-web-app && cd my-web-app
|
|
606
|
-
fastcar-cli init web
|
|
607
|
-
npm install
|
|
608
|
-
npm run debug
|
|
449
|
+
fastcar-cli init web && npm install && npm run debug
|
|
609
450
|
|
|
610
451
|
# Static 项目
|
|
611
452
|
mkdir my-static-app && cd my-static-app
|
|
612
|
-
fastcar-cli init static
|
|
613
|
-
npm install
|
|
614
|
-
npm run debug
|
|
453
|
+
fastcar-cli init static && npm install && npm run debug
|
|
615
454
|
|
|
616
455
|
# RPC 项目
|
|
617
456
|
mkdir my-rpc-app && cd my-rpc-app
|
|
618
|
-
fastcar-cli init rpc
|
|
619
|
-
npm install
|
|
620
|
-
npm run debug
|
|
457
|
+
fastcar-cli init rpc && npm install && npm run debug
|
|
621
458
|
|
|
622
459
|
# COS 项目
|
|
623
460
|
mkdir my-cos-app && cd my-cos-app
|
|
624
|
-
fastcar-cli init cos
|
|
625
|
-
npm install
|
|
626
|
-
npm run debug
|
|
461
|
+
fastcar-cli init cos && npm install && npm run debug
|
|
627
462
|
|
|
628
463
|
# Microservices 项目
|
|
629
464
|
mkdir my-ms-app && cd my-ms-app
|
|
630
|
-
fastcar-cli init microservices
|
|
631
|
-
npm
|
|
632
|
-
npm run start-
|
|
633
|
-
# 或
|
|
634
|
-
npm run start-pm2 # PM2 模式
|
|
465
|
+
fastcar-cli init microservices && npm install
|
|
466
|
+
npm run start-node # 单节点模式
|
|
467
|
+
# 或 npm run start-pm2 # PM2 模式
|
|
635
468
|
```
|
|
636
469
|
|
|
637
470
|
### 手动创建项目
|
|
638
471
|
|
|
639
472
|
```bash
|
|
640
|
-
# 1. 创建项目
|
|
641
473
|
mkdir my-fastcar-app && cd my-fastcar-app
|
|
642
474
|
npm init -y
|
|
643
|
-
|
|
644
|
-
# 2. 安装依赖
|
|
645
475
|
npm i @fastcar/core @fastcar/koa @fastcar/server
|
|
646
476
|
npm i -D typescript ts-node @types/node
|
|
647
|
-
|
|
648
|
-
# 3. 初始化 TypeScript
|
|
649
477
|
npx tsc --init
|
|
650
|
-
|
|
651
|
-
# 4. 启用装饰器(tsconfig.json)
|
|
652
|
-
# "experimentalDecorators": true
|
|
653
|
-
# "emitDecoratorMetadata": true
|
|
654
|
-
|
|
655
|
-
# 5. 创建入口文件和配置文件,开始开发
|
|
478
|
+
# 启用装饰器(tsconfig.json): experimentalDecorators, emitDecoratorMetadata
|
|
656
479
|
```
|
|
657
480
|
|
|
658
481
|
## 参考资源
|
package/src/skill-targets.js
CHANGED
|
@@ -9,9 +9,9 @@ const TARGETS = {
|
|
|
9
9
|
name: 'Kimi Code CLI',
|
|
10
10
|
description: 'Kimi Code extension for VS Code',
|
|
11
11
|
globalPaths: {
|
|
12
|
-
win32: path.join(os.homedir(), '
|
|
13
|
-
darwin: path.join(os.homedir(), '.
|
|
14
|
-
linux: path.join(os.homedir(), '.
|
|
12
|
+
win32: path.join(os.homedir(), '.kimi/skills'),
|
|
13
|
+
darwin: path.join(os.homedir(), '.kimi/skills'),
|
|
14
|
+
linux: path.join(os.homedir(), '.kimi/skills')
|
|
15
15
|
},
|
|
16
16
|
localPath: '.agents/skills'
|
|
17
17
|
},
|
package/src/skill.js
CHANGED
|
@@ -197,9 +197,11 @@ async function installSkill(skillName, options = {}) {
|
|
|
197
197
|
console.log(`✅ 成功 ${modeText} 安装 ${skillName}`);
|
|
198
198
|
console.log(` 位置: ${destPath}`);
|
|
199
199
|
console.log();
|
|
200
|
-
console.log('
|
|
201
|
-
console.log(
|
|
202
|
-
console.log(
|
|
200
|
+
console.log('⚠️ 重要: 请重启你的 AI agent 以加载新安装的 skill!');
|
|
201
|
+
console.log();
|
|
202
|
+
console.log('重启后,你可以在对话中:');
|
|
203
|
+
console.log(` • 直接询问关于 "${skillName}" 的内容`);
|
|
204
|
+
console.log(` • 使用 /skill:${skillName} 强制加载该 skill`);
|
|
203
205
|
} else {
|
|
204
206
|
console.log('❌ 安装验证失败');
|
|
205
207
|
}
|