mirror of
https://github.com/Lydanne/spaceflow.git
synced 2026-03-11 19:52:45 +08:00
chore: 初始化仓库
This commit is contained in:
6
templates/command/README.md.hbs
Normal file
6
templates/command/README.md.hbs
Normal file
@@ -0,0 +1,6 @@
|
||||
# @spaceflow/{{kebabName}}
|
||||
|
||||
{{name}}
|
||||
命令插件 ## 使用方法 ```bash spaceflow
|
||||
{{kebabName}}
|
||||
[options] ``` ## 选项 TODO: 添加命令选项说明
|
||||
6
templates/command/package.json.hbs
Normal file
6
templates/command/package.json.hbs
Normal file
@@ -0,0 +1,6 @@
|
||||
{ "name": "@spaceflow/{{kebabName}}", "version": "1.0.0", "description": "Spaceflow
|
||||
{{name}}
|
||||
命令插件", "main": "./dist/index.js", "type": "module", "spaceflow": { "commands": [ "." ] },
|
||||
"scripts": { "build": "spaceflow build", "dev": "spaceflow dev" }, "peerDependencies": {
|
||||
"spaceflow": "workspace:*", "@nestjs/common": "catalog:", "@nestjs/config": "catalog:",
|
||||
"nest-commander": "catalog:" }, "devDependencies": { "@types/node": "catalog:" } }
|
||||
33
templates/command/src/__name__.command.ts.hbs
Normal file
33
templates/command/src/__name__.command.ts.hbs
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Command, CommandRunner, Option } from "nest-commander";
|
||||
import { {{pascalName}}Service } from "./{{kebabName}}.service";
|
||||
|
||||
export interface {{pascalName}}Options {
|
||||
verbose?: boolean;
|
||||
}
|
||||
|
||||
@Command({
|
||||
name: "{{kebabName}}",
|
||||
description: "{{name}} 命令",
|
||||
})
|
||||
export class {{pascalName}}Command extends CommandRunner {
|
||||
constructor(protected readonly {{camelName}}Service: {{pascalName}}Service) {
|
||||
super();
|
||||
}
|
||||
|
||||
async run(_passedParams: string[], options: {{pascalName}}Options): Promise<void> {
|
||||
try {
|
||||
await this.{{camelName}}Service.execute(options);
|
||||
} catch (error) {
|
||||
console.error("执行失败:", error instanceof Error ? error.message : error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Option({
|
||||
flags: "-v, --verbose",
|
||||
description: "显示详细日志",
|
||||
})
|
||||
parseVerbose(): boolean {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
5
templates/command/src/__name__.module.ts.hbs
Normal file
5
templates/command/src/__name__.module.ts.hbs
Normal file
@@ -0,0 +1,5 @@
|
||||
import { Module } from "@nestjs/common"; import {
|
||||
{{pascalName}}Command } from "./{{kebabName}}.command"; import {
|
||||
{{pascalName}}Service } from "./{{kebabName}}.service"; @Module({ providers: [{{pascalName}}Command,
|
||||
{{pascalName}}Service], }) export class
|
||||
{{pascalName}}Module {}
|
||||
17
templates/command/src/__name__.service.ts.hbs
Normal file
17
templates/command/src/__name__.service.ts.hbs
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
export interface {{pascalName}}Options {
|
||||
verbose?: boolean;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class {{pascalName}}Service {
|
||||
async execute(options: {{pascalName}}Options): Promise<void> {
|
||||
if (options.verbose) {
|
||||
console.log("执行 {{name}} 命令...");
|
||||
}
|
||||
|
||||
// TODO: 实现命令逻辑
|
||||
console.log("Hello from {{name}}!");
|
||||
}
|
||||
}
|
||||
9
templates/command/src/index.ts.hbs
Normal file
9
templates/command/src/index.ts.hbs
Normal file
@@ -0,0 +1,9 @@
|
||||
import { SpaceflowPlugin, SpaceflowPluginMetadata } from "spaceflow"; import {
|
||||
{{pascalName}}Module } from "./{{kebabName}}.module"; export class
|
||||
{{pascalName}}Plugin implements SpaceflowPlugin { getMetadata(): SpaceflowPluginMetadata { return {
|
||||
name: "{{kebabName}}", commands: ["{{kebabName}}"], configKey: "{{kebabName}}", version: "1.0.0",
|
||||
description: "{{name}}
|
||||
命令插件", }; } getModule() { return
|
||||
{{pascalName}}Module; } } export default
|
||||
{{pascalName}}Plugin; export * from "./{{kebabName}}.command"; export * from "./{{kebabName}}.service";
|
||||
export * from "./{{kebabName}}.module";
|
||||
2
templates/command/tsconfig.json.hbs
Normal file
2
templates/command/tsconfig.json.hbs
Normal file
@@ -0,0 +1,2 @@
|
||||
{ "extends": "../../core/tsconfig.skill.json", "include": ["src/**/*"], "exclude": ["node_modules",
|
||||
"dist"] }
|
||||
29
templates/mcp/README.md.hbs
Normal file
29
templates/mcp/README.md.hbs
Normal file
@@ -0,0 +1,29 @@
|
||||
# @spaceflow/{{kebabName}}
|
||||
|
||||
{{name}} MCP 工具插件
|
||||
|
||||
## 使用方法
|
||||
|
||||
该插件通过 `spaceflow mcp` 命令自动发现并注册 MCP 工具。
|
||||
|
||||
```bash
|
||||
# 启动 MCP Server(包含所有已安装插件的工具)
|
||||
spaceflow mcp
|
||||
|
||||
# 使用 Inspector 调试
|
||||
spaceflow mcp --inspector
|
||||
```
|
||||
|
||||
## 提供的工具
|
||||
|
||||
- **{{kebabName}}_hello** — 示例工具,返回问候信息
|
||||
|
||||
## 开发
|
||||
|
||||
```bash
|
||||
# 构建
|
||||
spaceflow build
|
||||
|
||||
# 开发模式
|
||||
spaceflow dev
|
||||
```
|
||||
26
templates/mcp/package.json.hbs
Normal file
26
templates/mcp/package.json.hbs
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "@spaceflow/{{kebabName}}",
|
||||
"version": "1.0.0",
|
||||
"description": "Spaceflow {{name}} MCP 工具插件",
|
||||
"main": "./dist/index.js",
|
||||
"type": "module",
|
||||
"spaceflow": {
|
||||
"commands": ["."]
|
||||
},
|
||||
"scripts": {
|
||||
"build": "spaceflow build",
|
||||
"dev": "spaceflow dev"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"spaceflow": "workspace:*",
|
||||
"@nestjs/common": "catalog:",
|
||||
"@nestjs/config": "catalog:",
|
||||
"@nestjs/swagger": "catalog:",
|
||||
"nest-commander": "catalog:",
|
||||
"class-validator": "catalog:",
|
||||
"class-transformer": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "catalog:"
|
||||
}
|
||||
}
|
||||
22
templates/mcp/src/__name__.mcp.ts.hbs
Normal file
22
templates/mcp/src/__name__.mcp.ts.hbs
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* {{pascalName}} MCP 服务
|
||||
* 提供 {{name}} 相关的 MCP 工具
|
||||
*/
|
||||
|
||||
import { McpServer, McpTool } from "@spaceflow/core";
|
||||
import { {{pascalName}}Service } from "./{{kebabName}}.service";
|
||||
import { {{pascalName}}HelloInput } from "./dto/mcp.dto";
|
||||
|
||||
@McpServer({ name: "{{kebabName}}-mcp", version: "1.0.0", description: "{{name}} MCP 工具" })
|
||||
export class {{pascalName}}Mcp {
|
||||
constructor(private readonly {{camelName}}Service: {{pascalName}}Service) {}
|
||||
|
||||
@McpTool({
|
||||
name: "{{kebabName}}_hello",
|
||||
description: "示例工具:返回问候信息",
|
||||
dto: {{pascalName}}HelloInput,
|
||||
})
|
||||
async hello(input: {{pascalName}}HelloInput) {
|
||||
return this.{{camelName}}Service.hello(input.name, input.lang);
|
||||
}
|
||||
}
|
||||
9
templates/mcp/src/__name__.module.ts.hbs
Normal file
9
templates/mcp/src/__name__.module.ts.hbs
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Module } from "@spaceflow/core";
|
||||
import { {{pascalName}}Mcp } from "./{{kebabName}}.mcp";
|
||||
import { {{pascalName}}Service } from "./{{kebabName}}.service";
|
||||
|
||||
@Module({
|
||||
providers: [{{pascalName}}Service, {{pascalName}}Mcp],
|
||||
exports: [{{pascalName}}Mcp],
|
||||
})
|
||||
export class {{pascalName}}Module {}
|
||||
19
templates/mcp/src/__name__.service.ts.hbs
Normal file
19
templates/mcp/src/__name__.service.ts.hbs
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Injectable } from "@spaceflow/core";
|
||||
|
||||
export interface HelloResult {
|
||||
readonly message: string;
|
||||
readonly timestamp: string;
|
||||
}
|
||||
|
||||
/** {{pascalName}} 业务逻辑服务 */
|
||||
@Injectable()
|
||||
export class {{pascalName}}Service {
|
||||
/** 生成问候信息 */
|
||||
hello(name: string, lang: string = "zh"): HelloResult {
|
||||
const message = lang === "en" ? `Hello, ${name}!` : `你好,${name}!`;
|
||||
return {
|
||||
message,
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
18
templates/mcp/src/dto/mcp.dto.ts.hbs
Normal file
18
templates/mcp/src/dto/mcp.dto.ts.hbs
Normal file
@@ -0,0 +1,18 @@
|
||||
import {
|
||||
ApiProperty,
|
||||
ApiPropertyOptional,
|
||||
IsString,
|
||||
IsOptional,
|
||||
} from "@spaceflow/core";
|
||||
|
||||
/** {{pascalName}} hello 工具输入参数 */
|
||||
export class {{pascalName}}HelloInput {
|
||||
@ApiProperty({ description: "用户名称" })
|
||||
@IsString()
|
||||
name!: string;
|
||||
|
||||
@ApiPropertyOptional({ description: "问候语言(zh/en)" })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
lang?: string;
|
||||
}
|
||||
27
templates/mcp/src/index.ts.hbs
Normal file
27
templates/mcp/src/index.ts.hbs
Normal file
@@ -0,0 +1,27 @@
|
||||
import { SpaceflowExtension, SpaceflowExtensionMetadata } from "spaceflow";
|
||||
import { {{pascalName}}Module } from "./{{kebabName}}.module";
|
||||
|
||||
/** {{pascalName}} Extension 元数据 */
|
||||
export const {{camelName}}Metadata: SpaceflowExtensionMetadata = {
|
||||
name: "{{kebabName}}",
|
||||
commands: [],
|
||||
configKey: "{{kebabName}}",
|
||||
version: "1.0.0",
|
||||
description: "{{name}} MCP 工具插件",
|
||||
};
|
||||
|
||||
export class {{pascalName}}Extension implements SpaceflowExtension {
|
||||
getMetadata(): SpaceflowExtensionMetadata {
|
||||
return {{camelName}}Metadata;
|
||||
}
|
||||
|
||||
getModule() {
|
||||
return {{pascalName}}Module;
|
||||
}
|
||||
}
|
||||
|
||||
export default {{pascalName}}Extension;
|
||||
|
||||
export * from "./{{kebabName}}.module";
|
||||
export * from "./{{kebabName}}.mcp";
|
||||
export * from "./{{kebabName}}.service";
|
||||
5
templates/mcp/tsconfig.json.hbs
Normal file
5
templates/mcp/tsconfig.json.hbs
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "../../core/tsconfig.skill.json",
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
8
templates/skills/README.md.hbs
Normal file
8
templates/skills/README.md.hbs
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
{{name}}
|
||||
|
||||
{{name}}
|
||||
技能插件 ## 目录结构 ```
|
||||
{{name}}/ ├── SKILL.md # 技能说明文件 ├── README.md # 详细文档 └── ... # 其他资源文件 ``` ## 安装
|
||||
```bash spaceflow install ./{{name}}
|
||||
```
|
||||
5
templates/skills/SKILL.md.hbs
Normal file
5
templates/skills/SKILL.md.hbs
Normal file
@@ -0,0 +1,5 @@
|
||||
#
|
||||
{{name}}
|
||||
|
||||
{{name}}
|
||||
技能插件 ## 说明 TODO: 添加技能说明 ## 使用方法 TODO: 添加使用说明
|
||||
Reference in New Issue
Block a user