@spaceflow/core 0.10.0 → 0.11.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/package.json
CHANGED
package/src/cli-runtime/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
declare const __CORE_VERSION__: string;
|
|
2
|
+
|
|
1
3
|
import { Command } from "commander";
|
|
2
4
|
import type { ExtensionDefinition } from "@spaceflow/core";
|
|
3
5
|
import { ServiceContainer, initializeContainer } from "./di";
|
|
@@ -16,7 +18,14 @@ export { internalExtensions } from "./internal-extensions";
|
|
|
16
18
|
*
|
|
17
19
|
* @param extensions 外部扩展定义列表(来自 .spaceflow/bin/index.js 的静态导入)
|
|
18
20
|
*/
|
|
19
|
-
export
|
|
21
|
+
export interface ExecOptions {
|
|
22
|
+
cliVersion?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function exec(
|
|
26
|
+
extensions: ExtensionDefinition[] = [],
|
|
27
|
+
options: ExecOptions = {},
|
|
28
|
+
): Promise<void> {
|
|
20
29
|
// 1. 初始化 i18n(如果尚未初始化,由生成的 bin/index.js 提前调用)
|
|
21
30
|
initCliI18n();
|
|
22
31
|
|
|
@@ -40,7 +49,14 @@ export async function exec(extensions: ExtensionDefinition[] = []): Promise<void
|
|
|
40
49
|
|
|
41
50
|
// 6. 创建 CLI 程序
|
|
42
51
|
const program = new Command();
|
|
43
|
-
|
|
52
|
+
const cliVersion = options.cliVersion || "0.0.0";
|
|
53
|
+
const coreVersion = typeof __CORE_VERSION__ !== "undefined" ? __CORE_VERSION__ : "0.0.0";
|
|
54
|
+
const versionOutput = `spaceflow/${cliVersion} core/${coreVersion}`;
|
|
55
|
+
|
|
56
|
+
program
|
|
57
|
+
.name("spaceflow")
|
|
58
|
+
.description("Spaceflow CLI")
|
|
59
|
+
.version(versionOutput, "-V, --version", "显示版本信息");
|
|
44
60
|
|
|
45
61
|
// 定义全局 verbose 选项(支持计数:-v, -vv, -vvv)
|
|
46
62
|
program.option(
|
|
@@ -21,6 +21,11 @@ export class McpService {
|
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
if (shouldLog(verbose, 1)) {
|
|
24
|
+
const cwd = process.env.SPACEFLOW_CWD || process.cwd();
|
|
25
|
+
console.error(t("mcp:cwdInfo", { cwd }));
|
|
26
|
+
if (!process.env.SPACEFLOW_CWD) {
|
|
27
|
+
console.error(t("mcp:cwdEnvHint"));
|
|
28
|
+
}
|
|
24
29
|
console.error(t("mcp:scanning"));
|
|
25
30
|
}
|
|
26
31
|
|
package/src/locales/en/mcp.json
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
"inspectorDebugCmd": " Debug command: pnpm space mcp",
|
|
6
6
|
"inspectorFailed": "❌ Failed to start MCP Inspector: {{error}}",
|
|
7
7
|
"extensionDescription": "Start MCP Server with all installed extension tools",
|
|
8
|
+
"cwdInfo": "📂 Working directory: {{cwd}}",
|
|
9
|
+
"cwdEnvHint": " 💡 Set SPACEFLOW_CWD environment variable to specify workspace path",
|
|
8
10
|
"scanning": "🔍 Scanning installed extensions...",
|
|
9
11
|
"foundExtensions": " Found {{count}} extensions",
|
|
10
12
|
"checkingExport": " Checking {{key}}: __mcp_server__={{hasMcpServer}}",
|
|
@@ -12,8 +14,8 @@
|
|
|
12
14
|
"containerFailed": " ⚠️ Failed to get {{key}} from container: {{error}}",
|
|
13
15
|
"loadToolsFailed": " ⚠️ {{name}}: Failed to load MCP tools",
|
|
14
16
|
"noToolsFound": "❌ No MCP tools found",
|
|
15
|
-
"noToolsHint": " Hint: Make sure you have installed MCP-enabled extensions that export mcpService or getMcpTools",
|
|
17
|
+
"noToolsHint": " Hint: Make sure you have installed MCP-enabled extensions that export mcpService or getMcpTools\n If the working directory is incorrect, set the environment variable in your MCP config:\n \"env\": { \"SPACEFLOW_CWD\": \"/path/to/your/project\" }",
|
|
16
18
|
"toolsFound": "✅ Found {{count}} MCP tools",
|
|
17
|
-
"ttyHint": "💡 MCP Server must be started by an MCP client (e.g. Cursor, Claude Desktop) via pipe.\n Add the following config to your MCP client:\n\n \"spaceflow\": {\n \"command\": \"
|
|
19
|
+
"ttyHint": "💡 MCP Server must be started by an MCP client (e.g. Cursor, Claude Desktop) via pipe.\n Add the following config to your MCP client:\n\n \"spaceflow\": {\n \"command\": \"npx\",\n \"args\": [\"@spaceflow/cli\", \"mcp\"],\n \"env\": { \"SPACEFLOW_CWD\": \"/path/to/your/project\" }\n }",
|
|
18
20
|
"serverStarted": "🚀 MCP Server started with {{count}} tools"
|
|
19
21
|
}
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
"inspectorDebugCmd": " 调试命令: pnpm space mcp",
|
|
6
6
|
"inspectorFailed": "❌ 启动 MCP Inspector 失败: {{error}}",
|
|
7
7
|
"extensionDescription": "启动 MCP Server,提供所有已安装扩展的 MCP 工具",
|
|
8
|
+
"cwdInfo": "📂 工作目录: {{cwd}}",
|
|
9
|
+
"cwdEnvHint": " 💡 可通过环境变量 SPACEFLOW_CWD 指定工作区路径",
|
|
8
10
|
"scanning": "🔍 扫描已安装的扩展...",
|
|
9
11
|
"foundExtensions": " 发现 {{count}} 个扩展",
|
|
10
12
|
"checkingExport": " 检查 {{key}}: __mcp_server__={{hasMcpServer}}",
|
|
@@ -12,8 +14,8 @@
|
|
|
12
14
|
"containerFailed": " ⚠️ 从容器获取 {{key}} 失败: {{error}}",
|
|
13
15
|
"loadToolsFailed": " ⚠️ {{name}}: 加载 MCP 工具失败",
|
|
14
16
|
"noToolsFound": "❌ 没有找到任何 MCP 工具",
|
|
15
|
-
"noToolsHint": " 提示: 确保已安装支持 MCP 的扩展,并导出 mcpService 或 getMcpTools",
|
|
17
|
+
"noToolsHint": " 提示: 确保已安装支持 MCP 的扩展,并导出 mcpService 或 getMcpTools\n 如果工作目录不正确,请在 MCP 配置中设置环境变量:\n \"env\": { \"SPACEFLOW_CWD\": \"/path/to/your/project\" }",
|
|
16
18
|
"toolsFound": "✅ 共发现 {{count}} 个 MCP 工具",
|
|
17
|
-
"ttyHint": "💡 MCP Server 需要由 MCP 客户端(如 Cursor、Claude Desktop)通过管道启动。\n 请将以下配置添加到你的 MCP 客户端中:\n\n \"spaceflow\": {\n \"command\": \"
|
|
19
|
+
"ttyHint": "💡 MCP Server 需要由 MCP 客户端(如 Cursor、Claude Desktop)通过管道启动。\n 请将以下配置添加到你的 MCP 客户端中:\n\n \"spaceflow\": {\n \"command\": \"npx\",\n \"args\": [\"@spaceflow/cli\", \"mcp\"],\n \"env\": { \"SPACEFLOW_CWD\": \"/path/to/your/project\" }\n }",
|
|
18
20
|
"serverStarted": "🚀 MCP Server 已启动,共 {{count}} 个工具"
|
|
19
21
|
}
|