staff-mcp 1.0.5 → 1.0.7

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.
Files changed (63) hide show
  1. package/README.md +66 -78
  2. package/README_zh.md +70 -80
  3. package/dist/src/index.js +104 -2
  4. package/dist/src/index.js.map +1 -1
  5. package/dist/src/server.d.ts +2 -1
  6. package/dist/src/server.js +4 -3
  7. package/dist/src/server.js.map +1 -1
  8. package/dist/src/{tools/skill-manager.d.ts → skills/manager.d.ts} +2 -3
  9. package/dist/src/{tools/skill-manager.js → skills/manager.js} +9 -26
  10. package/dist/src/skills/manager.js.map +1 -0
  11. package/dist/src/skills/resolver.d.ts +12 -0
  12. package/dist/src/skills/resolver.js +50 -0
  13. package/dist/src/skills/resolver.js.map +1 -0
  14. package/dist/src/tools/shell-tools.js +56 -8
  15. package/dist/src/tools/shell-tools.js.map +1 -1
  16. package/dist/src/tools/{skill-tools.d.ts → skills.d.ts} +1 -1
  17. package/dist/src/tools/skills.js +207 -0
  18. package/dist/src/tools/skills.js.map +1 -0
  19. package/dist/src/tools/system-tools.js +13 -1
  20. package/dist/src/tools/system-tools.js.map +1 -1
  21. package/dist/src/utils/paths.d.ts +2 -0
  22. package/dist/src/utils/paths.js +3 -1
  23. package/dist/src/utils/paths.js.map +1 -1
  24. package/package.json +1 -1
  25. package/dist/constants.d.ts +0 -2
  26. package/dist/constants.js +0 -3
  27. package/dist/constants.js.map +0 -1
  28. package/dist/index.d.ts +0 -1
  29. package/dist/index.js +0 -26
  30. package/dist/index.js.map +0 -1
  31. package/dist/security.d.ts +0 -16
  32. package/dist/security.js +0 -43
  33. package/dist/security.js.map +0 -1
  34. package/dist/server.d.ts +0 -9
  35. package/dist/server.js +0 -25
  36. package/dist/server.js.map +0 -1
  37. package/dist/src/test_dummy.d.ts +0 -1
  38. package/dist/src/test_dummy.js +0 -6
  39. package/dist/src/test_dummy.js.map +0 -1
  40. package/dist/src/test_lsp.d.ts +0 -1
  41. package/dist/src/test_lsp.js +0 -4
  42. package/dist/src/test_lsp.js.map +0 -1
  43. package/dist/src/tools/skill-manager.js.map +0 -1
  44. package/dist/src/tools/skill-tools.js +0 -117
  45. package/dist/src/tools/skill-tools.js.map +0 -1
  46. package/dist/tests/system-tools.test.d.ts +0 -1
  47. package/dist/tests/system-tools.test.js +0 -26
  48. package/dist/tests/system-tools.test.js.map +0 -1
  49. package/dist/tools/file-tools.d.ts +0 -6
  50. package/dist/tools/file-tools.js +0 -102
  51. package/dist/tools/file-tools.js.map +0 -1
  52. package/dist/tools/lsp-tools.d.ts +0 -6
  53. package/dist/tools/lsp-tools.js +0 -70
  54. package/dist/tools/lsp-tools.js.map +0 -1
  55. package/dist/tools/shell-tools.d.ts +0 -6
  56. package/dist/tools/shell-tools.js +0 -39
  57. package/dist/tools/shell-tools.js.map +0 -1
  58. package/dist/transports/http.d.ts +0 -5
  59. package/dist/transports/http.js +0 -58
  60. package/dist/transports/http.js.map +0 -1
  61. package/dist/transports/stdio.d.ts +0 -2
  62. package/dist/transports/stdio.js +0 -18
  63. package/dist/transports/stdio.js.map +0 -1
package/README.md CHANGED
@@ -2,26 +2,32 @@
2
2
 
3
3
  [English](./README.md) | [简体中文](./README_zh.md)
4
4
 
5
- A robust Model Context Protocol (MCP) server that provides AI assistants with a secure, cross-platform environment for file management, shell execution, and LSP-powered code intelligence.
5
+ A next-generation Model Context Protocol (MCP) server that transforms any AI assistant into a highly capable, container-aware, and role-adaptable digital employee.
6
6
 
7
- ---
8
-
9
- ## 🚀 Usage
10
-
11
- Use this section if you want to run the published package.
7
+ It provides secure file management, shell execution, LSP-powered code intelligence, a 5-tier Skill & Profile ecosystem, and a revolutionary **Docker Transparent Proxy Mode**.
12
8
 
13
- ### Run with npx
9
+ ---
14
10
 
15
- Recommended command:
11
+ ## 🚀 Quick Start
16
12
 
13
+ ### 1. Standard Host Mode
14
+ Run directly on your physical machine or virtual environment.
17
15
  ```bash
18
16
  npx -y staff-mcp@latest --working-dir /path/to/your/project
19
17
  ```
20
18
 
21
- Using `@latest` is the safest option for a published CLI package and avoids resolution issues such as `could not determine executable to run`.
19
+ ### 2. Docker Transparent Proxy Mode (Cyber-Shell)
20
+ Seamlessly spawn the AI assistant **inside any Docker container** while keeping the protocol connection with the host. It mounts your project and the `staff-mcp` binary automatically—zero overhead, instant startup!
21
+
22
+ ```bash
23
+ # Debug a Node.js project inside a pure Alpine container
24
+ npx -y staff-mcp@latest --docker node:20-alpine
22
25
 
23
- ### Configure for Claude Desktop
26
+ # Perform security analysis inside a custom reverse-engineering image
27
+ npx -y staff-mcp@latest --docker reverse-engineer:v3 --profile reverse-engineer
28
+ ```
24
29
 
30
+ ### 3. Claude Desktop Configuration
25
31
  Add the following to your `claude_desktop_config.json`:
26
32
 
27
33
  ```json
@@ -40,92 +46,74 @@ Add the following to your `claude_desktop_config.json`:
40
46
  }
41
47
  ```
42
48
 
43
- ### CLI Arguments
44
-
45
- | Option | Description | Default |
46
- | :--- | :--- | :--- |
47
- | `--working-dir` | Root directory for the sandbox | `process.cwd()` |
48
- | `--allowed-dir` | Extra directories allowed for access | `[]` |
49
- | `--transport` | Transport type (`stdio` or `http`) | `stdio` |
50
- | `--port` | Port for HTTP server (if using http) | `3000` |
51
-
52
- ### Skill Loading
53
-
54
- `staff-mcp` can work with skill directories if they already exist in your workspace or home directory. To use them, place skill files in any supported location such as:
55
-
56
- - `.staff/skills/<skill-name>/SKILL.md`
57
- - `.claude/skills/<skill-name>/SKILL.md`
58
- - `.agents/skills/<skill-name>/SKILL.md`
59
- - `.opencode/skills/<skill-name>/SKILL.md`
60
-
61
- The server discovers them automatically at startup.
62
-
63
49
  ---
64
50
 
65
- ## 🛠️ Core Features
51
+ ## 🛠️ Core Capabilities
66
52
 
67
- - **File Operations**: Secure read, write, delete, and list operations within the sandbox.
68
- - **Shell Integration**: Execute non-interactive commands or start background tasks (e.g., dev servers).
69
- - **Code Intelligence**: LSP-based symbol extraction and diagnostics for better code understanding.
70
- - **Skill System**: Automatically detects and loads domain-specific instructions from `.staff/skills/`, `.claude/skills/`, and `.agents/skills/`.
71
- - **Environment Awareness**: Native support for Windows (CMD/PowerShell) and Unix-like (Bash/Sh) systems.
53
+ ### 1. Seamless Containerization (`--docker`)
54
+ Never pollute your host machine again. By simply appending `--docker <image>`, `staff-mcp`:
55
+ - Instantly injects itself into the container via read-only bind mounts (no `npm install` inside the container).
56
+ - Automatically translates Windows/Mac paths to Linux container paths.
57
+ - Provides a `--docker-args` backdoor for hardware pass-through (e.g., ADB USB debugging, GPUs, host network).
72
58
 
73
- ### Adding Skills
59
+ ### 2. Skill & Profile Ecosystem (`--profile`)
60
+ `staff-mcp` acts as an "AI Workspace Configurator". It uses a **5-tier Cascade Resolution** architecture to load role-specific skills (SOPs & Prompts) dynamically:
61
+ 1. **Project Level**: \`<cwd>/.staff/skills\` (Highest priority)
62
+ 2. **Project Profile Level**: \`<cwd>/.staff/profiles/<profile>/skills\`
63
+ 3. **Global Profile Level**: \`~/.staff/profiles/<profile>/skills\`
64
+ 4. **Global Level**: \`~/.staff/skills\`
65
+ 5. **Built-in Infrastructure**: \`staff-mcp/builtin-profiles\` (e.g., the built-in \`skill-manager\`)
74
66
 
75
- Create a `SKILL.md` file in `.staff/skills/your-skill/`:
76
-
77
- ```markdown
78
- ---
79
- name: my-skill
80
- description: Custom logic for my project
81
- ---
82
- Add your domain-specific instructions or workflows here.
67
+ Switch roles on the fly:
68
+ ```bash
69
+ npx -y staff-mcp@latest --profile developer
70
+ npx -y staff-mcp@latest --profile reverse-engineer
83
71
  ```
84
72
 
85
- ---
86
-
87
- ## 🧪 Development
88
-
89
- Use this section only if you want to work on the repository itself.
73
+ ### 3. Built-in `skill-manager`
74
+ Out of the box, the AI assistant knows how to manage its own skills! You can simply ask it to:
75
+ > *"Install the official Anthropic canvas-design skill into my project."*
76
+ It will securely download, configure, and reload the skill without you lifting a finger.
90
77
 
91
- ### Local setup
78
+ ### 4. Advanced Shell & Code Intelligence
79
+ - **Intelligent Shell Execution**: Auto-detects and upgrades to `/bin/bash` if available, supporting complex pipelines and background tasks (e.g., starting dev servers and tailing logs).
80
+ - **LSP Integration**: Extract symbols, get diagnostics, go to definitions, and find references for TypeScript, Python, and more.
81
+ - **Secure Sandbox**: Strictly confines the AI to the specified working directory and user-defined allowed paths.
92
82
 
93
- ```bash
94
- git clone https://github.com/your-username/staff-mcp.git
95
- cd staff-mcp
96
- npm install
97
- npm run build
98
- ```
99
-
100
- ### Run the local build
83
+ ---
101
84
 
102
- ```bash
103
- node dist/src/index.js --working-dir ./test-workspace
104
- ```
85
+ ## 🎛️ CLI Arguments
105
86
 
106
- ### Run with npm scripts
87
+ | Option | Description | Default |
88
+ | :--- | :--- | :--- |
89
+ | `-w, --working-dir` | Root directory for the sandbox | `process.cwd()` |
90
+ | `-d, --allowed-dir` | Extra directories allowed for access | `[]` |
91
+ | `-r, --profile` | The active profile for skills (e.g., developer) | `default` |
92
+ | `--docker` | Run inside a Docker container using this image | `undefined` |
93
+ | `-D, --docker-args` | Extra args for `docker run` (e.g., `-e FOO=BAR`) | `[]` |
94
+ | `-t, --transport` | Transport type (`stdio` or `http`) | `stdio` |
95
+ | `-p, --port` | Port for HTTP server | `3000` |
96
+ | `-h, --host` | Host for HTTP server | `127.0.0.1` |
97
+
98
+ ### Hardware Pass-through Example (Android Reverse Engineering)
99
+ If you need the AI to interact with an Android device connected via USB while running inside a container, utilizing network-based ADB pass-through is the most reliable cross-platform solution:
107
100
 
108
101
  ```bash
109
- npm start -- --working-dir ./test-workspace
110
- npm run dev -- --working-dir ./test-workspace
111
- ```
102
+ # 1. Start ADB Server on the host machine listening on all interfaces:
103
+ # adb kill-server && adb -a nodaemon server start
112
104
 
113
- ## Testing
105
+ # 2. Start staff-mcp with the ADB_SERVER_SOCKET environment variable injected
106
+ # On Mac/Windows:
107
+ npx -y staff-mcp@latest --docker reverse-engineer:v1 -D "-e ADB_SERVER_SOCKET=tcp:host.docker.internal:5037"
114
108
 
115
- Examples for verifying the package behavior separately from normal usage:
109
+ # On Native Linux (If not using --network host, point to the docker bridge IP):
110
+ npx -y staff-mcp@latest --docker reverse-engineer:v1 -D "-e ADB_SERVER_SOCKET=tcp:172.17.0.1:5037"
116
111
 
117
- ### Verify the published package
118
-
119
- ```bash
120
- npx -y staff-mcp@latest --working-dir /tmp
112
+ # Alternative for Native Linux (Share host network stack completely):
113
+ npx -y staff-mcp@latest --docker reverse-engineer:v1 -D "--network host"
121
114
  ```
122
115
 
123
- ### Verify the local build
124
-
125
- ```bash
126
- npm run build
127
- node dist/src/index.js --working-dir /tmp
128
- ```
116
+ ---
129
117
 
130
118
  ## 📄 License
131
119
 
package/README_zh.md CHANGED
@@ -2,27 +2,33 @@
2
2
 
3
3
  [English](./README.md) | [简体中文](./README_zh.md)
4
4
 
5
- 一个稳健的 Model Context Protocol (MCP) 服务端,为 AI 助手提供安全、跨平台的文件管理、Shell 执行和基于 LSP 的代码智能环境。
5
+ 新一代模型上下文协议 (MCP) 服务器,它将普通的 AI 助手转变为一位极具能力的、支持容器化和按角色动态适配的“数字员工”。
6
6
 
7
- ---
8
-
9
- ## 🚀 使用
10
-
11
- 这一节用于说明如何直接使用已发布的包,而不是如何开发或测试这个仓库。
7
+ 内置安全的文件管理、终端执行、基于 LSP 的代码理解能力,以及创新的 **5 级技能与档案生态系统 (Skill & Profile)** 和革命性的 **Docker 透明代理模式**。
12
8
 
13
- ### 使用 npx 运行
9
+ ---
14
10
 
15
- 推荐命令:
11
+ ## 🚀 快速开始
16
12
 
13
+ ### 1. 标准宿主机模式
14
+ 直接在物理机或虚拟环境中运行。
17
15
  ```bash
18
- npx -y staff-mcp@latest --working-dir /你的项目/路径
16
+ npx -y staff-mcp@latest --working-dir /path/to/your/project
19
17
  ```
20
18
 
21
- 对于已发布的 CLI 包,显式使用 `@latest` 更稳妥,也可以避免类似 `could not determine executable to run` 的解析问题。
19
+ ### 2. Docker 透明代理模式 (Cyber-Shell)
20
+ 以“零侵入”的方式,将 AI 助手瞬间无缝注入到**任意 Docker 容器**中,同时保持与宿主机客户端的协议连接!底层自动挂载你的项目和 `staff-mcp` 程序包——无需 `npm install`,瞬间启动!
22
21
 
23
- ### 在 Claude Desktop 中配置
22
+ ```bash
23
+ # 在一个纯净的 Alpine Node 容器里调试你的代码
24
+ npx -y staff-mcp@latest --docker node:20-alpine
24
25
 
25
- 将以下内容添加到你的 `claude_desktop_config.json` 文件中:
26
+ # 在自带逆向工程工具链的镜像里执行安全分析
27
+ npx -y staff-mcp@latest --docker reverse-engineer:v3 --profile reverse-engineer
28
+ ```
29
+
30
+ ### 3. Claude Desktop 配置
31
+ 将以下内容添加到你的 `claude_desktop_config.json`:
26
32
 
27
33
  ```json
28
34
  {
@@ -33,98 +39,82 @@ npx -y staff-mcp@latest --working-dir /你的项目/路径
33
39
  "-y",
34
40
  "staff-mcp@latest",
35
41
  "--working-dir",
36
- "/你的项目/路径"
42
+ "/path/to/your/project"
37
43
  ]
38
44
  }
39
45
  }
40
46
  }
41
47
  ```
42
48
 
43
- ### 命令行参数
44
-
45
- | 参数 | 说明 | 默认值 |
46
- | :--- | :--- | :--- |
47
- | `--working-dir` | 沙箱根目录 | `process.cwd()` |
48
- | `--allowed-dir` | 额外允许访问的目录 | `[]` |
49
- | `--transport` | 传输方式 (`stdio` 或 `http`) | `stdio` |
50
- | `--port` | HTTP 服务端口 (如果使用 http 模式) | `3000` |
51
-
52
- ### Skill 加载方式
53
-
54
- 如果你的工作区或用户目录里已经存在 skill 目录,`staff-mcp` 会在启动时自动发现并加载。可用目录示例:
55
-
56
- - `.staff/skills/<skill-name>/SKILL.md`
57
- - `.claude/skills/<skill-name>/SKILL.md`
58
- - `.agents/skills/<skill-name>/SKILL.md`
59
- - `.opencode/skills/<skill-name>/SKILL.md`
60
-
61
49
  ---
62
50
 
63
- ## 🛠️ 核心特性
51
+ ## 🛠️ 核心能力
64
52
 
65
- - **文件操作**: 在沙箱范围内提供安全的读、写、删除和列表操作。
66
- - **Shell 集成**: 执行非交互式命令或启动后台任务(如开发服务器)。
67
- - **代码智能**: 基于 LSP 的符号提取和诊断,帮助 AI 更好地理解代码结构。
68
- - **技能系统 (Skills)**: 自动检测并加载 `.staff/skills/`、`.claude/skills/` `.agents/skills/` 目录下的领域特定指令。
69
- - **环境感知**: 原生支持 Windows (CMD/PowerShell) Unix-like (Bash/Sh) 系统。
53
+ ### 1. 无缝容器化支持 (`--docker`)
54
+ 告别污染宿主机的时代。只要加上 `--docker <image>`,`staff-mcp` 将会:
55
+ - 通过只读挂载 (`read-only bind mounts`) 瞬间注入容器(无需网络重下)。
56
+ - 自动处理 Windows/Mac Linux 容器之间的路径转换问题。
57
+ - 提供 `--docker-args` 硬件透传后门(如 ADB USB 调试、GPU 计算、宿主机网络)。
70
58
 
71
- ### 如何添加技能
59
+ ### 2. 技能与工种生态系统 (`--profile`)
60
+ `staff-mcp` 充当了“AI 工位配置器”的角色。它采用 **5 级级联寻址架构 (Cascade Resolution)** 动态加载角色专属的技能包 (SOP 与提示词):
61
+ 1. **项目级 (最高优)**:\`<cwd>/.staff/skills\`
62
+ 2. **项目级角色层**:\`<cwd>/.staff/profiles/<profile>/skills\`
63
+ 3. **全局级角色层**:\`~/.staff/profiles/<profile>/skills\`
64
+ 4. **全局级默认层**:\`~/.staff/skills\`
65
+ 5. **内置基建层**:\`staff-mcp/builtin-profiles\` (如系统自带的 \`skill-manager\`)
72
66
 
73
- 在 `.staff/skills/your-skill/` 目录下创建一个 `SKILL.md` 文件:
74
-
75
- ```markdown
76
- ---
77
- name: my-skill
78
- description: 我的项目专属逻辑
79
- ---
80
- 在此处添加你的领域特定指令或工作流。
67
+ 在不同角色中自由切换:
68
+ ```bash
69
+ npx -y staff-mcp@latest --profile developer
70
+ npx -y staff-mcp@latest --profile reverse-engineer
81
71
  ```
82
72
 
83
- ---
84
-
85
- ## 🧪 开发
86
-
87
- 这一节只面向要修改仓库源码的开发者。
73
+ ### 3. 聪明的“技能管家” (`skill-manager`)
74
+ 系统内置了基础设施技能,AI 助手生来就知道如何管理自己!你可以直接对它说:
75
+ > *"请帮我把 Anthropic 官方的 canvas-design 技能安装到当前项目里。"*
76
+ 它会自动帮你下载、配置并热更新技能文件,全程不需要你动手。
88
77
 
89
- ### 本地准备
78
+ ### 4. 增强的终端与代码智能
79
+ - **智能终端执行**:自动检测并在支持的环境中升级为 `/bin/bash`,完美支持复杂的管道命令、后台守护进程 (如开发服务器) 及日志持续读取。
80
+ - **LSP 深度集成**:支持提取符号 (Symbols)、获取诊断信息 (Diagnostics)、跳转定义 (Definition) 和查找引用 (References),大幅提升 AI 理解 TypeScript/Python 等代码的能力。
81
+ - **沙盒安全**:将 AI 严格限制在你指定的工作区和允许的目录内,对全局破坏“零容忍”。
90
82
 
91
- ```bash
92
- git clone https://github.com/your-username/staff-mcp.git
93
- cd staff-mcp
94
- npm install
95
- npm run build
96
- ```
97
-
98
- ### 运行本地构建产物
83
+ ---
99
84
 
100
- ```bash
101
- node dist/src/index.js --working-dir ./test-workspace
102
- ```
85
+ ## 🎛️ CLI 参数说明
103
86
 
104
- ### 使用 npm 脚本运行
87
+ | 选项 | 描述 | 默认值 |
88
+ | :--- | :--- | :--- |
89
+ | `-w, --working-dir` | 沙盒的根目录 (工作区) | `process.cwd()` |
90
+ | `-d, --allowed-dir` | 额外允许 AI 访问的宿主机目录 | `[]` |
91
+ | `-r, --profile` | 当前激活的技能档案/工种 (如 developer) | `default` |
92
+ | `--docker` | 在指定的 Docker 镜像内运行 AI | `undefined` |
93
+ | `-D, --docker-args` | 传递给 `docker run` 的自定义底层参数 | `[]` |
94
+ | `-t, --transport` | 传输协议 (`stdio` 或 `http`) | `stdio` |
95
+ | `-p, --port` | HTTP 服务的监听端口 | `3000` |
96
+ | `-h, --host` | HTTP 服务的监听地址 | `127.0.0.1` |
97
+
98
+ ### 硬件透传案例 (Android 移动端逆向)
99
+ 如果你希望 AI 在容器内运行时,仍能连接并控制物理机上的 Android 手机,利用基于网络端口的 ADB 透传是最稳妥的跨平台方案:
105
100
 
106
101
  ```bash
107
- npm start -- --working-dir ./test-workspace
108
- npm run dev -- --working-dir ./test-workspace
109
- ```
102
+ # 1. 首先在物理机上启动 ADB Server,允许所有网卡连接:
103
+ # adb kill-server && adb -a nodaemon server start
110
104
 
111
- ## 测试
105
+ # 2. 启动 staff-mcp 并注入 ADB_SERVER_SOCKET 环境变量
106
+ # Mac/Win 环境下:
107
+ npx -y staff-mcp@latest --docker reverse-engineer:v1 -D "-e ADB_SERVER_SOCKET=tcp:host.docker.internal:5037"
112
108
 
113
- 这一节单独用于说明如何验证包是否可用,而不是日常使用方式。
109
+ # 原生 Linux 环境下(若不使用 host 网络,可指向虚拟桥接 IP):
110
+ npx -y staff-mcp@latest --docker reverse-engineer:v1 -D "-e ADB_SERVER_SOCKET=tcp:172.17.0.1:5037"
114
111
 
115
- ### 验证已发布包
116
-
117
- ```bash
118
- npx -y staff-mcp@latest --working-dir /tmp
112
+ # 原生 Linux 的极简方案(直接与物理机共享网络栈):
113
+ npx -y staff-mcp@latest --docker reverse-engineer:v1 -D "--network host"
119
114
  ```
120
115
 
121
- ### 验证本地构建
122
-
123
- ```bash
124
- npm run build
125
- node dist/src/index.js --working-dir /tmp
126
- ```
116
+ ---
127
117
 
128
- ## 📄 开源协议
118
+ ## 📄 License
129
119
 
130
120
  MIT
package/dist/src/index.js CHANGED
@@ -1,10 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
3
  import * as path from "path";
4
+ import * as fs from "fs";
5
+ import * as os from "os";
6
+ import { spawn } from "child_process";
7
+ import { fileURLToPath } from "url";
4
8
  import { createServer } from "./server.js";
5
9
  import { startStdioServer } from "./transports/stdio.js";
6
10
  import { startHttpServer } from "./transports/http.js";
7
11
  import { ensureStaffDirs } from "./utils/paths.js";
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
8
14
  const program = new Command();
9
15
  program
10
16
  .name("staff-mcp")
@@ -15,11 +21,107 @@ program
15
21
  .option("-h, --host <address>", "Host for HTTP server", "127.0.0.1")
16
22
  .option("-w, --working-dir <path>", "Working directory for the server (defaults to current execution path)", process.cwd())
17
23
  .option("-d, --allowed-dir <paths...>", "Additional directories allowed for sandbox", [])
18
- .action(async (options) => {
24
+ .option("-r, --profile <name>", "The active profile for skills and instructions (e.g., developer, default)", "default")
25
+ .option("--docker <image>", "Run the MCP server inside a Docker container using the specified image")
26
+ .option("-D, --docker-args <args...>", "Additional arguments to pass to the docker run command (e.g., -e ADB_SERVER_SOCKET=...)")
27
+ .allowUnknownOption()
28
+ .action(async (options, command) => {
29
+ // -------------------------------------------------------------
30
+ // Docker Transparent Proxy Mode
31
+ // -------------------------------------------------------------
32
+ if (options.docker) {
33
+ // 1. Locate the package root (where package.json is)
34
+ let pkgRoot = path.resolve(__dirname, "..");
35
+ while (!fs.existsSync(path.join(pkgRoot, "package.json")) && pkgRoot !== "/") {
36
+ pkgRoot = path.dirname(pkgRoot);
37
+ }
38
+ // 2. Cross-platform path normalizer for Volume Mounts
39
+ const toDockerVolumePath = (p) => {
40
+ if (os.platform() === "win32") {
41
+ return p.replace(/^([a-zA-Z]):/, (_, drive) => `/${drive.toLowerCase()}`).replace(/\\/g, "/");
42
+ }
43
+ return p;
44
+ };
45
+ const hostCwd = path.resolve(options.workingDir);
46
+ const dockerArgs = ["run", "-i", "--rm"];
47
+ // 3. Mount working directory and package source
48
+ dockerArgs.push("-v", `${toDockerVolumePath(hostCwd)}:/workspace`);
49
+ dockerArgs.push("-w", "/workspace");
50
+ dockerArgs.push("-v", `${toDockerVolumePath(pkgRoot)}:/opt/staff-mcp:ro`);
51
+ // 4. Mount additional allowed directories
52
+ if (options.allowedDir && options.allowedDir.length > 0) {
53
+ options.allowedDir.forEach((dir) => {
54
+ const absDir = path.resolve(dir);
55
+ dockerArgs.push("-v", `${toDockerVolumePath(absDir)}:${absDir}`);
56
+ });
57
+ }
58
+ // 5. Handle HTTP port forwarding
59
+ if (options.transport === "http") {
60
+ dockerArgs.push("-p", `${options.port}:${options.port}`);
61
+ }
62
+ // 6. Inject advanced custom args (e.g., ADB pass-through, network configs)
63
+ if (options.dockerArgs && options.dockerArgs.length > 0) {
64
+ // commander parses varargs as an array of strings
65
+ options.dockerArgs.forEach((arg) => {
66
+ // simple split by space if the user quoted them (e.g., "-e FOO=1")
67
+ // If the user uses standard bash expansion, commander already handles it.
68
+ const parts = arg.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) || [arg];
69
+ parts.forEach(p => dockerArgs.push(p.replace(/^['"]|['"]$/g, '')));
70
+ });
71
+ }
72
+ // 7. Inject environment variable to detect docker proxy mode
73
+ dockerArgs.push("-e", "STAFF_MCP_IS_DOCKER=1");
74
+ // 8. Specify the target image
75
+ dockerArgs.push(options.docker);
76
+ // 9. Reconstruct the command inside the container
77
+ dockerArgs.push("node", "/opt/staff-mcp/dist/src/index.js");
78
+ dockerArgs.push("-t", options.transport);
79
+ dockerArgs.push("-p", String(options.port));
80
+ // Inside container, we must listen on all interfaces for HTTP to be exposed
81
+ if (options.transport === "http") {
82
+ dockerArgs.push("-h", "0.0.0.0");
83
+ }
84
+ else {
85
+ dockerArgs.push("-h", options.host);
86
+ }
87
+ dockerArgs.push("-w", "/workspace");
88
+ if (options.allowedDir && options.allowedDir.length > 0) {
89
+ options.allowedDir.forEach((dir) => {
90
+ dockerArgs.push("-d", path.resolve(dir)); // paths inside container match host
91
+ });
92
+ }
93
+ dockerArgs.push("-r", options.profile);
94
+ // 10. Spawn Docker and pipe I/O natively
95
+ const child = spawn("docker", dockerArgs, { stdio: ["pipe", "inherit", "inherit"] });
96
+ process.stdin.pipe(child.stdin);
97
+ child.on("exit", (code) => process.exit(code ?? 0));
98
+ child.on("error", (err) => {
99
+ console.error("[staff-mcp] Failed to start docker proxy:", err.message);
100
+ process.exit(1);
101
+ });
102
+ return; // Terminate host process execution
103
+ }
104
+ // -------------------------------------------------------------
105
+ // Standard Host Mode
106
+ // -------------------------------------------------------------
107
+ // Auto-exit if we are running as a proxy child and the host pipe breaks
108
+ if (process.env.STAFF_MCP_IS_DOCKER === "1") {
109
+ if (options.transport === "http") {
110
+ process.stdin.resume(); // keep reading to detect end in HTTP mode
111
+ }
112
+ process.stdin.on("end", () => {
113
+ console.error("[staff-mcp] Host pipe closed, terminating container...");
114
+ process.exit(0);
115
+ });
116
+ process.stdin.on("error", () => {
117
+ process.exit(1);
118
+ });
119
+ }
19
120
  ensureStaffDirs();
20
121
  const workingDir = path.resolve(options.workingDir);
21
122
  const allowedDirs = options.allowedDir.map((d) => path.resolve(d));
22
- const server = createServer("staff-mcp", "1.0.0", workingDir, allowedDirs);
123
+ const profile = options.profile;
124
+ const server = createServer("staff-mcp", "1.0.0", workingDir, allowedDirs, profile);
23
125
  if (options.transport === "http") {
24
126
  await startHttpServer(server, parseInt(options.port, 10), options.host);
25
127
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,WAAW,CAAC;KACjB,WAAW,CAAC,oDAAoD,CAAC;KACjE,OAAO,CAAC,OAAO,CAAC;KAChB,MAAM,CAAC,wBAAwB,EAAE,gCAAgC,EAAE,OAAO,CAAC;KAC3E,MAAM,CAAC,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,CAAC;KAC7D,MAAM,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,WAAW,CAAC;KACn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C,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -5,6 +5,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
5
  * @param version The server's version.
6
6
  * @param workingDir The working directory for the server.
7
7
  * @param allowedDirs Additional directories for the SecurityManager.
8
+ * @param profile The active profile for skills and instructions.
8
9
  * @returns An initialized McpServer instance.
9
10
  */
10
- export declare function createServer(name: string, version: string, workingDir: string, allowedDirs: string[]): McpServer;
11
+ export declare function createServer(name: string, version: string, workingDir: string, allowedDirs: string[], profile?: string): McpServer;
@@ -3,7 +3,7 @@ import { SecurityManager } from "./security.js";
3
3
  import { registerFileTools } from "./tools/file-tools.js";
4
4
  import { registerShellTools } from "./tools/shell-tools.js";
5
5
  import { registerLspTools } from "./tools/lsp-tools.js";
6
- import { registerSkillTools } from "./tools/skill-tools.js";
6
+ import { registerSkillTools } from "./tools/skills.js";
7
7
  import { getMcpInstructions } from "./tools/system-tools.js";
8
8
  /**
9
9
  * Creates and initializes a new McpServer with all functional tools.
@@ -11,9 +11,10 @@ import { getMcpInstructions } from "./tools/system-tools.js";
11
11
  * @param version The server's version.
12
12
  * @param workingDir The working directory for the server.
13
13
  * @param allowedDirs Additional directories for the SecurityManager.
14
+ * @param profile The active profile for skills and instructions.
14
15
  * @returns An initialized McpServer instance.
15
16
  */
16
- export function createServer(name, version, workingDir, allowedDirs) {
17
+ export function createServer(name, version, workingDir, allowedDirs, profile = "default") {
17
18
  const security = new SecurityManager(workingDir, allowedDirs);
18
19
  // Generate instructions with system-specific details (OS, shell, etc.)
19
20
  const instructions = getMcpInstructions(workingDir, security);
@@ -28,7 +29,7 @@ export function createServer(name, version, workingDir, allowedDirs) {
28
29
  registerFileTools(server, security);
29
30
  registerShellTools(server, security);
30
31
  registerLspTools(server, security);
31
- registerSkillTools(server, workingDir, security);
32
+ registerSkillTools(server, workingDir, security, profile);
32
33
  return server;
33
34
  }
34
35
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,OAAe,EAAE,UAAkB,EAAE,WAAqB;IACnG,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAE9D,uEAAuE;IACvE,MAAM,YAAY,GAAG,kBAAkB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI;QACJ,OAAO;KACR,EACD;QACE,yDAAyD;QACzD,YAAY;KACb,CACF,CAAC;IAEF,uCAAuC;IACvC,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACpC,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnC,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAEjD,OAAO,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,OAAe,EAAE,UAAkB,EAAE,WAAqB,EAAE,UAAkB,SAAS;IAChI,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAE9D,uEAAuE;IACvE,MAAM,YAAY,GAAG,kBAAkB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI;QACJ,OAAO;KACR,EACD;QACE,yDAAyD;QACzD,YAAY;KACb,CACF,CAAC;IAEF,uCAAuC;IACvC,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACpC,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnC,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE1D,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -5,9 +5,8 @@ export interface SkillInfo {
5
5
  content: string;
6
6
  }
7
7
  export declare class SkillManager {
8
- private static readonly SEARCH_DIRS;
9
- private static readonly SKILL_SUBDIRS;
10
- static loadSkills(workingDir: string): Record<string, SkillInfo>;
8
+ static getSearchPaths(workingDir: string, profile?: string): string[];
9
+ static loadSkills(workingDir: string, profile?: string): Record<string, SkillInfo>;
11
10
  private static scanDirSync;
12
11
  private static addSkillSync;
13
12
  private static parseMarkdown;
@@ -1,31 +1,14 @@
1
1
  import * as fs from "fs";
2
2
  import * as path from "path";
3
- import * as os from "os";
3
+ import { getSearchPaths } from "./resolver.js";
4
4
  export class SkillManager {
5
- // 定义搜索的基准目录名(隐藏目录)
6
- static SEARCH_DIRS = [".staff", ".claude", ".agents", ".opencode"];
7
- // 定义技能子目录名
8
- static SKILL_SUBDIRS = ["skills", "skill"];
9
- static loadSkills(workingDir) {
5
+ static getSearchPaths(workingDir, profile = "default") {
6
+ return getSearchPaths(workingDir, profile);
7
+ }
8
+ static loadSkills(workingDir, profile = "default") {
10
9
  const skills = {};
11
- const searchPaths = [];
12
- // 0. 直接检查工作目录下的 skills (兼容旧逻辑)
13
- searchPaths.push(path.join(workingDir, "skills"));
14
- searchPaths.push(path.join(workingDir, "skill"));
15
- // 1. 添加当前工作区搜索路径
16
- this.SEARCH_DIRS.forEach(dir => {
17
- this.SKILL_SUBDIRS.forEach(sub => {
18
- searchPaths.push(path.join(workingDir, dir, sub));
19
- });
20
- });
21
- // 2. 添加全局搜索路径 (用户主目录)
22
- const homeDir = os.homedir();
23
- this.SEARCH_DIRS.forEach(dir => {
24
- this.SKILL_SUBDIRS.forEach(sub => {
25
- searchPaths.push(path.join(homeDir, dir, sub));
26
- });
27
- });
28
- // 3. 扫描所有有效路径
10
+ const searchPaths = this.getSearchPaths(workingDir, profile);
11
+ // 扫描所有有效路径
29
12
  for (const root of searchPaths) {
30
13
  if (fs.existsSync(root) && fs.statSync(root).isDirectory()) {
31
14
  this.scanDirSync(root, skills);
@@ -60,7 +43,7 @@ export class SkillManager {
60
43
  const { data, content } = this.parseMarkdown(fileContent);
61
44
  // 确保有必要的元数据
62
45
  if (data.name && data.description) {
63
- // 如果名称冲突,优先保留先扫描到的(项目本地优先于全局)
46
+ // 如果名称冲突,优先保留先扫描到的(优先级高的路径在前)
64
47
  if (!skills[data.name]) {
65
48
  skills[data.name] = {
66
49
  name: data.name,
@@ -94,4 +77,4 @@ export class SkillManager {
94
77
  return { data, content: body };
95
78
  }
96
79
  }
97
- //# sourceMappingURL=skill-manager.js.map
80
+ //# sourceMappingURL=manager.js.map