@spaceflow/core 0.8.0 → 0.10.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.
- package/README.md +75 -56
- package/dist/index.js +5589 -970
- package/dist/index.js.map +1 -1
- package/package.json +9 -3
- package/src/cli-runtime/di/config.ts +157 -0
- package/src/cli-runtime/di/container.ts +120 -0
- package/src/cli-runtime/di/index.ts +3 -0
- package/src/cli-runtime/di/services.ts +53 -0
- package/src/cli-runtime/extension-loader.ts +74 -0
- package/src/{shared → cli-runtime}/i18n/index.ts +7 -1
- package/src/cli-runtime/i18n/init.ts +117 -0
- package/src/cli-runtime/index.ts +131 -0
- package/src/cli-runtime/internal-extensions.ts +33 -0
- package/src/commands/build/build.service.ts +323 -0
- package/src/commands/build/index.ts +49 -0
- package/src/commands/clear/clear.service.ts +159 -0
- package/src/commands/clear/index.ts +35 -0
- package/src/commands/commit/commit.config.ts +168 -0
- package/src/commands/commit/commit.service.ts +950 -0
- package/src/commands/commit/index.ts +58 -0
- package/src/commands/create/create.service.ts +318 -0
- package/src/commands/create/index.ts +42 -0
- package/src/commands/dev/index.ts +30 -0
- package/src/commands/install/index.ts +65 -0
- package/src/commands/install/install.service.ts +1539 -0
- package/src/commands/list/index.ts +33 -0
- package/src/commands/list/list.service.ts +127 -0
- package/src/commands/mcp/index.ts +37 -0
- package/src/commands/mcp/mcp.service.ts +246 -0
- package/src/commands/runx/index.ts +47 -0
- package/src/commands/runx/runx.service.ts +142 -0
- package/src/commands/runx/runx.utils.ts +83 -0
- package/src/commands/schema/index.ts +30 -0
- package/src/commands/setup/index.ts +34 -0
- package/src/commands/setup/setup.service.ts +234 -0
- package/src/commands/uninstall/index.ts +42 -0
- package/src/commands/uninstall/uninstall.service.ts +166 -0
- package/src/commands/update/index.ts +42 -0
- package/src/commands/update/update.service.ts +373 -0
- package/src/config/index.ts +1 -30
- package/src/config/spaceflow.config.ts +226 -278
- package/src/index.ts +11 -1
- package/src/locales/en/build.json +22 -0
- package/src/locales/en/clear.json +16 -0
- package/src/locales/en/commit.json +45 -0
- package/src/locales/en/create.json +27 -0
- package/src/locales/en/dev.json +5 -0
- package/src/locales/en/install.json +71 -0
- package/src/locales/en/list.json +8 -0
- package/src/locales/en/mcp.json +19 -0
- package/src/locales/en/runx.json +13 -0
- package/src/locales/en/schema.json +4 -0
- package/src/locales/en/setup.json +14 -0
- package/src/locales/en/uninstall.json +18 -0
- package/src/locales/en/update.json +28 -0
- package/src/locales/zh-cn/build.json +22 -0
- package/src/locales/zh-cn/clear.json +16 -0
- package/src/locales/zh-cn/commit.json +45 -0
- package/src/locales/zh-cn/create.json +27 -0
- package/src/locales/zh-cn/dev.json +5 -0
- package/src/locales/zh-cn/install.json +71 -0
- package/src/locales/zh-cn/list.json +8 -0
- package/src/locales/zh-cn/mcp.json +19 -0
- package/src/locales/zh-cn/runx.json +13 -0
- package/src/locales/zh-cn/schema.json +4 -0
- package/src/locales/zh-cn/setup.json +14 -0
- package/src/locales/zh-cn/uninstall.json +18 -0
- package/src/locales/zh-cn/update.json +28 -0
- package/src/shared/editor-config/index.ts +2 -21
- package/src/shared/llm-proxy/adapters/openai.adapter.ts +3 -1
- package/src/shared/package-manager/index.ts +5 -76
- package/src/shared/source-utils/index.ts +12 -130
- package/src/shared/spaceflow-dir/index.ts +13 -135
- package/src/shared/verbose/index.ts +10 -87
- package/dist/524.js +0 -9
- package/src/config/ci.config.ts +0 -29
- package/src/config/config-loader.ts +0 -100
- package/src/config/config-reader.service.ts +0 -128
- package/src/config/config-reader.ts +0 -75
- package/src/config/feishu.config.ts +0 -35
- package/src/config/git-provider.config.ts +0 -29
- package/src/config/llm.config.ts +0 -110
- package/src/config/load-env.ts +0 -15
- package/src/config/storage.config.ts +0 -33
- /package/src/{shared → cli-runtime}/i18n/i18n.spec.ts +0 -0
- /package/src/{shared → cli-runtime}/i18n/i18n.ts +0 -0
- /package/src/{shared → cli-runtime}/i18n/locale-detect.ts +0 -0
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@spaceflow/core)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
> Spaceflow
|
|
6
|
+
> Spaceflow 核心运行时,包含 CLI 运行时引擎、13 个内置命令、扩展系统和共享模块。
|
|
7
7
|
|
|
8
8
|
## 安装
|
|
9
9
|
|
|
@@ -11,71 +11,96 @@
|
|
|
11
11
|
pnpm add @spaceflow/core
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
##
|
|
14
|
+
## 核心职责
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
| `git-provider` | `@spaceflow/core` | Git 平台适配器(GitHub / Gitea / GitLab) |
|
|
21
|
-
| `git-sdk` | `@spaceflow/core` | Git 命令操作封装 |
|
|
22
|
-
| `llm-proxy` | `@spaceflow/core/llm-proxy` | 多 LLM 适配器(OpenAI、Claude、Gemini) |
|
|
23
|
-
| `llm-jsonput` | `@spaceflow/core/llm-jsonput` | LLM JSON 结构化输出 |
|
|
24
|
-
| `feishu-sdk` | `@spaceflow/core` | 飞书 API 操作封装 |
|
|
25
|
-
| `storage` | `@spaceflow/core` | 通用存储服务 |
|
|
26
|
-
| `logger` | `@spaceflow/core` | 日志系统(TUI / Plain 双模式) |
|
|
27
|
-
| `parallel` | `@spaceflow/core/parallel` | 并行执行工具 |
|
|
28
|
-
| `verbose` | `@spaceflow/core/verbose` | 日志级别控制 |
|
|
29
|
-
| `editor-config` | `@spaceflow/core/editor-config` | 编辑器配置管理 |
|
|
30
|
-
| `source-utils` | `@spaceflow/core/source-utils` | 源码工具 |
|
|
31
|
-
| `package-manager` | `@spaceflow/core/package-manager` | 包管理器抽象 |
|
|
32
|
-
| `rspack-config` | `@spaceflow/core/rspack-config` | Rspack 构建配置 |
|
|
16
|
+
- **CLI 运行时** — `exec()` 入口函数,初始化 i18n、ServiceContainer、ExtensionLoader,构建 Commander 命令树
|
|
17
|
+
- **13 个内置命令** — install、uninstall、build、dev、create、update、list、clear、runx、schema、commit、setup、mcp
|
|
18
|
+
- **扩展系统** — `defineExtension()` 纯函数式 API、类型定义(`ExtensionDefinition`、`CommandDefinition`、`SpaceflowContext`)
|
|
19
|
+
- **共享模块** — Git、LLM、Logger、Storage 等服务
|
|
33
20
|
|
|
34
21
|
## 快速上手
|
|
35
22
|
|
|
36
23
|
```typescript
|
|
24
|
+
// 扩展开发 — 使用 defineExtension 定义扩展
|
|
25
|
+
import { defineExtension, t } from "@spaceflow/core";
|
|
26
|
+
|
|
27
|
+
export default defineExtension({
|
|
28
|
+
name: "my-extension",
|
|
29
|
+
commands: [
|
|
30
|
+
{
|
|
31
|
+
name: "hello",
|
|
32
|
+
description: "Say hello",
|
|
33
|
+
run: async (args, options, ctx) => {
|
|
34
|
+
ctx.output.info("Hello from my extension!");
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// 共享模块 — 直接导入使用
|
|
37
43
|
import {
|
|
38
44
|
GitProviderService,
|
|
39
45
|
GitSdkService,
|
|
40
46
|
LlmProxyService,
|
|
41
47
|
FeishuSdkService,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// NestJS 重导出
|
|
46
|
-
Command,
|
|
47
|
-
CommandRunner,
|
|
48
|
-
Module,
|
|
49
|
-
Injectable,
|
|
48
|
+
LoggerService,
|
|
49
|
+
ParallelService,
|
|
50
50
|
} from "@spaceflow/core";
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
## 共享模块
|
|
54
|
+
|
|
55
|
+
| 模块 | 说明 |
|
|
56
|
+
| ------------ | ----------------------------------------- |
|
|
57
|
+
| Git Provider | Git 平台适配器(GitHub / Gitea / GitLab) |
|
|
58
|
+
| Git SDK | Git 命令操作封装 |
|
|
59
|
+
| LLM Proxy | 多 LLM 统一代理(OpenAI、Claude) |
|
|
60
|
+
| Logger | 日志系统(TUI / Plain 双模式) |
|
|
61
|
+
| Feishu SDK | 飞书 API 操作封装 |
|
|
62
|
+
| Storage | 通用存储服务(支持 TTL) |
|
|
63
|
+
| Parallel | 并行执行工具 |
|
|
64
|
+
| i18n | 国际化(i18next) |
|
|
65
|
+
|
|
53
66
|
## 目录结构
|
|
54
67
|
|
|
55
68
|
```text
|
|
56
69
|
core/
|
|
57
70
|
├── src/
|
|
71
|
+
│ ├── cli-runtime/ # CLI 运行时引擎
|
|
72
|
+
│ │ ├── exec.ts # exec() 入口
|
|
73
|
+
│ │ ├── service-container.ts # DI 容器
|
|
74
|
+
│ │ ├── extension-loader.ts # 扩展加载器
|
|
75
|
+
│ │ └── internal-extensions.ts # 内置扩展注册
|
|
76
|
+
│ ├── commands/ # 13 个内置命令
|
|
77
|
+
│ │ ├── build/
|
|
78
|
+
│ │ ├── clear/
|
|
79
|
+
│ │ ├── commit/
|
|
80
|
+
│ │ ├── create/
|
|
81
|
+
│ │ ├── dev/
|
|
82
|
+
│ │ ├── install/
|
|
83
|
+
│ │ ├── list/
|
|
84
|
+
│ │ ├── mcp/
|
|
85
|
+
│ │ ├── runx/
|
|
86
|
+
│ │ ├── schema/
|
|
87
|
+
│ │ ├── setup/
|
|
88
|
+
│ │ ├── uninstall/
|
|
89
|
+
│ │ └── update/
|
|
58
90
|
│ ├── config/ # 配置管理(Zod Schema)
|
|
59
91
|
│ ├── extension-system/ # 扩展系统核心
|
|
60
|
-
│ ├──
|
|
61
|
-
│ ├──
|
|
62
|
-
│ │
|
|
63
|
-
│
|
|
64
|
-
│
|
|
65
|
-
│
|
|
66
|
-
│
|
|
67
|
-
│
|
|
68
|
-
│
|
|
69
|
-
│
|
|
70
|
-
│
|
|
71
|
-
│
|
|
72
|
-
│ │ ├── verbose/ # 日志级别控制
|
|
73
|
-
│ │ ├── source-utils/ # 源码工具
|
|
74
|
-
│ │ ├── package-manager/ # 包管理器抽象
|
|
75
|
-
│ │ └── rspack-config/ # Rspack 构建配置
|
|
76
|
-
│ ├── app.module.ts # NestJS 根模块
|
|
77
|
-
│ └── index.ts # 库导出入口
|
|
78
|
-
└── test/ # E2E 测试
|
|
92
|
+
│ │ ├── types.ts # ExtensionDefinition 等类型
|
|
93
|
+
│ │ ├── define-extension.ts # defineExtension 工厂函数
|
|
94
|
+
│ │ └── extension.interface.ts # package.json spaceflow 字段解析
|
|
95
|
+
│ ├── locales/ # 国际化资源(en + zh-cn)
|
|
96
|
+
│ └── shared/ # 共享模块
|
|
97
|
+
│ ├── git-provider/ # Git 平台适配器
|
|
98
|
+
│ ├── git-sdk/ # Git 命令封装
|
|
99
|
+
│ ├── llm-proxy/ # LLM 统一代理
|
|
100
|
+
│ ├── feishu-sdk/ # 飞书 SDK
|
|
101
|
+
│ ├── logger/ # 日志系统(TUI/Plain)
|
|
102
|
+
│ ├── parallel/ # 并行执行工具
|
|
103
|
+
│ └── storage/ # 通用存储服务
|
|
79
104
|
```
|
|
80
105
|
|
|
81
106
|
## 开发
|
|
@@ -84,20 +109,14 @@ core/
|
|
|
84
109
|
# 构建
|
|
85
110
|
pnpm run build
|
|
86
111
|
|
|
87
|
-
#
|
|
88
|
-
pnpm run
|
|
89
|
-
|
|
90
|
-
# 代码检查
|
|
91
|
-
pnpm run lint
|
|
92
|
-
|
|
93
|
-
# 代码格式化
|
|
94
|
-
pnpm run format
|
|
112
|
+
# 类型检查
|
|
113
|
+
pnpm run type-check
|
|
95
114
|
```
|
|
96
115
|
|
|
97
116
|
## 技术栈
|
|
98
117
|
|
|
99
|
-
- **
|
|
100
|
-
- **
|
|
118
|
+
- **Commander.js** — CLI 命令框架
|
|
119
|
+
- **ServiceContainer** — 自定义 DI 容器
|
|
101
120
|
- **Rspack** — 构建工具
|
|
102
121
|
- **i18next** — 国际化
|
|
103
122
|
- **Zod** — 配置校验
|