dsh-desktop-kit 2.15.3 → 2.15.5
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/CHANGELOG.md +13 -0
- package/README.md +21 -21
- package/client.js +2 -2
- package/docs/TEST-2.15.4.md +22 -0
- package/docs/TEST-2.15.5.md +16 -0
- package/package.json +2 -2
- package/plugins/dsh-agent-extensions/client.js +1 -1
- package/plugins/dsh-agent-extensions/index.js +12 -5
- package/plugins/dsh-agent-extensions/lib/board.js +44 -7
- package/plugins/dsh-agent-extensions/lib/worktrees.js +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.15.5 (2026-11-12)
|
|
4
|
+
|
|
5
|
+
- **Worktree merge.** `project_worktree action=merge` вливает чистую ветку `dsh/<slug>` в main через `--no-ff`; грязный main/worktree отклоняется, конфликт автоматически отменяется (`merge --abort`), ветка сохраняется.
|
|
6
|
+
- **Тесты.** merge-сценарий в `worktrees-tests`.
|
|
7
|
+
- **UI.** Подсказка Worktrees обновлена.
|
|
8
|
+
|
|
9
|
+
## 2.15.4 (2026-11-12)
|
|
10
|
+
|
|
11
|
+
- **Зависимости задач.** `team_board add-task dependsOn=[...]`; `read` показывает `blockedBy` и `ready`.
|
|
12
|
+
- **Атомарный claim.** Задачу нельзя взять дважды разными владельцами и нельзя закрыть до выполнения зависимостей.
|
|
13
|
+
- **UI.** Заблокированная задача помечается `⊘`, готовые — `○`.
|
|
14
|
+
- **Тесты.** `team-board-tests`: blocked claim/done, claim conflict, dependency completion.
|
|
15
|
+
|
|
3
16
|
## 2.15.3 (2026-11-12)
|
|
4
17
|
|
|
5
18
|
- **Live team messages.** `team_message` — лид пишет любому участнику по run id, участник — лиду через `to="parent"`; сообщение идёт через `subagents.sendMessage` и дублируется в board.
|
package/README.md
CHANGED
|
@@ -4,33 +4,33 @@
|
|
|
4
4
|
|
|
5
5
|
Набор из **16 плагинов и 30 навыков** для DeepSeek Harness 0.2.x: MCP tools/resources/prompts + OAuth 2.1, sampling, elicitation; проектные агенты, worktrees, фон и read-only рой с общей доской; русский интерфейс, автопилот навыков, токен-лаборатория, студия навыков, память проектов, guardrails, карта репозитория, чекпоинты, plan mode, browser QA, GitHub review, hooks/commands и резервные копии профиля.
|
|
6
6
|
|
|
7
|
-

|
|
8
8
|
|
|
9
9
|
## MCP: подключения без JSON
|
|
10
10
|
|
|
11
11
|
Настройки → **MCP**: пресеты GitHub, PostgreSQL и Filesystem, живые статусы, health, список tools и безопасное хранение токенов в `~/.dsh/mcp.secrets.json`. Промпты сервера открываются кнопкой **Prompts**: аргументы, запуск и копирование результата. HTTP-серверы подключаются через **OAuth 2.1 + PKCE**, **sampling** идёт через approval-карточку DSH, а **elicitation** — через глобальную форму с Accept/Decline.
|
|
12
12
|
|
|
13
|
-

|
|
14
14
|
|
|
15
|
-

|
|
16
16
|
|
|
17
|
-

|
|
18
18
|
|
|
19
19
|
## Агенты, worktrees и рой
|
|
20
20
|
|
|
21
21
|
- **Проектные роли** — `.dsh/agents/*.md`: `tools`, `permission` и `model` реально ограничивают ребёнка.
|
|
22
|
-
- **Worktrees** — `project_worktree` создаёт ветку `dsh/<slug>` и папку `.dsh/worktrees/<slug>`; `project_agent worktree=auto` запускает агента в изоляции.
|
|
22
|
+
- **Worktrees** — `project_worktree` создаёт ветку `dsh/<slug>` и папку `.dsh/worktrees/<slug>`; `merge` вливает чистую ветку в main и делает abort при конфликте; `project_agent worktree=auto` запускает агента в изоляции.
|
|
23
23
|
- **Фон** — `background=true` возвращает run id сразу; страница **Агенты** показывает очередь и кнопку «Остановить».
|
|
24
24
|
- **Команда** — `project_agent action=team names=[reviewer,researcher] task=...` запускает 2–6 read-only ролей; `worktrees=true` даёт каждому писателю отдельную ветку.
|
|
25
25
|
- **Рой и общая доска** — `team_board` хранит сообщения и задачи в `.dsh/agents/board.json` (0600, redaction, лимиты); team автоматически создаёт `teamId` и передаёт его ролям.
|
|
26
26
|
- **Живые сообщения** — `team_message` отправляет текст лиду (`to="parent"`) или участнику по run id; копия каждого сообщения остаётся в board.
|
|
27
27
|
- **Инструкции проекта** — `AGENTS.md`/`CLAUDE.md` иерархически (root → вложенные папки → `.dsh`) с `@import`; MCP roots сообщает корень проекта.
|
|
28
28
|
|
|
29
|
-

|
|
30
30
|
|
|
31
|
-

|
|
32
32
|
|
|
33
|
-

|
|
34
34
|
|
|
35
35
|
## Права и субагенты
|
|
36
36
|
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
- **Worktrees и фоновые агенты.** `project_worktree` создаёт ветку `dsh/<slug>` и отдельную папку `.dsh/worktrees/<slug>`; `project_agent ... worktree=auto background=true` запускает агента в изоляции, а страница **Агенты** показывает worktrees и очередь запусков с кнопкой «Остановить».
|
|
42
42
|
- **Инструкции проекта.** `AGENTS.md` и `CLAUDE.md` читаются иерархически (root → вложенные папки → `.dsh`) с `@import`; MCP roots сообщает серверу корень проекта.
|
|
43
43
|
|
|
44
|
-

|
|
45
45
|
|
|
46
|
-

|
|
47
47
|
|
|
48
|
-
**v2.15.
|
|
48
|
+
**v2.15.5** · MIT · проверено на DSH `0.2.1-rc.5` и `0.2.2-rc.1` (Windows 11) · без внешних зависимостей и телеметрии
|
|
49
49
|
|
|
50
50
|
**План развития:** [docs/ROADMAP-3.0.md](docs/ROADMAP-3.0.md) — Memory Fabric, семантическое
|
|
51
51
|
слияние, локальный индекс памяти, шифрованные переносы, Memory Hub и npm trusted publishing.
|
|
@@ -140,27 +140,27 @@
|
|
|
140
140
|
- перед каждой синхронизацией проверяется, что репозиторий всё ещё приватный;
|
|
141
141
|
- секреты и PII вычищаются, домашние пути заменяются токеном `%DSH_HOME%`; LLM не вызывается — **0 токенов**.
|
|
142
142
|
|
|
143
|
-

|
|
144
144
|
|
|
145
|
-

|
|
146
146
|
|
|
147
147
|
## Скриншоты
|
|
148
148
|
|
|
149
149
|
### Skills Studio: каталог, стоимость и редактор
|
|
150
150
|
|
|
151
|
-

|
|
152
152
|
|
|
153
|
-

|
|
154
154
|
|
|
155
155
|
### Token Lab: куда уходит контекст
|
|
156
156
|
|
|
157
|
-

|
|
158
158
|
|
|
159
159
|
### Тёмная тема и мобильный
|
|
160
160
|
|
|
161
|
-

|
|
162
162
|
|
|
163
|
-

|
|
164
164
|
|
|
165
165
|
## Окно-напоминание: пиковый тариф
|
|
166
166
|
|
|
@@ -170,11 +170,11 @@ DeepSeek включает двойной тариф в пиковые часы (
|
|
|
170
170
|
- **в окне** — красная карточка: причина, границы окна в местном времени и UTC, живой отсчёт до конца и рекомендация, когда вернуться;
|
|
171
171
|
- **после окна** — карточка исчезает; состояние всегда доступно через `window.__DSH_PEAK_GUARD__.state()`.
|
|
172
172
|
|
|
173
|
-

|
|
174
174
|
|
|
175
|
-

|
|
176
176
|
|
|
177
|
-

|
|
178
178
|
|
|
179
179
|
Подробности и настройки — [plugins/dsh-peak-guard/README.md](plugins/dsh-peak-guard/README.md).
|
|
180
180
|
|
package/client.js
CHANGED
|
@@ -7760,7 +7760,7 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
|
|
|
7760
7760
|
)))
|
|
7761
7761
|
: h("div", { className: "ag-mini-empty" }, "Сообщений пока нет. Запустите team — board создастся автоматически."),
|
|
7762
7762
|
board.tasks.length > 0
|
|
7763
|
-
? h("div", { className: "ag-tools" }, board.tasks.slice(-8).map((task) => h("span", { key: task.id, className: "ag-tool", title: task.title }, `${task.status === "done" ? "✓" : task.status === "claimed" ? "…" : "○"} ${task.title}`)))
|
|
7763
|
+
? h("div", { className: "ag-tools" }, board.tasks.slice(-8).map((task) => h("span", { key: task.id, className: "ag-tool", title: task.blockedBy?.length ? `blocked by ${task.blockedBy.join(", ")}` : task.title }, `${task.status === "done" ? "✓" : task.status === "claimed" ? "…" : task.ready ? "○" : "⊘"} ${task.title}`)))
|
|
7764
7764
|
: null,
|
|
7765
7765
|
),
|
|
7766
7766
|
h("div", { className: "ag-section" },
|
|
@@ -8042,7 +8042,7 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
|
|
|
8042
8042
|
if (__kitErrors.length <= 5) console.error("[dsh-desktop-kit] registration failed:", label, message);
|
|
8043
8043
|
};
|
|
8044
8044
|
try {
|
|
8045
|
-
window.__DSH_DESKTOP_KIT__ = { version: "2.15.
|
|
8045
|
+
window.__DSH_DESKTOP_KIT__ = { version: "2.15.5", parts: __partNames, errors: __kitErrors, ready: false };
|
|
8046
8046
|
} catch {}
|
|
8047
8047
|
const __inject = [];
|
|
8048
8048
|
for (const __part of __parts) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# DSH Desktop Kit 2.15.4 — тест
|
|
2
|
+
|
|
3
|
+
Дата: 2026-11-12.
|
|
4
|
+
|
|
5
|
+
## Task graph
|
|
6
|
+
|
|
7
|
+
- `team_board add-task dependsOn=[id]`.
|
|
8
|
+
- `read` returns `ready`, `blockedBy`.
|
|
9
|
+
- `claim-task` rejected while blocked or owned by another agent.
|
|
10
|
+
- `done-task` rejected until dependencies are done.
|
|
11
|
+
- Unknown dependency/self dependency rejected.
|
|
12
|
+
|
|
13
|
+
## UI
|
|
14
|
+
|
|
15
|
+
- `⊘` blocked, `○` ready, `…` claimed, `✓` done.
|
|
16
|
+
- 390/768/1440: overflow 0, console 0, markup 0.
|
|
17
|
+
|
|
18
|
+
## Проверки
|
|
19
|
+
|
|
20
|
+
- `team-board-tests` — OK.
|
|
21
|
+
- `npm test` — exit 0.
|
|
22
|
+
- `build:client` / `check:client` — OK.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# DSH Desktop Kit 2.15.5 — тест
|
|
2
|
+
|
|
3
|
+
Дата: 2026-11-12.
|
|
4
|
+
|
|
5
|
+
## Worktree merge
|
|
6
|
+
|
|
7
|
+
- `project_worktree action=merge slug=<id>`.
|
|
8
|
+
- Требования: main чистый, source worktree чистый, branch не detached.
|
|
9
|
+
- `git merge --no-ff`; при конфликте `merge --abort`, ветка остаётся.
|
|
10
|
+
- Branch после merge не удаляется.
|
|
11
|
+
|
|
12
|
+
## Тесты
|
|
13
|
+
|
|
14
|
+
- `worktrees-tests`: create → commit → merge → файл в main → commit message.
|
|
15
|
+
- `npm test` — exit 0.
|
|
16
|
+
- `build:client` / `check:client` — OK.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-desktop-kit",
|
|
3
|
-
"version": "2.15.
|
|
4
|
-
"description": "DeepSeek Harness desktop kit 2.15.
|
|
3
|
+
"version": "2.15.5",
|
|
4
|
+
"description": "DeepSeek Harness desktop kit 2.15.5: 16 plugins and 30 skills — MCP tools/resources/prompts with OAuth 2.1, sampling and elicitation, project agents, git worktrees, background runs and a read-only/writer swarm with a shared board, plus self-applying skills, token lab, Skills Studio, project memory, guardrails, repo map, checkpoints, plan mode, browser QA, GitHub review, hooks/commands, Russian UI and profile transfer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|
|
7
7
|
"dsh",
|
|
@@ -204,7 +204,7 @@ window.__ModuleLoader__.load({
|
|
|
204
204
|
)))
|
|
205
205
|
: h("div", { className: "ag-mini-empty" }, "Сообщений пока нет. Запустите team — board создастся автоматически."),
|
|
206
206
|
board.tasks.length > 0
|
|
207
|
-
? h("div", { className: "ag-tools" }, board.tasks.slice(-8).map((task) => h("span", { key: task.id, className: "ag-tool", title: task.title }, `${task.status === "done" ? "✓" : task.status === "claimed" ? "…" : "○"} ${task.title}`)))
|
|
207
|
+
? h("div", { className: "ag-tools" }, board.tasks.slice(-8).map((task) => h("span", { key: task.id, className: "ag-tool", title: task.blockedBy?.length ? `blocked by ${task.blockedBy.join(", ")}` : task.title }, `${task.status === "done" ? "✓" : task.status === "claimed" ? "…" : task.ready ? "○" : "⊘"} ${task.title}`)))
|
|
208
208
|
: null,
|
|
209
209
|
),
|
|
210
210
|
h("div", { className: "ag-section" },
|
|
@@ -13,7 +13,7 @@ import { registerProjectHooks } from "./lib/hooks.js";
|
|
|
13
13
|
import { createCheckpoint } from "./lib/checkpoints.js";
|
|
14
14
|
import { runProjectAgent, runProjectTeam } from "./lib/agents.js";
|
|
15
15
|
import { cancelRun, listRuns } from "./lib/agents.js";
|
|
16
|
-
import { createWorktree, removeWorktree, worktreeSummary } from "./lib/worktrees.js";
|
|
16
|
+
import { createWorktree, mergeWorktree, removeWorktree, worktreeSummary } from "./lib/worktrees.js";
|
|
17
17
|
import { registerChildPolicyHook } from "./lib/policy.js";
|
|
18
18
|
import { registerCommands } from "./lib/commands.js";
|
|
19
19
|
import { registerAgentApi } from "./lib/api.js";
|
|
@@ -157,12 +157,12 @@ function worktreeToolDefinition() {
|
|
|
157
157
|
return {
|
|
158
158
|
name: WORKTREE_TOOL,
|
|
159
159
|
description:
|
|
160
|
-
"Manage isolated git worktrees for project agents. `list` shows branches, paths, dirty state; `create` adds `.dsh/worktrees/<slug>` on branch `dsh/<slug>`; `remove` refuses a dirty worktree unless force=true. The branch is kept after removal.",
|
|
160
|
+
"Manage isolated git worktrees for project agents. `list` shows branches, paths, dirty state; `create` adds `.dsh/worktrees/<slug>` on branch `dsh/<slug>`; `merge` merges a clean managed branch into the main worktree and aborts on conflict; `remove` refuses a dirty worktree unless force=true. The branch is kept after removal.",
|
|
161
161
|
parameters: {
|
|
162
162
|
type: "object",
|
|
163
163
|
additionalProperties: false,
|
|
164
164
|
properties: {
|
|
165
|
-
action: { type: "string", enum: ["list", "create", "remove"], description: "list, create or remove a worktree" },
|
|
165
|
+
action: { type: "string", enum: ["list", "create", "merge", "remove"], description: "list, create, merge or remove a worktree" },
|
|
166
166
|
slug: { type: "string", description: "Worktree id: lowercase letters, digits, hyphen" },
|
|
167
167
|
base: { type: "string", description: "Base ref for create; default HEAD" },
|
|
168
168
|
force: { type: "boolean", description: "Remove a dirty/locked worktree (data loss risk)" },
|
|
@@ -183,6 +183,12 @@ function worktreeToolDefinition() {
|
|
|
183
183
|
const created = createWorktree({ cwd: project.root, slug, base: input?.base });
|
|
184
184
|
return { ok: true, text: `project_worktree create: ${created.branch} → ${created.path}`, worktree: created };
|
|
185
185
|
}
|
|
186
|
+
if (input?.action === "merge") {
|
|
187
|
+
const slug = String(input?.slug ?? "").trim();
|
|
188
|
+
if (!slug) return { ok: false, text: "project_worktree merge: slug is required" };
|
|
189
|
+
const merged = mergeWorktree({ cwd: project.root, id: slug });
|
|
190
|
+
return { ok: true, text: `project_worktree merge: ${merged.branch} → ${merged.commit.slice(0, 12)}`, worktree: merged };
|
|
191
|
+
}
|
|
186
192
|
if (input?.action === "remove") {
|
|
187
193
|
const slug = String(input?.slug ?? "").trim();
|
|
188
194
|
if (!slug) return { ok: false, text: "project_worktree remove: slug is required" };
|
|
@@ -212,6 +218,7 @@ function boardToolDefinition() {
|
|
|
212
218
|
to: { type: "string", description: "optional recipient label" },
|
|
213
219
|
title: { type: "string", description: "task title for add-task" },
|
|
214
220
|
id: { type: "string", description: "task id for claim-task/done-task" },
|
|
221
|
+
dependsOn: { type: "array", items: { type: "string" }, description: "task ids that must be done first" },
|
|
215
222
|
},
|
|
216
223
|
required: ["action"],
|
|
217
224
|
},
|
|
@@ -227,11 +234,11 @@ function boardToolDefinition() {
|
|
|
227
234
|
if (input?.action === "read") {
|
|
228
235
|
const board = readBoard(cwd, { teamId });
|
|
229
236
|
const messages = board.messages.slice(-20).map((message) => `- ${message.from}${message.to ? ` → ${message.to}` : ""}: ${message.text}`);
|
|
230
|
-
const tasks = board.tasks.map((task) => `- [${task.status}] ${task.id} ${task.title}${task.owner ? ` (${task.owner})` : ""}`);
|
|
237
|
+
const tasks = board.tasks.map((task) => `- [${task.status}${task.ready ? "" : " · blocked"}] ${task.id} ${task.title}${task.owner ? ` (${task.owner})` : ""}${task.blockedBy?.length ? ` ← ${task.blockedBy.join(", ")}` : ""}`);
|
|
231
238
|
return { ok: true, text: `team_board ${teamId || "all"}:\n${messages.join("\n") || "messages: none"}\n${tasks.join("\n") || "tasks: none"}`, messages: board.messages, tasks: board.tasks };
|
|
232
239
|
}
|
|
233
240
|
if (input?.action === "add-task") {
|
|
234
|
-
const result = addTask(cwd, { teamId, title: input?.title, owner: from });
|
|
241
|
+
const result = addTask(cwd, { teamId, title: input?.title, owner: from, dependsOn: input?.dependsOn, priority: input?.priority });
|
|
235
242
|
return { ok: true, text: `team_board task: ${result.task.id} · ${result.task.title}`, task: result.task };
|
|
236
243
|
}
|
|
237
244
|
if (input?.action === "claim-task" || input?.action === "done-task") {
|
|
@@ -75,28 +75,54 @@ export function readBoard(cwd, { teamId = "", since = "" } = {}) {
|
|
|
75
75
|
const root = projectRoot(cwd);
|
|
76
76
|
const board = read(root);
|
|
77
77
|
const messages = board.messages.filter((message) => (!teamId || message.teamId === teamId) && (!since || message.createdAt > since));
|
|
78
|
-
const tasks = board.tasks
|
|
78
|
+
const tasks = board.tasks
|
|
79
|
+
.filter((task) => !teamId || task.teamId === teamId)
|
|
80
|
+
.map((task) => ({ ...task, ...taskState(board.tasks, task) }));
|
|
79
81
|
return { root, messages, tasks };
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
function dependencyIds(task) {
|
|
85
|
+
return Array.isArray(task?.dependsOn) ? task.dependsOn.map(String) : [];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function taskState(tasks, task) {
|
|
89
|
+
const byId = new Map(tasks.map((item) => [String(item.id), item]));
|
|
90
|
+
const blockedBy = dependencyIds(task).filter((id) => byId.get(id)?.status !== "done");
|
|
91
|
+
return { blockedBy, ready: task.status !== "done" && blockedBy.length === 0 };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function validateDependencies(tasks, id, dependsOn) {
|
|
95
|
+
const ids = [...new Set(dependsOn.map(String).filter(Boolean))];
|
|
96
|
+
const known = new Set(tasks.map((task) => String(task.id)));
|
|
97
|
+
for (const dependency of ids) {
|
|
98
|
+
if (dependency === id) throw new Error("board task cannot depend on itself");
|
|
99
|
+
if (!known.has(dependency)) throw new Error(`board dependency not found: ${dependency}`);
|
|
100
|
+
}
|
|
101
|
+
return ids;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function addTask(cwd, { teamId = "", title = "", owner = "", dependsOn = [], priority = "normal" } = {}) {
|
|
83
105
|
const clean = redact(title).trim();
|
|
84
106
|
if (!clean) throw new Error("board task title is required");
|
|
85
107
|
const root = projectRoot(cwd);
|
|
86
108
|
const board = read(root);
|
|
109
|
+
const id = crypto.randomUUID();
|
|
110
|
+
const dependencies = validateDependencies(board.tasks, id, Array.isArray(dependsOn) ? dependsOn : []);
|
|
87
111
|
const task = {
|
|
88
|
-
id
|
|
112
|
+
id,
|
|
89
113
|
teamId: String(teamId),
|
|
90
114
|
title: clean,
|
|
91
115
|
owner: String(owner),
|
|
92
116
|
status: "open",
|
|
117
|
+
priority: ["low", "normal", "high"].includes(priority) ? priority : "normal",
|
|
118
|
+
dependsOn: dependencies,
|
|
93
119
|
createdAt: new Date().toISOString(),
|
|
94
120
|
updatedAt: new Date().toISOString(),
|
|
95
121
|
};
|
|
96
122
|
board.tasks.push(task);
|
|
97
123
|
board.tasks = board.tasks.slice(-MAX_TASKS);
|
|
98
124
|
write(root, board);
|
|
99
|
-
return { root, task };
|
|
125
|
+
return { root, task: { ...task, ...taskState(board.tasks, task) } };
|
|
100
126
|
}
|
|
101
127
|
|
|
102
128
|
export function updateTask(cwd, { id = "", status = "", owner = "" } = {}) {
|
|
@@ -105,9 +131,20 @@ export function updateTask(cwd, { id = "", status = "", owner = "" } = {}) {
|
|
|
105
131
|
const board = read(root);
|
|
106
132
|
const task = board.tasks.find((item) => item.id === String(id));
|
|
107
133
|
if (!task) throw new Error(`board task not found: ${id}`);
|
|
108
|
-
|
|
109
|
-
if (
|
|
134
|
+
const state = taskState(board.tasks, task);
|
|
135
|
+
if (status === "claimed") {
|
|
136
|
+
if (task.status === "claimed" && task.owner && owner && task.owner !== owner) throw new Error(`board task already claimed by ${task.owner}`);
|
|
137
|
+
if (!state.ready) throw new Error(`board task is blocked by: ${state.blockedBy.join(", ")}`);
|
|
138
|
+
task.status = "claimed";
|
|
139
|
+
task.owner = owner || task.owner;
|
|
140
|
+
} else if (status === "done") {
|
|
141
|
+
if (task.owner && owner && task.owner !== owner) throw new Error(`board task is owned by ${task.owner}`);
|
|
142
|
+
if (!state.ready) throw new Error(`board task cannot be done before: ${state.blockedBy.join(", ")}`);
|
|
143
|
+
task.status = "done";
|
|
144
|
+
} else {
|
|
145
|
+
task.status = "open";
|
|
146
|
+
}
|
|
110
147
|
task.updatedAt = new Date().toISOString();
|
|
111
148
|
write(root, board);
|
|
112
|
-
return { root, task };
|
|
149
|
+
return { root, task: { ...task, ...taskState(board.tasks, task) } };
|
|
113
150
|
}
|
|
@@ -158,3 +158,28 @@ export function worktreeSummary({ cwd }) {
|
|
|
158
158
|
main: list.find((item) => item.main) ?? null,
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Merge one managed branch into the main worktree. Refuses a dirty main or
|
|
164
|
+
* dirty source worktree. On conflict the merge is aborted, leaving the repo
|
|
165
|
+
* exactly as before; the branch is preserved for manual resolution.
|
|
166
|
+
*/
|
|
167
|
+
export function mergeWorktree({ cwd, id }) {
|
|
168
|
+
const repo = repoRoot(cwd);
|
|
169
|
+
const name = validateSlug(id);
|
|
170
|
+
const list = listWorktrees({ cwd: repo });
|
|
171
|
+
const item = list.find((entry) => entry.id === name && !entry.main);
|
|
172
|
+
if (!item) throw new Error(`worktree not found: ${name}`);
|
|
173
|
+
if (item.branch == null) throw new Error(`worktree ${name} is detached; cannot merge`);
|
|
174
|
+
if (item.dirty) throw new Error(`worktree ${name} has uncommitted changes`);
|
|
175
|
+
if (tryRun(repo, ["status", "--porcelain"])) throw new Error("main worktree is dirty; commit or stash before merge");
|
|
176
|
+
const branch = item.branch;
|
|
177
|
+
try {
|
|
178
|
+
run(repo, ["merge", "--no-ff", branch, "-m", `merge ${branch} (dsh worktree)`]);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
tryRun(repo, ["merge", "--abort"]);
|
|
181
|
+
const detail = error instanceof Error ? error.message.slice(0, 500) : String(error);
|
|
182
|
+
throw new Error(`merge ${branch} failed and was aborted: ${detail}`);
|
|
183
|
+
}
|
|
184
|
+
return { repo, branch, commit: run(repo, ["rev-parse", "HEAD"]) };
|
|
185
|
+
}
|