@xi4z/dsh-utils 0.5.0 → 0.7.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 +99 -104
- package/cordis.patch.yml +36 -37
- package/lib/index.d.ts +5 -63
- package/lib/index.js +6 -859
- package/lib/index.js.map +1 -1
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +10 -46
- package/src/index.ts +6 -927
- package/client.js +0 -2330
- package/lib/ui-host.d.ts +0 -96
- package/lib/ui-host.js +0 -970
- package/lib/ui-host.js.map +0 -1
- package/packages/approval-policy/lib/index.d.ts +0 -297
- package/packages/approval-policy/lib/index.js +0 -425
- package/packages/approval-policy/lib/index.js.map +0 -1
- package/packages/approval-policy/locale/en.json +0 -6
- package/packages/approval-policy/locale/zh.json +0 -6
- package/packages/notify/lib/index.d.ts +0 -290
- package/packages/notify/lib/index.js +0 -915
- package/packages/notify/lib/index.js.map +0 -1
- package/packages/notify/locale/en.json +0 -6
- package/packages/notify/locale/zh.json +0 -6
- package/packages/skill-panel/lib/index.d.ts +0 -49
- package/packages/skill-panel/lib/index.js +0 -420
- package/packages/skill-panel/lib/index.js.map +0 -1
- package/packages/skill-panel/locale/en.json +0 -6
- package/packages/skill-panel/locale/zh.json +0 -6
- package/packages/utils-agents/lib/git.d.ts +0 -87
- package/packages/utils-agents/lib/git.js +0 -403
- package/packages/utils-agents/lib/git.js.map +0 -1
- package/packages/utils-agents/lib/global-repo.d.ts +0 -57
- package/packages/utils-agents/lib/global-repo.js +0 -301
- package/packages/utils-agents/lib/global-repo.js.map +0 -1
- package/packages/utils-agents/lib/index.d.ts +0 -80
- package/packages/utils-agents/lib/index.js +0 -435
- package/packages/utils-agents/lib/index.js.map +0 -1
- package/packages/utils-agents/lib/legacy.d.ts +0 -30
- package/packages/utils-agents/lib/legacy.js +0 -141
- package/packages/utils-agents/lib/legacy.js.map +0 -1
- package/packages/utils-agents/lib/native.d.ts +0 -74
- package/packages/utils-agents/lib/native.js +0 -232
- package/packages/utils-agents/lib/native.js.map +0 -1
- package/packages/utils-agents/lib/presets.d.ts +0 -34
- package/packages/utils-agents/lib/presets.js +0 -312
- package/packages/utils-agents/lib/presets.js.map +0 -1
- package/packages/utils-agents/lib/shared.d.ts +0 -105
- package/packages/utils-agents/lib/shared.js +0 -507
- package/packages/utils-agents/lib/shared.js.map +0 -1
- package/packages/utils-agents/lib/update.d.ts +0 -129
- package/packages/utils-agents/lib/update.js +0 -507
- package/packages/utils-agents/lib/update.js.map +0 -1
- package/packages/utils-agents/lib/util.d.ts +0 -215
- package/packages/utils-agents/lib/util.js +0 -475
- package/packages/utils-agents/lib/util.js.map +0 -1
- package/packages/utils-agents/locale/en.json +0 -6
- package/packages/utils-agents/locale/zh.json +0 -6
- package/skills/dsh-approval-policy-config/SKILL.md +0 -96
- package/src/ui-host.ts +0 -1073
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Preset discovery and preset-scoped file operations for the utils-agents panel.
|
|
3
|
-
*
|
|
4
|
-
* A preset is one directory under a configured preset root (default
|
|
5
|
-
* $DSH_HOME/.agent-presets). The panel reads its preset.yml display name,
|
|
6
|
-
* scans its skills/ tree for SKILL.md / SKILL.md.disabled, and treats the
|
|
7
|
-
* preset root as the editable Markdown scope (AGENTS.md first).
|
|
8
|
-
*
|
|
9
|
-
* @module dsh-utils/utils-agents/presets
|
|
10
|
-
*/
|
|
11
|
-
import { lstat, readdir, readFile, rename, rm } from 'node:fs/promises';
|
|
12
|
-
import { basename, dirname, join, relative, resolve, sep } from 'node:path';
|
|
13
|
-
import { AGENTS_CANDIDATES, GLOBAL_PRESET, IGNORED_DIRS, AgentsError, agentsHome, decodeIdPart, dshHome, encodeIdPart, errorMessage, exists, expandAbsolute, fileRow, findProjectRoot, insideJoin, presetRoots, projectChain, scopeOf, walkFiles, } from './util.js';
|
|
14
|
-
/** Deepest walk inside one preset. */
|
|
15
|
-
const PRESET_MAX_DEPTH = 8;
|
|
16
|
-
/** Discover every preset directory in the configured roots. */
|
|
17
|
-
export async function discoverPresets(ctx, options) {
|
|
18
|
-
const presets = [];
|
|
19
|
-
for (const root of presetRoots(options)) {
|
|
20
|
-
let entries;
|
|
21
|
-
try {
|
|
22
|
-
entries = await readdir(root, { withFileTypes: true });
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
if (error.code !== 'ENOENT')
|
|
26
|
-
ctx.logger.debug('utils-agents: cannot read preset root ' + root + ': ' + errorMessage(error));
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
30
|
-
for (const entry of entries) {
|
|
31
|
-
if (!entry.isDirectory() || entry.name.startsWith('.'))
|
|
32
|
-
continue;
|
|
33
|
-
const path = join(root, entry.name);
|
|
34
|
-
presets.push(await describePreset(ctx, entry.name, path, options));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return presets;
|
|
38
|
-
}
|
|
39
|
-
/** Find one preset by id; throws 404 when it is not in a configured root. */
|
|
40
|
-
export async function presetById(ctx, options, id) {
|
|
41
|
-
const presets = await discoverPresets(ctx, options);
|
|
42
|
-
const found = presets.find((preset) => preset.id === id);
|
|
43
|
-
if (found === undefined)
|
|
44
|
-
throw new AgentsError('未知的预设:' + id, 404);
|
|
45
|
-
return found;
|
|
46
|
-
}
|
|
47
|
-
/** Build the browser row for one discovered preset. */
|
|
48
|
-
async function describePreset(ctx, id, path, options) {
|
|
49
|
-
const meta = await readPresetMeta(path);
|
|
50
|
-
const skills = await scanSkills(ctx, path);
|
|
51
|
-
return {
|
|
52
|
-
id,
|
|
53
|
-
name: meta.name === '' ? id : meta.name,
|
|
54
|
-
description: meta.description,
|
|
55
|
-
path,
|
|
56
|
-
skills,
|
|
57
|
-
agents: await fileRow(agentsId(path), 'AGENTS.md', join(path, 'AGENTS.md'), id, 'agents'),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
/** Read name/description from preset.yml with a deliberately small parser. */
|
|
61
|
-
async function readPresetMeta(presetPath) {
|
|
62
|
-
let text;
|
|
63
|
-
try {
|
|
64
|
-
text = await readFile(join(presetPath, 'preset.yml'), 'utf8');
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
return { name: '', description: '' };
|
|
68
|
-
}
|
|
69
|
-
const values = parseSimpleYaml(text);
|
|
70
|
-
return { name: values.name ?? '', description: values.description ?? '' };
|
|
71
|
-
}
|
|
72
|
-
/** Parse top-level scalar keys, including simple folded/literal blocks. */
|
|
73
|
-
function parseSimpleYaml(text) {
|
|
74
|
-
const values = {};
|
|
75
|
-
const lines = text.split(/\r?\n/);
|
|
76
|
-
for (let index = 0; index < lines.length; index += 1) {
|
|
77
|
-
const match = /^([A-Za-z_][A-Za-z0-9_-]*):\s*(.*)$/.exec(lines[index]);
|
|
78
|
-
if (match === null)
|
|
79
|
-
continue;
|
|
80
|
-
const key = match[1];
|
|
81
|
-
let value = match[2].trim();
|
|
82
|
-
if (value === '>-' || value === '>' || value === '|' || value === '|-') {
|
|
83
|
-
const parts = [];
|
|
84
|
-
while (index + 1 < lines.length && /^\s+/.test(lines[index + 1])) {
|
|
85
|
-
index += 1;
|
|
86
|
-
parts.push(lines[index].trim());
|
|
87
|
-
}
|
|
88
|
-
value = parts.join(' ').trim();
|
|
89
|
-
}
|
|
90
|
-
values[key] = unquote(value);
|
|
91
|
-
}
|
|
92
|
-
return values;
|
|
93
|
-
}
|
|
94
|
-
/** Strip YAML quotes from one scalar. */
|
|
95
|
-
function unquote(value) {
|
|
96
|
-
if (value.length >= 2 && value.startsWith("'") && value.endsWith("'"))
|
|
97
|
-
return value.slice(1, -1).replace(/''/g, "'");
|
|
98
|
-
if (value.length >= 2 && value.startsWith('"') && value.endsWith('"')) {
|
|
99
|
-
return value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
|
100
|
-
}
|
|
101
|
-
return value;
|
|
102
|
-
}
|
|
103
|
-
/** Scan skills/ for SKILL.md and SKILL.md.disabled, one row per skill directory. */
|
|
104
|
-
export async function scanSkills(ctx, presetPath) {
|
|
105
|
-
const root = join(presetPath, 'skills');
|
|
106
|
-
if (!(await exists(root)))
|
|
107
|
-
return [];
|
|
108
|
-
const files = [];
|
|
109
|
-
await walkFiles(root, PRESET_MAX_DEPTH, new Set(IGNORED_DIRS), (path) => {
|
|
110
|
-
const name = basename(path);
|
|
111
|
-
if (name === 'SKILL.md' || name === 'SKILL.md.disabled')
|
|
112
|
-
files.push(path);
|
|
113
|
-
}, ctx);
|
|
114
|
-
const byDirectory = new Map();
|
|
115
|
-
for (const path of files) {
|
|
116
|
-
const rel = relative(presetPath, path).split(sep).join('/');
|
|
117
|
-
const directory = dirname(rel);
|
|
118
|
-
const enabled = basename(path) === 'SKILL.md';
|
|
119
|
-
const existing = byDirectory.get(directory);
|
|
120
|
-
if (existing !== undefined && existing.enabled)
|
|
121
|
-
continue;
|
|
122
|
-
const meta = await readSkillMeta(path);
|
|
123
|
-
const row = {
|
|
124
|
-
name: meta.name === '' ? basename(directory) : meta.name,
|
|
125
|
-
description: meta.description,
|
|
126
|
-
path: rel,
|
|
127
|
-
enabled,
|
|
128
|
-
size: await fileSize(path),
|
|
129
|
-
mtimeMs: await fileMtime(path),
|
|
130
|
-
};
|
|
131
|
-
byDirectory.set(directory, row);
|
|
132
|
-
}
|
|
133
|
-
return [...byDirectory.values()].sort((left, right) => left.name.localeCompare(right.name));
|
|
134
|
-
}
|
|
135
|
-
/** Read name/description from one SKILL.md frontmatter. */
|
|
136
|
-
async function readSkillMeta(path) {
|
|
137
|
-
let text;
|
|
138
|
-
try {
|
|
139
|
-
text = await readFile(path, 'utf8');
|
|
140
|
-
}
|
|
141
|
-
catch {
|
|
142
|
-
return { name: '', description: '' };
|
|
143
|
-
}
|
|
144
|
-
if (!text.startsWith('---'))
|
|
145
|
-
return { name: '', description: '' };
|
|
146
|
-
const end = text.indexOf('\n---', 3);
|
|
147
|
-
if (end < 0)
|
|
148
|
-
return { name: '', description: '' };
|
|
149
|
-
const values = parseSimpleYaml(text.slice(3, end));
|
|
150
|
-
return { name: values.name ?? '', description: values.description ?? '' };
|
|
151
|
-
}
|
|
152
|
-
/** File size, or 0 when it disappears. */
|
|
153
|
-
async function fileSize(path) {
|
|
154
|
-
try {
|
|
155
|
-
const info = await lstat(path);
|
|
156
|
-
return info.isFile() ? info.size : 0;
|
|
157
|
-
}
|
|
158
|
-
catch {
|
|
159
|
-
return 0;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/** File mtime, or null when it disappears. */
|
|
163
|
-
async function fileMtime(path) {
|
|
164
|
-
try {
|
|
165
|
-
const info = await lstat(path);
|
|
166
|
-
return Number.isFinite(info.mtimeMs) ? info.mtimeMs : null;
|
|
167
|
-
}
|
|
168
|
-
catch {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
/** Toggle one preset skill by renaming SKILL.md and SKILL.md.disabled. */
|
|
173
|
-
export async function toggleSkill(preset, relPath, enabled) {
|
|
174
|
-
const normalized = relPath.split(sep).join('/');
|
|
175
|
-
if (!normalized.startsWith('skills/') || normalized.includes('..'))
|
|
176
|
-
throw new AgentsError('技能路径不合法', 400);
|
|
177
|
-
const name = basename(normalized);
|
|
178
|
-
if (name !== 'SKILL.md' && name !== 'SKILL.md.disabled')
|
|
179
|
-
throw new AgentsError('只允许切换 SKILL.md', 400);
|
|
180
|
-
const sourceName = enabled ? 'SKILL.md.disabled' : 'SKILL.md';
|
|
181
|
-
if (name !== sourceName)
|
|
182
|
-
throw new AgentsError('开关状态与文件名不一致', 400);
|
|
183
|
-
const source = insideJoin(preset.path, normalized);
|
|
184
|
-
const targetRel = enabled ? normalized.slice(0, -'.disabled'.length) : normalized + '.disabled';
|
|
185
|
-
const target = insideJoin(preset.path, targetRel);
|
|
186
|
-
const info = await lstat(source);
|
|
187
|
-
if (info.isSymbolicLink() || !info.isFile())
|
|
188
|
-
throw new AgentsError('技能文件不是普通文件', 409);
|
|
189
|
-
if (await exists(target))
|
|
190
|
-
throw new AgentsError('目标文件已存在:' + relative(preset.path, target), 409);
|
|
191
|
-
await rename(source, target);
|
|
192
|
-
const meta = await readSkillMeta(target);
|
|
193
|
-
return {
|
|
194
|
-
name: meta.name === '' ? basename(dirname(targetRel)) : meta.name,
|
|
195
|
-
description: meta.description,
|
|
196
|
-
path: targetRel,
|
|
197
|
-
enabled,
|
|
198
|
-
size: await fileSize(target),
|
|
199
|
-
mtimeMs: await fileMtime(target),
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
/** All Markdown files for one preset, AGENTS.md first. */
|
|
203
|
-
export async function presetFiles(ctx, preset) {
|
|
204
|
-
const paths = [];
|
|
205
|
-
await walkFiles(preset.path, PRESET_MAX_DEPTH, new Set(IGNORED_DIRS), (path) => {
|
|
206
|
-
if (path === preset.agents.path)
|
|
207
|
-
return;
|
|
208
|
-
const lower = path.toLowerCase();
|
|
209
|
-
if (!lower.endsWith('.md') && !lower.endsWith('.md.disabled'))
|
|
210
|
-
return;
|
|
211
|
-
paths.push(path);
|
|
212
|
-
}, ctx);
|
|
213
|
-
const rows = [preset.agents];
|
|
214
|
-
for (const path of paths) {
|
|
215
|
-
const rel = relative(preset.path, path).split(sep).join('/');
|
|
216
|
-
rows.push(await fileRow(presetFileId(preset.path, rel), rel, path, preset.id, kindOf(path)));
|
|
217
|
-
}
|
|
218
|
-
return rows.sort((left, right) => {
|
|
219
|
-
if (left.kind === 'agents' && right.kind !== 'agents')
|
|
220
|
-
return -1;
|
|
221
|
-
if (right.kind === 'agents' && left.kind !== 'agents')
|
|
222
|
-
return 1;
|
|
223
|
-
return left.label.localeCompare(right.label);
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
/** Classify one Markdown file inside a preset. */
|
|
227
|
-
function kindOf(path) {
|
|
228
|
-
const name = basename(path);
|
|
229
|
-
return name === 'SKILL.md' || name === 'SKILL.md.disabled' ? 'skill' : 'reference';
|
|
230
|
-
}
|
|
231
|
-
/** Build the opaque id for one preset file. */
|
|
232
|
-
export function presetFileId(presetPath, rel) {
|
|
233
|
-
return 'preset:' + encodeIdPart(presetPath) + ':' + encodeIdPart(rel);
|
|
234
|
-
}
|
|
235
|
-
/** Build the opaque id for one global AGENTS-family file. */
|
|
236
|
-
export function globalFileId(path) {
|
|
237
|
-
return 'global:' + encodeIdPart(path);
|
|
238
|
-
}
|
|
239
|
-
/** The preset AGENTS.md id. */
|
|
240
|
-
function agentsId(presetPath) {
|
|
241
|
-
return presetFileId(presetPath, 'AGENTS.md');
|
|
242
|
-
}
|
|
243
|
-
/** Resolve one opaque file id to a path and browser row. */
|
|
244
|
-
export async function resolveFileId(ctx, options, id, cwd) {
|
|
245
|
-
if (id.startsWith('global:')) {
|
|
246
|
-
const path = decodeIdPart(id.slice('global:'.length));
|
|
247
|
-
const row = (await globalFiles(ctx, options, cwd)).find((candidate) => candidate.path === path);
|
|
248
|
-
if (row === undefined)
|
|
249
|
-
throw new AgentsError('未知的全局文件 id', 404);
|
|
250
|
-
return { row, path, preset: null };
|
|
251
|
-
}
|
|
252
|
-
if (!id.startsWith('preset:'))
|
|
253
|
-
throw new AgentsError('未知的文件 id', 404);
|
|
254
|
-
const rest = id.slice('preset:'.length);
|
|
255
|
-
const at = rest.indexOf(':');
|
|
256
|
-
if (at <= 0)
|
|
257
|
-
throw new AgentsError('预设文件 id 不合法', 400);
|
|
258
|
-
const presetPath = decodeIdPart(rest.slice(0, at));
|
|
259
|
-
const rel = decodeIdPart(rest.slice(at + 1));
|
|
260
|
-
const presets = await discoverPresets(ctx, options);
|
|
261
|
-
const preset = presets.find((candidate) => resolve(candidate.path) === resolve(presetPath));
|
|
262
|
-
if (preset === undefined)
|
|
263
|
-
throw new AgentsError('未知的预设路径', 404);
|
|
264
|
-
const lower = rel.toLowerCase();
|
|
265
|
-
if ((!lower.endsWith('.md') && !lower.endsWith('.md.disabled')) || rel.includes('..'))
|
|
266
|
-
throw new AgentsError('只允许编辑 .md / .md.disabled 文件', 400);
|
|
267
|
-
const path = insideJoin(preset.path, rel);
|
|
268
|
-
const row = await fileRow(id, rel.split(sep).join('/'), path, preset.id, rel === 'AGENTS.md' ? 'agents' : kindOf(path));
|
|
269
|
-
return { row, path, preset };
|
|
270
|
-
}
|
|
271
|
-
/** Global AGENTS.md family for the global pseudo preset. */
|
|
272
|
-
export async function globalFiles(ctx, options, cwd) {
|
|
273
|
-
const rows = [];
|
|
274
|
-
const add = async (path, label, scope) => {
|
|
275
|
-
const row = await fileRow(globalFileId(path), label, path, GLOBAL_PRESET, 'global');
|
|
276
|
-
rows.push({ ...row, scope });
|
|
277
|
-
};
|
|
278
|
-
await add(join(dshHome(), 'AGENTS.md'), 'AGENTS.md', '用户全局 · $DSH_HOME');
|
|
279
|
-
await add(join(agentsHome(), 'AGENTS.md'), 'AGENTS.md', '共享全局 · $DSH_AGENTS_HOME');
|
|
280
|
-
const projectRoot = await findProjectRoot(cwd);
|
|
281
|
-
for (const dir of projectChain(projectRoot, cwd)) {
|
|
282
|
-
for (const candidate of AGENTS_CANDIDATES) {
|
|
283
|
-
const path = join(dir, candidate);
|
|
284
|
-
const present = await exists(path);
|
|
285
|
-
const primary = candidate === 'AGENTS.md' && (dir === cwd || dir === projectRoot);
|
|
286
|
-
if (!present && !primary)
|
|
287
|
-
continue;
|
|
288
|
-
await add(path, candidate, scopeOf(dir, cwd, projectRoot));
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
if (options.scanNestedAgents) {
|
|
292
|
-
const known = new Set(rows.map((row) => row.path));
|
|
293
|
-
const nested = [];
|
|
294
|
-
await walkFiles(cwd, options.nestedDepth, new Set(IGNORED_DIRS), (path) => {
|
|
295
|
-
const name = basename(path);
|
|
296
|
-
if ((name === 'AGENTS.md' || name === 'CLAUDE.md') && !known.has(path))
|
|
297
|
-
nested.push(path);
|
|
298
|
-
}, ctx);
|
|
299
|
-
for (const path of nested)
|
|
300
|
-
await add(path, basename(path), relative(projectRoot, dirname(path)) || '.');
|
|
301
|
-
}
|
|
302
|
-
for (const raw of options.extraAgentsFiles) {
|
|
303
|
-
try {
|
|
304
|
-
await add(expandAbsolute(raw), basename(expandAbsolute(raw)), '额外文件');
|
|
305
|
-
}
|
|
306
|
-
catch {
|
|
307
|
-
// Invalid extras are ignored.
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
return rows;
|
|
311
|
-
}
|
|
312
|
-
//# sourceMappingURL=presets.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAE3E,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,cAAc,EACd,OAAO,EACP,eAAe,EACf,UAAU,EACV,WAAW,EACX,YAAY,EACZ,OAAO,EACP,SAAS,GAKV,MAAM,WAAW,CAAA;AAElB,sCAAsC;AACtC,MAAM,gBAAgB,GAAG,CAAC,CAAA;AAE1B,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAY,EAAE,OAAgB;IAClE,MAAM,OAAO,GAAiB,EAAE,CAAA;IAChC,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,IAAI,OAAO,CAAA;QACX,IAAI,CAAC;YACH,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAA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AI,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE;YACxE,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;YAC3B,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC3F,CAAC,EAAE,GAAG,CAAC,CAAA;QACP,KAAK,MAAM,IAAI,IAAI,MAAM;YAAE,MAAM,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAA;IACzG,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC3C,IAAI,CAAC;YACH,MAAM,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;QACvE,CAAC;QAAC,MAAM,CAAC;YACP,8BAA8B;QAChC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared preset sources for the utils-agents panel.
|
|
3
|
-
*
|
|
4
|
-
* A skill repository may carry a ".dsh" directory that mirrors part of the DSH
|
|
5
|
-
* home, so presets can travel with the skills instead of being copied by hand.
|
|
6
|
-
* This module discovers those presets and copies them into
|
|
7
|
-
* "$DSH_HOME/.agent-presets"; the existing legacy bridge then registers the
|
|
8
|
-
* result as real Agent presets.
|
|
9
|
-
*
|
|
10
|
-
* Accepted layouts inside one repository root:
|
|
11
|
-
*
|
|
12
|
-
* - ".dsh/preset/<id>/" (canonical)
|
|
13
|
-
* - ".dsh/preset/" itself when it holds "preset.yml" or "agent.cordis.yml"
|
|
14
|
-
* - ".dsh/presets/<id>/" and ".dsh/.agent-presets/<id>/" (tolerated aliases)
|
|
15
|
-
* - ".dsh/<id>/" when the directory holds "preset.yml" or "agent.cordis.yml"
|
|
16
|
-
*
|
|
17
|
-
* Sources are read-only: the repository checkout is never modified. Writes are
|
|
18
|
-
* limited to the local preset home, and a removed source file is only deleted
|
|
19
|
-
* when the caller asks for a pruning sync.
|
|
20
|
-
*
|
|
21
|
-
* @module dsh-utils/utils-agents/shared
|
|
22
|
-
*/
|
|
23
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
24
|
-
import { type Options, type PresetInfo } from './util.js';
|
|
25
|
-
/** Status of one source preset against the local preset home. */
|
|
26
|
-
export type SharedStatus = 'new' | 'update' | 'same' | 'invalid';
|
|
27
|
-
/** Where a source repository came from. */
|
|
28
|
-
export type SharedSourceKind = 'preset-repo' | 'global-repo' | 'skills-home' | 'extra';
|
|
29
|
-
/** One preset found in a shared repository. */
|
|
30
|
-
export interface SharedPresetView {
|
|
31
|
-
readonly id: string;
|
|
32
|
-
readonly name: string;
|
|
33
|
-
readonly description: string;
|
|
34
|
-
readonly status: SharedStatus;
|
|
35
|
-
readonly sourceKind: SharedSourceKind;
|
|
36
|
-
readonly sourceRoot: string;
|
|
37
|
-
readonly sourcePath: string;
|
|
38
|
-
readonly targetPath: string;
|
|
39
|
-
readonly skills: number;
|
|
40
|
-
readonly files: number;
|
|
41
|
-
readonly managed: boolean;
|
|
42
|
-
readonly lastSyncAt: string | null;
|
|
43
|
-
readonly reason?: string;
|
|
44
|
-
}
|
|
45
|
-
/** One repository root that was scanned. */
|
|
46
|
-
export interface SharedSourceView {
|
|
47
|
-
readonly path: string;
|
|
48
|
-
readonly kind: SharedSourceKind;
|
|
49
|
-
readonly exists: boolean;
|
|
50
|
-
readonly presets: SharedPresetView[];
|
|
51
|
-
}
|
|
52
|
-
/** The complete shared-preset view returned to the browser. */
|
|
53
|
-
export interface SharedListView {
|
|
54
|
-
readonly localRoot: string;
|
|
55
|
-
readonly sources: SharedSourceView[];
|
|
56
|
-
}
|
|
57
|
-
/** One record remembered from a previous sync. */
|
|
58
|
-
interface ManagedPreset {
|
|
59
|
-
readonly source: string;
|
|
60
|
-
readonly syncedAt: string;
|
|
61
|
-
readonly files: string[];
|
|
62
|
-
}
|
|
63
|
-
/** The on-disk sync manifest. */
|
|
64
|
-
interface SharedManifest {
|
|
65
|
-
readonly version: 1;
|
|
66
|
-
readonly presets: Record<string, ManagedPreset>;
|
|
67
|
-
}
|
|
68
|
-
/** Outcome for one preset sync. */
|
|
69
|
-
export interface SharedSyncResult {
|
|
70
|
-
readonly id: string;
|
|
71
|
-
readonly status: SharedStatus;
|
|
72
|
-
readonly written: number;
|
|
73
|
-
readonly removed: number;
|
|
74
|
-
readonly skipped: string[];
|
|
75
|
-
readonly error?: string;
|
|
76
|
-
}
|
|
77
|
-
/** The response of one sync request. */
|
|
78
|
-
export interface SharedSyncPayload {
|
|
79
|
-
readonly results: SharedSyncResult[];
|
|
80
|
-
readonly view: SharedListView;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Scan every known repository for ".dsh" presets.
|
|
84
|
-
* @param ctx - host context.
|
|
85
|
-
* @param options - normalized settings.
|
|
86
|
-
* @param preset - the selected preset, whose synced checkout is also a source.
|
|
87
|
-
* @returns the source roots with their preset rows.
|
|
88
|
-
*/
|
|
89
|
-
export declare function sharedPresetView(ctx: Context, options: Options, preset: PresetInfo | null): Promise<SharedListView>;
|
|
90
|
-
/**
|
|
91
|
-
* Copy the requested source presets into the DSH preset home.
|
|
92
|
-
* @param ctx - host context.
|
|
93
|
-
* @param options - normalized settings.
|
|
94
|
-
* @param preset - the selected preset, used to locate its repository checkout.
|
|
95
|
-
* @param body - request body with optional "ids" and "prune".
|
|
96
|
-
* @returns per-preset results plus the refreshed view.
|
|
97
|
-
*/
|
|
98
|
-
export declare function syncSharedPresets(ctx: Context, options: Options, preset: PresetInfo | null, body: Record<string, unknown>): Promise<SharedSyncPayload>;
|
|
99
|
-
/** The storage path of the shared-preset manifest. */
|
|
100
|
-
export declare function sharedManifestPath(): string;
|
|
101
|
-
/** Normalize one preset directory name into a safe id, or null. */
|
|
102
|
-
export declare function sharedPresetId(name: string): string | null;
|
|
103
|
-
/** Read the sync manifest, tolerating a missing or broken file. */
|
|
104
|
-
export declare function readManifest(): Promise<SharedManifest>;
|
|
105
|
-
export {};
|