draftgo-cli 3.0.55 → 4.0.1
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 +112 -316
- package/package.json +5 -5
- package/resources/skill/SKILL.md +25 -24
- package/resources/skill/init/SKILL.md +5 -10
- package/resources/skill/manifest.json +2 -2
- package/resources/skill/references/aihub.md +10 -5
- package/resources/skill/references/chat-sdk.md +10 -0
- package/resources/skill/references/checkout.md +4 -4
- package/resources/skill/references/custom-services.md +65 -226
- package/resources/skill/references/data.md +3 -2
- package/resources/skill/references/frontend.md +96 -490
- package/resources/skill/references/mcp.md +39 -103
- package/resources/skill/references/runtime.md +3 -2
- package/resources/skill/story/SKILL.md +1 -2
- package/src/apiContractCache.js +112 -0
- package/src/cli.js +1 -21
- package/src/commandRegistry.js +6 -11
- package/src/commands/api.js +28 -8
- package/src/commands/check.js +1 -10
- package/src/commands/customService.js +2 -4
- package/src/commands/delete.js +23 -46
- package/src/commands/deploy.js +1 -1
- package/src/commands/help.js +16 -31
- package/src/commands/init.js +4 -10
- package/src/commands/listTargets.js +1 -1
- package/src/commands/local.js +2 -6
- package/src/commands/map.js +0 -11
- package/src/commands/status.js +1 -1
- package/src/commands/uninstall.js +3 -3
- package/src/commands/update.js +1 -1
- package/src/commands/verify.js +43 -21
- package/src/commands/{verifyUi.js → visualVerify.js} +28 -116
- package/src/commands/worklog.js +86 -0
- package/src/customServices.js +150 -33
- package/src/{localdev → localRuntime}/detect.js +1 -1
- package/src/{localdev → localRuntime}/mysqlClient.js +1 -1
- package/src/{localdev → localRuntime}/services.js +1 -1
- package/src/projectConfig.js +2 -0
- package/src/{installers/index.js → targets.js} +3 -5
- package/src/worklog.js +274 -0
- package/src/workspaceHealth.js +1 -1
- package/src/worktree/index.js +81 -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/src/{localdev → localRuntime}/compose.js +0 -0
- /package/src/{localdev → localRuntime}/index.js +0 -0
package/resources/skill/SKILL.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: draftgo
|
|
3
|
-
description: Use this skill to inspect, develop, debug, or deliver a DraftGo application. Read task-specific references before
|
|
3
|
+
description: Use this skill to inspect, develop, debug, or deliver a DraftGo application. Read task-specific references before live MCP discovery, use checkout/commit for complete page, navigation, document, and custom-service bodies, and track work in the project worklog.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## Workflow 2.0 authority
|
|
7
7
|
|
|
8
8
|
- Treat pages, navigations, docs/articles, and custom services as checkout resources. Never save complete MCP responses, duplicate source snapshots, temporary Go modules, SDK stubs, executables, or build directories by hand.
|
|
9
9
|
- The root Skill loads automatically. Before acting, read the smallest relevant Reference set from the task-routing table, then use MCP only for live project evidence.
|
|
10
|
-
- Custom-service flow: read `references/custom-services.md
|
|
11
|
-
-
|
|
12
|
-
- Normal delivery
|
|
10
|
+
- Custom-service flow: read `references/custom-services.md`, locate and checkout the service, edit four files, then commit and validate the cloud draft. Run a server test or publish only when the task requires it. CLI and admin UI edit the same cloud draft.
|
|
11
|
+
- At task start, run `draftgo work start "<item>"`. Add independent items with `draftgo work add`; mark them active with `start-item` and complete only after verification and delivery. `.draftgo/worklog.md` is the only task and completion record.
|
|
12
|
+
- Normal delivery runs `draftgo verify` once; it already includes the local checks. Never start browser verification or create screenshots unless the user explicitly requests visual acceptance. For explicit visual acceptance, capture and inspect a desktop screenshot first with `--url <url> --screenshot always`; use `--ui always` only when the user also requests interaction or DOM verification, and add mobile/multi-viewport checks only when requested.
|
|
13
13
|
- `.draftgo/tmp/` is entirely disposable. CLI data uses `.draftgo/tmp/<command>/<run-id>/`; AI-created scratch files use `.draftgo/tmp/ai/<run-id>/`. User-facing evidence belongs under registered `.draftgo/artifacts/`. Use `draftgo clean --dry-run` before `draftgo clean --yes`.
|
|
14
14
|
|
|
15
15
|
# DraftGo 开发助手
|
|
@@ -17,9 +17,9 @@ description: Use this skill to inspect, develop, debug, or deliver a DraftGo app
|
|
|
17
17
|
## 核心边界
|
|
18
18
|
|
|
19
19
|
- 本地 Skill / Reference 提供产品约束、运行机制和实践;MCP 提供当前项目、资源、API、权限与 schema。
|
|
20
|
-
- pages、navigations、docs/articles 的完整正文只通过 `draftgo checkout`、本地 worktree 和 `draftgo commit` 处理,不放进 MCP 参数、结果、日志或聊天上下文。
|
|
20
|
+
- pages、navigations、docs/articles、custom_services 的完整正文只通过 `draftgo checkout`、本地 worktree 和 `draftgo commit` 处理,不放进 MCP 参数、结果、日志或聊天上下文。
|
|
21
21
|
- db_meta、AIHub、system_config、roles、users、doc_categories 和自定义服务元数据直接通过 MCP 读写,不建立本地索引。
|
|
22
|
-
- 根 Skill 会在触发时自动加载。Agent 必须先按任务读取最少必要的 Reference,再通过 MCP 获取实时项目证据;MCP 不可用时报告连接、协议或 SAT
|
|
22
|
+
- 根 Skill 会在触发时自动加载。Agent 必须先按任务读取最少必要的 Reference,再通过 MCP 获取实时项目证据;MCP 不可用时报告连接、协议或 SAT 问题。
|
|
23
23
|
- CLI 不提供页面模板,不预设页面骨架、视觉风格、原生技术或组件库选择。Agent 根据任务、受众、现有产品语言和可用资源自主设计。
|
|
24
24
|
- 本地 Docker、MySQL、Redis、Milvus 与 `draftgo local ...` 独立于 MCP 工作流,必须保留。
|
|
25
25
|
|
|
@@ -44,9 +44,8 @@ description: Use this skill to inspect, develop, debug, or deliver a DraftGo app
|
|
|
44
44
|
## 所有权与执行
|
|
45
45
|
|
|
46
46
|
- 同一文件或 DraftGo 资源全程只能由一个 Agent 修改;其他 Agent 只读分析并回传建议。
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
- 主 Agent 负责 Reference/MCP 路由、owner 分配、汇总回读、统一验证、交付和完成日志;子 Agent 不单独写 changelog。
|
|
47
|
+
- 不同资源、operation 和 owner 不冲突的工作单元并发执行,不设置客户端并发上限;同一资源的依赖步骤保持串行。
|
|
48
|
+
- 主 Agent 负责 Reference/MCP 路由、owner 分配、汇总回读、统一验证、交付和 worklog 状态。
|
|
50
49
|
- 冲突 owner、接口依赖或验证失败会阻塞依赖项,不影响无关分支继续汇总。
|
|
51
50
|
|
|
52
51
|
## 开发与交付
|
|
@@ -55,25 +54,26 @@ description: Use this skill to inspect, develop, debug, or deliver a DraftGo app
|
|
|
55
54
|
|
|
56
55
|
1. 确认目标 pages/nav/docs 已存在并通过 MCP 读取 metadata;新增资源先按实时 API 契约创建并取得 ID。
|
|
57
56
|
2. 对需要完整分析或编辑的目标批量 checkout;在 `.draftgo/worktree/` 按唯一 owner 编辑。
|
|
58
|
-
3. 主 Agent
|
|
59
|
-
4. 用 `draftgo diff <type> <id>` 检查 base/local 差异,再按类型运行 `draftgo commit ...`。
|
|
57
|
+
3. 主 Agent 回读全部修改,并按顶部统一验证策略完成交付前验收。
|
|
58
|
+
4. 用 `draftgo diff <type> <id>` 检查 base/local 差异,再按类型运行 `draftgo commit ...`。
|
|
60
59
|
5. 409/412 时停止自动提交,保留 base/local/remote 冲突材料;不得 force、覆盖或自动合并。
|
|
61
60
|
|
|
62
61
|
完整 manifest、流式传输、哈希和冲突规则见 `references/checkout.md`。
|
|
63
62
|
|
|
64
63
|
### 结构化资源
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
遵循 `references/mcp.md` 的契约缓存:operation 未知才 search,首次使用或 revision 变化时 describe,其他情况复用缓存并直接 call。describe 不完整就停止,不猜参数、响应、权限或风险。独立资源并发读写,回读结果并验证副作用;结构化资源不 checkout。
|
|
67
66
|
|
|
68
|
-
###
|
|
67
|
+
### 工作记录
|
|
69
68
|
|
|
70
|
-
|
|
69
|
+
任务开始即写入开发中状态;独立事项可先以待开发状态加入:
|
|
71
70
|
|
|
72
71
|
```bash
|
|
73
|
-
draftgo
|
|
72
|
+
draftgo work start "<事项>"
|
|
73
|
+
draftgo work add "<独立事项>"
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
开始处理待开发项时运行 `draftgo work start-item <编号>`。只有 `draftgo verify` 和所有 commit/MCP 写入成功后,才运行 `draftgo work complete <编号> --note "<结果或证据>"`。用户明确要求视觉验收时还需完成对应截图或浏览器校验。任何验证失败、409/412 或交付失败都不得标记为完成。
|
|
77
77
|
|
|
78
78
|
## 安全规则
|
|
79
79
|
|
|
@@ -82,25 +82,26 @@ draftgo changelog add "<完成结果>"
|
|
|
82
82
|
- 页面通过 `window.parent.App` 使用认证、权限、反馈和主题;登出调用 `await App.logout()`,路由参数读取运行时注入对象。详细规则见 `frontend.md`、`runtime.md` 与 `app-api.md`。
|
|
83
83
|
- 自定义服务普通 SDK 继承调用者权限;仅显式 `draftgo.Admin.*` 提升单次调用并进入审计。Route 权限、脚本管理权限、定时/事件身份和出站限制见 `custom-services.md`。
|
|
84
84
|
- 高风险 MCP operation 仅在用户意图明确且影响范围已核对时设置 `confirm=true`。不要传 SAT、Authorization、tenant override 或自行实现旧式二次认证。
|
|
85
|
-
-
|
|
85
|
+
- 不要隐式 force、自动重试覆盖或自动合并冲突。
|
|
86
86
|
|
|
87
87
|
## 验证证据
|
|
88
88
|
|
|
89
89
|
| 范围 | 最低证据 |
|
|
90
90
|
|---|---|
|
|
91
91
|
| MCP 连接 | 失败时用 `draftgo mcp test` 核对 initialize、tools/list 和关键工具;输出不含 SAT |
|
|
92
|
-
| 页面、导航、文档 | checkout manifest
|
|
93
|
-
| 结构化资源 |
|
|
94
|
-
| 自定义服务 |
|
|
95
|
-
| 冲突 | `.draftgo/conflicts/` 的 base/local/remote;解决后重新
|
|
92
|
+
| 页面、导航、文档 | checkout manifest、交付前 `draftgo verify`、diff、commit 返回版本与哈希 |
|
|
93
|
+
| 结构化资源 | 缓存或最新 describe 契约、call 结果与必要回读 |
|
|
94
|
+
| 自定义服务 | commit revision、validate 结果;任务涉及运行或发布时再提供 test/publish 结果 |
|
|
95
|
+
| 冲突 | `.draftgo/conflicts/` 的 base/local/remote;解决后重新 `draftgo verify`、diff 和 commit |
|
|
96
96
|
| 本地底座 | `draftgo local status`、日志和相关 local 测试 |
|
|
97
97
|
|
|
98
|
-
`draftgo deploy
|
|
98
|
+
`draftgo deploy` 和 `auto-push` 只能沿用当前 check/commit 语义。主 Agent 最终明确区分 Skill 约束、MCP 实时状态和 checkout 正文证据。
|
|
99
99
|
|
|
100
100
|
## 本地工作区
|
|
101
101
|
|
|
102
102
|
- `.draftgo/config.json`:server、SAT 与 CLI 设置,必须 gitignore。
|
|
103
|
+
- `.draftgo/api-contract-cache.json`:按 registry revision 缓存的私有 operation schema,必须 gitignore。
|
|
103
104
|
- `.draftgo/worktree/`、`.base/`、`manifest.json`:checkout 正文及基线,必须 gitignore。
|
|
104
105
|
- `.draftgo/conflicts/`:409/412 材料,必须 gitignore。
|
|
105
|
-
- `.draftgo/story.yaml`、`
|
|
106
|
-
- `.draftgo/
|
|
106
|
+
- `.draftgo/story.yaml`、`lessons/`:项目决策和经验。
|
|
107
|
+
- `.draftgo/worklog.md`:待开发、开发中和已完成事项及备注。
|
|
@@ -17,30 +17,25 @@ description: Install or refresh the DraftGo skill, connect a project to a DraftG
|
|
|
17
17
|
- 已有 DraftGo 服务器:运行 draftgo connect。
|
|
18
18
|
- 需要本地 Docker 基座:运行 draftgo local setup。
|
|
19
19
|
6. 连接后运行 draftgo mcp setup(或指定目标),再运行 draftgo mcp test 验证 initialize、tools/list 和关键工具。
|
|
20
|
-
7. 根 Skill 自动加载后,按实际任务读取最少必要的 Reference,并通过 MCP project_overview、resource_search 或 api_search 获取实时信息;需要叠加本地 checkout 状态时运行 `draftgo map`。MCP
|
|
20
|
+
7. 根 Skill 自动加载后,按实际任务读取最少必要的 Reference,并通过 MCP project_overview、resource_search 或 api_search 获取实时信息;需要叠加本地 checkout 状态时运行 `draftgo map`。MCP 不可用时报告原因。
|
|
21
21
|
|
|
22
22
|
draftgo init 只负责 Skill 安装;draftgo connect 负责保存并验证 server/SAT;draftgo mcp setup 负责宿主配置。不要混用职责。
|
|
23
23
|
|
|
24
|
-
初始化后 `.draftgo/` 只保留已经写入的 `config.json`。不要预建
|
|
24
|
+
初始化后 `.draftgo/` 只保留已经写入的 `config.json`。不要预建 worklog、lessons、worktree、conflicts 或其他占位文件和目录;首次实际使用对应能力时再创建。
|
|
25
25
|
|
|
26
26
|
## SAT 与配置
|
|
27
27
|
|
|
28
28
|
- 交互式连接应使用隐藏输入;不要把 SAT 写入宿主配置、Skill 文件、命令行示例或日志。
|
|
29
29
|
- .draftgo/config.json、checkout manifest、base 和冲突目录必须加入项目 .gitignore。
|
|
30
30
|
- bridge 从当前项目配置读取 SAT;宿主配置只引用 draftgo mcp serve。
|
|
31
|
-
- 旧 .draftgo 缓存不自动删除。把它当作 legacy 数据,提示用户使用 MCP 或 checkout 重新建立上下文。
|
|
32
31
|
|
|
33
32
|
## 后续动作
|
|
34
33
|
|
|
35
34
|
- 宿主配置和诊断:draftgo mcp setup/status/test,详见 ../references/mcp.md。
|
|
36
35
|
- 开发准备:根 Skill 自动加载;按任务路由读取最少必要的 Reference,再按需直接调用 MCP。
|
|
37
36
|
- 远端资源补充定位:MCP project_overview、resource_search、resource_list。
|
|
38
|
-
-
|
|
37
|
+
- 正文编辑:遵循根 Skill 的 checkout/commit 与统一验证策略。
|
|
39
38
|
- 结构化资源:直接使用 MCP 的 api_search、api_describe、api_call;不 checkout、不生成本地镜像。
|
|
40
|
-
-
|
|
41
|
-
- 管理本地基座:draftgo local start|stop|logs|status
|
|
39
|
+
- 工作记录:开发开始时运行 `draftgo work start "<事项>"`;只有统一验证且全部 commit/MCP 交付成功后运行 `draftgo work complete <编号> --note "<结果>"`。验证、冲突或交付失败时不得标记为完成。
|
|
40
|
+
- 管理本地基座:draftgo local setup|start|stop|logs|status。
|
|
42
41
|
- 移除指定目标:draftgo uninstall <target>;完整移除所有目标只在用户明确要求时运行 draftgo uninstall all,--purge 会删除 .draftgo/。
|
|
43
|
-
|
|
44
|
-
## 迁移旧命令
|
|
45
|
-
|
|
46
|
-
draftgo pull 不再执行同步。它只能给出迁移提示并返回非零,指导使用 MCP 定位资源或 checkout 长正文。不要悄悄恢复全量下载。
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
"schema_version": "1.0",
|
|
3
3
|
"id": "draftgo",
|
|
4
4
|
"name": "DraftGo 开发助手",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "4.0.1",
|
|
6
6
|
"entry": "SKILL.md",
|
|
7
7
|
"description": "以 Skill/reference 任务路由、MCP 实时发现、长正文 checkout/commit、统一验证和完成日志为边界的 DraftGo 工作流。",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"capabilities": [
|
|
10
10
|
"draftgo-development",
|
|
11
11
|
"reference-routing",
|
|
12
|
-
"
|
|
12
|
+
"worklog-tracking",
|
|
13
13
|
"custom-service-ai-sdk",
|
|
14
14
|
"mcp-bridge",
|
|
15
15
|
"content-checkout-commit",
|
|
@@ -5,7 +5,7 @@ read_when: 创建或调优 AI Agent 时 · 需要工具/子智能体/记忆/多
|
|
|
5
5
|
# AIHub / Agent 资源
|
|
6
6
|
|
|
7
7
|
AIHub 是结构化远端资源,不 checkout,也不生成本地镜像。先使用 MCP `draftgo_resource_search`/`draftgo_resource_list`
|
|
8
|
-
|
|
8
|
+
定位资产;未知 operation 才用 `draftgo_api_search`,首次使用或 registry revision 变化时 `draftgo_api_describe`,然后通过 `draftgo_api_call` 读写。
|
|
9
9
|
更新 AIHub 资产时只发送实时契约允许的字段;常见字段包括
|
|
10
10
|
`type, name, data, priority, version, tags, describe, permission, status`。供应商和模型使用各自的实时接口,
|
|
11
11
|
不要经旧 AIHub 资产接口写入。任何输出、工作区文件或调用参数都不得保存 API Key 或 header 值;只可处理
|
|
@@ -29,7 +29,7 @@ AIHub 是结构化远端资源,不 checkout,也不生成本地镜像。先
|
|
|
29
29
|
|
|
30
30
|
页面对话 UI 使用 `<dg-chat protocol="draftgo-agent" agent-id="AGENT_ID">` 或 `DraftGoChat.create()`;
|
|
31
31
|
旧代码/无 UI 文本调用可用 `DraftGoAI.chat(...)`,图片模式使用 `DraftGoAI.images(...)`。调用前都必须加载
|
|
32
|
-
`/assets/draftgo-chat.js`,完整用法见 `references/chat-sdk.md`。后端 operation 与可调用 Agent 列表通过 MCP
|
|
32
|
+
`/assets/draftgo-chat.js`,完整用法见 `references/chat-sdk.md`。后端 operation 与可调用 Agent 列表通过 MCP 实时确认;已知契约可复用项目缓存。
|
|
33
33
|
|
|
34
34
|
## `data.spec` 字段地图
|
|
35
35
|
|
|
@@ -44,7 +44,8 @@ AIHub 是结构化远端资源,不 checkout,也不生成本地镜像。先
|
|
|
44
44
|
| `ttft_timeout` | number(秒,1–600,空=不启用) | 首字超时 failover:首个 SSE data 事件超时即跨模型+跨供应商切换,推理模型不误杀 |
|
|
45
45
|
| `sync_request_timeout` | number(秒,1–600,默认 100) | 非流式请求上限 |
|
|
46
46
|
| `stream_ttl` | number(秒,1–3600,默认 600) | 流式请求上限 |
|
|
47
|
-
| `
|
|
47
|
+
| `max_tokens` | number / 空 | 最大输出 token;留空时不写入请求,即不由 Agent 额外限制 |
|
|
48
|
+
| `reasoning_effort` | `off`/`minimal`/`low`/`medium`/`high` | `off`/留空均不透传;其它值仅 OpenAI 系模型生效 |
|
|
48
49
|
| `system_prompt_template` | string | 系统提示模板 |
|
|
49
50
|
| `context.max_history` | number(默认 20) | 工作窗口:保留最近 N 条;关闭持续对话时即滑动窗口硬上限 |
|
|
50
51
|
| `output_format.mode` | `text` / `json` | JSON 时按 `output_format.json.{schema,schema_name,strategy}` 约束/校验/降级 |
|
|
@@ -68,7 +69,9 @@ AIHub 是结构化远端资源,不 checkout,也不生成本地镜像。先
|
|
|
68
69
|
| `memory.{enabled,scope}` | false / `user_agent` | 长期记忆:对话后自动提炼、下轮召回注入;作用域 `agent`/`user`/`user_agent` |
|
|
69
70
|
| `compaction.{enabled,keep_recent,trigger_messages,trigger_tokens,preset}` | 关闭 | **持续对话/上下文闭环**:见下 |
|
|
70
71
|
| `checkpoint_input_mode` / `checkpoint_max_messages` / `checkpoint_ttl_seconds` | 全量 / 100 / 86400 | 会话历史持久化(配合请求 `session_id`) |
|
|
71
|
-
| `delegation.{max_depth,max_total_calls}` | 2 / 8 |
|
|
72
|
+
| `delegation.{max_depth,max_total_calls}` | 2 / 8 | 最大嵌套层数与整棵调用树共享的子 Agent 调用次数;并行分支也从同一预算扣减 |
|
|
73
|
+
|
|
74
|
+
同一模型步骤返回多个子 Agent 工具调用时,运行时立即按 `tool_concurrency` 并发执行;不同步骤自然串行,由模型自行决定编排方式。委派成功后,子 Agent 的每个模型回合 token 会汇总到入口 run,总量也写入对应委派 span。一次入口请求只创建一条主 run,Agent 列归属入口 Agent,委派链路从 span 查看。
|
|
72
75
|
|
|
73
76
|
### 持续对话(上下文闭环)
|
|
74
77
|
|
|
@@ -83,6 +86,8 @@ AIHub 是结构化远端资源,不 checkout,也不生成本地镜像。先
|
|
|
83
86
|
## 观测
|
|
84
87
|
|
|
85
88
|
每次调用都开一条 AI run,管理台 `/admin/ai-runs` 展示状态、tokens、延迟、`ttft_ms` 与 span 链路。
|
|
86
|
-
运行记录接口通过 MCP
|
|
89
|
+
运行记录接口通过 MCP 实时发现,不维护静态路径表;已知 operation 复用 registry revision 未变化的契约缓存。
|
|
90
|
+
|
|
91
|
+
Agent 对外响应(`/api/agents/{id}/chat`、图片接口、Go/Script SDK Agent 调用)不返回内部 `model`、`fallback_models` 或 `upstream_model`;错误也不暴露内部模型名、供应商名称、服务地址或运行时实现名。只有显式启用 `model_selection.user_selectable` 后,`/selectable-models` 才作为授权的模型选择目录返回可选逻辑模型名。运行日志仍在服务端保留真实模型、供应商与链路信息用于定位。
|
|
87
92
|
|
|
88
93
|
> 权威细节以 DraftGo 后端 `docs/backend/modules/agent-runtime.md` 为准;本页是基座开发者视角的字段速查。
|
|
@@ -165,6 +165,9 @@ chat.addEventListener('dg-chat:run-finish', event => {
|
|
|
165
165
|
- `persist` 默认开启,将 UI thread 历史写入 `localStorage`;敏感或临时页面设为 `false`。
|
|
166
166
|
- 同一路由存在多个实例时,每个实例设置唯一 `storageKey`。
|
|
167
167
|
- 每个 UI thread 自动维护独立 `sessionId`;`draftgo-agent` 将其作为 `session_id` 发送。
|
|
168
|
+
- 切换会话只改变当前视图,不会停止其它 thread 的在途请求。会话列表标题左侧显示运行中状态;后台完成或失败后显示未读状态,进入该会话即视为已读并清除。
|
|
169
|
+
- 每个请求使用独立 `run_id`。用户停止或 SDK 超时会调用 Agent 取消接口;普通会话切换不会发送取消。
|
|
170
|
+
- 推理片段和工具调用按服务端事件的输出位置保留在消息内,不固定贴在消息底部;思考在正文、工具或结束事件到达后进入完成态,不再闪烁或滚动预览。
|
|
168
171
|
- `newThread()` 创建新的后端会话边界;不要让不同用户共享固定 `storageKey` 或 `sessionId`。
|
|
169
172
|
- `clear()` 和 `setMessages([])` 会重置当前 session,避免视觉清空后恢复旧 checkpoint。
|
|
170
173
|
|
|
@@ -197,5 +200,12 @@ chat.configure({ protocol: 'page-protocol' });
|
|
|
197
200
|
- 页面 HTML、JSON config、`headers`、`context` 和 `localStorage` 中不得保存长期供应商密钥。
|
|
198
201
|
- 不把模型输出直接赋给 `innerHTML`;使用 SDK 内置 Markdown/URL 安全渲染或显式净化。
|
|
199
202
|
- 后端始终负责 Agent 调用权限、模型白名单、附件能力和大小限制,前端开关不能越权。
|
|
203
|
+
- Agent 协议响应不应包含 Agent 内部模型名。模型选择器只能读取 Agent 明确授权的 `/selectable-models` 目录。
|
|
200
204
|
|
|
201
205
|
交付前确认:只加载一个完整版脚本;新页面以 `<dg-chat>` 为对话 UI;同页多实例隔离 `storageKey`;外部协议走服务端代理;页面离开时停止在途请求。
|
|
206
|
+
|
|
207
|
+
## 移动端契约
|
|
208
|
+
|
|
209
|
+
- `inline`、`floating`、`drawer`、`fullscreen` 四种 surface 均由 SDK 自适应窄屏;`threads`、`workspace` 和 Artifact 会按容器宽度自动收敛为单栏,不要复制 Shadow DOM 内部布局规则。
|
|
210
|
+
- SDK 使用 `VisualViewport` 和 `safe-area-inset-*` 跟随软键盘、浏览器工具栏与横竖屏变化。触摸设备打开面板时不会主动弹出软键盘。
|
|
211
|
+
- 触摸端按钮和行操作具有移动端点击尺寸,输入字号防止 iOS 自动缩放;所有内部滚动区隐藏滚动条,但仍保留触摸、滚轮和键盘滚动能力。
|
|
@@ -95,14 +95,14 @@ base 已变化时必须拒绝覆盖。
|
|
|
95
95
|
## Commit 流程
|
|
96
96
|
|
|
97
97
|
1. 读取 manifest 指向的 worktree 文件,计算当前字节数和 SHA-256;未变化时返回 `unchanged`。
|
|
98
|
-
2. 按 content_type
|
|
98
|
+
2. 按 content_type 执行本地结构和内联脚本检查。
|
|
99
99
|
3. 通过专用 HTTP 流式上传原始文件,携带 `If-Match`、base version/revision、content_type、长度和 SHA-256。
|
|
100
100
|
4. 完整正文不得作为 MCP tool 参数发送。
|
|
101
101
|
5. 底座确认 hash 和新版本后,CLI 原子更新 `.base` 与 manifest。返回 hash 不一致时不得推进基线。
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
本地正文已经等于远端、但 base/manifest 落后时,先用 `draftgo check --remote` 确认 `committed_unrecorded`,再运行 `draftgo reconcile`;不要手改 manifest。
|
|
104
104
|
|
|
105
|
-
单个 commit
|
|
105
|
+
单个 commit 成功不自动完成 worklog 项。只有整个事项统一验证且全部 commit/MCP 交付成功后,主 Agent 才执行 `draftgo work complete <编号> --note "<完成结果>"`。任何检查失败、409/412 或交付失败都不得标记为完成。
|
|
106
106
|
|
|
107
107
|
## 409 / 412 冲突
|
|
108
108
|
|
|
@@ -119,7 +119,7 @@ base 已变化时必须拒绝覆盖。
|
|
|
119
119
|
- `base` 是 checkout 时的内容;`local` 是发生冲突时的本地快照;`remote` 是重新下载并校验的当前远端内容。
|
|
120
120
|
- `conflict.json` 记录三份路径、版本、ETag 和哈希,不嵌入完整正文。
|
|
121
121
|
- Agent 或用户在 worktree local 文件中完成合并;不要手写 HTML 自动合并器,也不要改动保存的三份证据。
|
|
122
|
-
- 合并完成后运行 `draftgo
|
|
122
|
+
- 合并完成后运行 `draftgo verify`,再执行 `draftgo conflict resolve <type> <id>`。
|
|
123
123
|
- resolve 校验 worktree 与 remote,采用 remote 版本作为新的 base,但保留合并后的 worktree;随后运行
|
|
124
124
|
`draftgo diff` 并 `draftgo commit`。
|
|
125
125
|
|