dsh-tg-bridge 1.53.0 → 1.54.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/README.md +6 -3
- package/chat/speech.mjs +13 -1
- package/control/agentsets.mjs +2 -0
- package/control/cmd-model.mjs +1 -1
- package/control/cmd-skills.mjs +36 -1
- package/docs/CHANGELOG.md +42 -0
- package/docs/COMMANDS.md +6 -6
- package/docs/TOPIC-PROFILE.md +101 -0
- package/docs/VOICE.md +15 -5
- package/i18n/en/ctrl.mjs +8 -3
- package/i18n/ru/ctrl.mjs +8 -3
- package/i18n/zh/ctrl.mjs +8 -3
- package/package.json +1 -1
- package/profile/agentsets.mjs +6 -1
- package/profile/aset-profile.mjs +12 -1
- package/profile/patch-rows.mjs +98 -1
- package/profile/settings.mjs +8 -0
- package/profile/topic-docs.mjs +64 -0
- package/turn/aset-job.mjs +1 -1
package/README.md
CHANGED
|
@@ -38,8 +38,10 @@ that answers, one step at a time.
|
|
|
38
38
|
are prepended to every turn.
|
|
39
39
|
- **Two scopes for every setting.** `/reasoning <mode> all` moves the default,
|
|
40
40
|
without `all` it moves this topic; language and pinning follow the same rule,
|
|
41
|
-
and `/crew use reviewer` gives one topic its own effort, permissions
|
|
42
|
-
preset
|
|
41
|
+
and `/crew use reviewer` gives one topic its own effort, permissions, agent
|
|
42
|
+
preset and rule file — `AGENTS.<name>.md` loaded after the project's `AGENTS.md`
|
|
43
|
+
([docs/TOPIC-PROFILE.md](docs/TOPIC-PROFILE.md)); four built-in sets, read-only,
|
|
44
|
+
copyable.
|
|
43
45
|
- **It says what it cost.** A turn reports tokens and the cache hit rate; `/cost`
|
|
44
46
|
says what the session has spent and `/prices` shows the rates it used.
|
|
45
47
|
- **Out of quota is not a dead end.** When the quota runs out it switches to a
|
|
@@ -374,7 +376,7 @@ Agents: /agents · /agents <id> · /agents set model|depth|filter
|
|
|
374
376
|
Models: /model · /model <route> · /model <route> all · /model auto · /endpoint · /prices
|
|
375
377
|
Tuning: /effort · /permissions · /preset · /plan · /jobs · /remind · /every
|
|
376
378
|
Profiles: /profile · /profile <name> · /profile new <name> from <template>
|
|
377
|
-
Sets: /crew · /crew use|off|new|copy|rm · /crew model <v>
|
|
379
|
+
Sets: /crew · /crew use|off|new|copy|rm · /crew model|effort|lang <v> · /crew instructions <file.md> · /crew skills <dir>
|
|
378
380
|
Extensions: /skills · /plugins · /plugins search <word> · /plugins disable|enable <id> · /soul
|
|
379
381
|
Updates: /update · /update confirm · /update on|off|check|auto · /subscribe on|off
|
|
380
382
|
Diagnostics: /doctor · /logs [errors|N|text] · /report
|
|
@@ -698,6 +700,7 @@ no lock race and no lost update.
|
|
|
698
700
|
|
|
699
701
|
- [docs/COMMANDS.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/COMMANDS.md): every command with what it does, in English, Russian and Chinese — the page `/help` links to
|
|
700
702
|
- [docs/LAYOUT.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/LAYOUT.md): which folder answers which question, and why the entry points stay at the root
|
|
703
|
+
- [docs/TOPIC-PROFILE.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/TOPIC-PROFILE.md): the five layers between a turn and its profile, and how a set adds rules and skills to one topic
|
|
701
704
|
- [docs/TELEGRAM-SETUP.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/TELEGRAM-SETUP.md): BotFather settings, group and bot permissions
|
|
702
705
|
- [docs/SUPPORT.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/SUPPORT.md): what to send with a bug report, what never to send, and the one-line answer for "the bot went silent"
|
|
703
706
|
- [docs/VOICE.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/VOICE.md): any speech engine as input — a local script, a command with placeholders, an [OI]-compatible API
|
package/chat/speech.mjs
CHANGED
|
@@ -38,6 +38,12 @@ export function speechConfig(config) {
|
|
|
38
38
|
const raw = config?.speech || {};
|
|
39
39
|
return {
|
|
40
40
|
provider: raw.provider || 'edge-tts',
|
|
41
|
+
// The two fields `providerArgs` reads for a non-edge engine. They were
|
|
42
|
+
// documented ("a local Piper install is config, not a code change") but
|
|
43
|
+
// never copied here, so any provider other than edge-tts spawned itself
|
|
44
|
+
// by name and failed with ENOENT.
|
|
45
|
+
command: raw.command,
|
|
46
|
+
args: Array.isArray(raw.args) ? raw.args : undefined,
|
|
41
47
|
python: raw.python || 'python',
|
|
42
48
|
ffmpeg: raw.ffmpeg || 'ffmpeg',
|
|
43
49
|
// An engine that already speaks OGG/Opus skips the ffmpeg conversion; the
|
|
@@ -130,8 +136,14 @@ export function providerArgs(cfg, { text, mp3 }) {
|
|
|
130
136
|
}
|
|
131
137
|
// Any other provider receives the text and the target file through the same
|
|
132
138
|
// two placeholders, so a local Piper install is config, not a code change.
|
|
139
|
+
// `{voice}` is the third: `/voice <name>` sets the voice per topic, and an
|
|
140
|
+
// engine that owns its own voices (Piper maps them to model files) needs that
|
|
141
|
+
// name or the card would confirm a change nothing makes.
|
|
133
142
|
const args = (cfg.args || ['{text}', '{out}']).map((part) =>
|
|
134
|
-
String(part)
|
|
143
|
+
String(part)
|
|
144
|
+
.replace('{text}', text)
|
|
145
|
+
.replace('{out}', mp3)
|
|
146
|
+
.replace('{voice}', cfg.voice || ''));
|
|
135
147
|
return { command: cfg.command || cfg.provider, args };
|
|
136
148
|
}
|
|
137
149
|
|
package/control/agentsets.mjs
CHANGED
|
@@ -69,6 +69,8 @@ export function agentsetCard(set, lang, profile, boundId) {
|
|
|
69
69
|
`${t(lang, 'ctrl.set.field.permissions')}: ${pick('permissions')}`,
|
|
70
70
|
`${t(lang, 'ctrl.set.field.preset')}: ${pick('dshPreset')}`,
|
|
71
71
|
`${t(lang, 'ctrl.set.field.lang')}: ${pick('lang')}`,
|
|
72
|
+
`${t(lang, 'ctrl.set.field.instructions')}: ${(set.instructions || []).join(', ') || `— ${t(lang, 'ctrl.set.inherit')}`}`,
|
|
73
|
+
`${t(lang, 'ctrl.set.field.skills')}: ${(set.skillDirs || []).join(', ') || `— ${t(lang, 'ctrl.set.inherit')}`}`,
|
|
72
74
|
];
|
|
73
75
|
const warnings = [];
|
|
74
76
|
for (const field of ['model', 'effort', 'permissions', 'dshPreset']) {
|
package/control/cmd-model.mjs
CHANGED
|
@@ -50,7 +50,7 @@ export async function handleModelCommand(ctx) {
|
|
|
50
50
|
// The answer names where the topic lands, so it must read the profile the
|
|
51
51
|
// commands edit. `activeProfile` here is the route copy the topic boots, and
|
|
52
52
|
// its default is the very route that was just cleared — that is why `auto`
|
|
53
|
-
// used to answer
|
|
53
|
+
// used to answer with the provider it had just handed the topic back from.
|
|
54
54
|
const head = modelOf(topic.base);
|
|
55
55
|
say(t(lang, cleared ? 'ctrl.model.topicCleared' : 'ctrl.model.topicNone', {
|
|
56
56
|
route: `${head.provider}/${head.model}`,
|
package/control/cmd-skills.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { parseAgentPresets, parseModelSelection, parsePermissionPresets, parseRe
|
|
|
14
14
|
import { setRowConfig, unsetRowConfig } from '../profile/profile-edit.mjs';
|
|
15
15
|
import { parseReminder, stampAt, upcoming } from '../work/reminders.mjs';
|
|
16
16
|
import { AgentsetStore, emptySet, slugId } from '../profile/agentsets.mjs';
|
|
17
|
+
import { ensureInstructionFile, instructionName } from '../profile/topic-docs.mjs';
|
|
17
18
|
import { SETTINGS_PAGES, renderSettingsCard, settingsCurrent } from '../profile/settings-card.mjs';
|
|
18
19
|
import { applyFork, planFork, planRewind } from '../work/rewind.mjs';
|
|
19
20
|
import { cutSession, isRewindPress } from '../work/rewind-buttons.mjs';
|
|
@@ -270,7 +271,7 @@ export async function handleSkillCommands(ctx) {
|
|
|
270
271
|
// `/agentset model inherit`. The DSH profile keeps its own /agents set …
|
|
271
272
|
// verbs; this one only ever writes the topic's set.
|
|
272
273
|
const field = verb;
|
|
273
|
-
const known = new Set(['model', 'effort', 'permissions', 'preset', 'lang', 'notes']);
|
|
274
|
+
const known = new Set(['model', 'effort', 'permissions', 'preset', 'lang', 'notes', 'instructions', 'skills']);
|
|
274
275
|
if (!known.has(field)) {
|
|
275
276
|
say(t(lang, 'ctrl.set.badField', { field, list: [...known].join(', ') }));
|
|
276
277
|
return true;
|
|
@@ -287,6 +288,40 @@ export async function handleSkillCommands(ctx) {
|
|
|
287
288
|
const valueWords = maybe ? rest.slice(0, -1) : rest;
|
|
288
289
|
const value = valueWords.join(' ').trim();
|
|
289
290
|
const cleared = !value || value === 'inherit' || value === '-';
|
|
291
|
+
|
|
292
|
+
// Two fields are lists rather than scalars: `/agentset instructions
|
|
293
|
+
// AGENTS.game.md` names a candidate file, `/agentset skills <dir>` a skill
|
|
294
|
+
// directory. They replace the set's list wholesale, so `inherit` clears it
|
|
295
|
+
// exactly like a scalar field — a half-applied list has no meaning.
|
|
296
|
+
const listField = field === 'instructions' ? 'instructions' : field === 'skills' ? 'skillDirs' : '';
|
|
297
|
+
if (listField) {
|
|
298
|
+
const items = cleared ? [] : value.split(/[\s,]+/).map((item) => item.trim()).filter(Boolean);
|
|
299
|
+
if (listField === 'instructions') {
|
|
300
|
+
const bad = items.filter((item) => !instructionName(item));
|
|
301
|
+
if (bad.length > 0) {
|
|
302
|
+
say(t(lang, 'ctrl.set.badDocs', { value: bad.join(', ') }));
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (!commit(set.id, store.put({ ...set, [listField]: items }))) return true;
|
|
307
|
+
say(cleared
|
|
308
|
+
? t(lang, 'ctrl.set.fieldCleared', { field })
|
|
309
|
+
: t(lang, 'ctrl.set.fieldSet', { field, value: items.join(', '), name: set.name || set.id }));
|
|
310
|
+
if (listField === 'instructions' && !cleared) {
|
|
311
|
+
// The name is only worth setting if a file answers to it, so the same
|
|
312
|
+
// command creates it in the directory this topic's turns run in and
|
|
313
|
+
// says so — the alternative is a setting that reads as applied and
|
|
314
|
+
// changes nothing the model ever sees.
|
|
315
|
+
const dir = state.cwd?.[key] || config?.cwd || '';
|
|
316
|
+
for (const name of items) {
|
|
317
|
+
const made = ensureInstructionFile(name, dir);
|
|
318
|
+
if (made.created) say(t(lang, 'ctrl.set.docsCreated', { file: name, dir }));
|
|
319
|
+
else if (made.error) say(t(lang, 'ctrl.set.docsMissing', { file: name, dir }));
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
|
|
290
325
|
const storeField = field === 'preset' ? 'dshPreset' : field;
|
|
291
326
|
const next = { ...set, [storeField]: cleared ? '' : value };
|
|
292
327
|
if (commit(set.id, store.put(next))) {
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# CHANGELOG — DSH Telegram bridge
|
|
2
2
|
|
|
3
|
+
## 1.54.0
|
|
4
|
+
|
|
5
|
+
- **A set can carry the topic's own rules.** `/crew instructions AGENTS.game.md`
|
|
6
|
+
names a candidate file for the set's profile; the harness then loads it after
|
|
7
|
+
the project's `AGENTS.md`, so a topic gets instructions of its own without
|
|
8
|
+
editing a file every other topic reads. Naming the file creates it in the
|
|
9
|
+
directory this topic's turns run in, and the answer says where — a candidate
|
|
10
|
+
that does not exist loads nothing, and a setting that reads as applied while
|
|
11
|
+
nothing changed is the failure this command exists to avoid. `inherit` clears
|
|
12
|
+
it, `/crew show` lists it. The name is a bare `*.md` file name: candidates are
|
|
13
|
+
matched per directory, so a path would never match and is refused instead of
|
|
14
|
+
stored. Verified end to end on a real turn: with the project file and the topic
|
|
15
|
+
file both present, both markers arrive, in that order.
|
|
16
|
+
- **A set can carry its own skill directory.** `/crew skills <dir>` adds
|
|
17
|
+
directories to the catalog this topic scans, on top of the install's own roots
|
|
18
|
+
(`includeDefaultRoots` stays on), so project skills stop leaking into every
|
|
19
|
+
other topic.
|
|
20
|
+
- **Both fields are a delta like every other field.** An empty list inherits, the
|
|
21
|
+
derived profile's name hashes them, and a set that only names a rule file still
|
|
22
|
+
materialises a profile — otherwise the edit would land in the directory it did
|
|
23
|
+
not change and never be loaded. `docs/TOPIC-PROFILE.md` explains the five-layer
|
|
24
|
+
chain and what it costs; `/help` and `docs/COMMANDS.md` name the two verbs.
|
|
25
|
+
8 tests.
|
|
26
|
+
- **`/model` works for routes whose model id carries a slash.** Subscription
|
|
27
|
+
gateways name their models `gateway/model`, and the card drew a button whose
|
|
28
|
+
tap the route parser silently rejected — the offered route was the one tap
|
|
29
|
+
that did nothing, with no message saying why. The provider half stays
|
|
30
|
+
prefix-free; the model half may now contain `/`.
|
|
31
|
+
- **`/model auto` names where the topic actually lands.** A topic that chose a
|
|
32
|
+
model boots a generated copy of the profile in which the choice is the only
|
|
33
|
+
rewritten row, and the command read the default out of that copy — so
|
|
34
|
+
un-pinning answered with the very route it had just cleared ("back to the old
|
|
35
|
+
provider" while the topic went back to the profile). The answer now reads the
|
|
36
|
+
profile the commands edit. 2 tests.
|
|
37
|
+
- **A speech engine other than `edge-tts` can actually start.** `docs/VOICE.md`
|
|
38
|
+
promised that a local Piper install is a config block, not a code change, but
|
|
39
|
+
`speechConfig` never copied `command` and `args`, so every other provider
|
|
40
|
+
spawned itself by name and died with ENOENT. Both fields are read now, and
|
|
41
|
+
`{voice}` joins `{text}` and `{out}` as a placeholder — `/voice <name>` sets the
|
|
42
|
+
voice per topic, and an engine that owns its own voices needs that name or the
|
|
43
|
+
card confirms a change nothing makes.
|
|
44
|
+
|
|
3
45
|
## 1.53.0
|
|
4
46
|
|
|
5
47
|
- **`/voice` now speaks the whole answer.** 1.52.0 cut the spoken text at
|
package/docs/COMMANDS.md
CHANGED
|
@@ -42,7 +42,7 @@ Built from the same code as `/help`: the list, the sections and the sentences ar
|
|
|
42
42
|
|
|
43
43
|
### Model, prices, fallback
|
|
44
44
|
|
|
45
|
-
- `/model` — One command for the model of this profile: bare /model draws every route as buttons — provider and model together, because one model name can be served by several endpoints — and /model <provider>/<model> switches without tapping. A tap on the card moves THIS topic; the toggle above the list moves the whole profile at once, and it always says which of the two a tap will do. /model <route> all sets the default every topic follows — that is the one to reach for when an endpoint runs out of money and the fallback chain has to start elsewhere. /model <id> both also sets the desktop profile.
|
|
45
|
+
- `/model` — One command for the model of this profile: bare /model draws every route as buttons — provider and model together, because one model name can be served by several endpoints — and /model <provider>/<model> switches without tapping. A tap on the card moves THIS topic; the toggle above the list moves the whole profile at once, and it always says which of the two a tap will do. /model <route> all sets the default every topic follows — that is the one to reach for when an endpoint runs out of money and the fallback chain has to start elsewhere. /model <id> both also sets the desktop profile. A model id may itself carry a prefix (`gateway/model`), so a route is spelled `<endpoint>/<model id>` and the first slash is the one that separates them.
|
|
46
46
|
- `/effort` — How hard the model thinks before answering: /effort high.
|
|
47
47
|
- `/prices` — Prices of the models in use, and what the current model costs for the tokens this topic has spent.
|
|
48
48
|
- `/cost` — What this session has spent: tokens, cache hits and the sum, with the source of the prices named. /cost reads the catalog on disk, /prices is the one that fetches it.
|
|
@@ -55,7 +55,7 @@ Built from the same code as `/help`: the list, the sections and the sentences ar
|
|
|
55
55
|
### Agents and permissions
|
|
56
56
|
|
|
57
57
|
- `/agents` — Agents and subagents: who is configured, on which model, and who was actually spawned.
|
|
58
|
-
- `/crew` — A named bundle of model, permissions and
|
|
58
|
+
- `/crew` — A named bundle of model, permissions, preset and topic rules for this topic: /crew use <id> switches the whole thing, /crew off goes back to the profile, /crew new|copy|rm and /crew model <v> edit one. /crew instructions AGENTS.game.md gives the topic its own rules file, loaded after AGENTS.md; /crew skills <dir> adds skill directories.
|
|
59
59
|
- `/subagents` — The subagents this topic ran: the task each was given, how long it took, and whether it failed. The host reports no tokens per subagent, so the card does not split the turn's count. `/subagents clear` forgets them.
|
|
60
60
|
- `/preset` — The agent preset (persona and tools) of the profile: /preset <id>.
|
|
61
61
|
- `/plan` — Plan mode for this topic: /plan turns it on or off; the plan comes before any change, then an Approve card.
|
|
@@ -147,7 +147,7 @@ Inline: type @bot rew in any chat to see the commands that start with rew. Switc
|
|
|
147
147
|
|
|
148
148
|
### Модель, цены, подмена
|
|
149
149
|
|
|
150
|
-
- `/model` — Одна команда для модели этого профиля: голый /model рисует все маршруты кнопками — провайдер и модель вместе, потому что одно имя модели могут отдавать разные эндпоинты, — а /model <провайдер>/<модель> переключает без кнопок. Нажатие на карточке меняет ЭТУ тему; переключатель над списком меняет весь профиль разом и всегда говорит, что именно сделает нажатие. /model <маршрут> all задаёт значение по умолчанию для всех тем — это то, что нужно, когда у эндпоинта кончились деньги и цепочке fallback надо начинать с другого места. /model <id> both ещё и меняет профиль desktop.
|
|
150
|
+
- `/model` — Одна команда для модели этого профиля: голый /model рисует все маршруты кнопками — провайдер и модель вместе, потому что одно имя модели могут отдавать разные эндпоинты, — а /model <провайдер>/<модель> переключает без кнопок. Нажатие на карточке меняет ЭТУ тему; переключатель над списком меняет весь профиль разом и всегда говорит, что именно сделает нажатие. /model <маршрут> all задаёт значение по умолчанию для всех тем — это то, что нужно, когда у эндпоинта кончились деньги и цепочке fallback надо начинать с другого места. /model <id> both ещё и меняет профиль desktop. Сам id модели может нести префикс (`gateway/model`), поэтому маршрут пишется `<эндпоинт>/<id модели>`, и делит их первый слэш.
|
|
151
151
|
- `/effort` — Насколько глубоко модель думает перед ответом: /effort high.
|
|
152
152
|
- `/prices` — Цены моделей в работе и во что обходится текущая модель на токенах этой темы.
|
|
153
153
|
- `/cost` — Сколько потратила эта сессия: токены, попадания в кэш и сумма, с указанием источника цен. /cost читает каталог с диска, /prices — тот, кто его обновляет.
|
|
@@ -160,7 +160,7 @@ Inline: type @bot rew in any chat to see the commands that start with rew. Switc
|
|
|
160
160
|
### Агенты и права
|
|
161
161
|
|
|
162
162
|
- `/agents` — Агенты и субагенты: кто настроен, на какой модели, кого реально запускали.
|
|
163
|
-
- `/crew` — Именованный набор «модель + права +
|
|
163
|
+
- `/crew` — Именованный набор «модель + права + пресет + правила темы»: /crew use <id> включает целиком, /crew off возвращает профиль, /crew new|copy|rm и /crew model <v> правят набор. /crew instructions AGENTS.game.md даёт теме свой файл правил — он грузится после AGENTS.md; /crew skills <каталог> добавляет каталоги навыков.
|
|
164
164
|
- `/subagents` — Субагенты этой темы: какая задача была у каждого, сколько он работал и не упал ли. Хост не сообщает токены по субагентам, поэтому карточка не делит токены хода. `/subagents clear` забывает их.
|
|
165
165
|
- `/preset` — Пресет агента (персона и инструменты) профиля: /preset <id>.
|
|
166
166
|
- `/plan` — Режим плана в теме: /plan включает и выключает; план приходит до любых правок, потом карточка «Одобрить».
|
|
@@ -252,7 +252,7 @@ Inline: type @bot rew in any chat to see the commands that start with rew. Switc
|
|
|
252
252
|
|
|
253
253
|
### 模型、价格、替补
|
|
254
254
|
|
|
255
|
-
- `/model` — 本配置档模型的一条命令:直接 /model 把每条线路画成按钮 —— 提供方与模型一起选,因为同一个模型名可能由多个端点提供 —— 也可以用 /model <提供方>/<模型> 直接切换。点卡片上的线路只改本话题;列表上方的开关一次改整个配置档,并且始终写着这一下会改哪一边。用 /model <线路> all 设定所有话题跟随的默认 —— 当某个端点没钱了、fallback 链路必须从别处开始时,就用它。加 both 还会改 desktop
|
|
255
|
+
- `/model` — 本配置档模型的一条命令:直接 /model 把每条线路画成按钮 —— 提供方与模型一起选,因为同一个模型名可能由多个端点提供 —— 也可以用 /model <提供方>/<模型> 直接切换。点卡片上的线路只改本话题;列表上方的开关一次改整个配置档,并且始终写着这一下会改哪一边。用 /model <线路> all 设定所有话题跟随的默认 —— 当某个端点没钱了、fallback 链路必须从别处开始时,就用它。加 both 还会改 desktop 配置档。模型 id 本身可能带前缀(`gateway/model`),所以线路写作 `<端点>/<模型 id>`,由第一个斜杠分隔。
|
|
256
256
|
- `/effort` — 模型回答前的思考深度:/effort high。
|
|
257
257
|
- `/prices` — 在用模型的价格,以及当前模型花掉本话题令牌的费用。
|
|
258
258
|
- `/cost` — 本会话花了多少:令牌、缓存命中与合计,并注明价格来源。/cost 读取本地目录,/prices 负责更新它。
|
|
@@ -265,7 +265,7 @@ Inline: type @bot rew in any chat to see the commands that start with rew. Switc
|
|
|
265
265
|
### 智能体与权限
|
|
266
266
|
|
|
267
267
|
- `/agents` — 智能体与子智能体:配置了谁、用什么模型、实际启动了谁。
|
|
268
|
-
- `/crew` — 本话题的命名组合「模型 + 权限 +
|
|
268
|
+
- `/crew` — 本话题的命名组合「模型 + 权限 + 预设 + 话题规则」:/crew use <id> 整套启用,/crew off 回到配置档,/crew new|copy|rm 与 /crew model <v> 编辑组合。/crew instructions AGENTS.game.md 给本话题一个独立规则文件(在 AGENTS.md 之后加载);/crew skills <目录> 增加技能目录。
|
|
269
269
|
- `/subagents` — 本主题运行过的子代理:各自的任务、耗时以及是否失败。宿主不报告单个子代理的 token,因此卡片不拆分本回合的用量。`/subagents clear` 清空记录。
|
|
270
270
|
- `/preset` — 配置档的智能体预设(人格与工具):/preset <id>。
|
|
271
271
|
- `/plan` — 本话题的计划模式:/plan 打开或关闭,先给计划再改动,然后出现「批准」按钮。
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Per-topic agent profiles
|
|
2
|
+
|
|
3
|
+
One bridge, many topics, and each topic should not work like the others: a game
|
|
4
|
+
project needs rules about the engine and the build, a research topic needs rules
|
|
5
|
+
about sources and citations, a planning topic needs rules about scope. This page
|
|
6
|
+
is how that is configured, and what the harness actually loads.
|
|
7
|
+
|
|
8
|
+
Everything here is DSH behaviour plus one bridge field. Nothing in the bridge
|
|
9
|
+
rewrites your `AGENTS.md`, and nothing re-implements instruction loading.
|
|
10
|
+
|
|
11
|
+
## What a turn reads, in order
|
|
12
|
+
|
|
13
|
+
The harness loads workspace instructions from `dsh-agent-instructions`. Broad
|
|
14
|
+
first, each layer more specific than the one before:
|
|
15
|
+
|
|
16
|
+
| # | File | Scope | Who writes it |
|
|
17
|
+
|---|---|---|---|
|
|
18
|
+
| 1 | `$DSH_HOME/AGENTS.md` | this computer, every topic, every project | you, or `/remember` |
|
|
19
|
+
| 2 | `$DSH_HOME/profiles/<profile>/…` rows | profile-level defaults | the profile patch |
|
|
20
|
+
| 3 | `<project>/AGENTS.md` | the project the topic works in | you |
|
|
21
|
+
| 4 | `<project>/AGENTS.<name>.md` | **this topic's set** | the bridge, on `/crew instructions` |
|
|
22
|
+
| 5 | `<project>/*.local.md` | local overlay per directory | you |
|
|
23
|
+
|
|
24
|
+
A layer is only read when a profile names it as a *candidate*. That is what keeps
|
|
25
|
+
topics apart: `AGENTS.game.md` is a candidate only for the profile of the set that
|
|
26
|
+
named it, so two topics in the same directory share 1 and 3 and never see each
|
|
27
|
+
other's 4.
|
|
28
|
+
|
|
29
|
+
Order matters. A line in a topic file is the most specific instruction the agent
|
|
30
|
+
has, so it beats the project's rules — reach for it when a rule is *for this
|
|
31
|
+
topic*, not when it is true of the project.
|
|
32
|
+
|
|
33
|
+
The chain is re-read when the session's working directory changes, and nested
|
|
34
|
+
files discovered by file operations are picked up on later turns.
|
|
35
|
+
|
|
36
|
+
## Giving a topic its own rules
|
|
37
|
+
|
|
38
|
+
1. A set is the topic's own profile — model, permissions, preset, subagents,
|
|
39
|
+
skill directories and rule file. Create one and give it a rule file:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
/crew new game
|
|
43
|
+
/crew instructions AGENTS.game.md
|
|
44
|
+
/crew use game
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`/crew instructions` writes the candidate name into the set, and creates the file
|
|
48
|
+
in the directory this topic's turns run in when it is missing. The answer says
|
|
49
|
+
which file, where. `/crew show` lists the file next to the model and permissions.
|
|
50
|
+
|
|
51
|
+
2. Write rules into that file. Either edit it in the desktop app, or ask the agent
|
|
52
|
+
in the chat — it is a normal file in the workspace: *"добавь в правила темы:
|
|
53
|
+
сборка только через `pnpm build`, тесты перед коммитом"*. The next turn reads
|
|
54
|
+
it, because it is in the chain.
|
|
55
|
+
|
|
56
|
+
3. `inherit` clears the field and the topic goes back to the project's own files:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
/crew instructions inherit
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Own skills
|
|
63
|
+
|
|
64
|
+
`/crew skills <dir>` adds a directory to the catalog this topic scans, on top of
|
|
65
|
+
the install's roots. Useful when a project ships skills that must not appear in
|
|
66
|
+
every other topic. The directory is a `SKILL.md` collection, the same shape as
|
|
67
|
+
`~/.dsh/skills`:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
/crew skills C:\work\game\.dsh\skills
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Give an absolute path. A relative one is resolved by DSH, not by the bridge, and
|
|
74
|
+
the bridge will not guess for you.
|
|
75
|
+
|
|
76
|
+
## What a candidate name may be
|
|
77
|
+
|
|
78
|
+
A bare file name ending in `.md`: `AGENTS.game.md`, `RULES.research.md`. A path is
|
|
79
|
+
refused, because candidates are matched **per directory** — a path would never
|
|
80
|
+
match and the rule would read as applied while the model never saw it. Nothing is
|
|
81
|
+
stored in that case: the answer says which name cannot load and why, instead of
|
|
82
|
+
leaving a setting that cannot work.
|
|
83
|
+
|
|
84
|
+
## What it costs
|
|
85
|
+
|
|
86
|
+
Every loaded file is paid for on every request. That is why the budget exists
|
|
87
|
+
(`maxBytes`, 65 536 by default in the bridge's profile) and why broad files are
|
|
88
|
+
dropped before the most specific one is truncated. Keep a topic file to the rules
|
|
89
|
+
that actually change behaviour, not a project diary; `/remember` is for facts, and
|
|
90
|
+
the project's `AGENTS.md` is for what is true of the whole project.
|
|
91
|
+
|
|
92
|
+
## Failure modes
|
|
93
|
+
|
|
94
|
+
- **A typo in the name.** The file is created by the command, so the usual typo is
|
|
95
|
+
caught at the moment of naming. A file renamed later simply stops loading —
|
|
96
|
+
`/crew show` names the candidate, so the fix is visible.
|
|
97
|
+
- **A topic with no set.** It runs the base profile: global and project files
|
|
98
|
+
only, which is the same behaviour a fresh install has.
|
|
99
|
+
- **Two topics, one set.** They share the set's rule file, deliberately: a set is
|
|
100
|
+
a profile, and binding both topics to it is the way to say "these two work the
|
|
101
|
+
same way".
|
package/docs/VOICE.md
CHANGED
|
@@ -118,7 +118,7 @@ Everything lives in the `speech` block of `config.json`:
|
|
|
118
118
|
| `speech.provider` | What it runs | Needs |
|
|
119
119
|
| --- | --- | --- |
|
|
120
120
|
| `edge-tts` (default) | `python -m edge_tts --voice … --text … --write-media …` | `speech.python` with `edge-tts` installed, `speech.ffmpeg` |
|
|
121
|
-
| anything else | `speech.command` + `speech.args`, with `{text}` and `{
|
|
121
|
+
| anything else | `speech.command` + `speech.args`, with `{text}`, `{out}` and `{voice}` placeholders | an engine that takes the text as an argument and writes audio to `{out}` |
|
|
122
122
|
|
|
123
123
|
`voices` is one male voice per topic language; a language without an entry uses
|
|
124
124
|
the `ru` one rather than going silent. `/voice <name>` sets a voice for that topic
|
|
@@ -132,12 +132,22 @@ writes MP3 and `ffmpeg` converts it to OGG/Opus, because Telegram draws a voice
|
|
|
132
132
|
bubble only for that container. A provider that already speaks OGG sets
|
|
133
133
|
`speech.ogg: true` and needs no ffmpeg.
|
|
134
134
|
|
|
135
|
-
A local Piper install is the same shape:
|
|
135
|
+
A local Piper install is the same shape. Three placeholders exist: `{text}` is
|
|
136
|
+
the sentence to say, `{out}` the file to write, `{voice}` the name `/voice <name>`
|
|
137
|
+
set for the topic. The bridge passes the text as an argument and does not write to
|
|
138
|
+
stdin, and Piper reads its text from stdin, so one line of glue is what makes an
|
|
139
|
+
engine like that fit:
|
|
140
|
+
|
|
141
|
+
```bat
|
|
142
|
+
@echo off
|
|
143
|
+
rem %1 the text, %2 the output file, %3 the voice
|
|
144
|
+
echo %~1 | C:\piper\piper.exe --model C:\piper\%~3.onnx --output_file %~2
|
|
145
|
+
```
|
|
136
146
|
|
|
137
147
|
```json
|
|
138
|
-
{ "speech": { "provider": "piper", "command": "C:/piper/piper.
|
|
139
|
-
"args": ["
|
|
140
|
-
"
|
|
148
|
+
{ "speech": { "provider": "piper", "command": "C:/piper/piper.cmd",
|
|
149
|
+
"args": ["{text}", "{out}", "{voice}"],
|
|
150
|
+
"voices": { "ru": "ru_RU-ruslan-medium" } } }
|
|
141
151
|
```
|
|
142
152
|
|
|
143
153
|
`/voice` on a topic with no engine answers with the state it is in and the reason
|
package/i18n/en/ctrl.mjs
CHANGED
|
@@ -12,8 +12,8 @@ export default {
|
|
|
12
12
|
'ctrl.help.about.rewind': "Going back, one command with three words. /rewind 2 removes the last two turns so you can word the task differently: it shows a card of what will go and cuts only on the button; /rewind undo puts it back. /rewind fork [n] is a branch inside this topic: it copies the session as it stood n turns back and moves this topic onto the copy, cutting nothing. /rewind branches lists the copies, a press switches. A branch into another topic is /branch.",
|
|
13
13
|
'ctrl.help.about.profile': "The profile this topic runs on, and how to change it: /profile <name>, /profile new.",
|
|
14
14
|
'ctrl.help.about.agents': "Agents and subagents: who is configured, on which model, and who was actually spawned.",
|
|
15
|
-
'ctrl.help.about.crew': "A named bundle of model, permissions and
|
|
16
|
-
'ctrl.help.about.model': "One command for the model of this profile: bare /model draws every route as buttons — provider and model together, because one model name can be served by several endpoints — and /model <provider>/<model> switches without tapping. A tap on the card moves THIS topic; the toggle above the list moves the whole profile at once, and it always says which of the two a tap will do. /model <route> all sets the default every topic follows — that is the one to reach for when an endpoint runs out of money and the fallback chain has to start elsewhere. /model <id> both also sets the desktop profile.",
|
|
15
|
+
'ctrl.help.about.crew': "A named bundle of model, permissions, preset and topic rules for this topic: /crew use <id> switches the whole thing, /crew off goes back to the profile, /crew new|copy|rm and /crew model <v> edit one. /crew instructions AGENTS.game.md gives the topic its own rules file, loaded after AGENTS.md; /crew skills <dir> adds skill directories.",
|
|
16
|
+
'ctrl.help.about.model': "One command for the model of this profile: bare /model draws every route as buttons — provider and model together, because one model name can be served by several endpoints — and /model <provider>/<model> switches without tapping. A tap on the card moves THIS topic; the toggle above the list moves the whole profile at once, and it always says which of the two a tap will do. /model <route> all sets the default every topic follows — that is the one to reach for when an endpoint runs out of money and the fallback chain has to start elsewhere. /model <id> both also sets the desktop profile. A model id may itself carry a prefix (`gateway/model`), so a route is spelled `<endpoint>/<model id>` and the first slash is the one that separates them.",
|
|
17
17
|
'ctrl.help.about.prices': "Prices of the models in use, and what the current model costs for the tokens this topic has spent.",
|
|
18
18
|
'ctrl.help.about.thoughts': "The reasoning behind the last turn: text, file or off.",
|
|
19
19
|
'ctrl.help.about.balance': "What is left on the provider keys — the provider's own number, not a guess from an error. Shows both the key and the account: a key can run past its own grant while the account keeps paying. Needs the network.",
|
|
@@ -442,7 +442,7 @@ export default {
|
|
|
442
442
|
'ctrl.set.boundNow': 'This topic uses {name}.',
|
|
443
443
|
'ctrl.set.noneBound': 'No set bound: this topic follows profile {profile}.',
|
|
444
444
|
'ctrl.set.usage': 'Bind: /crew use <id> · card: /crew show [id] · detach: /crew off · new: /crew new <name> [from <id>]',
|
|
445
|
-
'ctrl.set.hint': 'A set is a delta over the profile: an empty field inherits it. Edit one field with /crew model|effort|permissions|preset|lang <value> [id], or "inherit" to clear.',
|
|
445
|
+
'ctrl.set.hint': 'A set is a delta over the profile: an empty field inherits it. Edit one field with /crew model|effort|permissions|preset|lang <value> [id], or "inherit" to clear. The topic\'s own rules file: /crew instructions AGENTS.game.md; its skill dirs: /crew skills <dir>.',
|
|
446
446
|
'ctrl.set.bound': '✅ This topic now uses {name}. Applies from the next turn.',
|
|
447
447
|
'ctrl.set.unbound': '✅ Back to profile {profile}.',
|
|
448
448
|
'ctrl.set.same': 'Already in that state.',
|
|
@@ -456,6 +456,11 @@ export default {
|
|
|
456
456
|
'ctrl.set.badField': 'No field "{field}". Editable: {list}',
|
|
457
457
|
'ctrl.set.fieldSet': '✅ {field} → {value} in {name}.',
|
|
458
458
|
'ctrl.set.fieldCleared': '✅ {field} inherits the profile again.',
|
|
459
|
+
'ctrl.set.field.instructions': 'Topic rules',
|
|
460
|
+
'ctrl.set.field.skills': 'Skill dirs',
|
|
461
|
+
'ctrl.set.docsCreated': '📄 {file} created in {dir} — this topic\'s next turn loads it after AGENTS.md.',
|
|
462
|
+
'ctrl.set.docsMissing': '⚠️ {file} is not in {dir}; the next turn loads it once the file exists.',
|
|
463
|
+
'ctrl.set.badDocs': 'A topic rule file is a bare name like AGENTS.game.md — "{value}" would never load.',
|
|
459
464
|
'ctrl.set.stale': 'Somebody changed the sets meanwhile — repeat the command.',
|
|
460
465
|
'ctrl.set.unreadable': 'agentsets.json cannot be rewritten ({error}) — fix or move it first.',
|
|
461
466
|
'ctrl.set.failed': 'Could not save the set ({error}).',
|
package/i18n/ru/ctrl.mjs
CHANGED
|
@@ -12,8 +12,8 @@ export default {
|
|
|
12
12
|
'ctrl.help.about.rewind': "Откат — одна команда с тремя словами. /rewind 2 убирает два последних хода, чтобы сформулировать иначе: сначала карточка того, что уйдёт, режет только кнопка; /rewind undo возвращает. /rewind fork [n] — ветка внутри темы: копирует сессию в том виде, каким она была n ходов назад, и переводит тему на копию, ничего не отрезая. /rewind branches показывает копии, нажатие переключает. Ветка в другую тему — это /branch.",
|
|
13
13
|
'ctrl.help.about.profile': "Профиль, на котором идёт тема, и как его сменить: /profile <имя>, /profile new.",
|
|
14
14
|
'ctrl.help.about.agents': "Агенты и субагенты: кто настроен, на какой модели, кого реально запускали.",
|
|
15
|
-
'ctrl.help.about.crew': "Именованный набор «модель + права +
|
|
16
|
-
'ctrl.help.about.model': "Одна команда для модели этого профиля: голый /model рисует все маршруты кнопками — провайдер и модель вместе, потому что одно имя модели могут отдавать разные эндпоинты, — а /model <провайдер>/<модель> переключает без кнопок. Нажатие на карточке меняет ЭТУ тему; переключатель над списком меняет весь профиль разом и всегда говорит, что именно сделает нажатие. /model <маршрут> all задаёт значение по умолчанию для всех тем — это то, что нужно, когда у эндпоинта кончились деньги и цепочке fallback надо начинать с другого места. /model <id> both ещё и меняет профиль desktop.",
|
|
15
|
+
'ctrl.help.about.crew': "Именованный набор «модель + права + пресет + правила темы»: /crew use <id> включает целиком, /crew off возвращает профиль, /crew new|copy|rm и /crew model <v> правят набор. /crew instructions AGENTS.game.md даёт теме свой файл правил — он грузится после AGENTS.md; /crew skills <каталог> добавляет каталоги навыков.",
|
|
16
|
+
'ctrl.help.about.model': "Одна команда для модели этого профиля: голый /model рисует все маршруты кнопками — провайдер и модель вместе, потому что одно имя модели могут отдавать разные эндпоинты, — а /model <провайдер>/<модель> переключает без кнопок. Нажатие на карточке меняет ЭТУ тему; переключатель над списком меняет весь профиль разом и всегда говорит, что именно сделает нажатие. /model <маршрут> all задаёт значение по умолчанию для всех тем — это то, что нужно, когда у эндпоинта кончились деньги и цепочке fallback надо начинать с другого места. /model <id> both ещё и меняет профиль desktop. Сам id модели может нести префикс (`gateway/model`), поэтому маршрут пишется `<эндпоинт>/<id модели>`, и делит их первый слэш.",
|
|
17
17
|
'ctrl.help.about.prices': "Цены моделей в работе и во что обходится текущая модель на токенах этой темы.",
|
|
18
18
|
'ctrl.help.about.thoughts': "Рассуждения последнего хода: текстом, файлом или выкл.",
|
|
19
19
|
'ctrl.help.about.balance': "Сколько осталось на ключах провайдеров — цифра от самого провайдера, а не догадка по ошибке. Показывает и остаток ключа, и остаток аккаунта: ключ может перебрать свой лимит, пока аккаунт платит. Нужна сеть.",
|
|
@@ -442,7 +442,7 @@ export default {
|
|
|
442
442
|
'ctrl.set.boundNow': 'Тема работает на «{name}».',
|
|
443
443
|
'ctrl.set.noneBound': 'Набор не привязан: тема идёт по профилю {profile}.',
|
|
444
444
|
'ctrl.set.usage': 'Привязать: /crew use <id> · карточка: /crew show [id] · отвязать: /crew off · создать: /crew new <имя> [из <id>]',
|
|
445
|
-
'ctrl.set.hint': 'Набор — дельта к профилю: пустое поле наследуется. Одно поле: /crew model|effort|permissions|preset|lang <значение> [id], «inherit» очищает.',
|
|
445
|
+
'ctrl.set.hint': 'Набор — дельта к профилю: пустое поле наследуется. Одно поле: /crew model|effort|permissions|preset|lang <значение> [id], «inherit» очищает. Свой файл правил темы: /crew instructions AGENTS.game.md; свои каталоги навыков: /crew skills <каталог>.',
|
|
446
446
|
'ctrl.set.bound': '✅ Тема перешла на «{name}». Действует со следующего хода.',
|
|
447
447
|
'ctrl.set.unbound': '✅ Снова профиль {profile}.',
|
|
448
448
|
'ctrl.set.same': 'Уже так.',
|
|
@@ -456,6 +456,11 @@ export default {
|
|
|
456
456
|
'ctrl.set.badField': 'Поля «{field}» нет. Можно: {list}',
|
|
457
457
|
'ctrl.set.fieldSet': '✅ {field} → {value} в наборе {name}.',
|
|
458
458
|
'ctrl.set.fieldCleared': '✅ {field} снова берётся из профиля.',
|
|
459
|
+
'ctrl.set.field.instructions': 'Правила темы',
|
|
460
|
+
'ctrl.set.field.skills': 'Каталоги навыков',
|
|
461
|
+
'ctrl.set.docsCreated': '📄 {file} создан в {dir} — следующий ход этой темы загрузит его после AGENTS.md.',
|
|
462
|
+
'ctrl.set.docsMissing': '⚠️ {file} нет в {dir}; ход загрузит его, как только файл появится.',
|
|
463
|
+
'ctrl.set.badDocs': 'Файл правил темы — просто имя вроде AGENTS.game.md: «{value}» не загрузится никогда.',
|
|
459
464
|
'ctrl.set.stale': 'Наборы успели измениться — повтори команду.',
|
|
460
465
|
'ctrl.set.unreadable': 'agentsets.json не перезаписать ({error}) — сначала почини или убери файл.',
|
|
461
466
|
'ctrl.set.failed': 'Не удалось сохранить набор ({error}).',
|
package/i18n/zh/ctrl.mjs
CHANGED
|
@@ -12,8 +12,8 @@ export default {
|
|
|
12
12
|
'ctrl.help.about.rewind': "回退只有一条命令、三种说法。/rewind 2 去掉最后两轮以便换种说法:先显示将移除内容的卡片,只有按按钮才裁切;/rewind undo 可恢复。/rewind fork [n] 是话题内部的分支:把会话复制成 n 轮前的样子并把本话题切到副本,不切断任何东西。/rewind branches 列出副本,按一下就切换。分支到另一个话题用 /branch。",
|
|
13
13
|
'ctrl.help.about.profile': "本话题使用的配置档,以及如何更换:/profile <名称>、/profile new。",
|
|
14
14
|
'ctrl.help.about.agents': "智能体与子智能体:配置了谁、用什么模型、实际启动了谁。",
|
|
15
|
-
'ctrl.help.about.crew': "本话题的命名组合「模型 + 权限 +
|
|
16
|
-
'ctrl.help.about.model': "本配置档模型的一条命令:直接 /model 把每条线路画成按钮 —— 提供方与模型一起选,因为同一个模型名可能由多个端点提供 —— 也可以用 /model <提供方>/<模型> 直接切换。点卡片上的线路只改本话题;列表上方的开关一次改整个配置档,并且始终写着这一下会改哪一边。用 /model <线路> all 设定所有话题跟随的默认 —— 当某个端点没钱了、fallback 链路必须从别处开始时,就用它。加 both 还会改 desktop
|
|
15
|
+
'ctrl.help.about.crew': "本话题的命名组合「模型 + 权限 + 预设 + 话题规则」:/crew use <id> 整套启用,/crew off 回到配置档,/crew new|copy|rm 与 /crew model <v> 编辑组合。/crew instructions AGENTS.game.md 给本话题一个独立规则文件(在 AGENTS.md 之后加载);/crew skills <目录> 增加技能目录。",
|
|
16
|
+
'ctrl.help.about.model': "本配置档模型的一条命令:直接 /model 把每条线路画成按钮 —— 提供方与模型一起选,因为同一个模型名可能由多个端点提供 —— 也可以用 /model <提供方>/<模型> 直接切换。点卡片上的线路只改本话题;列表上方的开关一次改整个配置档,并且始终写着这一下会改哪一边。用 /model <线路> all 设定所有话题跟随的默认 —— 当某个端点没钱了、fallback 链路必须从别处开始时,就用它。加 both 还会改 desktop 配置档。模型 id 本身可能带前缀(`gateway/model`),所以线路写作 `<端点>/<模型 id>`,由第一个斜杠分隔。",
|
|
17
17
|
'ctrl.help.about.prices': "在用模型的价格,以及当前模型花掉本话题令牌的费用。",
|
|
18
18
|
'ctrl.help.about.thoughts': "上一轮的推理:文本、文件或关闭。",
|
|
19
19
|
'ctrl.help.about.balance': "各提供商密钥还剩多少 — 数字来自提供商本身,而不是从错误里猜的。同时显示密钥与账户余额:密钥可能超出自身额度,而账户仍在付费。需要联网。",
|
|
@@ -442,7 +442,7 @@ export default {
|
|
|
442
442
|
'ctrl.set.boundNow': '本话题使用「{name}」。',
|
|
443
443
|
'ctrl.set.noneBound': '未绑定方案:本话题按配置档 {profile} 运行。',
|
|
444
444
|
'ctrl.set.usage': '绑定:/crew use <id> · 卡片:/crew show [id] · 取消:/crew off · 新建:/crew new <名称> [from <id>]',
|
|
445
|
-
'ctrl.set.hint': '方案是对配置档的增量:留空的字段沿用配置档。改单项:/crew model|effort|permissions|preset|lang <值> [id],inherit
|
|
445
|
+
'ctrl.set.hint': '方案是对配置档的增量:留空的字段沿用配置档。改单项:/crew model|effort|permissions|preset|lang <值> [id],inherit 表示清除。本话题的规则文件:/crew instructions AGENTS.game.md;技能目录:/crew skills <目录>。',
|
|
446
446
|
'ctrl.set.bound': '✅ 本话题已改用「{name}」,下一轮生效。',
|
|
447
447
|
'ctrl.set.unbound': '✅ 已恢复配置档 {profile}。',
|
|
448
448
|
'ctrl.set.same': '已经是这样。',
|
|
@@ -456,6 +456,11 @@ export default {
|
|
|
456
456
|
'ctrl.set.badField': '没有字段「{field}」。可改:{list}',
|
|
457
457
|
'ctrl.set.fieldSet': '✅ 方案 {name} 的 {field} → {value}。',
|
|
458
458
|
'ctrl.set.fieldCleared': '✅ {field} 改回沿用配置档。',
|
|
459
|
+
'ctrl.set.field.instructions': '话题规则',
|
|
460
|
+
'ctrl.set.field.skills': '技能目录',
|
|
461
|
+
'ctrl.set.docsCreated': '📄 已在 {dir} 创建 {file} —— 本话题下一轮会在 AGENTS.md 之后加载它。',
|
|
462
|
+
'ctrl.set.docsMissing': '⚠️ {dir} 里没有 {file};文件一出现,下一轮就会加载。',
|
|
463
|
+
'ctrl.set.badDocs': '话题规则文件只是文件名,如 AGENTS.game.md;「{value}」永远不会被加载。',
|
|
459
464
|
'ctrl.set.stale': '方案已被改动——请重试命令。',
|
|
460
465
|
'ctrl.set.unreadable': 'agentsets.json 无法重写({error})——请先修复或移走该文件。',
|
|
461
466
|
'ctrl.set.failed': '保存方案失败({error})。',
|
package/package.json
CHANGED
package/profile/agentsets.mjs
CHANGED
|
@@ -26,7 +26,7 @@ function snapshot(sets) {
|
|
|
26
26
|
|
|
27
27
|
/** Fields a set may carry. Anything else is preserved but never read. */
|
|
28
28
|
export const FIELDS = ['model', 'provider', 'effort', 'permissions', 'dshPreset', 'lang', 'thinkBlock', 'base', 'notes'];
|
|
29
|
-
export const LIST_FIELDS = ['plugins', 'toolFilter', 'agents'];
|
|
29
|
+
export const LIST_FIELDS = ['plugins', 'toolFilter', 'agents', 'instructions', 'skillDirs'];
|
|
30
30
|
|
|
31
31
|
export function emptySet(id, name = id) {
|
|
32
32
|
const now = new Date().toISOString();
|
|
@@ -46,6 +46,11 @@ export function emptySet(id, name = id) {
|
|
|
46
46
|
plugins: { add: [], remove: [], disable: [], enable: [] },
|
|
47
47
|
toolFilter: { deny: [], allow: [] },
|
|
48
48
|
agents: {},
|
|
49
|
+
// The topic's own documentation, layered after the project's AGENTS.md, and
|
|
50
|
+
// the skill directories only this topic's catalog scans. Both are lists of
|
|
51
|
+
// names/paths, and empty means "whatever the profile already loads".
|
|
52
|
+
instructions: [],
|
|
53
|
+
skillDirs: [],
|
|
49
54
|
lang: '',
|
|
50
55
|
thinkBlock: '',
|
|
51
56
|
notes: '',
|
package/profile/aset-profile.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import { createHash } from 'node:crypto';
|
|
|
16
16
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
|
|
17
17
|
import { homedir } from 'node:os';
|
|
18
18
|
import { join, resolve, sep } from 'node:path';
|
|
19
|
-
import { setAgentPreset, setModel, setSubagents } from './patch-rows.mjs';
|
|
19
|
+
import { setAgentPreset, setInstructionFiles, setModel, setSkillDirs, setSubagents } from './patch-rows.mjs';
|
|
20
20
|
import { sandboxModeOf, setPermission } from './permission-rows.mjs';
|
|
21
21
|
|
|
22
22
|
const DSH_HOME = process.env.DSH_HOME || join(homedir(), '.dsh');
|
|
@@ -41,6 +41,13 @@ export function derivedName(base, set, workspace = '') {
|
|
|
41
41
|
String(workspace || ''),
|
|
42
42
|
set?.agents || null,
|
|
43
43
|
set?.toolFilter || null,
|
|
44
|
+
// The topic's own instruction files and skill directories change what the
|
|
45
|
+
// turn reads, so they belong in the name: without them an edit would land in
|
|
46
|
+
// the same directory as the copy it does not change, and `materialiseProfile`
|
|
47
|
+
// returns early on the existing patch — the edit would look applied and never
|
|
48
|
+
// be loaded.
|
|
49
|
+
set?.instructions || null,
|
|
50
|
+
set?.skillDirs || null,
|
|
44
51
|
]);
|
|
45
52
|
return `${DERIVED_PREFIX}${createHash('sha256').update(material).digest('hex').slice(0, 10)}`;
|
|
46
53
|
}
|
|
@@ -77,6 +84,10 @@ export function overlayPatch(basePatch, set, base = {}, workspace = '') {
|
|
|
77
84
|
const preset = String(set?.dshPreset || '').trim();
|
|
78
85
|
if (preset && preset !== base.preset) next = setAgentPreset(next, preset);
|
|
79
86
|
if (set?.agents && typeof set.agents === 'object') next = setSubagents(next, set.agents);
|
|
87
|
+
// Documentation and skills the topic loads: the same delta rule as the rows
|
|
88
|
+
// above — a set that names none leaves the chain the base profile already has.
|
|
89
|
+
if (set?.instructions) next = setInstructionFiles(next, set.instructions);
|
|
90
|
+
if (set?.skillDirs) next = setSkillDirs(next, set.skillDirs);
|
|
80
91
|
return { patch: next, changed: next !== source };
|
|
81
92
|
}
|
|
82
93
|
|
package/profile/patch-rows.mjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
//
|
|
8
8
|
// Permissions live in `permission-rows.mjs`: they are two rows that must agree,
|
|
9
9
|
// and a writer that can move only one of them is the bug that file prevents.
|
|
10
|
-
import { setRowConfig } from './profile-edit.mjs';
|
|
10
|
+
import { appendRow, rowExists, setRowConfig } from './profile-edit.mjs';
|
|
11
11
|
|
|
12
12
|
/** The row that decides which model a turn runs on. */
|
|
13
13
|
export const MODEL = '@deepseek-ai/dsh-agent-default-model';
|
|
@@ -44,3 +44,100 @@ export function setSubagents(patch, agents) {
|
|
|
44
44
|
}
|
|
45
45
|
return next;
|
|
46
46
|
}
|
|
47
|
+
|
|
48
|
+
/** The row that loads the workspace instruction chain (AGENTS.md and friends). */
|
|
49
|
+
export const INSTRUCTIONS = '@deepseek-ai/dsh-agent-instructions';
|
|
50
|
+
/** The row that says which skill directories the catalog scans. */
|
|
51
|
+
export const SKILLS = '@deepseek-ai/dsh-skill-filesystem';
|
|
52
|
+
// The ids the base bundle declares. A profile that never mentions the row still
|
|
53
|
+
// gets one from `dsh-base`; appending the same id here is what makes the copy
|
|
54
|
+
// override it instead of adding a second, contradicting row.
|
|
55
|
+
const INSTRUCTION_ROW = 'agent-instructions';
|
|
56
|
+
const SKILL_ROW = 'skill-filesystem';
|
|
57
|
+
// `dsh-base` ships this budget and the plugin requires one, so a row written
|
|
58
|
+
// without it would lose the number the install already runs with.
|
|
59
|
+
const INSTRUCTION_MAX_BYTES = 65536;
|
|
60
|
+
// Every profile loads these; a topic's own file is an addition, never a swap.
|
|
61
|
+
const BASE_CANDIDATES = ['AGENTS.md', 'CLAUDE.md'];
|
|
62
|
+
|
|
63
|
+
const escapeRe = (text) => String(text).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
64
|
+
|
|
65
|
+
/** The line range of the row that declares `pkg`, or null. */
|
|
66
|
+
function rowRange(lines, pkg) {
|
|
67
|
+
const name = new RegExp(`^\\s*name:\\s*['"]?${escapeRe(pkg)}['"]?\\s*$`);
|
|
68
|
+
const start = lines.findIndex((line) => name.test(line));
|
|
69
|
+
if (start < 0) return null;
|
|
70
|
+
let end = start + 1;
|
|
71
|
+
for (; end < lines.length; end += 1) {
|
|
72
|
+
if (/^\s*-\s*(id|name):/.test(lines[end])) break;
|
|
73
|
+
}
|
|
74
|
+
return { start, end };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The list a row's config already holds under `key`, so an edit adds to it. */
|
|
78
|
+
function listInRow(text, pkg, key) {
|
|
79
|
+
const lines = String(text ?? '').split(/\r?\n/);
|
|
80
|
+
const range = rowRange(lines, pkg);
|
|
81
|
+
if (!range) return [];
|
|
82
|
+
const keyLine = new RegExp(`^\\s*${escapeRe(key)}:\\s*$`);
|
|
83
|
+
let at = -1;
|
|
84
|
+
for (let i = range.start + 1; i < range.end; i += 1) {
|
|
85
|
+
if (keyLine.test(lines[i])) { at = i; break; }
|
|
86
|
+
}
|
|
87
|
+
if (at < 0) return [];
|
|
88
|
+
const pad = /^\s*/.exec(lines[at])[0].length;
|
|
89
|
+
const out = [];
|
|
90
|
+
for (let i = at + 1; i < range.end; i += 1) {
|
|
91
|
+
if (!lines[i].trim()) continue;
|
|
92
|
+
if (/^\s*/.exec(lines[i])[0].length <= pad) break;
|
|
93
|
+
const item = /^\s*-\s*(.+?)\s*$/.exec(lines[i]);
|
|
94
|
+
if (item) out.push(item[1].replace(/^['"]|['"]$/g, ''));
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const cleanList = (value) => (Array.isArray(value) ? value : [value])
|
|
100
|
+
.map((item) => String(item ?? '').trim())
|
|
101
|
+
.filter(Boolean);
|
|
102
|
+
|
|
103
|
+
const unique = (items) => [...new Set(items)];
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Make the instruction chain also load this topic's own files.
|
|
107
|
+
*
|
|
108
|
+
* The candidate names are per-directory, and the plugin loads every existing
|
|
109
|
+
* candidate from the project root down to the turn's directory — so the topic's
|
|
110
|
+
* file lands after the project's `AGENTS.md` and after the global ones, which is
|
|
111
|
+
* exactly the precedence that makes a per-topic rule specific instead of
|
|
112
|
+
* authoritative. Nothing is removed from the chain: two topics in one project
|
|
113
|
+
* still share `AGENTS.md`, and each only sees the file its own profile names.
|
|
114
|
+
*/
|
|
115
|
+
export function setInstructionFiles(patch, names) {
|
|
116
|
+
const extra = cleanList(names);
|
|
117
|
+
if (extra.length === 0) return String(patch ?? '');
|
|
118
|
+
let next = String(patch ?? '');
|
|
119
|
+
if (!rowExists(next, INSTRUCTIONS)) {
|
|
120
|
+
next = appendRow(next, { id: INSTRUCTION_ROW, pkg: INSTRUCTIONS, config: { maxBytes: INSTRUCTION_MAX_BYTES } }) ?? next;
|
|
121
|
+
}
|
|
122
|
+
const wanted = unique([...BASE_CANDIDATES, ...listInRow(next, INSTRUCTIONS, 'instructionFileCandidates'), ...extra]);
|
|
123
|
+
return setRowConfig(next, { pkg: INSTRUCTIONS, path: ['instructionFileCandidates'], value: wanted }) ?? next;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Add skill directories to the catalog this profile scans.
|
|
128
|
+
*
|
|
129
|
+
* `customSkillDirs` is additive and `includeDefaultRoots` stays on, so a topic
|
|
130
|
+
* gets its own skills without losing the install's — the same delta rule the
|
|
131
|
+
* rest of a set follows. Paths are passed through as the person wrote them: a
|
|
132
|
+
* relative one is DSH's to resolve, and rewriting it here would guess wrong.
|
|
133
|
+
*/
|
|
134
|
+
export function setSkillDirs(patch, dirs) {
|
|
135
|
+
const extra = cleanList(dirs);
|
|
136
|
+
if (extra.length === 0) return String(patch ?? '');
|
|
137
|
+
let next = String(patch ?? '');
|
|
138
|
+
if (!rowExists(next, SKILLS)) {
|
|
139
|
+
next = appendRow(next, { id: SKILL_ROW, pkg: SKILLS, config: { includeDefaultRoots: true } }) ?? next;
|
|
140
|
+
}
|
|
141
|
+
const wanted = unique([...listInRow(next, SKILLS, 'customSkillDirs'), ...extra]);
|
|
142
|
+
return setRowConfig(next, { pkg: SKILLS, path: ['customSkillDirs'], value: wanted }) ?? next;
|
|
143
|
+
}
|
package/profile/settings.mjs
CHANGED
|
@@ -100,6 +100,10 @@ export function resolveSettings({
|
|
|
100
100
|
allow: [...(set?.toolFilter?.allow || [])],
|
|
101
101
|
};
|
|
102
102
|
const agents = { ...(set?.agents || {}) };
|
|
103
|
+
// Documentation and skills are lists, and an empty list is inheritance — the
|
|
104
|
+
// same delta rule the scalar fields above follow.
|
|
105
|
+
const instructions = Array.isArray(set?.instructions) ? [...set.instructions] : [];
|
|
106
|
+
const skillDirs = Array.isArray(set?.skillDirs) ? [...set.skillDirs] : [];
|
|
103
107
|
|
|
104
108
|
const out = {
|
|
105
109
|
model: checkedModel.value,
|
|
@@ -112,6 +116,8 @@ export function resolveSettings({
|
|
|
112
116
|
plugins,
|
|
113
117
|
toolFilter,
|
|
114
118
|
agents,
|
|
119
|
+
instructions,
|
|
120
|
+
skillDirs,
|
|
115
121
|
base: set?.base || '',
|
|
116
122
|
sources: src,
|
|
117
123
|
};
|
|
@@ -132,6 +138,8 @@ export function touchesProfile(resolved) {
|
|
|
132
138
|
|| own('permissions')
|
|
133
139
|
|| own('dshPreset')
|
|
134
140
|
|| Object.keys(resolved.agents || {}).length
|
|
141
|
+
|| resolved.instructions?.length
|
|
142
|
+
|| resolved.skillDirs?.length
|
|
135
143
|
|| resolved.toolFilter?.deny?.length
|
|
136
144
|
|| resolved.toolFilter?.allow?.length,
|
|
137
145
|
);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// The instruction file a topic loads on top of the project's own.
|
|
2
|
+
//
|
|
3
|
+
// The harness loads every candidate name it finds from the project root down to
|
|
4
|
+
// the turn's directory, broad first. That chain is the whole mechanism: a topic
|
|
5
|
+
// is given a file name of its own, its profile names that file, and the rules
|
|
6
|
+
// inside land after `AGENTS.md` and after the global file — specific, not
|
|
7
|
+
// authoritative. Two topics in one project keep sharing `AGENTS.md`, and neither
|
|
8
|
+
// sees the other's file, because a candidate only loads when a profile names it.
|
|
9
|
+
//
|
|
10
|
+
// The name is a bare file name on purpose: a candidate is matched per directory,
|
|
11
|
+
// so a path would never match and the file would silently never load.
|
|
12
|
+
import { existsSync, renameSync, writeFileSync } from 'node:fs';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
|
|
15
|
+
/** What a candidate name may look like: one file, markdown, no directories. */
|
|
16
|
+
const NAME = /^[A-Za-z0-9._-]+\.md$/i;
|
|
17
|
+
/** A name that is really a path is the mistake worth naming: it can never load. */
|
|
18
|
+
const PATHLIKE = /[\\/]/;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `AGENTS.game.md` -> `AGENTS.game.md`; anything that cannot be a candidate ->
|
|
22
|
+
* '' so the caller refuses it instead of writing a setting that never applies.
|
|
23
|
+
*/
|
|
24
|
+
export function instructionName(value) {
|
|
25
|
+
const name = String(value ?? '').trim();
|
|
26
|
+
if (!name || PATHLIKE.test(name) || !NAME.test(name)) return '';
|
|
27
|
+
return name;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The text a freshly created topic file starts with. */
|
|
31
|
+
function docBody(name) {
|
|
32
|
+
return [
|
|
33
|
+
`# ${name}`,
|
|
34
|
+
'',
|
|
35
|
+
'Rules for this topic only. Loaded after the project AGENTS.md and after the',
|
|
36
|
+
'global one, so a line here is the most specific instruction the agent has.',
|
|
37
|
+
'',
|
|
38
|
+
].join('\n');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Create the named file in `dir` when it is not there yet.
|
|
43
|
+
*
|
|
44
|
+
* A candidate that does not exist is a silent no-op: the setting would read as
|
|
45
|
+
* applied while nothing changed, and the person would have no way to tell. So
|
|
46
|
+
* naming the file creates it, empty but for its heading, and the answer says
|
|
47
|
+
* where it landed. Written aside and renamed: the harness may read it mid-write.
|
|
48
|
+
*
|
|
49
|
+
* @returns {{file: string, created: boolean}|{error: string}}
|
|
50
|
+
*/
|
|
51
|
+
export function ensureInstructionFile(name, dir) {
|
|
52
|
+
const clean = instructionName(name);
|
|
53
|
+
if (!clean) return { error: 'bad-name' };
|
|
54
|
+
if (!dir) return { error: 'no-dir' };
|
|
55
|
+
const file = join(dir, clean);
|
|
56
|
+
if (existsSync(file)) return { file, created: false };
|
|
57
|
+
try {
|
|
58
|
+
writeFileSync(`${file}.tmp`, docBody(clean), 'utf8');
|
|
59
|
+
renameSync(`${file}.tmp`, file);
|
|
60
|
+
return { file, created: true };
|
|
61
|
+
} catch (error) {
|
|
62
|
+
return { error: String(error?.message || error) };
|
|
63
|
+
}
|
|
64
|
+
}
|
package/turn/aset-job.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// before a turn — writing `<base>` + the set's rows into a profile of their own
|
|
7
7
|
// — is spawned as a detached child, and this CLI is that child.
|
|
8
8
|
//
|
|
9
|
-
// Usage (from a job file the agent writes, see docs/
|
|
9
|
+
// Usage (from a job file the agent writes, see docs/TOPIC-PROFILE.md):
|
|
10
10
|
// node cli.mjs aset materialise <setId> [--base <profile>]
|
|
11
11
|
// Prints one JSON line: {ok, profile, base} or {ok: false, error}.
|
|
12
12
|
import { spawn } from 'node:child_process';
|