dsh-desktop-kit 2.15.4 → 2.15.6
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 +12 -0
- package/README.md +21 -21
- package/client.js +2 -2
- package/docs/TEST-2.15.5.md +16 -0
- package/docs/TEST-2.15.6.md +16 -0
- package/package.json +2 -2
- package/plugins/dsh-agent-extensions/client.js +1 -1
- package/plugins/dsh-agent-extensions/index.js +33 -7
- package/plugins/dsh-agent-extensions/lib/agents.js +1 -0
- package/plugins/dsh-agent-extensions/lib/worktrees.js +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.15.6 (2026-11-12)
|
|
4
|
+
|
|
5
|
+
- **Team lead.** `project_agent action=team lead=<name>` запускает read-only координатора после участников; он получает `member=run-id`, читает board, назначает задачи и пишет участникам через `team_message`.
|
|
6
|
+
- **Лид не может быть участником** и должен быть read-only.
|
|
7
|
+
- **Тесты.** Полный набор; lead-путь использует существующий background runner.
|
|
8
|
+
|
|
9
|
+
## 2.15.5 (2026-11-12)
|
|
10
|
+
|
|
11
|
+
- **Worktree merge.** `project_worktree action=merge` вливает чистую ветку `dsh/<slug>` в main через `--no-ff`; грязный main/worktree отклоняется, конфликт автоматически отменяется (`merge --abort`), ветка сохраняется.
|
|
12
|
+
- **Тесты.** merge-сценарий в `worktrees-tests`.
|
|
13
|
+
- **UI.** Подсказка Worktrees обновлена.
|
|
14
|
+
|
|
3
15
|
## 2.15.4 (2026-11-12)
|
|
4
16
|
|
|
5
17
|
- **Зависимости задач.** `team_board add-task dependsOn=[...]`; `read` показывает `blockedBy` и `ready`.
|
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.6** · 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
|
@@ -7742,7 +7742,7 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
|
|
|
7742
7742
|
agents.length > 0 ? h("div", { className: "ag-grid" }, agents.map((agent) => h(AgentCard, { key: agent.name, agent }))) : null,
|
|
7743
7743
|
h("div", { className: "ag-section" },
|
|
7744
7744
|
h("h3", null, "Параллельная команда"),
|
|
7745
|
-
h("p", { className: "ag-hint" }, "`project_agent action=team names=[reviewer,researcher] task=...` запускает 2–6 read-only ролей
|
|
7745
|
+
h("p", { className: "ag-hint" }, "`project_agent action=team names=[reviewer,researcher] lead=coordinator task=...` запускает 2–6 read-only ролей и лида, который видит их run id, пишет им через `team_message` и ведёт задачи на board. Для пишущих добавьте `worktrees=true`."),
|
|
7746
7746
|
agents.filter((agent) => agent.permission === "read-only").length > 0
|
|
7747
7747
|
? h("div", { className: "ag-tools" }, agents.filter((agent) => agent.permission === "read-only").map((agent) => h("span", { key: agent.name, className: "ag-tool" }, agent.name)))
|
|
7748
7748
|
: h("div", { className: "ag-mini-empty" }, "Нужна хотя бы одна read-only роль: team не запускает пишущих агентов в общем cwd."),
|
|
@@ -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.6", parts: __partNames, errors: __kitErrors, ready: false };
|
|
8046
8046
|
} catch {}
|
|
8047
8047
|
const __inject = [];
|
|
8048
8048
|
for (const __part of __parts) {
|
|
@@ -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.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# DSH Desktop Kit 2.15.6 — тест
|
|
2
|
+
|
|
3
|
+
Дата: 2026-11-12.
|
|
4
|
+
|
|
5
|
+
## Team lead
|
|
6
|
+
|
|
7
|
+
- `project_agent action=team names=[...] lead=<name> task=...`.
|
|
8
|
+
- Lead must be read-only and not a member.
|
|
9
|
+
- Members start first; lead gets `name=run-id` context.
|
|
10
|
+
- Lead can use `team_board` and `team_message to=<run-id>`.
|
|
11
|
+
|
|
12
|
+
## Проверки
|
|
13
|
+
|
|
14
|
+
- `npm test` — exit 0.
|
|
15
|
+
- `build:client` / `check:client` — OK.
|
|
16
|
+
- UI 390/768/1440 (hint-only change) — прежний чистый аудит.
|
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.6",
|
|
4
|
+
"description": "DeepSeek Harness desktop kit 2.15.6: 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",
|
|
@@ -186,7 +186,7 @@ window.__ModuleLoader__.load({
|
|
|
186
186
|
agents.length > 0 ? h("div", { className: "ag-grid" }, agents.map((agent) => h(AgentCard, { key: agent.name, agent }))) : null,
|
|
187
187
|
h("div", { className: "ag-section" },
|
|
188
188
|
h("h3", null, "Параллельная команда"),
|
|
189
|
-
h("p", { className: "ag-hint" }, "`project_agent action=team names=[reviewer,researcher] task=...` запускает 2–6 read-only ролей
|
|
189
|
+
h("p", { className: "ag-hint" }, "`project_agent action=team names=[reviewer,researcher] lead=coordinator task=...` запускает 2–6 read-only ролей и лида, который видит их run id, пишет им через `team_message` и ведёт задачи на board. Для пишущих добавьте `worktrees=true`."),
|
|
190
190
|
agents.filter((agent) => agent.permission === "read-only").length > 0
|
|
191
191
|
? h("div", { className: "ag-tools" }, agents.filter((agent) => agent.permission === "read-only").map((agent) => h("span", { key: agent.name, className: "ag-tool" }, agent.name)))
|
|
192
192
|
: h("div", { className: "ag-mini-empty" }, "Нужна хотя бы одна read-only роль: team не запускает пишущих агентов в общем cwd."),
|
|
@@ -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";
|
|
@@ -50,6 +50,7 @@ function toolDefinition(ctx) {
|
|
|
50
50
|
action: { type: "string", enum: ["list", "run", "team", "status", "cancel"], description: "list agents, run one, start a read-only team, list background runs, or cancel a run" },
|
|
51
51
|
name: { type: "string", description: "Agent name from `.dsh/agents/<name>.md`" },
|
|
52
52
|
names: { type: "array", items: { type: "string" }, maxItems: 6, description: "For team: 2–6 read-only agent names" },
|
|
53
|
+
lead: { type: "string", description: "Optional read-only coordinator agent; receives member run ids and can message them" },
|
|
53
54
|
task: { type: "string", description: "Task/prompt for the child agent (required for run)" },
|
|
54
55
|
background: { type: "boolean", description: "Return immediately with a durable run id instead of waiting for the child" },
|
|
55
56
|
worktree: { type: "string", description: "Run in a git worktree: `auto` picks a name, or pass a lowercase slug" },
|
|
@@ -99,8 +100,26 @@ function toolDefinition(ctx) {
|
|
|
99
100
|
}
|
|
100
101
|
definitions.push(definition);
|
|
101
102
|
}
|
|
103
|
+
const leadName = String(input?.lead ?? "").trim();
|
|
104
|
+
let leadDefinition = null;
|
|
105
|
+
if (leadName) {
|
|
106
|
+
if (names.includes(leadName)) return { ok: false, text: "project_agent team: lead cannot also be a member" };
|
|
107
|
+
leadDefinition = agents.find((agent) => agent.name === leadName);
|
|
108
|
+
if (!leadDefinition) return { ok: false, text: `project_agent team: unknown lead "${leadName}"` };
|
|
109
|
+
if (leadDefinition.permission !== "read-only") return { ok: false, text: "project_agent team: lead must be read-only" };
|
|
110
|
+
}
|
|
111
|
+
const teamId = `team-${Date.now().toString(36)}`;
|
|
112
|
+
const startLead = async (results) => {
|
|
113
|
+
if (!leadDefinition) return null;
|
|
114
|
+
const members = results.filter((result) => result.id).map((result) => `${result.name}=${result.id}`).join(", ");
|
|
115
|
+
const result = await runProjectAgent(ctx, exec, leadDefinition, task, {
|
|
116
|
+
background: true,
|
|
117
|
+
teamId,
|
|
118
|
+
leadContext: members || "none",
|
|
119
|
+
});
|
|
120
|
+
return { name: leadName, id: result.id, error: result.error ?? "", ok: !result.error };
|
|
121
|
+
};
|
|
102
122
|
if (input?.worktrees === true) {
|
|
103
|
-
const teamId = `team-${Date.now().toString(36)}`;
|
|
104
123
|
postMessage(project.root, { teamId, from: "lead", text: `Task: ${task}` });
|
|
105
124
|
const results = [];
|
|
106
125
|
for (const definition of definitions) {
|
|
@@ -113,14 +132,15 @@ function toolDefinition(ctx) {
|
|
|
113
132
|
results.push({ name: definition.name, ok: false, id: null, error: error instanceof Error ? error.message : String(error), worktree, teamId });
|
|
114
133
|
}
|
|
115
134
|
}
|
|
135
|
+
const lead = await startLead(results);
|
|
116
136
|
const text = results.map((result) => `${result.ok ? "✓" : "✗"} ${result.name}${result.id ? ` · ${result.id}` : ""}${result.worktree ? ` · ${result.worktree.branch}` : ""}${result.error ? ` — ${result.error}` : ""}`).join("\n");
|
|
117
|
-
return { ok: results.every((result) => result.ok), text: `project_agent team (isolated worktrees, board ${teamId}):\n${text}`, runs: results, teamId };
|
|
137
|
+
return { ok: results.every((result) => result.ok), text: `project_agent team (isolated worktrees, board ${teamId}${lead ? `, lead ${lead.id}` : ""}):\n${text}`, runs: results, teamId, lead };
|
|
118
138
|
}
|
|
119
|
-
const teamId = `team-${Date.now().toString(36)}`;
|
|
120
139
|
postMessage(project.root, { teamId, from: "lead", text: `Task: ${task}` });
|
|
121
140
|
const results = await runProjectTeam(ctx, exec, definitions, task, { teamId });
|
|
141
|
+
const lead = await startLead(results);
|
|
122
142
|
const text = results.map((result) => `${result.ok ? "✓" : "✗"} ${result.name}${result.id ? ` · ${result.id}` : ""}${result.error ? ` — ${result.error}` : ""}`).join("\n");
|
|
123
|
-
return { ok: results.every((result) => result.ok), text: `project_agent team (board ${teamId}):\n${text}`, runs: results, teamId };
|
|
143
|
+
return { ok: results.every((result) => result.ok), text: `project_agent team (board ${teamId}${lead ? `, lead ${lead.id}` : ""}):\n${text}`, runs: results, teamId, lead };
|
|
124
144
|
}
|
|
125
145
|
const name = String(input?.name ?? "").trim();
|
|
126
146
|
if (!name) return { ok: false, text: "project_agent: name is required for run" };
|
|
@@ -157,12 +177,12 @@ function worktreeToolDefinition() {
|
|
|
157
177
|
return {
|
|
158
178
|
name: WORKTREE_TOOL,
|
|
159
179
|
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.",
|
|
180
|
+
"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
181
|
parameters: {
|
|
162
182
|
type: "object",
|
|
163
183
|
additionalProperties: false,
|
|
164
184
|
properties: {
|
|
165
|
-
action: { type: "string", enum: ["list", "create", "remove"], description: "list, create or remove a worktree" },
|
|
185
|
+
action: { type: "string", enum: ["list", "create", "merge", "remove"], description: "list, create, merge or remove a worktree" },
|
|
166
186
|
slug: { type: "string", description: "Worktree id: lowercase letters, digits, hyphen" },
|
|
167
187
|
base: { type: "string", description: "Base ref for create; default HEAD" },
|
|
168
188
|
force: { type: "boolean", description: "Remove a dirty/locked worktree (data loss risk)" },
|
|
@@ -183,6 +203,12 @@ function worktreeToolDefinition() {
|
|
|
183
203
|
const created = createWorktree({ cwd: project.root, slug, base: input?.base });
|
|
184
204
|
return { ok: true, text: `project_worktree create: ${created.branch} → ${created.path}`, worktree: created };
|
|
185
205
|
}
|
|
206
|
+
if (input?.action === "merge") {
|
|
207
|
+
const slug = String(input?.slug ?? "").trim();
|
|
208
|
+
if (!slug) return { ok: false, text: "project_worktree merge: slug is required" };
|
|
209
|
+
const merged = mergeWorktree({ cwd: project.root, id: slug });
|
|
210
|
+
return { ok: true, text: `project_worktree merge: ${merged.branch} → ${merged.commit.slice(0, 12)}`, worktree: merged };
|
|
211
|
+
}
|
|
186
212
|
if (input?.action === "remove") {
|
|
187
213
|
const slug = String(input?.slug ?? "").trim();
|
|
188
214
|
if (!slug) return { ok: false, text: "project_worktree remove: slug is required" };
|
|
@@ -54,6 +54,7 @@ export async function runProjectAgent(ctx, exec, definition, task, options = {})
|
|
|
54
54
|
definition.body,
|
|
55
55
|
"</project-agent>",
|
|
56
56
|
options.teamId ? `<team id="${options.teamId}">Use team_board action=post/read with teamId=${options.teamId} to share findings; use add-task/claim/done for work items. Use team_message to=\"parent\" for a live message to the lead; sibling live messaging is not available — the board is the shared channel.</team>` : "",
|
|
57
|
+
options.leadContext ? `<team-lead>You coordinate this team. Members: ${options.leadContext}. Read the board first; assign/claim tasks; use team_message to=<run-id> for live directions and team_message to=\"parent\" to report to the parent.</team-lead>` : "",
|
|
57
58
|
"",
|
|
58
59
|
"Task:",
|
|
59
60
|
String(task ?? ""),
|
|
@@ -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
|
+
}
|