dsh-desktop-kit 2.16.1 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.17.0 (2026-11-12)
4
+
5
+ **Одна консолидированная версия.** Включает всё, что было выпущено по частям в 2.16.x, плюс исправления и защиту от потери данных.
6
+
7
+ - **17-й плагин `dsh-integrations`:** локальный marketplace с SHA-256/backup, localhost IDE bridge (`/health`, `/context`, bearer), sandbox audit (`enforcement:false`).
8
+ - **API fix:** `/api/dsh-integrations/*` регистрируется напрямую через `connection`; `/integrations` команда удалена.
9
+ - **Board lock:** `.dsh/agents/board.lock`, stale 30 с, timeout 5 с; конкурентные 4×10 сообщений не теряются.
10
+ - **MCP HTTP server requests:** sampling/elicitation/roots в streamable HTTP SSR, не только stdio.
11
+ - **Team:** board UI, live messages, task dependencies, worktree merge, lead, presets, auto-swarm, research policy.
12
+ - **Transcript:** live + persisted redacted snapshots.
13
+ - **Release:** provenance workflow в GitHub Actions; `npm run verify:release` проверяет version/latest/README.
14
+ - **README:** 17 плагинов, интеграции, новые скриншоты 1440/390.
15
+
16
+ ## 2.16.2 (2026-11-12)
17
+
18
+ - **Board lock.** `.dsh/agents/board.lock` (`wx`, 30s stale, 5s timeout) вокруг post/add/claim/done; параллельные агенты больше не теряют сообщения.
19
+ - **Concurrency test.** 4 процесса × 10 сообщений → ровно 40 в board.
20
+ - **Release workflow.** `.github/workflows/publish.yml` с `id-token: write` и `npm publish --provenance`; секрет только `NPM_TOKEN`.
21
+
3
22
  ## 2.16.1 (2026-11-12)
4
23
 
5
24
  - **Fix `/api/dsh-integrations/*` 404.** Host plugin now registers routes directly through `connection`, with `ctx.inject` only as fallback; removed the optional `/integrations` command that could abort the injection.
package/README.md CHANGED
@@ -1,20 +1,20 @@
1
- # DSH Desktop Kit 2.15.1
1
+ # DSH Desktop Kit 2.17
2
2
 
3
3
  **MCP с OAuth, sampling и elicitation. Агенты, worktrees и рой с общей доской. Интерфейс, который не мешает.**
4
4
 
5
5
  Набор из **17 плагинов и 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
- ![DSH Desktop Kit 2.7](https://unpkg.com/dsh-desktop-kit@2.16.1/docs/images/hero.png)
7
+ ![DSH Desktop Kit 2.7](https://unpkg.com/dsh-desktop-kit@2.17.0/docs/images/hero.png)
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
- ![MCP Settings](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-mcp-manager/screenshots/settings-1440.png)
13
+ ![MCP Settings](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-mcp-manager/screenshots/settings-1440.png)
14
14
 
15
- ![MCP на 390px](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-mcp-manager/screenshots/settings-390.png)
15
+ ![MCP на 390px](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-mcp-manager/screenshots/settings-390.png)
16
16
 
17
- ![Добавление MCP-сервера](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-mcp-manager/screenshots/modal-390.png)
17
+ ![Добавление MCP-сервера](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-mcp-manager/screenshots/modal-390.png)
18
18
 
19
19
  ## Агенты, worktrees и рой
20
20
 
@@ -26,17 +26,17 @@
26
26
  - **Живые сообщения** — `team_message` отправляет текст лиду (`to="parent"`) или участнику по run id; копия каждого сообщения остаётся в board.
27
27
  - **Инструкции проекта** — `AGENTS.md`/`CLAUDE.md` иерархически (root → вложенные папки → `.dsh`) с `@import`; MCP roots сообщает корень проекта.
28
28
 
29
- ![Доска команды](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-agent-extensions/screenshots/board-1440.png)
29
+ ![Доска команды](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-agent-extensions/screenshots/board-1440.png)
30
30
 
31
- ![Доска команды на 390px](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-agent-extensions/screenshots/board-390.png)
31
+ ![Доска команды на 390px](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-agent-extensions/screenshots/board-390.png)
32
32
 
33
- ![Транскрипт фонового агента](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-agent-extensions/screenshots/transcript-1440.png)
33
+ ![Транскрипт фонового агента](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-agent-extensions/screenshots/transcript-1440.png)
34
34
 
35
- Транскрипт сохраняется в `.dsh/agents/transcripts/<run>.json` (0600) и доступен после restart.\n\n![Транскрипт на 390px](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-agent-extensions/screenshots/transcript-390.png)
35
+ Транскрипт сохраняется в `.dsh/agents/transcripts/<run>.json` (0600) и доступен после restart.\n\n![Транскрипт на 390px](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-agent-extensions/screenshots/transcript-390.png)
36
36
 
37
- ![MCP sampling](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-mcp-manager/screenshots/sampling-1440.png)
37
+ ![MCP sampling](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-mcp-manager/screenshots/sampling-1440.png)
38
38
 
39
- ![MCP elicitation](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-mcp-manager/screenshots/elicitation-1440.png)
39
+ ![MCP elicitation](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-mcp-manager/screenshots/elicitation-1440.png)
40
40
 
41
41
  ## Интеграции
42
42
 
@@ -46,9 +46,9 @@ Marketplace, IDE bridge и sandbox-аудит — в одном экране **
46
46
  - **IDE bridge** — localhost JSON API (`/health`, `/context`) с bearer-токеном; расширение редактора — отдельный проект.
47
47
  - **Sandbox** — честный аудит: DSH preset + kit guardrails — это политика, не OS sandbox.
48
48
 
49
- ![Интеграции](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-integrations/screenshots/integrations-1440.png)
49
+ ![Интеграции](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-integrations/screenshots/integrations-1440.png)
50
50
 
51
- ![Интеграции на 390px](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-integrations/screenshots/integrations-390.png)
51
+ ![Интеграции на 390px](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-integrations/screenshots/integrations-390.png)
52
52
 
53
53
  ## Права и субагенты
54
54
 
@@ -59,11 +59,11 @@ Marketplace, IDE bridge и sandbox-аудит — в одном экране **
59
59
  - **Worktrees и фоновые агенты.** `project_worktree` создаёт ветку `dsh/<slug>` и отдельную папку `.dsh/worktrees/<slug>`; `project_agent ... worktree=auto background=true` запускает агента в изоляции, а страница **Агенты** показывает worktrees и очередь запусков с кнопкой «Остановить».
60
60
  - **Инструкции проекта.** `AGENTS.md` и `CLAUDE.md` читаются иерархически (root → вложенные папки → `.dsh`) с `@import`; MCP roots сообщает серверу корень проекта.
61
61
 
62
- ![Агенты проекта](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-agent-extensions/screenshots/agents-1440.png)
62
+ ![Агенты проекта](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-agent-extensions/screenshots/agents-1440.png)
63
63
 
64
- ![Права и ограничения](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-guardrails/screenshots/permissions-1440.png)
64
+ ![Права и ограничения](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-guardrails/screenshots/permissions-1440.png)
65
65
 
66
- **v2.16.1** · MIT · проверено на DSH `0.2.1-rc.5` и `0.2.2-rc.1` (Windows 11) · без внешних зависимостей и телеметрии
66
+ **v2.17.0** · MIT · проверено на DSH `0.2.1-rc.5` и `0.2.2-rc.1` (Windows 11) · без внешних зависимостей и телеметрии
67
67
 
68
68
  **План развития:** [docs/ROADMAP-3.0.md](docs/ROADMAP-3.0.md) — Memory Fabric, семантическое
69
69
  слияние, локальный индекс памяти, шифрованные переносы, Memory Hub и npm trusted publishing.
@@ -158,27 +158,27 @@ Marketplace, IDE bridge и sandbox-аудит — в одном экране **
158
158
  - перед каждой синхронизацией проверяется, что репозиторий всё ещё приватный;
159
159
  - секреты и PII вычищаются, домашние пути заменяются токеном `%DSH_HOME%`; LLM не вызывается — **0 токенов**.
160
160
 
161
- ![Настройки памяти проектов](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-memory-bridge/docs/images/settings-light.png)
161
+ ![Настройки памяти проектов](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-memory-bridge/docs/images/settings-light.png)
162
162
 
163
- ![Конфликты досье](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-memory-bridge/docs/images/conflicts.png)
163
+ ![Конфликты досье](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-memory-bridge/docs/images/conflicts.png)
164
164
 
165
165
  ## Скриншоты
166
166
 
167
167
  ### Skills Studio: каталог, стоимость и редактор
168
168
 
169
- ![Каталог навыков](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-gkb-ru-ui/screenshots/02-skills-1440-light.png)
169
+ ![Каталог навыков](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-gkb-ru-ui/screenshots/02-skills-1440-light.png)
170
170
 
171
- ![Редактор навыка](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-gkb-ru-ui/screenshots/03-skills-editor-1440-light.png)
171
+ ![Редактор навыка](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-gkb-ru-ui/screenshots/03-skills-editor-1440-light.png)
172
172
 
173
173
  ### Token Lab: куда уходит контекст
174
174
 
175
- ![Токен-лаборатория](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-token-lab/screenshots/01-token-lab-1440-light.png)
175
+ ![Токен-лаборатория](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-token-lab/screenshots/01-token-lab-1440-light.png)
176
176
 
177
177
  ### Тёмная тема и мобильный
178
178
 
179
- ![Тёмная тема](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-gkb-ru-ui/screenshots/04-skills-1440-dark.png)
179
+ ![Тёмная тема](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-gkb-ru-ui/screenshots/04-skills-1440-dark.png)
180
180
 
181
- ![Каталог навыков на 390 px](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-gkb-ru-ui/screenshots/05-skills-390-light.png)
181
+ ![Каталог навыков на 390 px](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-gkb-ru-ui/screenshots/05-skills-390-light.png)
182
182
 
183
183
  ## Окно-напоминание: пиковый тариф
184
184
 
@@ -188,11 +188,11 @@ DeepSeek включает двойной тариф в пиковые часы (
188
188
  - **в окне** — красная карточка: причина, границы окна в местном времени и UTC, живой отсчёт до конца и рекомендация, когда вернуться;
189
189
  - **после окна** — карточка исчезает; состояние всегда доступно через `window.__DSH_PEAK_GUARD__.state()`.
190
190
 
191
- ![Окно-напоминание: светлая тема](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-peak-guard/screenshots/03-peak-card-1440-light.png)
191
+ ![Окно-напоминание: светлая тема](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-peak-guard/screenshots/03-peak-card-1440-light.png)
192
192
 
193
- ![Окно-напоминание: тёмная тема](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-peak-guard/screenshots/04-peak-card-1440-dark.png)
193
+ ![Окно-напоминание: тёмная тема](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-peak-guard/screenshots/04-peak-card-1440-dark.png)
194
194
 
195
- ![Окно-напоминание на 390 px](https://unpkg.com/dsh-desktop-kit@2.16.1/plugins/dsh-peak-guard/screenshots/05-peak-card-390-light.png)
195
+ ![Окно-напоминание на 390 px](https://unpkg.com/dsh-desktop-kit@2.17.0/plugins/dsh-peak-guard/screenshots/05-peak-card-390-light.png)
196
196
 
197
197
  Подробности и настройки — [plugins/dsh-peak-guard/README.md](plugins/dsh-peak-guard/README.md).
198
198
 
package/client.js CHANGED
@@ -8253,7 +8253,7 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
8253
8253
  if (__kitErrors.length <= 5) console.error("[dsh-desktop-kit] registration failed:", label, message);
8254
8254
  };
8255
8255
  try {
8256
- window.__DSH_DESKTOP_KIT__ = { version: "2.16.1", parts: __partNames, errors: __kitErrors, ready: false };
8256
+ window.__DSH_DESKTOP_KIT__ = { version: "2.17.0", parts: __partNames, errors: __kitErrors, ready: false };
8257
8257
  } catch {}
8258
8258
  const __inject = [];
8259
8259
  for (const __part of __parts) {
@@ -0,0 +1,21 @@
1
+ # DSH Desktop Kit 2.16.2 — тест
2
+
3
+ Дата: 2026-11-12.
4
+
5
+ ## Board lock
6
+
7
+ - `board.lock` через `open(..., "wx")`.
8
+ - Stale lock старше 30 с удаляется.
9
+ - Таймаут ожидания 5 с.
10
+ - `postMessage`, `addTask`, `updateTask` — под lock.
11
+ - 4 параллельных процесса × 10 сообщений = 40, без потерь.
12
+
13
+ ## Release
14
+
15
+ - GitHub Actions `publish.yml`, provenance, `NPM_TOKEN`.
16
+
17
+ ## Проверки
18
+
19
+ - `team-board-tests` — OK, включая concurrency.
20
+ - `npm test` — exit 0.
21
+ - build/check — OK.
@@ -0,0 +1,24 @@
1
+ # DSH Desktop Kit 2.17.0 — консолидированный тест
2
+
3
+ Дата: 2026-11-12.
4
+
5
+ ## Включено
6
+
7
+ - `dsh-integrations` + исправление API.
8
+ - Board lock + concurrency test.
9
+ - MCP HTTP server-request test.
10
+ - Все team/swarm/transcript функции 2.15.x.
11
+ - Release workflow + verify tool.
12
+
13
+ ## Проверки
14
+
15
+ - `npm test` — exit 0.
16
+ - `integrations-tests` — OK, включая fake mount routes.
17
+ - `team-board-tests` — OK, включая 4×10.
18
+ - `mcp-http-tests` — OK.
19
+ - UI 390/768/1440 — overflow 0.
20
+ - `npm run verify:release` после публикации.
21
+
22
+ ## npm
23
+
24
+ Одна версия вместо цепочки 2.16.x; `latest` переключается на 2.17.0.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-desktop-kit",
3
- "version": "2.16.1",
4
- "description": "DeepSeek Harness desktop kit 2.16.1: 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. Includes local marketplace, localhost IDE bridge and an honest sandbox audit.",
3
+ "version": "2.17.0",
4
+ "description": "DeepSeek Harness desktop kit 2.17.0: 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. Includes local marketplace, localhost IDE bridge and an honest sandbox audit.",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "dsh",
@@ -85,7 +85,8 @@
85
85
  "test": "node tools/integrations-tests.mjs && node tools/smoke-tests.mjs && node tools/memory-tests.mjs && node tools/skills-sync-tests.mjs && node tools/kit-upgrade-tests.mjs && node plugins/dsh-profile-transfer/test/transfer.test.mjs && node --test plugins/dsh-memory-bridge/test/bridge.test.mjs plugins/dsh-memory-bridge/test/github.test.mjs plugins/dsh-memory-bridge/test/merge.test.mjs plugins/dsh-memory-bridge/test/user-specific.test.mjs && node tools/repo-map-tests.mjs && node tools/checkpoints-tests.mjs && node tools/plan-mode-tests.mjs && node tools/browser-qa-tests.mjs && node tools/ui-gate-tests.mjs && node tools/agent-extensions-tests.mjs && node tools/mcp-manager-tests.mjs && node tools/github-review-tests.mjs && node tools/instructions-tests.mjs && node tools/mcp-elicitation-tests.mjs && node tools/mcp-sampling-tests.mjs && node tools/mcp-oauth-tests.mjs && node tools/worktrees-tests.mjs && node tools/transcripts-tests.mjs && node tools/team-messages-tests.mjs && node tools/swarm-tests.mjs && node tools/team-presets-tests.mjs && node tools/team-board-tests.mjs && node tools/team-agents-tests.mjs && node tools/background-agents-tests.mjs && node tools/permissions-ui-tests.mjs && node plugins/dsh-guardrails/tools/guardrails-tests.mjs",
86
86
  "skills:cost": "node tools/skill-cost.mjs",
87
87
  "skills:check": "node tools/skill-cost.mjs --check",
88
- "release": "node tools/release.mjs"
88
+ "release": "node tools/release.mjs",
89
+ "verify:release": "node tools/verify-release.mjs"
89
90
  },
90
91
  "engines": {
91
92
  "node": ">=20"
@@ -51,12 +51,39 @@ function projectRoot(cwd) {
51
51
  return projectFor(cwd || process.cwd()).root;
52
52
  }
53
53
 
54
+ function withLock(root, operation) {
55
+ const dir = path.join(root, ".dsh", "agents");
56
+ fs.mkdirSync(dir, { recursive: true });
57
+ const lock = path.join(dir, "board.lock");
58
+ const started = Date.now();
59
+ const sleeper = new Int32Array(new SharedArrayBuffer(4));
60
+ while (true) {
61
+ try {
62
+ const fd = fs.openSync(lock, "wx");
63
+ try {
64
+ fs.writeFileSync(fd, `${process.pid}\n`, "utf8");
65
+ return operation();
66
+ } finally {
67
+ try { fs.closeSync(fd); } catch { /* best effort */ }
68
+ try { fs.unlinkSync(lock); } catch { /* best effort */ }
69
+ }
70
+ } catch (error) {
71
+ if (error?.code !== "EEXIST") throw error;
72
+ try {
73
+ const age = Date.now() - fs.statSync(lock).mtimeMs;
74
+ if (age > 30_000) fs.unlinkSync(lock);
75
+ } catch { /* lock vanished */ }
76
+ if (Date.now() - started > 5_000) throw new Error("board is busy; lock timeout");
77
+ Atomics.wait(sleeper, 0, 0, 25);
78
+ }
79
+ }
80
+ }
81
+
54
82
  export function postMessage(cwd, { teamId = "", from = "", to = "", text = "" } = {}) {
55
83
  const clean = redact(text).trim();
56
84
  if (!clean) throw new Error("board message text is required");
57
85
  if (clean.length > MAX_TEXT) throw new Error("board message is too long");
58
86
  const root = projectRoot(cwd);
59
- const board = read(root);
60
87
  const message = {
61
88
  id: crypto.randomUUID(),
62
89
  teamId: String(teamId),
@@ -65,9 +92,12 @@ export function postMessage(cwd, { teamId = "", from = "", to = "", text = "" }
65
92
  text: clean,
66
93
  createdAt: new Date().toISOString(),
67
94
  };
68
- board.messages.push(message);
69
- board.messages = board.messages.slice(-MAX_MESSAGES);
70
- write(root, board);
95
+ withLock(root, () => {
96
+ const board = read(root);
97
+ board.messages.push(message);
98
+ board.messages = board.messages.slice(-MAX_MESSAGES);
99
+ write(root, board);
100
+ });
71
101
  return { root, message };
72
102
  }
73
103
 
@@ -105,9 +135,7 @@ export function addTask(cwd, { teamId = "", title = "", owner = "", dependsOn =
105
135
  const clean = redact(title).trim();
106
136
  if (!clean) throw new Error("board task title is required");
107
137
  const root = projectRoot(cwd);
108
- const board = read(root);
109
138
  const id = crypto.randomUUID();
110
- const dependencies = validateDependencies(board.tasks, id, Array.isArray(dependsOn) ? dependsOn : []);
111
139
  const task = {
112
140
  id,
113
141
  teamId: String(teamId),
@@ -115,36 +143,45 @@ export function addTask(cwd, { teamId = "", title = "", owner = "", dependsOn =
115
143
  owner: String(owner),
116
144
  status: "open",
117
145
  priority: ["low", "normal", "high"].includes(priority) ? priority : "normal",
118
- dependsOn: dependencies,
146
+ dependsOn: [],
119
147
  createdAt: new Date().toISOString(),
120
148
  updatedAt: new Date().toISOString(),
121
149
  };
122
- board.tasks.push(task);
123
- board.tasks = board.tasks.slice(-MAX_TASKS);
124
- write(root, board);
125
- return { root, task: { ...task, ...taskState(board.tasks, task) } };
150
+ withLock(root, () => {
151
+ const board = read(root);
152
+ task.dependsOn = validateDependencies(board.tasks, id, Array.isArray(dependsOn) ? dependsOn : []);
153
+ board.tasks.push(task);
154
+ board.tasks = board.tasks.slice(-MAX_TASKS);
155
+ write(root, board);
156
+ task.state = taskState(board.tasks, task);
157
+ });
158
+ return { root, task: { ...task, ...(task.state ?? {}) } };
126
159
  }
127
160
 
128
161
  export function updateTask(cwd, { id = "", status = "", owner = "" } = {}) {
129
162
  if (!["open", "claimed", "done"].includes(status)) throw new Error("board task status must be open, claimed or done");
130
163
  const root = projectRoot(cwd);
131
- const board = read(root);
132
- const task = board.tasks.find((item) => item.id === String(id));
133
- if (!task) throw new Error(`board task not found: ${id}`);
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
- }
147
- task.updatedAt = new Date().toISOString();
148
- write(root, board);
149
- return { root, task: { ...task, ...taskState(board.tasks, task) } };
164
+ let result;
165
+ withLock(root, () => {
166
+ const board = read(root);
167
+ const task = board.tasks.find((item) => item.id === String(id));
168
+ if (!task) throw new Error(`board task not found: ${id}`);
169
+ const state = taskState(board.tasks, task);
170
+ if (status === "claimed") {
171
+ if (task.status === "claimed" && task.owner && owner && task.owner !== owner) throw new Error(`board task already claimed by ${task.owner}`);
172
+ if (!state.ready) throw new Error(`board task is blocked by: ${state.blockedBy.join(", ")}`);
173
+ task.status = "claimed";
174
+ task.owner = owner || task.owner;
175
+ } else if (status === "done") {
176
+ if (task.owner && owner && task.owner !== owner) throw new Error(`board task is owned by ${task.owner}`);
177
+ if (!state.ready) throw new Error(`board task cannot be done before: ${state.blockedBy.join(", ")}`);
178
+ task.status = "done";
179
+ } else {
180
+ task.status = "open";
181
+ }
182
+ task.updatedAt = new Date().toISOString();
183
+ write(root, board);
184
+ result = { ...task, ...taskState(board.tasks, task) };
185
+ });
186
+ return { root, task: result };
150
187
  }