dsh-desktop-kit 2.15.10 → 2.15.11

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.15.11 (2026-11-12)
4
+
5
+ - **Auto-swarm.** `project_agent action=auto` оценивает задачу (broad/security/architecture/audit/research, длина, несколько направлений) и сам запускает read-only рой или отказывается.
6
+ - **Research-aware.** Если задача требует внешних фактов, auto добавляет требование `web_search/web_fetch` + 2 источника с датами.
7
+ - **Конфиг.** `.dsh/swarm.json` → `{enabled, threshold}`.
8
+ - **Политика.** System prompt требует интернет-проверку для внешних фактов/версий/цен/референсов.
9
+ - **Тесты.** `swarm-tests`: narrow skip, broad swarm, RU-кейс, disabled.
10
+
3
11
  ## 2.15.10 (2026-11-12)
4
12
 
5
13
  - **Team presets.** `.dsh/teams/<id>.json` с `members` и `lead`; `project_agent action=team preset=review task=...`.
package/README.md CHANGED
@@ -4,39 +4,39 @@
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
- ![DSH Desktop Kit 2.7](https://unpkg.com/dsh-desktop-kit@2.15.10/docs/images/hero.png)
7
+ ![DSH Desktop Kit 2.7](https://unpkg.com/dsh-desktop-kit@2.15.11/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.15.10/plugins/dsh-mcp-manager/screenshots/settings-1440.png)
13
+ ![MCP Settings](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-mcp-manager/screenshots/settings-1440.png)
14
14
 
15
- ![MCP на 390px](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-mcp-manager/screenshots/settings-390.png)
15
+ ![MCP на 390px](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-mcp-manager/screenshots/settings-390.png)
16
16
 
17
- ![Добавление MCP-сервера](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-mcp-manager/screenshots/modal-390.png)
17
+ ![Добавление MCP-сервера](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-mcp-manager/screenshots/modal-390.png)
18
18
 
19
19
  ## Агенты, worktrees и рой
20
20
 
21
21
  - **Проектные роли** — `.dsh/agents/*.md`: `tools`, `permission` и `model` реально ограничивают ребёнка.
22
22
  - **Worktrees** — `project_worktree` создаёт ветку `dsh/<slug>` и папку `.dsh/worktrees/<slug>`; `merge` вливает чистую ветку в main и делает abort при конфликте; `project_agent worktree=auto` запускает агента в изоляции.
23
23
  - **Фон** — `background=true` возвращает run id сразу; страница **Агенты** показывает очередь и кнопку «Остановить».
24
- - **Команда** — `project_agent action=team names=[reviewer,researcher] task=...` или `preset=review` из `.dsh/teams/review.json` запускает 2–6 read-only ролей; `worktrees=true` даёт каждому писателю отдельную ветку.
24
+ - **Команда** — `project_agent action=team names=[reviewer,researcher] task=...` или `preset=review`; `action=auto` сам решает, нужен ли рой, и выбирает preset запускает 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
- ![Доска команды](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-agent-extensions/screenshots/board-1440.png)
29
+ ![Доска команды](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-agent-extensions/screenshots/board-1440.png)
30
30
 
31
- ![Доска команды на 390px](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-agent-extensions/screenshots/board-390.png)
31
+ ![Доска команды на 390px](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-agent-extensions/screenshots/board-390.png)
32
32
 
33
- ![Транскрипт фонового агента](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-agent-extensions/screenshots/transcript-1440.png)
33
+ ![Транскрипт фонового агента](https://unpkg.com/dsh-desktop-kit@2.15.11/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.15.10/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.15.11/plugins/dsh-agent-extensions/screenshots/transcript-390.png)
36
36
 
37
- ![MCP sampling](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-mcp-manager/screenshots/sampling-1440.png)
37
+ ![MCP sampling](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-mcp-manager/screenshots/sampling-1440.png)
38
38
 
39
- ![MCP elicitation](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-mcp-manager/screenshots/elicitation-1440.png)
39
+ ![MCP elicitation](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-mcp-manager/screenshots/elicitation-1440.png)
40
40
 
41
41
  ## Права и субагенты
42
42
 
@@ -47,11 +47,11 @@
47
47
  - **Worktrees и фоновые агенты.** `project_worktree` создаёт ветку `dsh/<slug>` и отдельную папку `.dsh/worktrees/<slug>`; `project_agent ... worktree=auto background=true` запускает агента в изоляции, а страница **Агенты** показывает worktrees и очередь запусков с кнопкой «Остановить».
48
48
  - **Инструкции проекта.** `AGENTS.md` и `CLAUDE.md` читаются иерархически (root → вложенные папки → `.dsh`) с `@import`; MCP roots сообщает серверу корень проекта.
49
49
 
50
- ![Агенты проекта](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-agent-extensions/screenshots/agents-1440.png)
50
+ ![Агенты проекта](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-agent-extensions/screenshots/agents-1440.png)
51
51
 
52
- ![Права и ограничения](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-guardrails/screenshots/permissions-1440.png)
52
+ ![Права и ограничения](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-guardrails/screenshots/permissions-1440.png)
53
53
 
54
- **v2.15.10** · MIT · проверено на DSH `0.2.1-rc.5` и `0.2.2-rc.1` (Windows 11) · без внешних зависимостей и телеметрии
54
+ **v2.15.11** · MIT · проверено на DSH `0.2.1-rc.5` и `0.2.2-rc.1` (Windows 11) · без внешних зависимостей и телеметрии
55
55
 
56
56
  **План развития:** [docs/ROADMAP-3.0.md](docs/ROADMAP-3.0.md) — Memory Fabric, семантическое
57
57
  слияние, локальный индекс памяти, шифрованные переносы, Memory Hub и npm trusted publishing.
@@ -146,27 +146,27 @@
146
146
  - перед каждой синхронизацией проверяется, что репозиторий всё ещё приватный;
147
147
  - секреты и PII вычищаются, домашние пути заменяются токеном `%DSH_HOME%`; LLM не вызывается — **0 токенов**.
148
148
 
149
- ![Настройки памяти проектов](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-memory-bridge/docs/images/settings-light.png)
149
+ ![Настройки памяти проектов](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-memory-bridge/docs/images/settings-light.png)
150
150
 
151
- ![Конфликты досье](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-memory-bridge/docs/images/conflicts.png)
151
+ ![Конфликты досье](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-memory-bridge/docs/images/conflicts.png)
152
152
 
153
153
  ## Скриншоты
154
154
 
155
155
  ### Skills Studio: каталог, стоимость и редактор
156
156
 
157
- ![Каталог навыков](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-gkb-ru-ui/screenshots/02-skills-1440-light.png)
157
+ ![Каталог навыков](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-gkb-ru-ui/screenshots/02-skills-1440-light.png)
158
158
 
159
- ![Редактор навыка](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-gkb-ru-ui/screenshots/03-skills-editor-1440-light.png)
159
+ ![Редактор навыка](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-gkb-ru-ui/screenshots/03-skills-editor-1440-light.png)
160
160
 
161
161
  ### Token Lab: куда уходит контекст
162
162
 
163
- ![Токен-лаборатория](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-token-lab/screenshots/01-token-lab-1440-light.png)
163
+ ![Токен-лаборатория](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-token-lab/screenshots/01-token-lab-1440-light.png)
164
164
 
165
165
  ### Тёмная тема и мобильный
166
166
 
167
- ![Тёмная тема](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-gkb-ru-ui/screenshots/04-skills-1440-dark.png)
167
+ ![Тёмная тема](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-gkb-ru-ui/screenshots/04-skills-1440-dark.png)
168
168
 
169
- ![Каталог навыков на 390 px](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-gkb-ru-ui/screenshots/05-skills-390-light.png)
169
+ ![Каталог навыков на 390 px](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-gkb-ru-ui/screenshots/05-skills-390-light.png)
170
170
 
171
171
  ## Окно-напоминание: пиковый тариф
172
172
 
@@ -176,11 +176,11 @@ DeepSeek включает двойной тариф в пиковые часы (
176
176
  - **в окне** — красная карточка: причина, границы окна в местном времени и UTC, живой отсчёт до конца и рекомендация, когда вернуться;
177
177
  - **после окна** — карточка исчезает; состояние всегда доступно через `window.__DSH_PEAK_GUARD__.state()`.
178
178
 
179
- ![Окно-напоминание: светлая тема](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-peak-guard/screenshots/03-peak-card-1440-light.png)
179
+ ![Окно-напоминание: светлая тема](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-peak-guard/screenshots/03-peak-card-1440-light.png)
180
180
 
181
- ![Окно-напоминание: тёмная тема](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-peak-guard/screenshots/04-peak-card-1440-dark.png)
181
+ ![Окно-напоминание: тёмная тема](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-peak-guard/screenshots/04-peak-card-1440-dark.png)
182
182
 
183
- ![Окно-напоминание на 390 px](https://unpkg.com/dsh-desktop-kit@2.15.10/plugins/dsh-peak-guard/screenshots/05-peak-card-390-light.png)
183
+ ![Окно-напоминание на 390 px](https://unpkg.com/dsh-desktop-kit@2.15.11/plugins/dsh-peak-guard/screenshots/05-peak-card-390-light.png)
184
184
 
185
185
  Подробности и настройки — [plugins/dsh-peak-guard/README.md](plugins/dsh-peak-guard/README.md).
186
186
 
package/client.js CHANGED
@@ -7764,7 +7764,7 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
7764
7764
  agents.length > 0 ? h("div", { className: "ag-grid" }, agents.map((agent) => h(AgentCard, { key: agent.name, agent }))) : null,
7765
7765
  h("div", { className: "ag-section" },
7766
7766
  h("h3", null, "Параллельная команда"),
7767
- 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`."),
7767
+ h("p", { className: "ag-hint" }, "`project_agent action=auto` сам оценивает задачу: если она широкая, запускает read-only рой с лидом; `team` — вручную. `action=auto` также добавляет research-требование для внешних фактов."),
7768
7768
  agents.filter((agent) => agent.permission === "read-only").length > 0
7769
7769
  ? h("div", { className: "ag-tools" }, agents.filter((agent) => agent.permission === "read-only").map((agent) => h("span", { key: agent.name, className: "ag-tool" }, agent.name)))
7770
7770
  : h("div", { className: "ag-mini-empty" }, "Нужна хотя бы одна read-only роль: team не запускает пишущих агентов в общем cwd."),
@@ -8086,7 +8086,7 @@ var(--dsw-alias-bg-layer-1,#fff);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff
8086
8086
  if (__kitErrors.length <= 5) console.error("[dsh-desktop-kit] registration failed:", label, message);
8087
8087
  };
8088
8088
  try {
8089
- window.__DSH_DESKTOP_KIT__ = { version: "2.15.10", parts: __partNames, errors: __kitErrors, ready: false };
8089
+ window.__DSH_DESKTOP_KIT__ = { version: "2.15.11", parts: __partNames, errors: __kitErrors, ready: false };
8090
8090
  } catch {}
8091
8091
  const __inject = [];
8092
8092
  for (const __part of __parts) {
@@ -0,0 +1,22 @@
1
+ # DSH Desktop Kit 2.15.11 — тест
2
+
3
+ Дата: 2026-11-12.
4
+
5
+ ## Auto-swarm
6
+
7
+ - `project_agent action=auto task=...`.
8
+ - Score: broad/security/architecture/audit/research + length + multi-area.
9
+ - `.dsh/swarm.json`: `{ "enabled": true, "threshold": 3 }`.
10
+ - Narrow task → `swarm:false`, reason.
11
+ - Broad → preset/roles + lead; external facts → research suffix.
12
+
13
+ ## Research policy
14
+
15
+ - System prompt: web_search + 2 sources + dates for external facts, versions, prices, standards, references.
16
+ - UI hint updated.
17
+
18
+ ## Проверки
19
+
20
+ - `swarm-tests` — OK.
21
+ - `npm test` — exit 0.
22
+ - `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.10",
4
- "description": "DeepSeek Harness desktop kit 2.15.10: 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.",
3
+ "version": "2.15.11",
4
+ "description": "DeepSeek Harness desktop kit 2.15.11: 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",
@@ -82,7 +82,7 @@
82
82
  "build:client": "node tools/build-client.mjs",
83
83
  "build:skills": "node tools/build-skill-manifest.mjs",
84
84
  "check:client": "node tools/check-client.mjs client.js",
85
- "test": "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/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",
85
+ "test": "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
88
  "release": "node tools/release.mjs"
@@ -208,7 +208,7 @@ window.__ModuleLoader__.load({
208
208
  agents.length > 0 ? h("div", { className: "ag-grid" }, agents.map((agent) => h(AgentCard, { key: agent.name, agent }))) : null,
209
209
  h("div", { className: "ag-section" },
210
210
  h("h3", null, "Параллельная команда"),
211
- 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`."),
211
+ h("p", { className: "ag-hint" }, "`project_agent action=auto` сам оценивает задачу: если она широкая, запускает read-only рой с лидом; `team` — вручную. `action=auto` также добавляет research-требование для внешних фактов."),
212
212
  agents.filter((agent) => agent.permission === "read-only").length > 0
213
213
  ? h("div", { className: "ag-tools" }, agents.filter((agent) => agent.permission === "read-only").map((agent) => h("span", { key: agent.name, className: "ag-tool" }, agent.name)))
214
214
  : h("div", { className: "ag-mini-empty" }, "Нужна хотя бы одна read-only роль: team не запускает пишущих агентов в общем cwd."),
@@ -23,6 +23,7 @@ import { sendTeamMessage } from "./lib/messages.js";
23
23
  import { ensureGlobalScaffold, ensureProjectScaffold } from "./lib/scaffold.js";
24
24
  import { findDshDir, loadAgents, projectFor } from "./lib/project.js";
25
25
  import { findTeam, loadTeams } from "./lib/teams.js";
26
+ import { chooseSwarm, loadSwarmOptions } from "./lib/swarm.js";
26
27
 
27
28
  export const inject = ["tools", "systemPrompt"];
28
29
 
@@ -48,7 +49,7 @@ function toolDefinition(ctx) {
48
49
  type: "object",
49
50
  additionalProperties: false,
50
51
  properties: {
51
- 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" },
52
+ action: { type: "string", enum: ["list", "run", "team", "auto", "status", "cancel"], description: "list agents, run one, start a team, auto-decide whether a swarm is warranted, list runs, or cancel" },
52
53
  name: { type: "string", description: "Agent name from `.dsh/agents/<name>.md`" },
53
54
  names: { type: "array", items: { type: "string" }, maxItems: 6, description: "For team: 2–6 read-only agent names" },
54
55
  lead: { type: "string", description: "Optional read-only coordinator agent; receives member run ids and can message them" },
@@ -87,9 +88,17 @@ function toolDefinition(ctx) {
87
88
  return { ok: false, text: `project_agent cancel ${id}: ${error instanceof Error ? error.message : String(error)}` };
88
89
  }
89
90
  }
90
- if (input?.action !== "run" && input?.action !== "team") return { ok: false, text: "project_agent: action must be list, run, team, status or cancel" };
91
- const task = String(input?.task ?? "").trim();
91
+ if (input?.action !== "run" && input?.action !== "team" && input?.action !== "auto") return { ok: false, text: "project_agent: action must be list, run, team, auto, status or cancel" };
92
+ let task = String(input?.task ?? "").trim();
92
93
  if (!task) return { ok: false, text: `project_agent: task is required for ${input.action}` };
94
+ if (input.action === "auto") {
95
+ const decision = chooseSwarm(task, loadTeams(project.root, project.dsh ?? path.join(project.root, ".dsh")), agents, loadSwarmOptions(project.root));
96
+ if (!decision.swarm) return { ok: true, swarm: false, score: decision.score, text: `project_agent auto: swarm not needed (${decision.reason})` };
97
+ const members = decision.members.filter((name) => name !== decision.lead);
98
+ if (members.length < 2) return { ok: true, swarm: false, score: decision.score, text: "project_agent auto: not enough members after removing the lead" };
99
+ task = decision.research ? `${task}\n\nResearch requirement: use web_search/web_fetch, prefer official docs, and cite at least two sources with dates before conclusions.` : task;
100
+ input = { ...input, action: "team", names: members, lead: decision.lead, preset: "" };
101
+ }
93
102
  if (input.action === "team") {
94
103
  const preset = input?.preset ? findTeam(project.root, project.dsh ?? path.join(project.root, ".dsh"), input.preset) : null;
95
104
  if (input?.preset && !preset) return { ok: false, text: `project_agent team: unknown preset "${input.preset}"` };
@@ -369,6 +378,18 @@ export function apply(ctx) {
369
378
  ctx.logger?.warn?.(`[agent-extensions] system prompt registration failed: ${error instanceof Error ? error.message : String(error)}`);
370
379
  }
371
380
 
381
+ try {
382
+ ctx.systemPrompt.context({
383
+ name: "dsh-agent-extensions: research and swarm policy",
384
+ order: 136,
385
+ interpolate: false,
386
+ required: false,
387
+ text: () => "<research-policy>For external facts, versions, prices, standards, best practices, or UI references: call web_search and open at least two sources; cite URLs and dates before recommending. For broad, multi-area, security, architecture, audit or research tasks: call project_agent action=auto first; it decides whether to start a read-only swarm.</research-policy>",
388
+ });
389
+ } catch (error) {
390
+ ctx.logger?.warn?.(`[agent-extensions] research policy skipped: ${error instanceof Error ? error.message : String(error)}`);
391
+ }
392
+
372
393
  try {
373
394
  ctx.systemPrompt.context({
374
395
  name: "dsh-agent-extensions: project instructions",
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Automatic swarm router.
3
+ *
4
+ * The model (or a future host hook) calls `project_agent action=auto`.
5
+ * A cheap deterministic score decides whether a narrow task should run alone
6
+ * or whether a read-only team + lead is worth the tokens. No LLM call here.
7
+ */
8
+ import fs from "node:fs";
9
+ import path from "node:path";
10
+
11
+ const BROAD = [
12
+ /(?:audit|review|architecture|security|migration|refactor|research|compare|analy[sz]e|investigate)/iu,
13
+ /(?:провер|ревью|архитект|безопас|миграц|рефактор|исслед|сравн|проанализ|разбер)/iu,
14
+ ];
15
+ const EXTERNAL = [
16
+ /(?:latest|current|price|pricing|version|release|docs?|documentation|rfc|standard|benchmark|cve)/iu,
17
+ /(?:последн|актуальн|цен|тариф|верси|релиз|документац|стандарт|бенчмарк|уязвим)/iu,
18
+ ];
19
+ const MULTI = [/\b(?:and|plus|also)\b/iu, /(?:^|\s)(?:и|плюс|также)(?:\s|$)/iu];
20
+
21
+ export function loadSwarmOptions(projectRoot) {
22
+ try {
23
+ const parsed = JSON.parse(fs.readFileSync(path.join(projectRoot, ".dsh", "swarm.json"), "utf8"));
24
+ return { enabled: parsed.enabled !== false, threshold: Number(parsed.threshold) || 3 };
25
+ } catch {
26
+ return { enabled: true, threshold: 3 };
27
+ }
28
+ }
29
+
30
+ export function chooseSwarm(task, teams = [], agents = [], options = {}) {
31
+ const text = String(task ?? "").trim();
32
+ if (options.enabled === false) return { swarm: false, score: 0, reason: "auto-swarm disabled" };
33
+ const threshold = Number.isFinite(options.threshold) ? options.threshold : 3;
34
+ let score = 0;
35
+ const reasons = [];
36
+ if (text.length > 180) { score += 1; reasons.push("long task"); }
37
+ if (BROAD.some((pattern) => pattern.test(text))) { score += 2; reasons.push("broad/quality task"); }
38
+ if (EXTERNAL.some((pattern) => pattern.test(text))) { score += 1; reasons.push("external facts"); }
39
+ if (MULTI.some((pattern) => pattern.test(text))) { score += 1; reasons.push("multiple areas"); }
40
+ if ((text.match(/,/gu) ?? []).length >= 2) { score += 1; reasons.push("several deliverables"); }
41
+
42
+ const readOnly = agents.filter((agent) => agent.permission === "read-only");
43
+ if (readOnly.length < 2) return { swarm: false, score, reasons, reason: "need at least two read-only agents" };
44
+ if (score < threshold) return { swarm: false, score, reasons, reason: `score ${score} < ${threshold}` };
45
+
46
+ const research = EXTERNAL.some((pattern) => pattern.test(text));
47
+ const preset = teams.find((team) => team.members.every((name) => agents.some((agent) => agent.name === name)))
48
+ ?? teams[0]
49
+ ?? null;
50
+ if (preset && preset.members.length >= 2) {
51
+ return { swarm: true, score, reasons, research, preset: preset.id, members: preset.members, lead: preset.lead || "" };
52
+ }
53
+ const preferred = ["reviewer", "researcher", "tester"];
54
+ const members = readOnly
55
+ .slice()
56
+ .sort((a, b) => (preferred.indexOf(a.name) + 1 || 99) - (preferred.indexOf(b.name) + 1 || 99))
57
+ .slice(0, 4)
58
+ .map((agent) => agent.name);
59
+ const lead = readOnly.find((agent) => /^(?:lead|coordinator|orchestrator)$/iu.test(agent.name))?.name ?? "";
60
+ return { swarm: true, score, reasons, research, preset: "", members, lead };
61
+ }