@zleap-ai/sag-cli 0.4.1 → 0.6.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.en.md +76 -8
- package/README.md +66 -8
- package/dist/cli.js +8083 -1855
- package/dist/cli.js.map +1 -1
- package/dist/sag-knowledge.zip +0 -0
- package/dist/skill-cli.cjs +172 -0
- package/package.json +4 -3
- package/skill/SKILL.md +49 -45
- package/skill/manifest.json +8 -0
- package/skill/references/citation-rules.md +5 -83
- package/skill/references/cli-reference.md +31 -205
- package/skill/references/ndjson-contract.md +38 -0
- package/skill/references/safety.md +17 -0
- package/skill/references/search-strategies.md +5 -71
- package/skill/scripts/sag-knowledge.cjs +172 -0
- package/skills/sag-mcp/SKILL.md +21 -0
- package/skills/sag-mcp/references/cli-reference.md +9 -0
- package/skills/sag-mcp/references/tool-safety.md +10 -0
package/README.en.md
CHANGED
|
@@ -38,7 +38,7 @@ sag version
|
|
|
38
38
|
|
|
39
39
|
## Quick start: pick the path that fits you
|
|
40
40
|
|
|
41
|
-
The CLI offers
|
|
41
|
+
The CLI offers three independent paths. Pick one based on your situation.
|
|
42
42
|
|
|
43
43
|
### Path A: Local Docker, no token required (recommended for local dev)
|
|
44
44
|
|
|
@@ -99,18 +99,83 @@ sag search "how to wire MCP" --source <source-id> --top-k 5
|
|
|
99
99
|
|
|
100
100
|
A profile stores only `scheme://host[:port]`. The `/api/v1` prefix is added by the CLI — do not put it in the URL yourself.
|
|
101
101
|
|
|
102
|
+
### Path C: Connect an enterprise MCP published by the platform
|
|
103
|
+
|
|
104
|
+
After the enterprise platform generates standard `mcpServers` JSON, no Profile or environment label is required. Run the command below and paste the complete JSON when prompted. The CLI validates `initialize` and `tools/list` before saving it:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
sag mcp connect
|
|
108
|
+
sag mcp list
|
|
109
|
+
sag mcp tools
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The connection name comes from the key inside `mcpServers`, for example `sag-847674ad`. Use `sag mcp use <name>` to select another default connection. Inspect tool inputs before calling one:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
sag mcp tools
|
|
116
|
+
sag mcp call <tool-name> --arguments-json '{"key":"value"}' --yes
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Attach the connection through each Agent's own MCP configuration command:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
sag mcp attach codex
|
|
123
|
+
sag mcp attach claude-code
|
|
124
|
+
sag mcp attach workbuddy
|
|
125
|
+
sag mcp status
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Add `--dry-run` to preview changes. Use `sag mcp detach <agent>` to remove an Agent entry and `sag mcp disconnect` to remove the local connection. Enterprise connections, credentials, and managed state are stored separately from personal Profiles, JWTs, and Docker stdio integration.
|
|
129
|
+
|
|
102
130
|
## Use with the Skill
|
|
103
131
|
|
|
104
|
-
|
|
132
|
+
`sag-knowledge` ships in this package. Install it for an explicit Agent target;
|
|
133
|
+
an explicit target is useful in automation even when its host cannot be
|
|
134
|
+
auto-detected:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
sag skill install --origin https://sag.example.com --agent codex --yes --output ndjson
|
|
138
|
+
sag skill status --agent codex --output ndjson
|
|
139
|
+
sag skill update --agent codex --yes --output ndjson
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`update` resolves a newly downloaded `@zleap-ai/sag-cli@latest` bundle; it does
|
|
143
|
+
not silently reuse the running or cached bundle. `--yes` only skips the local
|
|
144
|
+
install/update/remove confirmation. It never bypasses browser approval, drift
|
|
145
|
+
checks, or conflict checks.
|
|
146
|
+
|
|
147
|
+
Installation only copies the verified bundle and is not authorization.
|
|
148
|
+
`--origin` saves the enterprise SAG address in shared `~/.sag/config.json`.
|
|
149
|
+
A manually installed ZIP asks for the full HTTP or HTTPS address on first use.
|
|
150
|
+
Authorization covers the current SAG account, not an Agent, device, capability
|
|
151
|
+
set, or one Knowledge Base:
|
|
105
152
|
|
|
106
153
|
```bash
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
154
|
+
sag skill auth login --origin https://sag.example.com --output ndjson
|
|
155
|
+
sag skill auth status --origin https://sag.example.com --output ndjson
|
|
156
|
+
sag skill auth logout --origin https://sag.example.com --output ndjson
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The browser asks only to allow or deny. The CLI stores and refreshes the account
|
|
160
|
+
session as plaintext JSON but never emits credentials. Machine-readable output
|
|
161
|
+
uses NDJSON v1 (`sag.skill.ndjson.v1`), one JSON event per stdout line.
|
|
110
162
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
163
|
+
`sag skill knowledge` lists Knowledge Bases and documents, asks globally or in
|
|
164
|
+
one Knowledge Base, uploads one file with progress, renames, and soft-deletes.
|
|
165
|
+
Global questions omit the Knowledge Base identifier and use SAG's current
|
|
166
|
+
strategy. Writes require an exact ID, alias, or unique name. Upload accepts one
|
|
167
|
+
regular file with an effective limit of at most 25 MiB, never a folder or batch.
|
|
168
|
+
|
|
169
|
+
Enterprise MCP uses the separate, compatible `skills/sag-mcp` Skill;
|
|
170
|
+
`sag-knowledge` uses the account Knowledge API. The two integration paths are
|
|
171
|
+
independent, and installing either one does not remove or rewrite the other.
|
|
172
|
+
Only selected, successfully attached Agents get the default `sag-mcp` Skill. With no Agent selected, connect saves only the connection and installs no Skill.
|
|
173
|
+
You can also manage it directly:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
sag mcp skill install --agent claude-code
|
|
177
|
+
sag mcp skill status --agent claude-code
|
|
178
|
+
sag mcp skill uninstall --agent claude-code
|
|
114
179
|
```
|
|
115
180
|
|
|
116
181
|
## Command reference
|
|
@@ -124,6 +189,9 @@ sag source list | get | status
|
|
|
124
189
|
sag document list | get | status
|
|
125
190
|
sag search <query>
|
|
126
191
|
sag mcp test
|
|
192
|
+
sag skill install | status | update | uninstall
|
|
193
|
+
sag skill auth login | status | logout
|
|
194
|
+
sag skill knowledge list | documents | ask | upload | upload-status | rename | delete
|
|
127
195
|
sag agent list
|
|
128
196
|
sag agent connect <codex | claude-code>
|
|
129
197
|
sag agent status [codex | claude-code]
|
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ sag version
|
|
|
38
38
|
|
|
39
39
|
## 快速上手:选一条适合你的路径
|
|
40
40
|
|
|
41
|
-
CLI
|
|
41
|
+
CLI 提供三条互相独立的路径,按你的场景选。
|
|
42
42
|
|
|
43
43
|
### 路径 A:本机 Docker,免 Token(推荐给本地开发者)
|
|
44
44
|
|
|
@@ -99,18 +99,73 @@ sag search "MCP 如何接入" --source <source-id> --top-k 5
|
|
|
99
99
|
|
|
100
100
|
Profile URL 只保存 `scheme://host[:port]`。API 前缀 `/api/v1` 由 CLI 自动补齐,不要自己写。
|
|
101
101
|
|
|
102
|
+
### 路径 C:接入企业平台开放的 MCP
|
|
103
|
+
|
|
104
|
+
企业平台生成标准 `mcpServers` JSON 后,不需要创建 Profile,也不需要区分开发或生产环境。执行下面的命令并按中文提示粘贴完整 JSON,CLI 会验证 `initialize` 和 `tools/list`,然后保存连接:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
sag mcp connect
|
|
108
|
+
sag mcp list
|
|
109
|
+
sag mcp tools
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
连接名称来自平台 JSON 中的 `mcpServers` 键,例如 `sag-847674ad`。需要切换默认连接时使用 `sag mcp use <连接名>`;调用工具前可先查看参数:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
sag mcp tools
|
|
116
|
+
sag mcp call <工具名> --arguments-json '{"key":"value"}' --yes
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
将连接接入 Agent 时,CLI 会调用 Agent 自己的 MCP 配置能力写入 URL 和 Header:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
sag mcp attach codex
|
|
123
|
+
sag mcp attach claude-code
|
|
124
|
+
sag mcp attach workbuddy
|
|
125
|
+
sag mcp status
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
可以先加 `--dry-run` 查看计划。移除 Agent 配置用 `sag mcp detach <agent>`,彻底删除本地连接用 `sag mcp disconnect`。企业连接、凭据和受管状态与个人版 Profile、JWT 及 Docker stdio 接入分别存放,互不覆盖。
|
|
129
|
+
|
|
102
130
|
## 搭配 Skill 使用
|
|
103
131
|
|
|
104
|
-
|
|
132
|
+
`sag-knowledge` 随本包发布。可显式指定 Agent 安装;即使自动探测不到宿主,这也适合自动化场景:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
sag skill install --origin https://sag.example.com --agent codex --yes --output ndjson
|
|
136
|
+
sag skill status --agent codex --output ndjson
|
|
137
|
+
sag skill update --agent codex --yes --output ndjson
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`update` 会新下载并解析 `@zleap-ai/sag-cli@latest`,不会静默复用当前运行中或缓存中的
|
|
141
|
+
Bundle。`--yes` 只跳过本地安装、更新、删除确认;不会跳过浏览器授权、漂移检查或冲突检查。
|
|
142
|
+
|
|
143
|
+
安装只复制已校验 Bundle,**不等于已授权**。`--origin` 会把企业 SAG 地址保存到共享的
|
|
144
|
+
`~/.sag/config.json`;手动安装 ZIP 时,Agent 会在首次使用时询问完整的 HTTP/HTTPS 地址。
|
|
145
|
+
授权使用当前 SAG 登录账号,不绑定 Agent、设备、能力集合或单个知识库:
|
|
105
146
|
|
|
106
147
|
```bash
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
148
|
+
sag skill auth login --origin https://sag.example.com --output ndjson
|
|
149
|
+
sag skill auth status --origin https://sag.example.com --output ndjson
|
|
150
|
+
sag skill auth logout --origin https://sag.example.com --output ndjson
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
浏览器页面只要求用户允许或拒绝;CLI 把账号会话以明文 JSON 保存并自动刷新,不在输出中
|
|
154
|
+
展示凭据。供程序读取的 Skill 输出为 NDJSON v1(`sag.skill.ndjson.v1`),stdout 每行一个
|
|
155
|
+
JSON event。
|
|
110
156
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
157
|
+
`sag skill knowledge` 提供知识库列表、文档列表、全局/指定知识库问答、单文件上传与进度、
|
|
158
|
+
重命名和软删除。全局问答不传知识库标识,沿用 SAG 当前检索策略。写操作要求精确的知识库
|
|
159
|
+
ID、alias 或唯一名称。上传只接受一个普通文件,有效上限不超过 25 MiB;不支持文件夹或批量。
|
|
160
|
+
|
|
161
|
+
企业 MCP 使用独立且兼容的 `skills/sag-mcp` Skill;`sag-knowledge` 使用账号级知识库
|
|
162
|
+
接口。两种接入方式彼此独立,安装其中一种不会移除或改写另一种。
|
|
163
|
+
仅为本次成功接入的所选 Agent 默认安装 `sag-mcp` Skill;不选 Agent 时只保存连接,不安装 Skill。也可以单独管理:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
sag mcp skill install --agent claude-code
|
|
167
|
+
sag mcp skill status --agent claude-code
|
|
168
|
+
sag mcp skill uninstall --agent claude-code
|
|
114
169
|
```
|
|
115
170
|
|
|
116
171
|
## 命令一览
|
|
@@ -124,6 +179,9 @@ sag source list | get | status
|
|
|
124
179
|
sag document list | get | status
|
|
125
180
|
sag search <query>
|
|
126
181
|
sag mcp test
|
|
182
|
+
sag skill install | status | update | uninstall
|
|
183
|
+
sag skill auth login | status | logout
|
|
184
|
+
sag skill knowledge list | documents | ask | upload | upload-status | rename | delete
|
|
127
185
|
sag agent list
|
|
128
186
|
sag agent connect <codex | claude-code>
|
|
129
187
|
sag agent status [codex | claude-code]
|