draftgo-cli 3.0.56 → 4.0.22
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 +169 -297
- package/package.json +12 -7
- package/resources/custom-service-sdk/ai.go +520 -0
- package/resources/custom-service-sdk/ai_test.go +156 -0
- package/resources/custom-service-sdk/billing.go +596 -0
- package/resources/custom-service-sdk/billing_test.go +150 -0
- package/resources/custom-service-sdk/go.mod +3 -0
- package/resources/custom-service-sdk/manifest.json +72 -0
- package/resources/custom-service-sdk/platform.go +360 -0
- package/resources/custom-service-sdk/platform_logger_test.go +24 -0
- package/resources/custom-service-sdk/registration_test.go +39 -0
- package/resources/custom-service-sdk/resources.go +246 -0
- package/resources/custom-service-sdk/resources_billing_test.go +115 -0
- package/resources/custom-service-sdk/resources_files_test.go +57 -0
- package/resources/custom-service-sdk/resources_scope_test.go +87 -0
- package/resources/custom-service-sdk/sdk.go +208 -0
- package/resources/skill/SKILL.md +36 -87
- package/resources/skill/init/SKILL.md +9 -14
- package/resources/skill/manifest.json +6 -2
- package/resources/skill/references/aihub.md +28 -5
- package/resources/skill/references/app-api.md +56 -6
- package/resources/skill/references/architecture.md +2 -2
- package/resources/skill/references/chat-sdk.md +4 -2
- package/resources/skill/references/checkout.md +21 -7
- package/resources/skill/references/custom-services.md +124 -222
- package/resources/skill/references/data.md +22 -6
- package/resources/skill/references/delivery.md +33 -0
- package/resources/skill/references/diagnostics.md +51 -0
- package/resources/skill/references/frontend.md +93 -499
- package/resources/skill/references/mcp.md +65 -101
- package/resources/skill/references/methods.md +189 -0
- package/resources/skill/references/modules.md +36 -8
- package/resources/skill/references/runtime.md +26 -3
- package/resources/skill/story/SKILL.md +1 -2
- package/src/apiContractCache.js +112 -0
- package/src/cli.js +24 -20
- package/src/commandRegistry.js +15 -12
- package/src/commands/api.js +41 -10
- package/src/commands/apiKey.js +34 -0
- package/src/commands/capabilities.js +93 -0
- package/src/commands/check.js +1 -10
- package/src/commands/checkout.js +1 -1
- package/src/commands/commit.js +1 -1
- package/src/commands/components.js +550 -0
- package/src/commands/conflict.js +1 -1
- package/src/commands/connect.js +18 -8
- package/src/commands/customService.js +22 -8
- package/src/commands/dataRange.js +33 -0
- package/src/commands/delete.js +34 -46
- package/src/commands/deploy.js +1 -1
- package/src/commands/diff.js +18 -2
- package/src/commands/grant.js +29 -0
- package/src/commands/group.js +38 -0
- package/src/commands/help.js +80 -51
- package/src/commands/init.js +6 -12
- package/src/commands/listTargets.js +1 -1
- package/src/commands/local.js +2 -6
- package/src/commands/map.js +145 -28
- package/src/commands/mcp.js +2 -2
- package/src/commands/reconcile.js +1 -1
- package/src/commands/role.js +32 -0
- package/src/commands/space.js +41 -0
- package/src/commands/status.js +111 -8
- package/src/commands/uninstall.js +3 -3
- package/src/commands/update.js +24 -12
- package/src/commands/verify.js +118 -21
- package/src/commands/{verifyUi.js → visualVerify.js} +28 -116
- package/src/commands/worklog.js +90 -0
- package/src/consoleEncoding.js +34 -0
- package/src/contractCompatibility.js +57 -0
- package/src/customServices.js +278 -41
- package/src/diffReport.js +106 -0
- package/src/index.js +2 -0
- package/src/{localdev → localRuntime}/compose.js +14 -17
- package/src/{localdev → localRuntime}/detect.js +1 -1
- package/src/{localdev → localRuntime}/index.js +22 -23
- package/src/{localdev → localRuntime}/mysqlClient.js +1 -1
- package/src/{localdev → localRuntime}/services.js +28 -37
- package/src/mcp/client.js +11 -2
- package/src/mcp/protocol.js +2 -2
- package/src/mcp/tools.js +14 -1
- package/src/platforms.js +9 -0
- package/src/projectConfig.js +8 -4
- package/src/releaseInstall.js +105 -0
- package/src/{installers/index.js → targets.js} +3 -5
- package/src/updateCheck.js +48 -28
- package/src/worklog.js +275 -0
- package/src/workspaceHealth.js +1 -1
- package/src/worktree/backend.js +1 -1
- package/src/worktree/index.js +86 -51
- package/src/changelog.js +0 -276
- package/src/commands/changelog.js +0 -24
- package/src/commands/localDev.js +0 -9
- package/src/commands/sync.js +0 -46
- package/src/commands/task.js +0 -408
- package/src/commands/verifyUiCompat.js +0 -16
package/README.md
CHANGED
|
@@ -1,381 +1,253 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DraftGo CLI 4
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
面向 AI 编码工具的 DraftGo 工作台 CLI。它负责 Skill 安装、项目连接、MCP 发现、长正文 checkout/commit、自定义服务草稿、统一本地验收和 worklog 记录。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 核心规则
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- 根 Skill 自动加载;Agent 只读取当前任务需要的 Reference。
|
|
8
|
+
- pages、navigations、docs/articles 和 custom services 的完整正文使用 `checkout`、worktree、`diff`、`commit`;结构化资源使用 MCP/API。
|
|
9
|
+
- MCP schema 是服务端实时契约。已知 operation 优先使用项目私有缓存;首次使用或 `registry_revision` 变化时 describe。schema 不写入 Skill 或聊天上下文。
|
|
10
|
+
- 不同资源、operation 和 owner 的工作全部并发;同一资源的依赖步骤保持串行。
|
|
11
|
+
- 每个任务开始记录到 `.draftgo/worklog.md`,验证和交付成功后再标记完成。
|
|
12
|
+
- 已知页面使用 `draftgo map --type pages --route <path>` 或 `--title <title>` 精确定位;只需范围和状态时使用 `--summary`,浏览列表时使用 `--limit`(默认 20)/`--cursor`,不默认全量 map。
|
|
13
|
+
- `--output json` 的 stdout 只包含 UTF-8 JSON;诊断和进度写入 stderr。大变更先用 `draftgo diff --stat` 或 `--summary`。
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
跨板块任务先看[极简方法指南](resources/skill/references/methods.md):它按 AIHub、知识库/记忆、页面/内容、动态数据、自定义服务、MCP、运行诊断和交付验收给出“适用场景 + 最短正确命令链 + 失败定位 + 完成条件”。动态 operation 不写死;未知契约统一用 `draftgo api search`、`draftgo api describe`、`draftgo api call` 实时发现。
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
## 验收策略
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
普通交付只运行:
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## 前置条件
|
|
18
|
-
|
|
19
|
-
- Node.js >=20.19
|
|
20
|
-
- 使用 `draftgo local ...` 时需要 Docker 和 Docker Compose
|
|
21
|
-
|
|
22
|
-
CLI 不再依赖 Python 同步脚本,也不会创建 DraftGo 业务资源的全量本地镜像。
|
|
23
|
-
|
|
24
|
-
## 工作模型
|
|
25
|
-
|
|
26
|
-
```text
|
|
27
|
-
根 SKILL.md -> Agent 按任务读取最少必要的 Reference
|
|
28
|
-
AI 宿主 -> draftgo mcp serve -> DraftGo /mcp
|
|
29
|
-
|
|
|
30
|
-
+-> 结构化资源、元数据、搜索和正文片段
|
|
31
|
-
|
|
32
|
-
draftgo checkout/commit -> DraftGo 专用 HTTP 正文端点
|
|
33
|
-
(完整 HTML/Markdown 不经过 MCP 上下文)
|
|
21
|
+
```bash
|
|
22
|
+
draftgo verify
|
|
34
23
|
```
|
|
35
24
|
|
|
36
|
-
|
|
37
|
-
- MCP 用于项目概览、资源搜索/列表、元数据、正文片段和实时 API 调用。
|
|
38
|
-
- `pages`、`navigations` 和 `docs/articles` 的完整正文使用 `checkout` / `commit`。
|
|
39
|
-
- `db_meta`、AIHub、`system_config`、角色、用户、文档分类、自定义服务等结构化资源直接通过 MCP/API 操作,不生成本地索引。
|
|
40
|
-
- `.draftgo/pages/`、`.draftgo/navigations/` 等旧 `index.json` 缓存只视为 legacy 数据;CLI 不删除它们,但 `map` 和 `check` 会忽略它们。
|
|
41
|
-
- DraftGo Skill 继续提供资源关系、前端运行能力与实践、数据和权限、安全规则、自定义服务经验以及验证流程;MCP 不替代 Skill。
|
|
42
|
-
- CLI 不提供页面模板,也不替 Agent 选择页面结构或视觉风格。
|
|
25
|
+
默认验收只做本地检查,不启动浏览器,也不生成截图。只有用户明确要求视觉验收时才访问浏览器或截图;两者同时要求时先截图并查看结果,再做交互或 DOM 检查。
|
|
43
26
|
|
|
44
|
-
|
|
27
|
+
```bash
|
|
28
|
+
# 截图验收,默认 desktop 1440x900
|
|
29
|
+
draftgo verify --url http://localhost:3000/path --screenshot always
|
|
45
30
|
|
|
46
|
-
|
|
31
|
+
# 用户明确要求交互或 DOM 验收
|
|
32
|
+
draftgo verify --url http://localhost:3000/path --ui always
|
|
47
33
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
-> 读取任务所需的最少 Reference
|
|
51
|
-
-> 用 resource_search / api_search 精确定位
|
|
52
|
-
-> 按需 describe、读取 metadata 或片段
|
|
53
|
-
-> 必要时 checkout 正文
|
|
34
|
+
# 仅在用户要求时增加移动端
|
|
35
|
+
draftgo verify --url http://localhost:3000/path --screenshot always --viewport both
|
|
54
36
|
```
|
|
55
37
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
页面需求先结合用户意图和 MCP 实时资源判断是修改已有页面还是新增页面。已有页面在确认唯一 ID 后 checkout;独立新页面先通过实时 API 创建并取得 ID,再 checkout 完整正文。“做一个功能页面”本身不预设新建或修改,只有不同判断会产生明显不同结果时才需要向用户澄清。
|
|
59
|
-
|
|
60
|
-
只回答无需实时状态的本地规则问题时,不必调用 MCP。静态资源须先区分:平台内置目录由 `frontend.md` 说明,指定页面依赖经 MCP 定位、checkout 后本地搜索,服务器全量文件不能凭现有 Skill、MCP 摘要或 checkout 声称已枚举。
|
|
61
|
-
|
|
62
|
-
Skill 说明产品约束、内置能力和操作规则;MCP 说明当前远端状态;checkout 正文才能证明某个页面完整引用了哪些静态资源。汇报时应明确标注这三类证据,不能互相替代。
|
|
38
|
+
`--ui` 和 `--screenshot` 的默认值都是 `never`;截图模式只有 `always` 和 `never`。默认视口是 desktop `1440x900`,移动端为 `390x844`。
|
|
63
39
|
|
|
64
40
|
## 安装与连接
|
|
65
41
|
|
|
66
42
|
```bash
|
|
67
43
|
npm install -g draftgo-cli
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
draftgo
|
|
71
|
-
draftgo
|
|
44
|
+
cd /path/to/project
|
|
45
|
+
draftgo init
|
|
46
|
+
draftgo connect --server https://draftgo.example --api-key "$DRAFTGO_API_KEY"
|
|
47
|
+
draftgo mcp setup
|
|
48
|
+
draftgo mcp test
|
|
72
49
|
```
|
|
73
50
|
|
|
74
|
-
|
|
51
|
+
`connect` 会验证当前用户的 DraftGo API Key、MCP initialize、tools/list 和关键工具调用,然后把连接写入项目私有的 `.draftgo/config.json`。宿主 MCP 配置只包含 `draftgo mcp serve`,不会保存 API Key。需要开发 space 资源时增加 `--scope-type space --space-id <id>`;平台组件和系统配置仍按 operation 契约使用 platform 上下文。
|
|
52
|
+
|
|
53
|
+
本地底座:
|
|
75
54
|
|
|
76
55
|
```bash
|
|
77
|
-
draftgo
|
|
56
|
+
draftgo local setup
|
|
57
|
+
draftgo local start
|
|
58
|
+
draftgo local status
|
|
59
|
+
draftgo local logs app
|
|
60
|
+
draftgo local stop
|
|
78
61
|
```
|
|
79
62
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
`connect` 会先验证 SAT、MCP `initialize`、`tools/list` 和关键 `tools/call`,成功后写入项目私有配置 `.draftgo/config.json`,并尝试为指定或自动检测到的宿主执行 MCP setup。`init` / `connect` 不会预建 Task、lessons、changelog、worktree、conflicts 等运行时内容;这些文件和目录只在对应能力首次使用时按需创建。它不会 pull 页面、导航、文档或任何其他业务资源。
|
|
63
|
+
## 命令
|
|
83
64
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
`connect` 会把以下运行时路径加入项目 `.gitignore`:
|
|
65
|
+
### 项目与 Skill
|
|
87
66
|
|
|
88
67
|
```text
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
68
|
+
draftgo init [target...]
|
|
69
|
+
draftgo update [target...]
|
|
70
|
+
draftgo uninstall <target|all> [--purge]
|
|
71
|
+
draftgo status
|
|
72
|
+
draftgo list-targets
|
|
73
|
+
draftgo connect [target...]
|
|
93
74
|
```
|
|
94
75
|
|
|
95
|
-
|
|
76
|
+
`draftgo status` 会通过只读 MCP/API 诊断显示服务连接健康状态、服务版本和当前用户 API Key 的 `platform`/`space` 上下文;`--output json` 适合读取 `connection.health`、`workspace_id` 与 `space_id`。
|
|
96
77
|
|
|
97
|
-
|
|
78
|
+
### 发现与正文
|
|
98
79
|
|
|
99
|
-
```
|
|
100
|
-
draftgo
|
|
101
|
-
draftgo
|
|
102
|
-
draftgo
|
|
103
|
-
draftgo
|
|
80
|
+
```text
|
|
81
|
+
draftgo map [--type pages|nav|docs|custom-services] [--route <path>] [--title <title>] [--summary] [--limit <1-100>] [--cursor <opaque>] [--output json]
|
|
82
|
+
draftgo checkout <pages|nav|docs|custom-services> <id...> [--force]
|
|
83
|
+
draftgo check [custom-services <id...>] [--remote]
|
|
84
|
+
draftgo verify [<type> <id...>] [visual flags]
|
|
85
|
+
draftgo diff <type> <id> [--stat|--summary] [--output json]
|
|
86
|
+
draftgo commit <type> <id...>
|
|
87
|
+
draftgo refresh <type> <id...>
|
|
88
|
+
draftgo reconcile <type> <id...>
|
|
89
|
+
draftgo conflicts [--all]
|
|
90
|
+
draftgo conflict show <type> <id>
|
|
91
|
+
draftgo conflict resolve <type> <id>
|
|
104
92
|
```
|
|
105
93
|
|
|
106
|
-
`
|
|
94
|
+
`checkout` 下载正文和经过 hash 校验的 base。`commit` 先并发完成所有目标的本地与远端 preflight,全部通过后再并发上传;任何 409/412 都保留 base/local/remote 冲突材料,不 force、不覆盖、不自动合并。
|
|
95
|
+
|
|
96
|
+
`--route`、`--title` 为精确匹配,同时给出时取交集。CLI 可用资源搜索缩小候选,但最终在本地做精确判定;服务端 `resource_search` 只接受通用 `query`,不能传 route/title。`map --summary` 不输出 project overview、资源列表或 hash。`diff --stat` 输出文件与增删行数,`--summary` 输出资源、版本和变更概要;只有不带这两个参数的 diff 才展开正文。
|
|
107
97
|
|
|
108
|
-
|
|
98
|
+
### Page 组件库
|
|
109
99
|
|
|
110
|
-
|
|
100
|
+
```bash
|
|
101
|
+
draftgo components search <query> --output json
|
|
102
|
+
draftgo components show <library/component> --output json
|
|
103
|
+
draftgo components expand --page <id> --instance <data-dg-instance>
|
|
104
|
+
draftgo verify pages <id>
|
|
105
|
+
|
|
106
|
+
# 开发组件:commit 保存草稿,publish 显式上线
|
|
107
|
+
draftgo components checkout <library/component>
|
|
108
|
+
draftgo components diff <library/component>
|
|
109
|
+
draftgo components verify <library/component>
|
|
110
|
+
draftgo components commit <library/component>
|
|
111
|
+
draftgo components publish <library/component>
|
|
112
|
+
|
|
113
|
+
# 库管理和标准 ZIP 迁移
|
|
114
|
+
draftgo components libraries list|show|create|update|delete
|
|
115
|
+
draftgo components import <archive.zip> --dry-run
|
|
116
|
+
draftgo components export <library> --file <archive.zip>
|
|
117
|
+
```
|
|
111
118
|
|
|
112
|
-
|
|
113
|
-
|---|---|---|
|
|
114
|
-
| Codex CLI | `.codex/config.toml` | 支持 |
|
|
115
|
-
| Claude Code | `.mcp.json` | 支持 |
|
|
116
|
-
| Cursor | `.cursor/mcp.json` | 支持 |
|
|
117
|
-
| Gemini CLI | `.gemini/settings.json` | 支持 |
|
|
118
|
-
| Kiro | `.kiro/settings/mcp.json` | 支持 |
|
|
119
|
-
| GitHub Copilot | `.vscode/mcp.json` | 支持 |
|
|
120
|
-
| Windsurf | - | 不支持项目级 MCP setup |
|
|
121
|
-
| Antigravity | - | 不支持项目级 MCP setup |
|
|
119
|
+
`search` 和 `show` 始终读取当前 DraftGo 实例的组件目录,AI 不得按名称猜写 props/slots。Page 以真实根标签和 `data-dg-use="library/component"` 保存活引用,发布新 revision 后刷新自动升级。高度个性化时先 checkout Page,再用 `expand` 固化当前 props、slots、组件/库 CSS、公共资产和 mount 初始化;展开实例变成普通 HTML/CSS/JavaScript,不再随组件升级,仍需经过 `diff -> verify -> commit`。
|
|
122
120
|
|
|
123
|
-
|
|
121
|
+
### Custom service
|
|
124
122
|
|
|
125
|
-
|
|
126
|
-
[mcp_servers.draftgo]
|
|
127
|
-
command = "draftgo"
|
|
128
|
-
args = ["mcp", "serve"]
|
|
129
|
-
```
|
|
123
|
+
最短开发闭环:
|
|
130
124
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
"command": "draftgo",
|
|
138
|
-
"args": ["mcp", "serve"]
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
125
|
+
```bash
|
|
126
|
+
# 先用 MCP 定位或创建服务并取得 ID
|
|
127
|
+
draftgo checkout custom-services <id...>
|
|
128
|
+
draftgo diff custom-services <id> --stat
|
|
129
|
+
draftgo commit custom-services <id...>
|
|
130
|
+
draftgo test custom-services <id> --source draft --handler route:POST:/path --input request.json
|
|
142
131
|
```
|
|
143
132
|
|
|
144
|
-
|
|
133
|
+
每个 worktree 只有 `service.go` 与 `service.json` 是用户内容;Route/Event/Scheduled handler 仅由 `Register` 自动发现。CLI 另生成带 `DO NOT EDIT` 标记的 `go.mod/go.sum`、本地编译入口和 SDK 副本,供 gopls、`go build` 使用;它们会在 checkout 和 commit 时重建,且永不进入 diff、hash、归档、冲突材料或云端。第三方依赖只在源码顶部用 `//draftgo:require module@version` 固定。旧四文件 worktree 不受支持,请删除后用当前 CLI 重新 checkout。
|
|
145
134
|
|
|
146
|
-
|
|
135
|
+
`commit custom-services` 会自动完成提交、验证和发布,并输出明确的 published 提示;`validate`、`test`、`publish` 仍可作为单独的兼容入口。`test` 只运行 cloud draft,不调用线上版本;发布后如需再试运行,先修改并提交形成新草稿。默认拒绝外部副作用;外部调用用 `--side-effect-policy mock` 模拟,只有明确需要真实副作用时才组合 `--side-effect-policy live --test-write`。数据库等写操作也必须显式加 `--test-write`。
|
|
147
136
|
|
|
148
|
-
- `
|
|
149
|
-
- `draftgo_resource_list`
|
|
150
|
-
- `draftgo_resource_search`
|
|
151
|
-
- `draftgo_resource_get_metadata`
|
|
152
|
-
- `draftgo_resource_read_fragment`
|
|
153
|
-
- `draftgo_api_search`
|
|
154
|
-
- `draftgo_api_describe`
|
|
155
|
-
- `draftgo_api_call`
|
|
137
|
+
`--source` 支持 `draft`(默认)、`auto`、`published`。Selector 支持 `route:METHOD:/path`、`event:name`、`scheduled:name` 或 handler 名;`--input`、`--headers`、`--user` 都读取 UTF-8 JSON object。普通 SDK 调用继承已验证的 `platform` 或 `space` 上下文;可信服务可对单次操作显式使用 `ctx.Admin.*`,该提升会审计且不会泄漏到后续调用。余额扣款、权益、支付和订阅使用 `ctx.Billing` / `ctx.Admin.Billing`,精确签名查看 checkout 后只读的 `.draftgo-sdk/billing.go`。完整字段与规则见[自定义服务方法指南](resources/skill/references/custom-services.md)。
|
|
156
138
|
|
|
157
|
-
|
|
139
|
+
### MCP/API
|
|
158
140
|
|
|
159
141
|
```text
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
142
|
+
draftgo mcp setup [target...]
|
|
143
|
+
draftgo mcp status [target...]
|
|
144
|
+
draftgo mcp test
|
|
145
|
+
draftgo mcp serve
|
|
146
|
+
draftgo api <query>
|
|
147
|
+
draftgo api search <query>
|
|
148
|
+
draftgo api describe <operation_id>
|
|
149
|
+
draftgo api call <operation_id> --input <json-file>
|
|
150
|
+
draftgo delete <operation_id> [id] [--params JSON]
|
|
151
|
+
draftgo capabilities list [--module <name>] [--type <resource>] [--method <method>]
|
|
152
|
+
draftgo capabilities search <query> [--risk <level>] [--permission <permission>]
|
|
153
|
+
draftgo capabilities show <operation_id>
|
|
154
|
+
draftgo capabilities audit --output json
|
|
167
155
|
```
|
|
168
156
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
前端任务先读取 `references/frontend.md`,涉及 iframe、路由、认证或全局层时补读 `runtime.md` / `app-api.md`,再通过 MCP 定位目标资源。
|
|
157
|
+
`api call` 对已缓存 operation 直接调用并携带 `registry_revision`。服务端返回 `CONTRACT_CHANGED` 时重新 describe;只读或 operation 契约未变化时最多重试一次,危险 operation 自身契约变化时阻断调用并提示升级 CLI 后重新确认。调用输入必须是 UTF-8 JSON object;输出包含 HTTP status、服务端 code 和 request ID。
|
|
172
158
|
|
|
173
|
-
|
|
159
|
+
权限快捷命令:
|
|
174
160
|
|
|
175
161
|
```bash
|
|
176
|
-
draftgo
|
|
177
|
-
|
|
178
|
-
draftgo
|
|
179
|
-
draftgo
|
|
180
|
-
draftgo
|
|
181
|
-
draftgo
|
|
182
|
-
draftgo
|
|
183
|
-
draftgo
|
|
162
|
+
draftgo role list
|
|
163
|
+
draftgo space list
|
|
164
|
+
draftgo space members list --input request.json
|
|
165
|
+
draftgo group members add --input request.json
|
|
166
|
+
draftgo grant create --input request.json
|
|
167
|
+
draftgo api-key status
|
|
168
|
+
draftgo api-key rotate
|
|
169
|
+
draftgo data-range list
|
|
184
170
|
```
|
|
185
171
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
只有整个任务统一验证并且所有 commit/MCP 写入成功后才执行一次 `changelog add`。验证失败、409/412 或任一交付失败时不得写入。
|
|
191
|
-
|
|
192
|
-
## 命令清单
|
|
172
|
+
`role` 管理无作用域的 Role 模板;授权使用 `grant` 创建带 `platform` 或 `space` 范围的 AccessGrant。工作区成员关系不直接授予权限。资源归属由服务端持久化 ResourceOwnership 决定,DB 的 DataRange
|
|
173
|
+
只在该范围内应用 `none`、`owner` 或 `all` 记录策略。交互式 CLI、MCP 和普通 HTTP API 均使用当前用户的
|
|
174
|
+
API Key,并始终按该用户的 AccessGrant 授权;API Key 不能创建或伪造服务身份。CI、定时任务和共享服务等
|
|
175
|
+
无人值守自动化使用平台提供的独立服务凭据通道及服务主体 AccessGrant,不复用个人 API Key。
|
|
193
176
|
|
|
194
|
-
###
|
|
177
|
+
### 交付与记录
|
|
195
178
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
| 命令 | 说明 |
|
|
208
|
-
|---|---|
|
|
209
|
-
| `draftgo map` | 并行读取 pages、navigations、docs/articles 元数据,再叠加本地 checkout 状态;`--type` 可限制一种类型。 |
|
|
210
|
-
| `draftgo checkout <pages|nav|docs> <id...>` | 下载完整正文和 base,校验 hash 后原子落盘;`--force` 可显式覆盖已修改的本地正文。 |
|
|
211
|
-
| `draftgo check` | 默认只检查本地 checkout;`--remote` 额外对比 local/base/manifest/remote 的版本和 hash。 |
|
|
212
|
-
| `draftgo verify [<type> <id...>]` | 统一执行静态检查;`--remote` 增加远端比较,`--url` 增加 iframe-aware 浏览器验证。 |
|
|
213
|
-
| `draftgo diff <pages|nav|docs> <id>` | 显示 checkout base 与当前本地正文的差异。 |
|
|
214
|
-
| `draftgo commit <pages|nav|docs> <id...>` | 本地校验后,通过专用 HTTP 上传完整正文并更新 base/manifest。 |
|
|
215
|
-
| `draftgo reconcile <pages|nav|docs> <id...>` | 仅当 local 与经校验的 remote 字节一致时,安全修复落后的 base/manifest 元数据。 |
|
|
216
|
-
| `draftgo conflicts` | 列出未解决冲突;存在冲突时返回非零。`--all` 包括已解决记录。 |
|
|
217
|
-
| `draftgo conflict show <type> <id>` | 显示冲突的 base/local/remote/worktree 路径。 |
|
|
218
|
-
| `draftgo conflict resolve <type> <id>` | 确认 worktree 已合并,把保留的 remote 设为新 base;随后重新 check、diff、commit。 |
|
|
219
|
-
| `draftgo verify-ui <url>` | `verify --url <url> --ui always` 的弃用兼容入口。 |
|
|
220
|
-
|
|
221
|
-
`pages`、`page`,`nav`、`navigation`、`navigations`,以及 `docs`、`doc`、`article`、`articles`、`docs/articles` 都会规范化到三个支持的正文类型。
|
|
222
|
-
|
|
223
|
-
### 实时 API 与交付
|
|
224
|
-
|
|
225
|
-
| 命令 | 说明 |
|
|
226
|
-
|---|---|
|
|
227
|
-
| `draftgo api <query>` | 通过 MCP `api_search` 查询实时 API 契约。 |
|
|
228
|
-
| `draftgo api search <query>` | `draftgo api <query>` 的显式搜索形式。 |
|
|
229
|
-
| `draftgo api describe <operation_id>` | 通过 MCP `api_describe` 查看指定操作。 |
|
|
230
|
-
| `draftgo api call <operation_id> --input <file>` | 描述后调用实时 operation;JSON 文件严格按 UTF-8 解码并输出状态码、服务端 code 和 request ID。 |
|
|
231
|
-
| `draftgo delete <operation_id> [id]` | 描述并确认后调用实时 MCP `api_call`;支持 `--params JSON`、`--input file` 和 `--yes`。 |
|
|
232
|
-
| `draftgo deploy [<type> <id...>]` | 先 `check`,再按 delivery 模式检查 diff 或 commit。仅 `--delivery local` 可省略 type/id。 |
|
|
233
|
-
| `draftgo auto-push [<type> <id...>]` | `auto_push: true` 时检查并 commit 已 checkout 的变更;有冲突立即停止。 |
|
|
234
|
-
| `draftgo changelog add "<完成结果>"` | 在整个任务统一验证并全部交付成功后追加一条完成结果。 |
|
|
235
|
-
| `draftgo pull` | 仅输出迁移提示并返回非零;永不下载资源。 |
|
|
236
|
-
| `draftgo push <type> <id...>` | 已弃用;仅对 pages/nav/docs 显示提示后转发到 `commit`。不支持 push-all 或结构化资源。 |
|
|
237
|
-
|
|
238
|
-
`deploy` 的 `--delivery local` 只运行检查,`preview` 运行检查并显示 diff,`deploy` 运行检查后 commit 指定正文。它不会遍历旧索引。`push --dry-run` 只显示指定正文的 diff。
|
|
179
|
+
```text
|
|
180
|
+
draftgo deploy <type> <id...> [--delivery local|preview|deploy]
|
|
181
|
+
draftgo auto-push [<type> <id...>]
|
|
182
|
+
draftgo work start <item>
|
|
183
|
+
draftgo work add <item>
|
|
184
|
+
draftgo work start-item <number|date#number>
|
|
185
|
+
draftgo work complete <number|date#number> [--note <evidence>]
|
|
186
|
+
draftgo work show|list
|
|
187
|
+
draftgo clean [--dry-run|--yes]
|
|
188
|
+
```
|
|
239
189
|
|
|
240
|
-
`
|
|
190
|
+
`draftgo work start <item>` 的文本输出会返回可直接传给后续命令的引用,例如 `Started work item #21 (2026-08-20#21)`。
|
|
241
191
|
|
|
242
|
-
|
|
192
|
+
## Worklog
|
|
243
193
|
|
|
244
|
-
|
|
194
|
+
`.draftgo/worklog.md` 是任务、进度和完成证据的唯一记录。格式如下:
|
|
245
195
|
|
|
246
196
|
```markdown
|
|
247
|
-
2026-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
2.
|
|
251
|
-
|
|
252
|
-
2026-08-
|
|
253
|
-
|
|
254
|
-
|
|
197
|
+
[ 2026-08-09 ]
|
|
198
|
+
1. [ ● ] 实现页面权限
|
|
199
|
+
// 正在开发
|
|
200
|
+
2. [ ] 补充验收
|
|
201
|
+
|
|
202
|
+
[ 2026-08-10 ]
|
|
203
|
+
1. [ √ ] 完成文档
|
|
204
|
+
// draftgo verify、commit 已通过
|
|
255
205
|
```
|
|
256
206
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
### 本地 DraftGo
|
|
260
|
-
|
|
261
|
-
| 命令 | 说明 |
|
|
262
|
-
|---|---|
|
|
263
|
-
| `draftgo local setup` | 生成 `.draftgo/docker/docker-compose.yaml`,初始化并启动本地 DraftGo 栈。 |
|
|
264
|
-
| `draftgo local start` | 启动本地栈;`up` 是兼容别名。 |
|
|
265
|
-
| `draftgo local stop` | 停止本地栈;`down` 是兼容别名。 |
|
|
266
|
-
| `draftgo local logs [service...]` | 查看日志;不传服务时跟随 `app`。 |
|
|
267
|
-
| `draftgo local status` | 显示容器状态;`ps` 是兼容别名。 |
|
|
268
|
-
| `draftgo local-dev` | `draftgo local setup` 的兼容入口。 |
|
|
269
|
-
|
|
270
|
-
本地 Docker、MySQL、Redis、Milvus 和 app 生命周期与 MCP/checkout 工作流相互独立。
|
|
207
|
+
空状态表示待开发,`●` 表示开发中,`√` 表示开发完成。任务开始就写入记录;验证、冲突或交付失败时不能标记为完成。
|
|
271
208
|
|
|
272
|
-
##
|
|
209
|
+
## 运行时目录
|
|
273
210
|
|
|
274
211
|
```text
|
|
275
212
|
.draftgo/
|
|
276
213
|
├── config.json
|
|
214
|
+
├── api-contract-cache.json
|
|
215
|
+
├── worklog.md
|
|
277
216
|
├── worktree/
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
│ ├── docs/
|
|
282
|
-
│ └── .base/
|
|
283
|
-
└── conflicts/
|
|
217
|
+
├── conflicts/
|
|
218
|
+
├── artifacts/
|
|
219
|
+
└── tmp/
|
|
284
220
|
```
|
|
285
221
|
|
|
286
|
-
`.draftgo/
|
|
287
|
-
|
|
288
|
-
- `server`、`resource_type`、`resource_id`
|
|
289
|
-
- `title`、`route` / `code` / `slug`
|
|
290
|
-
- `local_path`、`base_path`
|
|
291
|
-
- `content_type`、`file_extension`、`content_size`
|
|
292
|
-
- `base_version`、`base_revision`、`base_etag`、`base_hash`
|
|
293
|
-
- `checked_out_at`,commit 后还会记录更新时间
|
|
294
|
-
|
|
295
|
-
已知正文类型保持原始字节和语义:`text/html` 使用 `.html`,Markdown 使用 `.md`,纯文本使用 `.txt`,其他类型使用底座返回且通过安全校验的扩展名。CLI 不转换 HTML、Markdown 或正文编码。
|
|
296
|
-
|
|
297
|
-
checkout 会通过 MCP 获取元数据和专用下载地址,流式写入临时文件,同时校验 content type、大小和 SHA-256,再原子安装 local/base 并写 manifest。commit 会校验本地结构,携带 checkout 时的 version/revision/ETag,通过专用 HTTP 上传原始正文;完整正文不会成为 MCP tool 参数。
|
|
222
|
+
连接配置、契约缓存、worktree、冲突材料和截图都属于项目运行时数据并写入 `.gitignore`。`.draftgo/tmp/` 可由 `draftgo clean` 清理;需要用户查看的证据放在已注册的 `.draftgo/artifacts/` 下。
|
|
298
223
|
|
|
299
|
-
##
|
|
224
|
+
## Skill 与 Reference
|
|
300
225
|
|
|
301
|
-
|
|
226
|
+
Skill 只放稳定的领域知识、项目边界和操作规则;动态 operation schema 由 MCP 提供并缓存在项目运行时。Reference 不拆成更小文件,保留按任务路由、前端运行时、安全、自定义服务、checkout 和 MCP 契约所需的完整上下文,避免过度拆分损失效果。
|
|
302
227
|
|
|
303
|
-
|
|
304
|
-
.draftgo/conflicts/<pages|navigations|docs>/<id>/
|
|
305
|
-
├── conflict.json
|
|
306
|
-
├── base.<ext>
|
|
307
|
-
├── local.<ext>
|
|
308
|
-
└── remote.<ext>
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
处理流程:
|
|
312
|
-
|
|
313
|
-
1. `draftgo conflict show <type> <id>` 定位三份材料和 worktree 文件。
|
|
314
|
-
2. 在 worktree 文件中人工或借助可靠的三方合并工具完成合并。
|
|
315
|
-
3. `draftgo conflict resolve <type> <id>` 校验 worktree,并把冲突时保存的 remote 版本设为新 base。
|
|
316
|
-
4. 重新运行 `draftgo check`、必要时 `draftgo verify`、`draftgo diff`,最后 `draftgo commit`。
|
|
228
|
+
支持的 Skill target 包括 Claude Code、Cursor、Windsurf、Antigravity、Kiro、GitHub Copilot、Codex CLI、Gemini CLI 和 Pi。Pi 的项目级 Skill 安装到 `.agents/skills/draftgo/`,可被 Pi 按 Agent Skills 标准自动发现。
|
|
317
229
|
|
|
318
|
-
##
|
|
230
|
+
## 开发与测试
|
|
319
231
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
{
|
|
324
|
-
"server": "https://draftgo.example",
|
|
325
|
-
"overview": {},
|
|
326
|
-
"resources": [],
|
|
327
|
-
"checkouts": [],
|
|
328
|
-
"legacy_cache": { "ignored": true, "detected": [] }
|
|
329
|
-
}
|
|
232
|
+
```bash
|
|
233
|
+
npm run validate:skill
|
|
234
|
+
npm test
|
|
330
235
|
```
|
|
331
236
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
`draftgo verify` 是交付前统一入口。无参数时只运行快速本地 `check`;`--remote` 才联网,`--url` 才启动浏览器。浏览器检查默认使用 `--frame auto`,同时检查顶层页面和可见 iframe,因此 `--selector` 可匹配 `iframe.srcdoc` 中的业务 DOM。`--viewport mobile|desktop|both` 控制目标视口,截图默认关闭。
|
|
237
|
+
本地开发要求 Node.js `>=20.19`。浏览器依赖仅在显式视觉验收时使用;普通 `npm test` 不会启动浏览器。
|
|
335
238
|
|
|
336
|
-
|
|
239
|
+
许可证:MIT
|
|
337
240
|
|
|
338
|
-
##
|
|
241
|
+
## Install without npm
|
|
339
242
|
|
|
340
|
-
|
|
243
|
+
DraftGo can be installed from the China download endpoint. The installer falls back to a GitHub mirror and the official GitHub Release when the primary endpoint is unavailable.
|
|
341
244
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
-
|
|
345
|
-
- 内置 UI、图标、Chat SDK、AIHub 结构化输出以及前端运行、交互和验收规则见 `resources/skill/references/`;CLI 和 Skill 不提供页面模板。
|
|
346
|
-
- 自定义服务使用 Go `draftgo/sdk`,通过 `Register(app *sdk.App)` 注册 Route、事件和定时任务;管理权限、调用权限、并发和出站请求约束见 `resources/skill/references/custom-services.md`。
|
|
347
|
-
- 自定义服务、数据、AIHub、权限和系统配置通过实时 MCP/API 操作,不从 `.draftgo/*/index.json` 推断远端状态。
|
|
348
|
-
|
|
349
|
-
`draftgo update` 只刷新 CLI 和 Skill 资源,不覆盖项目的 `.draftgo/config.json`、worktree、冲突材料、Task、lessons 或 changelog。渲染 Skill 时,`{{SKILL_DIR}}` / `{{SKILL_SCRIPTS}}` 会替换为当前宿主目录;CLI 不改写项目的 `AGENTS.md` 或 `GEMINI.md`。
|
|
350
|
-
|
|
351
|
-
## 常用选项
|
|
352
|
-
|
|
353
|
-
- `--project <dir>`:操作指定项目目录,默认当前目录。
|
|
354
|
-
- `--output json`:为 map、check、checkout、commit、diff、conflicts、conflict、api 或 delete 输出 JSON。
|
|
355
|
-
- `--type <type>`:限制 `map` 查询一种正文资源类型;支持 pages、nav/navigations、docs/articles 及其别名。
|
|
356
|
-
- `--strict`:check/deploy/auto-push 将 warnings 视为失败。
|
|
357
|
-
- `--remote`:让 check 按需对比 checkout 的远端版本和 hash;默认仍为快速离线检查。
|
|
358
|
-
- `--force`:init 覆盖已有 Skill;checkout 显式覆盖已修改的本地正文。update 始终刷新目标 Skill。
|
|
359
|
-
- `--purge`:uninstall 时同时删除整个 `.draftgo/` 运行时目录。
|
|
360
|
-
- `--skip-update-check`:update 不访问 npm,直接用当前 CLI 刷新 Skill。
|
|
361
|
-
- `--connect` / `--local-dev` / `--no-setup`:控制 init 安装 Skill 后的基座处理流程。
|
|
362
|
-
- `--target <name,...>`:为 MCP setup/status 指定一个或多个宿主。
|
|
363
|
-
- `--server <url>` / `--token <sat>`:非交互 connect;不传时安全提示输入。
|
|
364
|
-
- `--mcp-url <url>`:为 connect 显式指定完整 MCP endpoint;标准 `/mcp` 可自动推导基础地址,自定义路径需同时传 `--server`。
|
|
365
|
-
- `--allow-offline` / `--no-mcp-setup`:允许 connect 在 MCP 暂不可用时保存,或跳过宿主配置。
|
|
366
|
-
- `--yes`:跳过支持该选项的交互确认。
|
|
367
|
-
- `--ui auto|always|never`:控制 verify 的浏览器验证;默认 auto,只在提供 `--url` 时运行。
|
|
368
|
-
- `--viewport mobile|desktop|both`:控制 verify 的目标视口;不传时使用 `--width/--height` 或 390x844。
|
|
369
|
-
- `--frame auto|top|all|<iframe-selector>`:控制 verify 检查哪些 frame;默认检查顶层与可见 iframe。
|
|
370
|
-
- `--resource <type:id>`:兼容入口使用;推荐直接写 `draftgo verify pages 42 --url ...`。
|
|
371
|
-
- `--browser-path <file>`:verify 显式使用浏览器可执行文件;也可设置 `DRAFTGO_BROWSER_PATH`,否则自动查找系统浏览器和 Playwright 缓存。
|
|
372
|
-
- `--token auto|never`:verify 默认读取 `.draftgo/config.json`,对与 `server` 同源的地址自动附加 `token=<SAT>`;配置无 SAT、跨源地址或 `never` 模式均不附加。
|
|
373
|
-
- `--screenshot on-failure|always|never`:控制 UI 截图。
|
|
374
|
-
- `--delivery local|preview|deploy`:控制 deploy 行为。
|
|
375
|
-
- `--timeout <ms>`:控制 connect 或 MCP test 的远端请求超时。
|
|
376
|
-
|
|
377
|
-
设置 `DRAFTGO_NO_UPDATE_CHECK=1` 可关闭 npm 版本检查,适用于离线或 CI 环境。
|
|
245
|
+
```bash
|
|
246
|
+
# macOS / Linux
|
|
247
|
+
curl -fsSL https://draftgo.cn/draftgo-cli/install.sh | sh
|
|
378
248
|
|
|
379
|
-
|
|
249
|
+
# Windows PowerShell
|
|
250
|
+
irm https://draftgo.cn/draftgo-cli/install.ps1 | iex
|
|
251
|
+
```
|
|
380
252
|
|
|
381
|
-
|
|
253
|
+
The download source can be overridden with `DRAFTGO_INSTALL_BASE_URL`, the GitHub Release mirror with `DRAFTGO_GITHUB_MIRROR`, and the version with `DRAFTGO_VERSION`. The CLI archive includes its npm dependencies but currently requires Node.js >=20.19.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "draftgo-cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Install and manage the DraftGo skill across AI coding agents (Claude Code, Codex, Cursor, Windsurf, Antigravity, Copilot, Gemini, Kiro).",
|
|
3
|
+
"version": "4.0.22",
|
|
4
|
+
"description": "Install and manage the DraftGo skill across AI coding agents (Claude Code, Codex, Cursor, Windsurf, Antigravity, Copilot, Gemini, Kiro, Pi).",
|
|
5
5
|
"bin": {
|
|
6
6
|
"draftgo": "bin/draftgo.js"
|
|
7
7
|
},
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"antigravity",
|
|
30
30
|
"copilot",
|
|
31
31
|
"gemini",
|
|
32
|
-
"kiro"
|
|
32
|
+
"kiro",
|
|
33
|
+
"pi"
|
|
33
34
|
],
|
|
34
35
|
"author": "draftgo <cabinai@163.com> (https://github.com/draftgo)",
|
|
35
36
|
"license": "MIT",
|
|
@@ -44,14 +45,18 @@
|
|
|
44
45
|
"scripts": {
|
|
45
46
|
"lint": "node scripts/check-syntax.js",
|
|
46
47
|
"validate:skill": "node scripts/validate-skill.js",
|
|
48
|
+
"sync:custom-service-sdk": "node scripts/sync-custom-service-sdk.js",
|
|
49
|
+
"build:release": "node scripts/build-release.js",
|
|
47
50
|
"verify:package": "node scripts/verify-package.js",
|
|
48
|
-
"test": "npm run lint && npm run validate:skill && npm run verify:package && npm run test:unit && npm run test:workflow && npm run test:
|
|
51
|
+
"test": "npm run lint && npm run validate:skill && npm run verify:package && npm run test:unit && npm run test:components && npm run test:capabilities && npm run test:workflow && npm run test:worklog && npm run test:mcp && npm run test:worktree && npm run test:integration && npm run test:local && npm run test:e2e",
|
|
49
52
|
"test:unit": "node tests/unit.js",
|
|
50
|
-
"test:
|
|
51
|
-
"test:
|
|
53
|
+
"test:components": "node --test tests/components.test.js",
|
|
54
|
+
"test:capabilities": "node --test tests/capabilities.test.js",
|
|
55
|
+
"test:workflow": "node tests/workflow.test.js",
|
|
56
|
+
"test:worklog": "node tests/worklog.test.js",
|
|
52
57
|
"test:mcp": "node tests/mcp.test.js",
|
|
53
58
|
"test:worktree": "node tests/worktree.test.js",
|
|
54
|
-
"test:
|
|
59
|
+
"test:integration": "node tests/integration.test.js",
|
|
55
60
|
"test:local": "node tests/local-runtime.js",
|
|
56
61
|
"test:e2e": "node tests/e2e.js"
|
|
57
62
|
},
|