@aiwayds/dsh-tui-pi 0.1.1 → 0.4.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 +175 -41
- package/lib/agent-manager.d.ts +125 -0
- package/lib/agent-manager.js +298 -0
- package/lib/agent-manager.js.map +1 -0
- package/lib/agents.d.ts +30 -0
- package/lib/agents.js +489 -0
- package/lib/agents.js.map +1 -0
- package/lib/append-system.d.ts +2 -0
- package/lib/append-system.js +1 -1
- package/lib/append-system.js.map +1 -1
- package/lib/dsh-events.d.ts +12 -0
- package/lib/editor.d.ts +58 -0
- package/lib/editor.js +92 -0
- package/lib/editor.js.map +1 -1
- package/lib/footer.d.ts +46 -0
- package/lib/footer.js +65 -0
- package/lib/footer.js.map +1 -1
- package/lib/hotkeys.d.ts +93 -0
- package/lib/hotkeys.js +305 -0
- package/lib/hotkeys.js.map +1 -0
- package/lib/index.js +342 -61
- package/lib/index.js.map +1 -1
- package/lib/keymap.d.ts +243 -0
- package/lib/keymap.js +245 -0
- package/lib/keymap.js.map +1 -0
- package/lib/live-widgets.d.ts +59 -49
- package/lib/live-widgets.js +174 -117
- package/lib/live-widgets.js.map +1 -1
- package/lib/panels.d.ts +177 -0
- package/lib/panels.js +331 -0
- package/lib/panels.js.map +1 -0
- package/lib/selectors.d.ts +12 -1
- package/lib/selectors.js +1 -1
- package/lib/selectors.js.map +1 -1
- package/lib/session.d.ts +25 -0
- package/lib/session.js +173 -12
- package/lib/session.js.map +1 -1
- package/lib/settings.d.ts +1 -2
- package/lib/subagent-policy.d.ts +88 -0
- package/lib/subagent-policy.js +189 -0
- package/lib/subagent-policy.js.map +1 -0
- package/lib/subagent-viewer.d.ts +49 -0
- package/lib/subagent-viewer.js +523 -0
- package/lib/subagent-viewer.js.map +1 -0
- package/lib/theme/index.js +4 -0
- package/lib/theme/index.js.map +1 -1
- package/lib/theme/palette.d.ts +21 -3
- package/lib/theme/palette.js +27 -6
- package/lib/theme/palette.js.map +1 -1
- package/lib/theme-settings.d.ts +71 -9
- package/lib/theme-settings.js +145 -21
- package/lib/theme-settings.js.map +1 -1
- package/lib/tui.d.ts +23 -9
- package/lib/tui.js +110 -7
- package/lib/tui.js.map +1 -1
- package/package.json +3 -4
- package/patches/@earendil-works__pi-tui.patch +206 -2
- package/scripts/dev-install.mjs +87 -0
- package/scripts/link-dsh-closure.mjs +85 -0
- package/templates/agents/ArtyDuck.md +11 -0
- package/templates/agents/oldfox.md +33 -0
- package/templates/agents/workhorse.md +34 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent definitions as markdown files — the dsh terminal counterpart of the
|
|
3
|
+
* pi fun-agent / zcode "one file per agent" convention.
|
|
4
|
+
*
|
|
5
|
+
* An agent is a `<agents-dir>/<name>.md` file with a `---` frontmatter block
|
|
6
|
+
* and a markdown body that doubles as the agent's system prompt:
|
|
7
|
+
*
|
|
8
|
+
* ---
|
|
9
|
+
* name: oldfox
|
|
10
|
+
* display_name: 老法师
|
|
11
|
+
* description: "顾问角色:review、挑刺、保证健壮性。"
|
|
12
|
+
* color: red
|
|
13
|
+
* model: volc-ark-plan/glm-5.3
|
|
14
|
+
* thinking: high
|
|
15
|
+
* deep: 1
|
|
16
|
+
* ---
|
|
17
|
+
* You are 老法师 — 顾问…
|
|
18
|
+
*
|
|
19
|
+
* Frontmatter keys are parsed loosely (`key: value`, optional surrounding
|
|
20
|
+
* quotes); `name` is required, `description` feeds the picker subtitle,
|
|
21
|
+
* `model` is a dsh `provider/model` route (the picker rewrites it), and
|
|
22
|
+
* `deep` caps how many levels of subagents this agent may spawn (default 1,
|
|
23
|
+
* 0 = never, no unlimited — there is no spelling for unbounded depth).
|
|
24
|
+
* The body is kept verbatim.
|
|
25
|
+
*/
|
|
26
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
27
|
+
import { homedir } from 'node:os';
|
|
28
|
+
import { basename, join } from 'node:path';
|
|
29
|
+
/** The dsh agents directory (`~/.dsh/agents`, under the dsh home). */
|
|
30
|
+
export function agentsDir() {
|
|
31
|
+
return join(homedir(), '.dsh', 'agents');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The legacy agents directory from the first shipped layout (`~/dsh/agents`,
|
|
35
|
+
* no dot). Kept only for one-time migration — see `migrateLegacyAgentsDir`.
|
|
36
|
+
*/
|
|
37
|
+
export function legacyAgentsDir() {
|
|
38
|
+
return join(homedir(), 'dsh', 'agents');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* One-time migration from the legacy `~/dsh/agents` layout into
|
|
42
|
+
* `~/.dsh/agents`: when the target directory holds no agents but the legacy
|
|
43
|
+
* one does, every legacy file is copied over. Idempotent.
|
|
44
|
+
*/
|
|
45
|
+
export function migrateLegacyAgentsDir(targetDir = agentsDir(), legacyDir = legacyAgentsDir()) {
|
|
46
|
+
const { agents } = listAgentFiles(targetDir);
|
|
47
|
+
if (agents.length > 0)
|
|
48
|
+
return 0;
|
|
49
|
+
if (!existsSync(legacyDir))
|
|
50
|
+
return 0;
|
|
51
|
+
let migrated = 0;
|
|
52
|
+
for (const entry of readdirSync(legacyDir, { withFileTypes: true })) {
|
|
53
|
+
if (!entry.isFile() || !entry.name.endsWith('.md'))
|
|
54
|
+
continue;
|
|
55
|
+
mkdirSync(targetDir, { recursive: true });
|
|
56
|
+
writeFileSync(join(targetDir, entry.name), readFileSync(join(legacyDir, entry.name)));
|
|
57
|
+
migrated++;
|
|
58
|
+
}
|
|
59
|
+
return migrated;
|
|
60
|
+
}
|
|
61
|
+
/** zcode agent files are the one-time seeding source (model converted). */
|
|
62
|
+
export function zcodeAgentsDir() {
|
|
63
|
+
return join(homedir(), '.zcode', 'agents');
|
|
64
|
+
}
|
|
65
|
+
const FRONTMATTER_FENCE = '---';
|
|
66
|
+
/** Frontmatter key pattern (same loose shape fun-agent / zcode accept). */
|
|
67
|
+
const KEY_LINE = /^([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/;
|
|
68
|
+
/** Strip one pair of matching surrounding quotes, if present. */
|
|
69
|
+
function stripQuotes(value) {
|
|
70
|
+
if (value.length >= 2) {
|
|
71
|
+
const first = value[0];
|
|
72
|
+
const last = value[value.length - 1];
|
|
73
|
+
if ((first === '"' && last === '"') || (first === "'" && last === "'"))
|
|
74
|
+
return value.slice(1, -1);
|
|
75
|
+
}
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
/** Find the closing fence line index of a frontmatter starting at line 0. */
|
|
79
|
+
function frontmatterBounds(lines) {
|
|
80
|
+
if (lines[0]?.trim() !== FRONTMATTER_FENCE)
|
|
81
|
+
return undefined;
|
|
82
|
+
for (let i = 1; i < lines.length; i++) {
|
|
83
|
+
if (lines[i].trim() === FRONTMATTER_FENCE)
|
|
84
|
+
return { close: i };
|
|
85
|
+
}
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
/** Parse a loose `key: value` frontmatter block (lines 1..close-1). */
|
|
89
|
+
function parseFrontmatterValues(lines, close) {
|
|
90
|
+
const values = {};
|
|
91
|
+
for (let i = 1; i < close; i++) {
|
|
92
|
+
const match = KEY_LINE.exec(lines[i]);
|
|
93
|
+
if (match === null)
|
|
94
|
+
continue;
|
|
95
|
+
values[match[1]] = stripQuotes(match[2].trim());
|
|
96
|
+
}
|
|
97
|
+
return values;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Parse one agent markdown file. Tolerates CRLF, quotes, and non-key lines
|
|
101
|
+
* inside the frontmatter; `name` is required, `deep` must be a non-negative
|
|
102
|
+
* integer when present (absent defaults to 1).
|
|
103
|
+
*/
|
|
104
|
+
export function parseAgentMarkdown(text, path) {
|
|
105
|
+
const lines = text.split(/\r?\n/);
|
|
106
|
+
const bounds = frontmatterBounds(lines);
|
|
107
|
+
if (bounds === undefined) {
|
|
108
|
+
return { ok: false, error: 'missing frontmatter (file must start with `---`)' };
|
|
109
|
+
}
|
|
110
|
+
const values = parseFrontmatterValues(lines, bounds.close);
|
|
111
|
+
const name = values['name']?.trim();
|
|
112
|
+
if (name === undefined || name === '')
|
|
113
|
+
return { ok: false, error: 'missing required frontmatter key `name`' };
|
|
114
|
+
let deep = 1;
|
|
115
|
+
if (values['deep'] !== undefined) {
|
|
116
|
+
const raw = values['deep'].trim();
|
|
117
|
+
if (!/^\d+$/.test(raw)) {
|
|
118
|
+
return { ok: false, error: `invalid \`deep\`: expected a non-negative integer, got "${raw}"` };
|
|
119
|
+
}
|
|
120
|
+
deep = Number(raw);
|
|
121
|
+
}
|
|
122
|
+
const body = lines.slice(bounds.close + 1).join('\n').replace(/^\n+/, '').trimEnd();
|
|
123
|
+
const meta = { name, deep };
|
|
124
|
+
const displayName = values['display_name']?.trim();
|
|
125
|
+
if (displayName !== undefined && displayName !== '')
|
|
126
|
+
meta.displayName = displayName;
|
|
127
|
+
const description = values['description']?.trim();
|
|
128
|
+
if (description !== undefined && description !== '')
|
|
129
|
+
meta.description = description;
|
|
130
|
+
const color = values['color']?.trim();
|
|
131
|
+
if (color !== undefined && color !== '')
|
|
132
|
+
meta.color = color;
|
|
133
|
+
const model = values['model']?.trim();
|
|
134
|
+
if (model !== undefined && model !== '')
|
|
135
|
+
meta.model = model;
|
|
136
|
+
const thinking = values['thinking']?.trim();
|
|
137
|
+
if (thinking !== undefined && thinking !== '')
|
|
138
|
+
meta.thinking = thinking;
|
|
139
|
+
return { ok: true, agent: { path, meta, body } };
|
|
140
|
+
}
|
|
141
|
+
/** Render an agent back to markdown (frontmatter + blank line + body). */
|
|
142
|
+
export function renderAgentMarkdown(meta, body) {
|
|
143
|
+
const lines = ['---'];
|
|
144
|
+
lines.push(`name: ${meta.name}`);
|
|
145
|
+
if (meta.displayName !== undefined)
|
|
146
|
+
lines.push(`display_name: ${meta.displayName}`);
|
|
147
|
+
if (meta.description !== undefined)
|
|
148
|
+
lines.push(`description: ${JSON.stringify(meta.description)}`);
|
|
149
|
+
if (meta.color !== undefined)
|
|
150
|
+
lines.push(`color: ${meta.color}`);
|
|
151
|
+
if (meta.model !== undefined)
|
|
152
|
+
lines.push(`model: ${meta.model}`);
|
|
153
|
+
if (meta.thinking !== undefined)
|
|
154
|
+
lines.push(`thinking: ${meta.thinking}`);
|
|
155
|
+
lines.push(`deep: ${meta.deep}`);
|
|
156
|
+
lines.push('---');
|
|
157
|
+
if (body !== '')
|
|
158
|
+
lines.push('', body);
|
|
159
|
+
return lines.join('\n') + '\n';
|
|
160
|
+
}
|
|
161
|
+
/** List agents under `dir` (top level only), broken files reported aside. */
|
|
162
|
+
export function listAgentFiles(dir) {
|
|
163
|
+
const agents = [];
|
|
164
|
+
const broken = [];
|
|
165
|
+
if (!existsSync(dir))
|
|
166
|
+
return { agents, broken };
|
|
167
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
168
|
+
if (!entry.isFile() || !entry.name.endsWith('.md'))
|
|
169
|
+
continue;
|
|
170
|
+
const path = join(dir, entry.name);
|
|
171
|
+
const result = parseAgentMarkdown(readFileSync(path, 'utf8'), path);
|
|
172
|
+
if (result.ok)
|
|
173
|
+
agents.push(result.agent);
|
|
174
|
+
else
|
|
175
|
+
broken.push({ path, error: result.error });
|
|
176
|
+
}
|
|
177
|
+
agents.sort((a, b) => a.meta.name.localeCompare(b.meta.name));
|
|
178
|
+
return { agents, broken };
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Apply frontmatter updates in place: existing lines are rewritten in place,
|
|
182
|
+
* missing keys are inserted before the closing fence, `null` removes the
|
|
183
|
+
* line. CRLF is preserved; a no-op returns without touching the file.
|
|
184
|
+
* Resolves with an error message, or `undefined` on success.
|
|
185
|
+
*/
|
|
186
|
+
export function updateAgentFrontmatter(path, updates) {
|
|
187
|
+
const text = readFileSync(path, 'utf8');
|
|
188
|
+
const eol = text.includes('\r\n') ? '\r\n' : '\n';
|
|
189
|
+
const lines = text.split(/\r?\n/);
|
|
190
|
+
const bounds = frontmatterBounds(lines);
|
|
191
|
+
if (bounds === undefined)
|
|
192
|
+
return 'missing frontmatter (file must start with `---`)';
|
|
193
|
+
const pending = [];
|
|
194
|
+
if (updates.model !== undefined)
|
|
195
|
+
pending.push(['model', updates.model]);
|
|
196
|
+
if (updates.thinking !== undefined)
|
|
197
|
+
pending.push(['thinking', updates.thinking]);
|
|
198
|
+
if (updates.deep !== undefined)
|
|
199
|
+
pending.push(['deep', updates.deep === null ? null : String(updates.deep)]);
|
|
200
|
+
let changed = false;
|
|
201
|
+
let close = bounds.close;
|
|
202
|
+
for (const [key, value] of pending) {
|
|
203
|
+
let found = -1;
|
|
204
|
+
for (let i = 1; i < close; i++) {
|
|
205
|
+
if (KEY_LINE.test(lines[i]) && lines[i].trimStart().startsWith(`${key}:`)) {
|
|
206
|
+
found = i;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const rendered = value === null ? null : `${key}: ${value}`;
|
|
211
|
+
if (found >= 0) {
|
|
212
|
+
if (rendered === null) {
|
|
213
|
+
lines.splice(found, 1);
|
|
214
|
+
close--;
|
|
215
|
+
changed = true;
|
|
216
|
+
}
|
|
217
|
+
else if (lines[found] !== rendered) {
|
|
218
|
+
lines[found] = rendered;
|
|
219
|
+
changed = true;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else if (rendered !== null) {
|
|
223
|
+
lines.splice(close, 0, rendered);
|
|
224
|
+
close++;
|
|
225
|
+
changed = true;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (!changed)
|
|
229
|
+
return undefined;
|
|
230
|
+
writeFileSync(path, lines.join(eol));
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Convert a zcode `custom:<uri-encoded providerId>:<modelName>` model value
|
|
235
|
+
* to a dsh `provider/model` route for providers we know. Unknown providers
|
|
236
|
+
* return `undefined` (caller keeps the original line); a value without the
|
|
237
|
+
* `custom:` prefix is assumed to be dsh format already.
|
|
238
|
+
*/
|
|
239
|
+
export function convertZcodeModel(model) {
|
|
240
|
+
if (!model.startsWith('custom:'))
|
|
241
|
+
return model;
|
|
242
|
+
const rest = model.slice('custom:'.length);
|
|
243
|
+
const colon = rest.indexOf(':');
|
|
244
|
+
if (colon < 0)
|
|
245
|
+
return undefined;
|
|
246
|
+
const providerId = decodeURIComponent(rest.slice(0, colon));
|
|
247
|
+
const modelName = decodeURIComponent(rest.slice(colon + 1));
|
|
248
|
+
switch (providerId) {
|
|
249
|
+
case 'builtin:bigmodel':
|
|
250
|
+
// bigmodel's GLM family maps onto the volc-ark-plan route's glm-5.3.
|
|
251
|
+
return modelName === 'GLM-5.3' ? 'volc-ark-plan/glm-5.3' : undefined;
|
|
252
|
+
case '9524bbc9-01a6-4e24-9ea2-a0a076ef518b': // zcode provider "Opencode-Go"
|
|
253
|
+
return `opencode-go/${modelName}`;
|
|
254
|
+
case 'd7ef608b-857f-4960-9a4f-380e851fdedb': // zcode provider "minimax"
|
|
255
|
+
return `minimax-cn/${modelName}`;
|
|
256
|
+
default:
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* One-time seeding: when `targetDir` holds no agents yet, copy every
|
|
262
|
+
* parseable zcode agent into it with the model converted to a dsh route.
|
|
263
|
+
* Idempotent — once any agent exists, nothing is written.
|
|
264
|
+
*/
|
|
265
|
+
export function seedFromZcode(targetDir, sourceDir = zcodeAgentsDir()) {
|
|
266
|
+
mkdirSync(targetDir, { recursive: true });
|
|
267
|
+
const { agents } = listAgentFiles(targetDir);
|
|
268
|
+
if (agents.length > 0)
|
|
269
|
+
return { seeded: 0, errors: [] };
|
|
270
|
+
if (!existsSync(sourceDir))
|
|
271
|
+
return { seeded: 0, errors: [] };
|
|
272
|
+
let seeded = 0;
|
|
273
|
+
const errors = [];
|
|
274
|
+
for (const entry of readdirSync(sourceDir, { withFileTypes: true })) {
|
|
275
|
+
if (!entry.isFile() || !entry.name.endsWith('.md'))
|
|
276
|
+
continue;
|
|
277
|
+
const sourcePath = join(sourceDir, entry.name);
|
|
278
|
+
const result = parseAgentMarkdown(readFileSync(sourcePath, 'utf8'), sourcePath);
|
|
279
|
+
if (!result.ok) {
|
|
280
|
+
errors.push({ file: entry.name, error: result.error });
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const agent = result.agent;
|
|
284
|
+
if (agent.meta.model !== undefined) {
|
|
285
|
+
const converted = convertZcodeModel(agent.meta.model);
|
|
286
|
+
if (converted !== undefined)
|
|
287
|
+
agent.meta.model = converted;
|
|
288
|
+
}
|
|
289
|
+
writeFileSync(join(targetDir, `${agent.meta.name}.md`), renderAgentMarkdown(agent.meta, agent.body));
|
|
290
|
+
seeded++;
|
|
291
|
+
}
|
|
292
|
+
return { seeded, errors };
|
|
293
|
+
}
|
|
294
|
+
/** Short file label for diagnostics (kept importable for callers). */
|
|
295
|
+
export function agentFileLabel(path) {
|
|
296
|
+
return basename(path);
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=agent-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-manager.js","sourceRoot":"","sources":["../src/agent-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACzF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAgC1C,sEAAsE;AACtE,MAAM,UAAU,SAAS;IACvB,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,QA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ACtD,SAAQ;QACV,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;QAC1B,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACnC,MAAM,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACrD,IAAI,SAAS,KAAK,SAAS;gBAAE,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;QAC3D,CAAC;QACD,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,EAAE,mBAAmB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;QACpG,MAAM,EAAE,CAAA;IACV,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AAC3B,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;AACvB,CAAC"}
|
package/lib/agents.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/agents` — manage agent definition markdown files (the dsh terminal
|
|
3
|
+
* counterpart of pi's fun-agent `/fun-agent-cfg` and zcode's subagents page).
|
|
4
|
+
*
|
|
5
|
+
* Two layers, both built on the select-panel framework (src/panels.ts):
|
|
6
|
+
*
|
|
7
|
+
* 1. agent table (TablePanel) — one row per agent, four columns
|
|
8
|
+
* (name | model | deep | description), ↑↓/PgUp/PgDn navigate, Enter
|
|
9
|
+
* opens the agent.
|
|
10
|
+
* 2. agent fields window (FieldPanel) — title (display name + id), the
|
|
11
|
+
* full description, and the editable field rows model / thinking /
|
|
12
|
+
* deep. Enter edits the selected row (or m/t/d shortcuts), v opens the
|
|
13
|
+
* full system-prompt body (ViewerPanel), Esc returns to the table.
|
|
14
|
+
* 3. subagent-limits panel (FieldPanel, `l` from the table) — the live
|
|
15
|
+
* `maxAgents` / `maxRounds` caps, editable and written straight to the
|
|
16
|
+
* `dsh-tui` settings namespace. Also the initial view when no agent
|
|
17
|
+
* files exist yet, so the caps stay configurable before any agent.
|
|
18
|
+
*
|
|
19
|
+
* Edits go straight to the frontmatter of the agent's markdown file and
|
|
20
|
+
* take effect the next time the agent is spawned.
|
|
21
|
+
*/
|
|
22
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
23
|
+
import { type TUI } from '@earendil-works/pi-tui';
|
|
24
|
+
import { type TuiTheme } from './theme/index.ts';
|
|
25
|
+
/**
|
|
26
|
+
* Open the `/agents` manager. Resolves with a summary text when the user
|
|
27
|
+
* made changes (or seeded agents) and exits, or `undefined` when nothing
|
|
28
|
+
* changed. `preselect` jumps straight into one agent's fields window.
|
|
29
|
+
*/
|
|
30
|
+
export declare function openAgentManager(ctx: Context, tui: TUI, theme: TuiTheme, restoreFocus: () => void, preselect?: string): Promise<string | undefined>;
|