@appsys-sas/devtool 1.1.1 → 1.1.2
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/dist/lib/index.js +587 -111
- package/dist/schema/config.schema.json +20 -1
- package/dist/skills/devtool-files-environment/SKILL.md +5 -0
- package/dist/ui/assets/{Checkbox-D7yQGoEk.js → Checkbox-CVq_6d1B.js} +1 -1
- package/dist/ui/assets/{Collection-Cj-SRE7R.js → Collection-Dv0lbGp7.js} +1 -1
- package/dist/ui/assets/{ConfigFileChoice-C5HTIsQC.js → ConfigFileChoice-CFZLnj8X.js} +1 -1
- package/dist/ui/assets/{ConfirmDialog-XlKcsSom.js → ConfirmDialog-_1BDNgtZ.js} +1 -1
- package/dist/ui/assets/{DashboardView-e5G8IftI.js → DashboardView-DXRzHimq.js} +1 -1
- package/dist/ui/assets/{DialogClose-Bm5cPqtw.js → DialogClose-C-aIYwFB.js} +1 -1
- package/dist/ui/assets/{DirectoryCommandView-sxkZlLdw.js → DirectoryCommandView-CAUc4GnW.js} +1 -1
- package/dist/ui/assets/{DirectoryFilesView-DY-e-jJX.js → DirectoryFilesView-T468oXCJ.js} +1 -1
- package/dist/ui/assets/{DirectoryHomeView-C0SNUw30.js → DirectoryHomeView-D3oyUqO0.js} +1 -1
- package/dist/ui/assets/{DirectoryIndexView-DJl0vpIK.js → DirectoryIndexView-CPjvN2Xn.js} +1 -1
- package/dist/ui/assets/{DirectoryStreamView-DCmsEbUt.js → DirectoryStreamView-DSr0JWnZ.js} +1 -1
- package/dist/ui/assets/{EnvironmentView-XUkVme1D.js → EnvironmentView-jvH7y5Sm.js} +1 -1
- package/dist/ui/assets/{FieldRoot-Ba3ajGnY.js → FieldRoot-Bbrg1LYm.js} +1 -1
- package/dist/ui/assets/{FileSpaceView-DTt340y3.js → FileSpaceView-DCHH6PMO.js} +1 -1
- package/dist/ui/assets/{Input-BUX81dCB.js → Input-3xCA97AU.js} +1 -1
- package/dist/ui/assets/{IntegrationLink-WxPu1PS-.js → IntegrationLink-CIyRS6Lc.js} +1 -1
- package/dist/ui/assets/{IntegrationView-6XT1E1h5.js → IntegrationView-ChTN6Nj_.js} +1 -1
- package/dist/ui/assets/{MarkdownPreview-qt2DelWz.js → MarkdownPreview-Clc5xywn.js} +3 -3
- package/dist/ui/assets/{McpDiff-3VSkgfGc.js → McpDiff-DNItUyWT.js} +1 -1
- package/dist/ui/assets/{McpView-9lShvwe_.js → McpView-ySDTVOBS.js} +1 -1
- package/dist/ui/assets/{PopperContent-CmOAkcRf.js → PopperContent-3ZyVosH8.js} +1 -1
- package/dist/ui/assets/{ProjectHomeView-ClRdWD9W.js → ProjectHomeView-DYniNfdK.js} +1 -1
- package/dist/ui/assets/{ProjectStreamView-DHE-_9E4.js → ProjectStreamView-BtF7fMap.js} +1 -1
- package/dist/ui/assets/{RovingFocusItem-BymPUlxw.js → RovingFocusItem-CygIzYPE.js} +1 -1
- package/dist/ui/assets/{StreamView-CaR6s6cC.js → StreamView-AtVFmEw-.js} +1 -1
- package/dist/ui/assets/{TabsTrigger-khYkpwhU.js → TabsTrigger-C9_TH6ae.js} +1 -1
- package/dist/ui/assets/{Teleport-D-Oc12tT.js → Teleport-Cf6VW2ND.js} +1 -1
- package/dist/ui/assets/chevron-right-12ETR80V.js +1 -0
- package/dist/ui/assets/{file-text-DnA8xow4.js → file-text-C2c09hg_.js} +1 -1
- package/dist/ui/assets/{format-BC-XQyzO.js → format-CAwEw1SL.js} +1 -1
- package/dist/ui/assets/{index-poLkFtGg.js → index-Cptz-G8b.js} +5 -5
- package/dist/ui/assets/{jsonMode-D_auC3Tv.js → jsonMode-DbcpCX78.js} +1 -1
- package/dist/ui/assets/{message-square-l8KeR32R.js → message-square-CGN4nYlR.js} +1 -1
- package/dist/ui/assets/{monaco-IsdWhzYV.js → monaco-Bog1XhoK.js} +3 -3
- package/dist/ui/assets/{play-C3Tx0kFB.js → play-ikNY9RxH.js} +1 -1
- package/dist/ui/assets/search-CmFnMhsr.js +1 -0
- package/dist/ui/assets/{select-CRnMPn6I.js → select-BjT1WBpv.js} +1 -1
- package/dist/ui/assets/{sparkles-Cu2_kOi4.js → sparkles-Dk62UkaC.js} +1 -1
- package/dist/ui/assets/{triangle-alert-C84qG3jJ.js → triangle-alert-BUAUp_-r.js} +1 -1
- package/dist/ui/assets/{useNonce-DNT86VSl.js → useNonce-D2YQp-V_.js} +1 -1
- package/dist/ui/assets/{ws-B-gwM5Rj.js → ws-DK7KvC31.js} +2 -2
- package/dist/ui/index.html +13 -13
- package/package.json +10 -9
- package/dist/ui/assets/chevron-right-rDR2WFWU.js +0 -1
- package/dist/ui/assets/search-wk-YKNcO.js +0 -1
package/dist/lib/index.js
CHANGED
|
@@ -30,6 +30,7 @@ import { parse as parse$1, patch } from "@decimalturn/toml-patch";
|
|
|
30
30
|
import { isMap as isMap$2, isScalar, isSeq, parse as parse$2, parseDocument } from "yaml";
|
|
31
31
|
import { DOMImplementation, DOMParser, XMLSerializer, onErrorStopParsing } from "@xmldom/xmldom";
|
|
32
32
|
import net from "node:net";
|
|
33
|
+
import { GLOBSTAR, Minimatch, braceExpand } from "minimatch";
|
|
33
34
|
import { spawn as spawn$1 } from "@lydell/node-pty";
|
|
34
35
|
import { isUtf8 } from "node:buffer";
|
|
35
36
|
import treeKill from "tree-kill";
|
|
@@ -8002,7 +8003,7 @@ function runProxy({ adtSecurePort = 6731, proxyPort = 443 } = {}) {
|
|
|
8002
8003
|
return server;
|
|
8003
8004
|
}
|
|
8004
8005
|
// ../server/package.json
|
|
8005
|
-
var version$1 = "1.1.
|
|
8006
|
+
var version$1 = "1.1.2";
|
|
8006
8007
|
// ../../packages/certs/lib/certificate.js
|
|
8007
8008
|
const CERTIFICATE_BLOCK = /-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/;
|
|
8008
8009
|
const COMMON_NAME = /(?:^|\n| \+ )CN=((?:\\.|[^\\\n+])+?)(?= \+ |\n|$)/;
|
|
@@ -8198,6 +8199,301 @@ async function install(folder, log) {
|
|
|
8198
8199
|
});
|
|
8199
8200
|
return executable;
|
|
8200
8201
|
}
|
|
8202
|
+
/** The start of the name of an item moved aside next to where it was, until its removal is kept or undone. */
|
|
8203
|
+
const ASIDE_PREFIX = ".devtool-undo-";
|
|
8204
|
+
const MATCH_OPTIONS = {
|
|
8205
|
+
nonegate: true,
|
|
8206
|
+
nocomment: true
|
|
8207
|
+
};
|
|
8208
|
+
/** The most alternatives the braces of a pattern may expand to. */
|
|
8209
|
+
const MAX_BRACE_ALTERNATIVES = 1e3;
|
|
8210
|
+
/** The most characters the alternatives of a pattern may hold in all, well below where the expansion drops some. */
|
|
8211
|
+
const MAX_EXPANDED_LENGTH = 1e6;
|
|
8212
|
+
/**
|
|
8213
|
+
* Tells why a glob pattern cannot choose the files of a folder, checked in the composed Unicode form the filter
|
|
8214
|
+
* matches: a negation, a backslash, a pattern the matcher refuses, braces expanding to too many alternatives or
|
|
8215
|
+
* characters (past which the expansion drops some), braces left in an alternative (an incomplete set, or one the
|
|
8216
|
+
* expansion gave up on), or an absolute path, an empty, `.`
|
|
8217
|
+
* or `..` segment in the pattern or in one of its alternatives, none of which would match the paths of the folder
|
|
8218
|
+
* as written.
|
|
8219
|
+
*
|
|
8220
|
+
* @param written - The pattern.
|
|
8221
|
+
* @returns Why it cannot be used, null when it can.
|
|
8222
|
+
*/
|
|
8223
|
+
function filePatternProblem(written) {
|
|
8224
|
+
const pattern = written.normalize("NFC");
|
|
8225
|
+
if (pattern.startsWith("!")) return "is a negation, which is not supported: list what to hide in exclude";
|
|
8226
|
+
if (pattern.includes("\\")) return "holds a backslash: separate folders with /";
|
|
8227
|
+
let expansions;
|
|
8228
|
+
try {
|
|
8229
|
+
expansions = braceExpand(pattern, { braceExpandMax: 1001 });
|
|
8230
|
+
if (expansions.length <= MAX_BRACE_ALTERNATIVES) new Minimatch(pattern, MATCH_OPTIONS).makeRe();
|
|
8231
|
+
} catch (error) {
|
|
8232
|
+
return `is not a valid glob: ${error instanceof Error ? error.message : String(error)}`;
|
|
8233
|
+
}
|
|
8234
|
+
if (expansions.length > MAX_BRACE_ALTERNATIVES || expansions.reduce((total, expanded) => total + expanded.length, 0) > MAX_EXPANDED_LENGTH) return `expands to more than ${MAX_BRACE_ALTERNATIVES} alternatives or ${MAX_EXPANDED_LENGTH} characters: split it`;
|
|
8235
|
+
if (expansions.some((expanded) => /[{}]/.test(expanded))) return "holds braces that do not expand to alternatives: write complete sets such as {a,b}, or a shorter glob";
|
|
8236
|
+
for (const expanded of [pattern, ...expansions]) {
|
|
8237
|
+
const segments = expanded.split("/");
|
|
8238
|
+
if (expanded.startsWith("/")) return "is absolute: write it relative to the folder of files";
|
|
8239
|
+
if (segments.includes("..")) return "goes up with ..: write it relative to the folder of files";
|
|
8240
|
+
if (segments.some((segment) => segment === "" || segment === ".")) return "holds an empty or . segment: write it such as apps/*/.env, without ./, // nor a trailing /";
|
|
8241
|
+
}
|
|
8242
|
+
return null;
|
|
8243
|
+
}
|
|
8244
|
+
/**
|
|
8245
|
+
* Splits a path relative to a folder into its names, in their composed Unicode form.
|
|
8246
|
+
*
|
|
8247
|
+
* @param relativePath - The path, its names separated by `/`.
|
|
8248
|
+
* @returns The names.
|
|
8249
|
+
*/
|
|
8250
|
+
function namesOf(relativePath) {
|
|
8251
|
+
return relativePath.normalize("NFC").split("/");
|
|
8252
|
+
}
|
|
8253
|
+
/**
|
|
8254
|
+
* Decides which files and folders of a folder of files are shown, every path being relative to the folder with
|
|
8255
|
+
* `/` separators: `.git` and the items moved aside never; names starting with a dot only with `showHidden`, or
|
|
8256
|
+
* with `include`, when a pattern names them; a file only when an `include` pattern matches it, if any; nothing
|
|
8257
|
+
* an `exclude` pattern matches, nor anything in a folder it matches.
|
|
8258
|
+
*/
|
|
8259
|
+
var FileFilter = class {
|
|
8260
|
+
/** Whether `include` or `exclude` patterns choose what is shown. */
|
|
8261
|
+
filtered;
|
|
8262
|
+
/** Whether only the files `include` patterns match are shown. */
|
|
8263
|
+
selective;
|
|
8264
|
+
_showHidden;
|
|
8265
|
+
_include;
|
|
8266
|
+
_exclude;
|
|
8267
|
+
/**
|
|
8268
|
+
* @param settings - The patterns and whether names starting with a dot are shown.
|
|
8269
|
+
*/
|
|
8270
|
+
constructor(settings) {
|
|
8271
|
+
this._showHidden = settings.showHidden;
|
|
8272
|
+
this._include = settings.include?.map((pattern) => {
|
|
8273
|
+
const matcher = new Minimatch(pattern.normalize("NFC"), {
|
|
8274
|
+
...MATCH_OPTIONS,
|
|
8275
|
+
dot: settings.showHidden
|
|
8276
|
+
});
|
|
8277
|
+
return {
|
|
8278
|
+
matcher,
|
|
8279
|
+
namingParts: matcher.globParts.map((parts) => parts.filter((part) => part !== "**").map((part) => new Minimatch(part, {
|
|
8280
|
+
...MATCH_OPTIONS,
|
|
8281
|
+
dot: false
|
|
8282
|
+
})))
|
|
8283
|
+
};
|
|
8284
|
+
}) ?? null;
|
|
8285
|
+
this._exclude = settings.exclude.map((pattern) => new Minimatch(pattern.normalize("NFC"), {
|
|
8286
|
+
...MATCH_OPTIONS,
|
|
8287
|
+
dot: true
|
|
8288
|
+
}));
|
|
8289
|
+
this.selective = this._include !== null;
|
|
8290
|
+
this.filtered = this.selective || this._exclude.length > 0;
|
|
8291
|
+
}
|
|
8292
|
+
/**
|
|
8293
|
+
* Tells whether a file is shown.
|
|
8294
|
+
*
|
|
8295
|
+
* @param relativePath - The path of the file.
|
|
8296
|
+
* @returns True when it is shown.
|
|
8297
|
+
*/
|
|
8298
|
+
showsFile(relativePath) {
|
|
8299
|
+
const names = namesOf(relativePath);
|
|
8300
|
+
return this.reaches(names) && this.included(names, "file");
|
|
8301
|
+
}
|
|
8302
|
+
/**
|
|
8303
|
+
* Tells whether a folder may be shown and looked into: not hidden, and, with `include`, able to lead to a file
|
|
8304
|
+
* a pattern matches.
|
|
8305
|
+
*
|
|
8306
|
+
* @param relativePath - The path of the folder.
|
|
8307
|
+
* @returns True when it may be shown.
|
|
8308
|
+
*/
|
|
8309
|
+
showsFolder(relativePath) {
|
|
8310
|
+
const names = namesOf(relativePath);
|
|
8311
|
+
return this.reaches(names) && this.included(names, "directory");
|
|
8312
|
+
}
|
|
8313
|
+
/**
|
|
8314
|
+
* Tells whether a path is one of those always hidden, `.git` and the items moved aside, or lies in one of them.
|
|
8315
|
+
*
|
|
8316
|
+
* @param relativePath - The path.
|
|
8317
|
+
* @returns True when it is always hidden.
|
|
8318
|
+
*/
|
|
8319
|
+
alwaysHides(relativePath) {
|
|
8320
|
+
return this.alwaysHidden(namesOf(relativePath));
|
|
8321
|
+
}
|
|
8322
|
+
/**
|
|
8323
|
+
* Tells whether the patterns hide a file or folder: one an `exclude` pattern matches or lies in a folder it matches,
|
|
8324
|
+
* or, with `include`, a file no pattern matches or a folder that cannot lead to one, names starting with a dot
|
|
8325
|
+
* included. What is always hidden is not hidden by the patterns.
|
|
8326
|
+
*
|
|
8327
|
+
* @param relativePath - The path.
|
|
8328
|
+
* @param kind - Whether it is a file or a folder.
|
|
8329
|
+
* @returns True when the patterns hide it.
|
|
8330
|
+
*/
|
|
8331
|
+
hidesByPatterns(relativePath, kind) {
|
|
8332
|
+
const names = namesOf(relativePath);
|
|
8333
|
+
return !this.alwaysHidden(names) && (this.excluded(names) || !this.included(names, kind));
|
|
8334
|
+
}
|
|
8335
|
+
/**
|
|
8336
|
+
* Tells whether a path is `.git` or an item moved aside, whatever the case of the name, or lies in one of them.
|
|
8337
|
+
*
|
|
8338
|
+
* @param names - The names of the path.
|
|
8339
|
+
* @returns True when it is always hidden.
|
|
8340
|
+
*/
|
|
8341
|
+
alwaysHidden(names) {
|
|
8342
|
+
return names.some((name) => name.toLowerCase() === ".git" || name.toLowerCase().startsWith(".devtool-undo-"));
|
|
8343
|
+
}
|
|
8344
|
+
/**
|
|
8345
|
+
* Tells whether an `exclude` pattern matches a path or a folder holding it.
|
|
8346
|
+
*
|
|
8347
|
+
* @param names - The names of the path.
|
|
8348
|
+
* @returns True when it is excluded.
|
|
8349
|
+
*/
|
|
8350
|
+
excluded(names) {
|
|
8351
|
+
return names.some((_, index) => {
|
|
8352
|
+
const folder = names.slice(0, index + 1).join("/");
|
|
8353
|
+
return this._exclude.some((matcher) => matcher.match(folder));
|
|
8354
|
+
});
|
|
8355
|
+
}
|
|
8356
|
+
/**
|
|
8357
|
+
* Tells whether `include` lets a path through: always without `include`, else a file an include pattern matches,
|
|
8358
|
+
* or a folder that can lead to one.
|
|
8359
|
+
*
|
|
8360
|
+
* @param names - The names of the path.
|
|
8361
|
+
* @param kind - Whether it is a file or a folder.
|
|
8362
|
+
* @returns True when `include` lets it through.
|
|
8363
|
+
*/
|
|
8364
|
+
included(names, kind) {
|
|
8365
|
+
if (!this._include) return true;
|
|
8366
|
+
return kind === "file" ? this._include.some(({ matcher }) => matcher.match(names.join("/"))) : this._include.some((pattern) => this.leadsTo(pattern, names));
|
|
8367
|
+
}
|
|
8368
|
+
/**
|
|
8369
|
+
* Tells whether a path escapes the names always hidden, the names starting with a dot when no `include` decides,
|
|
8370
|
+
* and every `exclude` pattern.
|
|
8371
|
+
*
|
|
8372
|
+
* @param names - The names of the path.
|
|
8373
|
+
* @returns True when nothing hides it.
|
|
8374
|
+
*/
|
|
8375
|
+
reaches(names) {
|
|
8376
|
+
if (this.alwaysHidden(names) || this.excluded(names)) return false;
|
|
8377
|
+
return Boolean(this._include) || this._showHidden || !names.some((name) => name.startsWith("."));
|
|
8378
|
+
}
|
|
8379
|
+
/**
|
|
8380
|
+
* Tells whether a folder can lead to a file an include pattern matches: the folder matches the start of the
|
|
8381
|
+
* pattern and the pattern goes on after it, with more names or a `**`; unless names starting with a dot are shown,
|
|
8382
|
+
* each such name of the folder must be matched by a part of the pattern other than `**`.
|
|
8383
|
+
*
|
|
8384
|
+
* @param pattern - The include pattern.
|
|
8385
|
+
* @param names - The names of the path of the folder.
|
|
8386
|
+
* @returns True when a file under the folder may match the pattern.
|
|
8387
|
+
*/
|
|
8388
|
+
leadsTo(pattern, names) {
|
|
8389
|
+
return pattern.matcher.set.some((parts, index) => (parts.length > names.length || parts.includes(GLOBSTAR)) && pattern.matcher.matchOne(names, parts, true) && (this._showHidden || names.every((name) => !name.startsWith(".") || (pattern.namingParts[index] ?? []).some((part) => part.match(name)))));
|
|
8390
|
+
}
|
|
8391
|
+
};
|
|
8392
|
+
/**
|
|
8393
|
+
* Gives what lies at a path.
|
|
8394
|
+
*
|
|
8395
|
+
* @param absolutePath - The path.
|
|
8396
|
+
* @returns A folder, a file for anything else, or null when nothing lies there.
|
|
8397
|
+
*/
|
|
8398
|
+
async function fileKindAt(absolutePath) {
|
|
8399
|
+
const stat = await fs.lstat(absolutePath).catch(() => null);
|
|
8400
|
+
return stat ? stat.isDirectory() ? "directory" : "file" : null;
|
|
8401
|
+
}
|
|
8402
|
+
/**
|
|
8403
|
+
* Gives a name with its case and Unicode form left out, as a folder that ignores them compares names, the full
|
|
8404
|
+
* case mappings of Unicode applied (`ß` folds as `ss`).
|
|
8405
|
+
*
|
|
8406
|
+
* @param name - The name.
|
|
8407
|
+
* @returns The name in NFC form, upper-cased then lower-cased.
|
|
8408
|
+
*/
|
|
8409
|
+
function foldedName(name) {
|
|
8410
|
+
return name.normalize("NFC").toUpperCase().toLowerCase();
|
|
8411
|
+
}
|
|
8412
|
+
/**
|
|
8413
|
+
* Gives the name an item of a folder is stored under, which a lookup by another case or Unicode form of the name
|
|
8414
|
+
* may have reached: the one entry of the folder whose name differs from it only by case or Unicode form and which
|
|
8415
|
+
* is the item found.
|
|
8416
|
+
*
|
|
8417
|
+
* @param folder - The absolute path of the folder.
|
|
8418
|
+
* @param name - The name the item was reached by.
|
|
8419
|
+
* @param found - What the lookup by that name found.
|
|
8420
|
+
* @returns The stored name, null when the folder cannot be listed, or holds no such entry or several.
|
|
8421
|
+
*/
|
|
8422
|
+
async function storedNameOf(folder, name, found) {
|
|
8423
|
+
const names = await fs.readdir(folder).catch(() => null);
|
|
8424
|
+
if (!names) return null;
|
|
8425
|
+
if (names.includes(name)) return name;
|
|
8426
|
+
const matches = [];
|
|
8427
|
+
for (const stored of names.filter((entry) => foldedName(entry) === foldedName(name))) {
|
|
8428
|
+
const item = await fs.lstat(path.join(folder, stored)).catch(() => null);
|
|
8429
|
+
if (item?.ino === found.ino && item.dev === found.dev) matches.push(stored);
|
|
8430
|
+
}
|
|
8431
|
+
return matches.length === 1 ? matches[0] ?? null : null;
|
|
8432
|
+
}
|
|
8433
|
+
/**
|
|
8434
|
+
* Gives a path of a folder as it lies on the disk, so that another case, Unicode form or spelling of an existing
|
|
8435
|
+
* file never escapes what is decided for its stored names: each existing name of the path, up to a symbolic link,
|
|
8436
|
+
* is replaced by the name its folder stores it under; the names that do not exist yet are kept as given.
|
|
8437
|
+
*
|
|
8438
|
+
* @param root - The absolute path of the folder.
|
|
8439
|
+
* @param relativePath - The path, relative to the folder with `/` separators.
|
|
8440
|
+
* @returns The path as it lies on the disk, null when it is empty, absolute, holds an empty, `.` or `..` segment, a
|
|
8441
|
+
* backslash or a NUL, or when the stored name of an existing name cannot be found.
|
|
8442
|
+
*/
|
|
8443
|
+
async function realPathOf$1(root, relativePath) {
|
|
8444
|
+
const names = relativePath.split("/");
|
|
8445
|
+
if (!relativePath || path.isAbsolute(relativePath) || names.some((item) => !item || item === "." || item === ".." || item.includes("\\") || item.includes("\0"))) return null;
|
|
8446
|
+
const stored = [];
|
|
8447
|
+
let link = false;
|
|
8448
|
+
let folder = true;
|
|
8449
|
+
for (const item of names) {
|
|
8450
|
+
const parent = path.join(root, ...stored);
|
|
8451
|
+
const stat = await fs.lstat(path.join(parent, item)).catch(() => null);
|
|
8452
|
+
link = stat?.isSymbolicLink() ?? false;
|
|
8453
|
+
if (!stat || link) break;
|
|
8454
|
+
const name = await storedNameOf(parent, item, stat);
|
|
8455
|
+
if (name === null) return null;
|
|
8456
|
+
stored.push(name);
|
|
8457
|
+
folder = stat.isDirectory();
|
|
8458
|
+
}
|
|
8459
|
+
const existingPath = stored.join("/");
|
|
8460
|
+
return {
|
|
8461
|
+
path: [...stored, ...names.slice(stored.length)].join("/"),
|
|
8462
|
+
link,
|
|
8463
|
+
through: stored.length > 0 && !folder && !link && stored.length < names.length ? existingPath : null
|
|
8464
|
+
};
|
|
8465
|
+
}
|
|
8466
|
+
/**
|
|
8467
|
+
* Gives a path of a folder as it lies on the disk when the filter of the folder shows it, deciding on the real path
|
|
8468
|
+
* of its existing part: what lies at the path must be shown as what it is, and as what the path is meant to be, and
|
|
8469
|
+
* an existing file the path goes through must be shown, so that a hidden path gets the same refusal whether or not
|
|
8470
|
+
* something lies there.
|
|
8471
|
+
*
|
|
8472
|
+
* @param root - The absolute path of the folder.
|
|
8473
|
+
* @param relativePath - The path, relative to the folder with `/` separators.
|
|
8474
|
+
* @param filter - The filter of the folder.
|
|
8475
|
+
* @param kind - What the path is meant to be, by default what lies there, or a file when nothing does.
|
|
8476
|
+
* @returns The path relative to the folder, or why it is refused, a hidden path before one through a symbolic link.
|
|
8477
|
+
*/
|
|
8478
|
+
async function resolveShownPath(root, relativePath, filter, kind) {
|
|
8479
|
+
const real = await realPathOf$1(root, relativePath);
|
|
8480
|
+
if (!real) return {
|
|
8481
|
+
path: null,
|
|
8482
|
+
refused: "invalid"
|
|
8483
|
+
};
|
|
8484
|
+
const present = real.link || real.through !== null ? null : await fileKindAt(path.join(root, real.path));
|
|
8485
|
+
if (![.../* @__PURE__ */ new Set([kind ?? present ?? "file", present ?? kind ?? "file"])].every((item) => item === "directory" ? filter.showsFolder(real.path) : filter.showsFile(real.path)) || real.through !== null && !filter.showsFile(real.through)) return {
|
|
8486
|
+
path: null,
|
|
8487
|
+
refused: "hidden"
|
|
8488
|
+
};
|
|
8489
|
+
return real.link ? {
|
|
8490
|
+
path: null,
|
|
8491
|
+
refused: "link"
|
|
8492
|
+
} : {
|
|
8493
|
+
path: real.path,
|
|
8494
|
+
refused: null
|
|
8495
|
+
};
|
|
8496
|
+
}
|
|
8201
8497
|
// ../../packages/git/lib/forge.js
|
|
8202
8498
|
const REQUEST_TIMEOUT = 15e3;
|
|
8203
8499
|
/** A refusal or a failure of a forge. */
|
|
@@ -10760,6 +11056,8 @@ const AGENT_ACTION_SETTINGS = {
|
|
|
10760
11056
|
};
|
|
10761
11057
|
const FORGE_KINDS = ["pullRequests", "issues"];
|
|
10762
11058
|
const DEFAULT_AGENT_ICON = "lucide:bot";
|
|
11059
|
+
/** The most characters of a glob a warning quotes. */
|
|
11060
|
+
const MAX_SHOWN_PATTERN = 80;
|
|
10763
11061
|
const INTEGRATION_TYPES = ["web", ...FORGE_KINDS];
|
|
10764
11062
|
/** The optional parts of the sidebar, each shown or hidden. */
|
|
10765
11063
|
const SIDEBAR_PARTS = [
|
|
@@ -12359,6 +12657,9 @@ var DevtoolConfigure = class {
|
|
|
12359
12657
|
this.addWarning(`${slug}[${filesSlug}].type`, `must be ${FILES_TYPES.join(" or ")}`);
|
|
12360
12658
|
continue;
|
|
12361
12659
|
}
|
|
12660
|
+
const include = this.readFilePatterns(`${slug}[${filesSlug}].include`, entry.include, false);
|
|
12661
|
+
const exclude = this.readFilePatterns(`${slug}[${filesSlug}].exclude`, entry.exclude, true);
|
|
12662
|
+
if (include === false || exclude === false) continue;
|
|
12362
12663
|
files[filesSlug] = {
|
|
12363
12664
|
slug: filesSlug,
|
|
12364
12665
|
name: typeof entry.name === "string" ? entry.name : filesSlug,
|
|
@@ -12380,12 +12681,35 @@ var DevtoolConfigure = class {
|
|
|
12380
12681
|
"mcp"
|
|
12381
12682
|
]),
|
|
12382
12683
|
mcpSkills: this.readMcpSkills(`${slug}[${filesSlug}].mcpSkills`, entry.mcpSkills, type),
|
|
12383
|
-
showHidden: this.readFlag(`${slug}[${filesSlug}].showHidden`, entry.showHidden, false)
|
|
12684
|
+
showHidden: this.readFlag(`${slug}[${filesSlug}].showHidden`, entry.showHidden, false),
|
|
12685
|
+
include,
|
|
12686
|
+
exclude: exclude ?? []
|
|
12384
12687
|
};
|
|
12385
12688
|
}
|
|
12386
12689
|
return files;
|
|
12387
12690
|
}
|
|
12388
12691
|
/**
|
|
12692
|
+
* Reads glob patterns choosing what a folder of files shows, relative to the folder.
|
|
12693
|
+
* @param slug Names the setting in warnings.
|
|
12694
|
+
* @param value The raw setting.
|
|
12695
|
+
* @param allowEmpty Whether an empty list is valid.
|
|
12696
|
+
* @returns The patterns, null when the setting is missing, false when it is invalid.
|
|
12697
|
+
*/
|
|
12698
|
+
readFilePatterns(slug, value, allowEmpty) {
|
|
12699
|
+
if (value === void 0) return null;
|
|
12700
|
+
const patterns = toStringArray(value);
|
|
12701
|
+
if (!patterns || patterns.some((pattern) => !pattern)) return this.addWarning(slug, "must be a list of glob patterns, such as [ \"apps/*/.env\" ], the folder of files is left out");
|
|
12702
|
+
if (!allowEmpty && patterns.length === 0) return this.addWarning(slug, "must list at least one glob pattern, the folder of files is left out");
|
|
12703
|
+
for (const pattern of patterns) {
|
|
12704
|
+
const problem = filePatternProblem(pattern);
|
|
12705
|
+
if (problem) {
|
|
12706
|
+
const shown = pattern.length > MAX_SHOWN_PATTERN ? `${pattern.slice(0, MAX_SHOWN_PATTERN)}...` : pattern;
|
|
12707
|
+
return this.addWarning(slug, `${JSON.stringify(shown)} ${problem}, the folder of files is left out`);
|
|
12708
|
+
}
|
|
12709
|
+
}
|
|
12710
|
+
return patterns;
|
|
12711
|
+
}
|
|
12712
|
+
/**
|
|
12389
12713
|
* Reads a setting being true or false, warning about any other value.
|
|
12390
12714
|
* @param slug Names the setting in warnings.
|
|
12391
12715
|
* @param value The raw setting.
|
|
@@ -14838,9 +15162,6 @@ async function editConfigFile(file, edit) {
|
|
|
14838
15162
|
/** Identifier of the file space of the configuration files of the development environment. */
|
|
14839
15163
|
const CONFIGS_SPACE = "configs";
|
|
14840
15164
|
const YAML_EXTENSION = /\.ya?ml$/;
|
|
14841
|
-
const GIT_FOLDER = ".git";
|
|
14842
|
-
/** The start of the name of an item moved aside next to where it was, until its removal is kept or undone. */
|
|
14843
|
-
const ASIDE_PREFIX = ".devtool-undo-";
|
|
14844
15165
|
const LOCAL_YAML_EXTENSION = /\.local\.ya?ml$/;
|
|
14845
15166
|
/**
|
|
14846
15167
|
* Gives a new hidden path next to a file or folder, which no listing shows, to move it aside.
|
|
@@ -14928,38 +15249,38 @@ function configFiles(section, includedPaths) {
|
|
|
14928
15249
|
};
|
|
14929
15250
|
}
|
|
14930
15251
|
/**
|
|
14931
|
-
* A folder of files the interface reads and writes, every path relative to its root.
|
|
14932
|
-
* parent segments and symbolic links are out of reach; binary files are
|
|
15252
|
+
* A folder of files the interface reads and writes, every path relative to its root. What its filter hides,
|
|
15253
|
+
* parent segments and symbolic links are out of reach, whatever the spelling of the path; binary files are
|
|
15254
|
+
* reported, never sent.
|
|
14933
15255
|
*/
|
|
14934
15256
|
var FileSpace = class {
|
|
14935
15257
|
id;
|
|
14936
15258
|
root;
|
|
14937
15259
|
editable;
|
|
14938
|
-
|
|
15260
|
+
filter;
|
|
14939
15261
|
afterWrite;
|
|
14940
15262
|
/**
|
|
14941
15263
|
* @param id - Identifier of the space.
|
|
14942
15264
|
* @param root - Absolute path of its root.
|
|
14943
15265
|
* @param editable - Whether files and folders can be created, renamed and removed.
|
|
14944
|
-
* @param
|
|
15266
|
+
* @param filter - Decides which files and folders are reachable.
|
|
14945
15267
|
* @param afterWrite - Runs once a file of the space is written.
|
|
14946
15268
|
*/
|
|
14947
|
-
constructor(id, root, editable,
|
|
15269
|
+
constructor(id, root, editable, filter, afterWrite = null) {
|
|
14948
15270
|
this.id = id;
|
|
14949
15271
|
this.root = root;
|
|
14950
15272
|
this.editable = editable;
|
|
14951
|
-
this.
|
|
15273
|
+
this.filter = filter;
|
|
14952
15274
|
this.afterWrite = afterWrite;
|
|
14953
15275
|
}
|
|
14954
15276
|
/**
|
|
14955
|
-
*
|
|
14956
|
-
* change is kept or undone, and any other dot name unless the space shows them.
|
|
15277
|
+
* Builds the refusal of a path the space does not show.
|
|
14957
15278
|
*
|
|
14958
|
-
* @param
|
|
14959
|
-
* @returns
|
|
15279
|
+
* @param filePath - The path.
|
|
15280
|
+
* @returns The refusal, the same whether or not something lies at the path.
|
|
14960
15281
|
*/
|
|
14961
|
-
|
|
14962
|
-
return
|
|
15282
|
+
hiddenPathError(filePath) {
|
|
15283
|
+
return /* @__PURE__ */ new Error(this.filter.filtered ? `${filePath} is outside the include/exclude of ${this.id}` : `${filePath} is not a path of ${this.id}`);
|
|
14963
15284
|
}
|
|
14964
15285
|
/**
|
|
14965
15286
|
* Describes the files of the space.
|
|
@@ -15011,7 +15332,7 @@ var FileSpace = class {
|
|
|
15011
15332
|
error: null
|
|
15012
15333
|
};
|
|
15013
15334
|
try {
|
|
15014
|
-
const absolutePath = await this.resolve(filePath);
|
|
15335
|
+
const absolutePath = await this.resolve(filePath, "file");
|
|
15015
15336
|
const stat = await fs.lstat(absolutePath).catch((error) => {
|
|
15016
15337
|
if (error.code === "ENOENT") return null;
|
|
15017
15338
|
throw error;
|
|
@@ -15090,7 +15411,7 @@ var FileSpace = class {
|
|
|
15090
15411
|
};
|
|
15091
15412
|
try {
|
|
15092
15413
|
this.validate(filePath, content);
|
|
15093
|
-
await writeLocalFile(await this.resolve(filePath), content);
|
|
15414
|
+
await writeLocalFile(await this.resolve(filePath, "file"), content);
|
|
15094
15415
|
} catch (error) {
|
|
15095
15416
|
return {
|
|
15096
15417
|
...current,
|
|
@@ -15110,7 +15431,7 @@ var FileSpace = class {
|
|
|
15110
15431
|
* @returns The files the creation wrote.
|
|
15111
15432
|
*/
|
|
15112
15433
|
async create(filePath, kind) {
|
|
15113
|
-
const absolutePath = await this.resolveEditable(filePath);
|
|
15434
|
+
const absolutePath = await this.resolveEditable(filePath, kind);
|
|
15114
15435
|
if (kind === "directory") {
|
|
15115
15436
|
await fs.mkdir(absolutePath, {
|
|
15116
15437
|
recursive: true,
|
|
@@ -15137,7 +15458,7 @@ var FileSpace = class {
|
|
|
15137
15458
|
* @param filePath - The path of the file or folder.
|
|
15138
15459
|
*/
|
|
15139
15460
|
async remove(filePath) {
|
|
15140
|
-
await fs.rm(await this.
|
|
15461
|
+
await fs.rm(await this.resolveRemovable(filePath), { recursive: true });
|
|
15141
15462
|
}
|
|
15142
15463
|
/**
|
|
15143
15464
|
* Moves a file or folder aside, to a hidden item of the same folder no listing shows, so that its removal can
|
|
@@ -15147,7 +15468,7 @@ var FileSpace = class {
|
|
|
15147
15468
|
* @returns The absolute paths of the file or folder and of the item it was moved to.
|
|
15148
15469
|
*/
|
|
15149
15470
|
async moveAside(filePath) {
|
|
15150
|
-
const absolutePath = await this.
|
|
15471
|
+
const absolutePath = await this.resolveRemovable(filePath);
|
|
15151
15472
|
const aside = asidePathOf(absolutePath);
|
|
15152
15473
|
await fs.rename(absolutePath, aside);
|
|
15153
15474
|
return {
|
|
@@ -15163,8 +15484,13 @@ var FileSpace = class {
|
|
|
15163
15484
|
*/
|
|
15164
15485
|
async rename(from, to) {
|
|
15165
15486
|
const source = await this.resolveEditable(from);
|
|
15166
|
-
const
|
|
15167
|
-
|
|
15487
|
+
const kind = await fileKindAt(source) ?? "file";
|
|
15488
|
+
const target = await this.resolveEditable(to, kind);
|
|
15489
|
+
if (await fileKindAt(target)) throw new Error(`${to} already exists`);
|
|
15490
|
+
if (kind === "directory") await this.checkFolderChange(from, source, {
|
|
15491
|
+
to,
|
|
15492
|
+
target
|
|
15493
|
+
});
|
|
15168
15494
|
await fs.mkdir(path.dirname(target), {
|
|
15169
15495
|
recursive: true,
|
|
15170
15496
|
mode: 448
|
|
@@ -15175,41 +15501,86 @@ var FileSpace = class {
|
|
|
15175
15501
|
* Gives the absolute path of a file or folder of the space.
|
|
15176
15502
|
*
|
|
15177
15503
|
* @param filePath - The path, relative to the root.
|
|
15504
|
+
* @param kind - What the path is meant to be, the file or folder lying there by default.
|
|
15178
15505
|
* @returns The absolute path.
|
|
15179
|
-
* @throws {Error} When the path is not one
|
|
15506
|
+
* @throws {Error} When the path is not one the space shows.
|
|
15180
15507
|
*/
|
|
15181
|
-
async absolutePathOf(filePath) {
|
|
15182
|
-
return this.resolve(filePath);
|
|
15508
|
+
async absolutePathOf(filePath, kind) {
|
|
15509
|
+
return this.resolve(filePath, kind);
|
|
15183
15510
|
}
|
|
15184
15511
|
/**
|
|
15185
|
-
* Gives the absolute path of a path of the space, refusing anything
|
|
15186
|
-
* parent, current or
|
|
15187
|
-
* existing
|
|
15512
|
+
* Gives the absolute path of a path of the space as it lies on the disk, refusing anything the space does not
|
|
15513
|
+
* show: absolute paths, parent, current or empty segments, symbolic links among the existing names, and what the
|
|
15514
|
+
* filter hides, decided on the real path of the existing part, through an existing file included. In a filtered
|
|
15515
|
+
* space, a path through a symbolic link gets the same refusal as a hidden one.
|
|
15188
15516
|
*
|
|
15189
15517
|
* @param filePath - The path, relative to the root.
|
|
15518
|
+
* @param kind - What the path is meant to be, by default the file or folder lying there, or a file when nothing
|
|
15519
|
+
* does; something lying there of another kind must be shown too.
|
|
15190
15520
|
* @returns The absolute path.
|
|
15191
15521
|
*/
|
|
15192
|
-
async resolve(filePath) {
|
|
15193
|
-
const
|
|
15194
|
-
if (
|
|
15195
|
-
|
|
15196
|
-
|
|
15197
|
-
|
|
15198
|
-
const stat = await fs.lstat(current).catch(() => null);
|
|
15199
|
-
if (!stat) break;
|
|
15200
|
-
if (stat.isSymbolicLink()) throw new Error(`${filePath} goes through a symbolic link`);
|
|
15201
|
-
}
|
|
15202
|
-
return path.join(this.root, filePath);
|
|
15522
|
+
async resolve(filePath, kind) {
|
|
15523
|
+
const shown = await resolveShownPath(this.root, filePath, this.filter, kind);
|
|
15524
|
+
if (shown.refused === null) return path.join(this.root, shown.path);
|
|
15525
|
+
if (shown.refused === "invalid") throw new Error(`${filePath} is not a path of ${this.id}`);
|
|
15526
|
+
if (shown.refused === "link" && !this.filter.filtered) throw new Error(`${filePath} goes through a symbolic link`);
|
|
15527
|
+
throw this.hiddenPathError(filePath);
|
|
15203
15528
|
}
|
|
15204
15529
|
/**
|
|
15205
15530
|
* Gives the absolute path of a path of the space whose files and folders can be changed.
|
|
15206
15531
|
*
|
|
15207
15532
|
* @param filePath - The path, relative to the root.
|
|
15533
|
+
* @param kind - What the path is meant to be, by default the file or folder lying there.
|
|
15208
15534
|
* @returns The absolute path.
|
|
15209
15535
|
*/
|
|
15210
|
-
async resolveEditable(filePath) {
|
|
15536
|
+
async resolveEditable(filePath, kind) {
|
|
15211
15537
|
if (!this.editable) throw new Error(`files of ${this.id} cannot be created, renamed or removed`);
|
|
15212
|
-
return this.resolve(filePath);
|
|
15538
|
+
return this.resolve(filePath, kind);
|
|
15539
|
+
}
|
|
15540
|
+
/**
|
|
15541
|
+
* Gives the absolute path of a file or folder of the space that can be removed with everything it holds.
|
|
15542
|
+
*
|
|
15543
|
+
* @param filePath - The path, relative to the root.
|
|
15544
|
+
* @returns The absolute path.
|
|
15545
|
+
*/
|
|
15546
|
+
async resolveRemovable(filePath) {
|
|
15547
|
+
const absolutePath = await this.resolveEditable(filePath);
|
|
15548
|
+
if (await fileKindAt(absolutePath) === "directory") await this.checkFolderChange(filePath, absolutePath, null);
|
|
15549
|
+
return absolutePath;
|
|
15550
|
+
}
|
|
15551
|
+
/**
|
|
15552
|
+
* Refuses, in a filtered space, to move or remove a folder holding a file or folder its include or exclude hide,
|
|
15553
|
+
* which would go with it unseen, and to move one holding something the space shows that it would no longer show at
|
|
15554
|
+
* its new place. What the space hides without its patterns (names starting with a dot without `showHidden`, `.git`,
|
|
15555
|
+
* symbolic links, special files) goes with the folder as in a space without patterns.
|
|
15556
|
+
*
|
|
15557
|
+
* @param filePath - The path of the folder, as given.
|
|
15558
|
+
* @param folder - Its absolute path.
|
|
15559
|
+
* @param move - Where it moves, as given and as an absolute path, null for a removal.
|
|
15560
|
+
* @param move.to - The new path, as given.
|
|
15561
|
+
* @param move.target - The new absolute path.
|
|
15562
|
+
* @throws {Error} When the change is refused.
|
|
15563
|
+
*/
|
|
15564
|
+
async checkFolderChange(filePath, folder, move) {
|
|
15565
|
+
if (!this.filter.filtered) return;
|
|
15566
|
+
const relativeOf = (absolutePath) => path.relative(this.root, absolutePath).split(path.sep).join("/");
|
|
15567
|
+
const source = relativeOf(folder);
|
|
15568
|
+
const destination = move && {
|
|
15569
|
+
to: move.to,
|
|
15570
|
+
path: relativeOf(move.target)
|
|
15571
|
+
};
|
|
15572
|
+
const visit = async (inner) => {
|
|
15573
|
+
for (const dirent of await fs.readdir(path.join(folder, inner), { withFileTypes: true })) {
|
|
15574
|
+
const entry = inner ? `${inner}/${dirent.name}` : dirent.name;
|
|
15575
|
+
const kind = dirent.isDirectory() ? "directory" : "file";
|
|
15576
|
+
if (!dirent.isDirectory() && !dirent.isFile()) continue;
|
|
15577
|
+
if (this.filter.hidesByPatterns(`${source}/${entry}`, kind)) throw new Error(`${filePath} holds files the include/exclude of ${this.id} hides`);
|
|
15578
|
+
const shown = (base) => kind === "directory" ? this.filter.showsFolder(`${base}/${entry}`) : this.filter.showsFile(`${base}/${entry}`);
|
|
15579
|
+
if (destination && shown(source) && !shown(destination.path)) throw new Error(`${filePath} cannot move to ${destination.to}: ${entry} would be outside the include/exclude of ${this.id}`);
|
|
15580
|
+
if (kind === "directory" && !this.filter.alwaysHides(`${source}/${entry}`)) await visit(entry);
|
|
15581
|
+
}
|
|
15582
|
+
};
|
|
15583
|
+
await visit("");
|
|
15213
15584
|
}
|
|
15214
15585
|
};
|
|
15215
15586
|
/**
|
|
@@ -15227,7 +15598,11 @@ var ListedFileSpace = class extends FileSpace {
|
|
|
15227
15598
|
* path in the root, by their path in the list.
|
|
15228
15599
|
*/
|
|
15229
15600
|
constructor(id, root, _paths, afterWrite = null, _located = /* @__PURE__ */ new Map()) {
|
|
15230
|
-
super(id, root, false,
|
|
15601
|
+
super(id, root, false, new FileFilter({
|
|
15602
|
+
include: null,
|
|
15603
|
+
exclude: [],
|
|
15604
|
+
showHidden: true
|
|
15605
|
+
}), afterWrite);
|
|
15231
15606
|
this._paths = _paths;
|
|
15232
15607
|
this._located = _located;
|
|
15233
15608
|
}
|
|
@@ -15266,52 +15641,65 @@ var ListedFileSpace = class extends FileSpace {
|
|
|
15266
15641
|
* path of the others in the root.
|
|
15267
15642
|
*
|
|
15268
15643
|
* @param filePath - The path of the file.
|
|
15644
|
+
* @param kind - What the path is meant to be.
|
|
15269
15645
|
* @returns The absolute path.
|
|
15270
15646
|
*/
|
|
15271
|
-
async resolve(filePath) {
|
|
15647
|
+
async resolve(filePath, kind) {
|
|
15272
15648
|
if (!this._paths.includes(filePath)) throw new Error(`${filePath} is not a file of ${this.id}`);
|
|
15273
15649
|
const located = this._located.get(filePath);
|
|
15274
15650
|
if (located !== void 0) return fs.realpath(located).catch(() => located);
|
|
15275
|
-
return super.resolve(filePath);
|
|
15651
|
+
return super.resolve(filePath, kind);
|
|
15276
15652
|
}
|
|
15277
15653
|
};
|
|
15278
15654
|
/**
|
|
15279
|
-
* A file space made of everything its root holds, whose files and folders can be changed.
|
|
15655
|
+
* A file space made of everything its root holds that its filter shows, whose files and folders can be changed.
|
|
15280
15656
|
*/
|
|
15281
15657
|
var TreeFileSpace = class extends FileSpace {
|
|
15282
15658
|
/**
|
|
15283
15659
|
* @param id - Identifier of the space.
|
|
15284
15660
|
* @param root - Absolute path of its root.
|
|
15285
15661
|
* @param showHidden - Whether the files and folders whose name starts with a dot are listed.
|
|
15662
|
+
* @param patterns - The glob patterns of the files shown and of the files and folders hidden.
|
|
15286
15663
|
*/
|
|
15287
|
-
constructor(id, root, showHidden = false
|
|
15288
|
-
|
|
15664
|
+
constructor(id, root, showHidden = false, patterns = {
|
|
15665
|
+
include: null,
|
|
15666
|
+
exclude: []
|
|
15667
|
+
}) {
|
|
15668
|
+
super(id, root, true, new FileFilter({
|
|
15669
|
+
include: patterns.include,
|
|
15670
|
+
exclude: patterns.exclude,
|
|
15671
|
+
showHidden
|
|
15672
|
+
}));
|
|
15289
15673
|
}
|
|
15290
15674
|
/**
|
|
15291
|
-
* Lists the files and folders under the root
|
|
15675
|
+
* Lists the files and folders under the root its filter shows, symbolic links left out, never looking into a folder
|
|
15676
|
+
* it hides. With `include`, a folder is listed only when it holds something listed or nothing at all.
|
|
15292
15677
|
*
|
|
15293
15678
|
* @returns The entries, sorted by path.
|
|
15294
15679
|
*/
|
|
15295
15680
|
async entries() {
|
|
15296
|
-
const entries = [];
|
|
15297
15681
|
const visit = async (folder) => {
|
|
15298
|
-
|
|
15299
|
-
|
|
15682
|
+
const dirents = await fs.readdir(path.join(this.root, folder), { withFileTypes: true });
|
|
15683
|
+
const entries = [];
|
|
15684
|
+
for (const dirent of dirents) {
|
|
15300
15685
|
const entryPath = folder ? `${folder}/${dirent.name}` : dirent.name;
|
|
15301
|
-
if (dirent.isDirectory()) {
|
|
15302
|
-
|
|
15686
|
+
if (dirent.isDirectory() && this.filter.showsFolder(entryPath)) {
|
|
15687
|
+
const inner = await visit(entryPath);
|
|
15688
|
+
if (!this.filter.selective || inner.entries.length > 0 || inner.empty) entries.push({
|
|
15303
15689
|
path: entryPath,
|
|
15304
15690
|
kind: "directory"
|
|
15305
|
-
});
|
|
15306
|
-
|
|
15307
|
-
} else if (dirent.isFile()) entries.push({
|
|
15691
|
+
}, ...inner.entries);
|
|
15692
|
+
} else if (dirent.isFile() && this.filter.showsFile(entryPath)) entries.push({
|
|
15308
15693
|
path: entryPath,
|
|
15309
15694
|
kind: "file"
|
|
15310
15695
|
});
|
|
15311
15696
|
}
|
|
15697
|
+
return {
|
|
15698
|
+
entries,
|
|
15699
|
+
empty: dirents.length === 0
|
|
15700
|
+
};
|
|
15312
15701
|
};
|
|
15313
|
-
await visit("");
|
|
15314
|
-
return entries.sort((a, b) => a.path.localeCompare(b.path));
|
|
15702
|
+
return (await visit("")).entries.sort((a, b) => a.path.localeCompare(b.path));
|
|
15315
15703
|
}
|
|
15316
15704
|
/**
|
|
15317
15705
|
* Checks the syntax of a YAML file.
|
|
@@ -15382,19 +15770,18 @@ var AgentSkillsFileSpace = class extends TreeFileSpace {
|
|
|
15382
15770
|
* @returns The files the creation wrote.
|
|
15383
15771
|
*/
|
|
15384
15772
|
async create(filePath, kind) {
|
|
15773
|
+
if (kind !== "directory" || filePath.includes("/")) return super.create(filePath, kind);
|
|
15774
|
+
await this.resolve(filePath, kind);
|
|
15775
|
+
const skill = {
|
|
15776
|
+
path: await this.resolve(`${filePath}/${AGENT_SKILL_FILE}`, "file"),
|
|
15777
|
+
content: newAgentSkill(filePath)
|
|
15778
|
+
};
|
|
15385
15779
|
const created = await super.create(filePath, kind);
|
|
15386
|
-
|
|
15387
|
-
|
|
15388
|
-
|
|
15389
|
-
|
|
15390
|
-
|
|
15391
|
-
await fs.writeFile(skill.path, skill.content, {
|
|
15392
|
-
flag: "wx",
|
|
15393
|
-
mode: 384
|
|
15394
|
-
});
|
|
15395
|
-
return [...created, skill];
|
|
15396
|
-
}
|
|
15397
|
-
return created;
|
|
15780
|
+
await fs.writeFile(skill.path, skill.content, {
|
|
15781
|
+
flag: "wx",
|
|
15782
|
+
mode: 384
|
|
15783
|
+
});
|
|
15784
|
+
return [...created, skill];
|
|
15398
15785
|
}
|
|
15399
15786
|
};
|
|
15400
15787
|
/**
|
|
@@ -15443,7 +15830,7 @@ var DevtoolFileSpaces = class {
|
|
|
15443
15830
|
const agentSpaces = /* @__PURE__ */ new Map([[CONFIGS_SPACE, new ListedFileSpace(CONFIGS_SPACE, agentConfigs.folder, agentConfigs.paths, afterConfigWrite)]]);
|
|
15444
15831
|
for (const project of Object.values(projects)) for (const directory of Object.values(project.directories)) for (const files of Object.values(directory.files)) {
|
|
15445
15832
|
const id = `${project.slug}/${directory.slug}/${files.slug}`;
|
|
15446
|
-
const space = files.type === "agentSkills" ? new AgentSkillsFileSpace(id, files.path, files.showHidden) : new TreeFileSpace(id, files.path, files.showHidden);
|
|
15833
|
+
const space = files.type === "agentSkills" ? new AgentSkillsFileSpace(id, files.path, files.showHidden, files) : new TreeFileSpace(id, files.path, files.showHidden, files);
|
|
15447
15834
|
spaces.set(id, space);
|
|
15448
15835
|
agentSpaces.set(id, space);
|
|
15449
15836
|
}
|
|
@@ -15657,7 +16044,7 @@ async function removeCreatedFiles(files) {
|
|
|
15657
16044
|
* @returns The file as it now stands, and how to keep or undo the write.
|
|
15658
16045
|
*/
|
|
15659
16046
|
async function applyWrite(space, filePath, content, baseUpdatedAt) {
|
|
15660
|
-
const target = await space.absolutePathOf(filePath);
|
|
16047
|
+
const target = await space.absolutePathOf(filePath, "file");
|
|
15661
16048
|
const existed = await exists$1(target);
|
|
15662
16049
|
const mode = (await fs.stat(target).catch(() => null))?.mode ?? 384;
|
|
15663
16050
|
const previous = await fs.readFile(target).catch(() => null);
|
|
@@ -15699,7 +16086,7 @@ async function applyWrite(space, filePath, content, baseUpdatedAt) {
|
|
|
15699
16086
|
* @returns How to keep or undo the creation.
|
|
15700
16087
|
*/
|
|
15701
16088
|
async function applyCreate(space, filePath, kind) {
|
|
15702
|
-
const target = await space.absolutePathOf(filePath);
|
|
16089
|
+
const target = await space.absolutePathOf(filePath, kind);
|
|
15703
16090
|
const folders = [...kind === "directory" && !await exists$1(target) ? [target] : [], ...await missingFolders(target)];
|
|
15704
16091
|
let written;
|
|
15705
16092
|
try {
|
|
@@ -15727,9 +16114,10 @@ async function applyCreate(space, filePath, kind) {
|
|
|
15727
16114
|
*/
|
|
15728
16115
|
async function applyRename(space, from, to) {
|
|
15729
16116
|
const source = await space.absolutePathOf(from);
|
|
15730
|
-
const
|
|
16117
|
+
const stat = await fs.lstat(source).catch(() => null);
|
|
16118
|
+
const target = await space.absolutePathOf(to, stat?.isDirectory() ? "directory" : "file");
|
|
15731
16119
|
const created = await missingFolders(target);
|
|
15732
|
-
const moved =
|
|
16120
|
+
const moved = stat?.isFile() ? await hashOf(source) : null;
|
|
15733
16121
|
try {
|
|
15734
16122
|
await space.rename(from, to);
|
|
15735
16123
|
} catch (error) {
|
|
@@ -16703,7 +17091,7 @@ async function refuseDevtoolConfig(host, space, ...paths) {
|
|
|
16703
17091
|
async function changeAsAgent(host, space, change) {
|
|
16704
17092
|
let outcome;
|
|
16705
17093
|
try {
|
|
16706
|
-
outcome = await host.changeAsAgent(space.id, change);
|
|
17094
|
+
outcome = await host.changeAsAgent(space.id, change, space.space);
|
|
16707
17095
|
} catch (error) {
|
|
16708
17096
|
throw new McpToolError(error instanceof Error ? error.message : String(error));
|
|
16709
17097
|
}
|
|
@@ -17406,23 +17794,97 @@ function serves(source, name) {
|
|
|
17406
17794
|
return source.include.some((glob) => path.matchesGlob(name, glob));
|
|
17407
17795
|
}
|
|
17408
17796
|
/**
|
|
17409
|
-
*
|
|
17410
|
-
* @param
|
|
17411
|
-
* @returns
|
|
17797
|
+
* Gives the filter of a folder of skills when it hides anything.
|
|
17798
|
+
* @param source The folder.
|
|
17799
|
+
* @returns The filter, null when every file of the folder is served.
|
|
17412
17800
|
*/
|
|
17413
|
-
|
|
17801
|
+
function filterOf(source) {
|
|
17802
|
+
return source.filter?.filtered ? source.filter : null;
|
|
17803
|
+
}
|
|
17804
|
+
/**
|
|
17805
|
+
* Tells whether the names of a path of an unfiltered folder of skills are served: `.git` never, and names starting
|
|
17806
|
+
* with a dot only when its folder of files shows hidden files.
|
|
17807
|
+
* @param source The folder of skills.
|
|
17808
|
+
* @param rest The names of the path in the folder.
|
|
17809
|
+
* @param kind Whether the path is a file or a folder.
|
|
17810
|
+
* @returns True when every name of the path is served.
|
|
17811
|
+
*/
|
|
17812
|
+
function namesServed(source, rest, kind) {
|
|
17813
|
+
if (!source.filter) return true;
|
|
17814
|
+
return kind === "directory" ? source.filter.showsFolder(rest.join("/")) : source.filter.showsFile(rest.join("/"));
|
|
17815
|
+
}
|
|
17816
|
+
/**
|
|
17817
|
+
* Tells whether a path of an unfiltered folder of skills is served, symbolic links followed: its names, and those of
|
|
17818
|
+
* what it leads to, relative to the folder when it lies in it, else the name of what it leads to.
|
|
17819
|
+
* @param source The folder of skills.
|
|
17820
|
+
* @param rest The names of the path in the folder.
|
|
17821
|
+
* @param kind Whether the path is a file or a folder.
|
|
17822
|
+
* @returns True when the path and what it leads to are served, false when it leads nowhere.
|
|
17823
|
+
*/
|
|
17824
|
+
async function targetServed(source, rest, kind) {
|
|
17825
|
+
if (!namesServed(source, rest, kind)) return false;
|
|
17826
|
+
if (!source.filter || rest.length === 0) return true;
|
|
17827
|
+
const reals = await Promise.all([fs.realpath(source.folder), fs.realpath(path.join(source.folder, ...rest))]).catch(() => null);
|
|
17828
|
+
if (!reals) return false;
|
|
17829
|
+
const relative = path.relative(reals[0], reals[1]);
|
|
17830
|
+
return namesServed(source, relative !== "" && relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative) ? relative.split(path.sep) : [path.basename(reals[1])], kind);
|
|
17831
|
+
}
|
|
17832
|
+
/**
|
|
17833
|
+
* Lists a folder of an unfiltered folder of skills, symbolic links followed, leaving out the paths it does not serve.
|
|
17834
|
+
* @param source The folder of skills.
|
|
17835
|
+
* @param rest The names of the folder listed in the folder of skills, none for its root.
|
|
17836
|
+
* @returns Its children, none when it does not exist or is not served.
|
|
17837
|
+
*/
|
|
17838
|
+
async function listFolder(source, rest) {
|
|
17839
|
+
if (!await targetServed(source, rest, "directory")) return [];
|
|
17840
|
+
const folder = path.join(source.folder, ...rest);
|
|
17414
17841
|
const dirents = await fs.readdir(folder, { withFileTypes: true }).catch(() => []);
|
|
17415
|
-
return Promise.all(dirents.map(async (dirent) => {
|
|
17842
|
+
return (await Promise.all(dirents.map(async (dirent) => {
|
|
17416
17843
|
const stat = dirent.isSymbolicLink() ? await fs.stat(path.join(folder, dirent.name)).catch(() => null) : dirent;
|
|
17417
|
-
|
|
17844
|
+
const entry = {
|
|
17418
17845
|
name: dirent.name,
|
|
17419
17846
|
kind: stat?.isDirectory() ? "directory" : stat?.isFile() ? "file" : "unsupported"
|
|
17420
17847
|
};
|
|
17421
|
-
|
|
17848
|
+
return await targetServed(source, [...rest, entry.name], entry.kind === "directory" ? "directory" : "file") ? entry : null;
|
|
17849
|
+
}))).filter((entry) => entry !== null);
|
|
17850
|
+
}
|
|
17851
|
+
/**
|
|
17852
|
+
* Gives a path of a filtered folder of skills as it lies on the disk, when the filter shows it.
|
|
17853
|
+
* @param source The folder of skills.
|
|
17854
|
+
* @param filter Its filter.
|
|
17855
|
+
* @param rest The names of the path in the folder.
|
|
17856
|
+
* @param kind Whether the path is a file or a folder.
|
|
17857
|
+
* @returns The path relative to the folder, null when it is not a plain relative path, is not shown or goes through
|
|
17858
|
+
* a symbolic link.
|
|
17859
|
+
*/
|
|
17860
|
+
async function shownPath(source, filter, rest, kind) {
|
|
17861
|
+
return (await resolveShownPath(source.folder, rest.join("/"), filter, kind)).path;
|
|
17862
|
+
}
|
|
17863
|
+
/**
|
|
17864
|
+
* Lists what a filtered folder of skills shows in one of its folders, symbolic links left out.
|
|
17865
|
+
* @param source The folder of skills.
|
|
17866
|
+
* @param filter Its filter.
|
|
17867
|
+
* @param rest The names of the folder listed in the folder of skills, none for its root.
|
|
17868
|
+
* @returns The files and folders shown, none when the folder is not shown or does not exist.
|
|
17869
|
+
*/
|
|
17870
|
+
async function listShown(source, filter, rest) {
|
|
17871
|
+
const folder = rest.length > 0 ? await shownPath(source, filter, rest, "directory") : "";
|
|
17872
|
+
if (folder === null) return [];
|
|
17873
|
+
return (await fs.readdir(path.join(source.folder, folder), { withFileTypes: true }).catch(() => [])).flatMap((dirent) => {
|
|
17874
|
+
const entryPath = folder ? `${folder}/${dirent.name}` : dirent.name;
|
|
17875
|
+
if (dirent.isDirectory() && filter.showsFolder(entryPath)) return [{
|
|
17876
|
+
name: dirent.name,
|
|
17877
|
+
kind: "directory"
|
|
17878
|
+
}];
|
|
17879
|
+
return dirent.isFile() && filter.showsFile(entryPath) ? [{
|
|
17880
|
+
name: dirent.name,
|
|
17881
|
+
kind: "file"
|
|
17882
|
+
}] : [];
|
|
17883
|
+
});
|
|
17422
17884
|
}
|
|
17423
17885
|
/**
|
|
17424
17886
|
* Gives the storage of a skills catalog joining folders of skills under their prefixes, each showing
|
|
17425
|
-
* only the skill folders it serves.
|
|
17887
|
+
* only the skill folders it serves and, when it filters, only the files and folders its filter shows.
|
|
17426
17888
|
* @param folders Gives the folders, read again on every access.
|
|
17427
17889
|
* @returns The storage.
|
|
17428
17890
|
*/
|
|
@@ -17451,14 +17913,17 @@ function joinedSkillFiles(folders) {
|
|
|
17451
17913
|
}
|
|
17452
17914
|
for (const { source, rest } of locate(dir)) {
|
|
17453
17915
|
if (rest.length > 0 && !serves(source, rest[0])) continue;
|
|
17454
|
-
|
|
17916
|
+
const filter = filterOf(source);
|
|
17917
|
+
for (const entry of filter ? await listShown(source, filter, rest) : await listFolder(source, rest)) if (rest.length > 0 || entry.kind === "directory" && serves(source, entry.name)) entries.set(entry.name, entry);
|
|
17455
17918
|
}
|
|
17456
17919
|
return [...entries.values()];
|
|
17457
17920
|
},
|
|
17458
17921
|
async read(file) {
|
|
17459
17922
|
const found = locate(file).find(({ source, rest }) => rest.length > 1 && serves(source, rest[0]));
|
|
17460
|
-
|
|
17461
|
-
|
|
17923
|
+
const filter = found ? filterOf(found.source) : null;
|
|
17924
|
+
const shown = found && filter ? await shownPath(found.source, filter, found.rest, "file") : found && await targetServed(found.source, found.rest, "file") ? found.rest.join("/") : null;
|
|
17925
|
+
if (!found || shown === null) throw new Error(`${file} is not a file of a served skill`);
|
|
17926
|
+
return fs.readFile(path.join(found.source.folder, shown));
|
|
17462
17927
|
}
|
|
17463
17928
|
};
|
|
17464
17929
|
}
|
|
@@ -18334,21 +18799,23 @@ var DevtoolMcp = class {
|
|
|
18334
18799
|
setInterval(() => this.closeIdleSessions(), SESSION_SWEEP_MS).unref();
|
|
18335
18800
|
}
|
|
18336
18801
|
/**
|
|
18337
|
-
* Applies the configuration:
|
|
18338
|
-
* is
|
|
18802
|
+
* Applies the configuration: the skills it serves, given their folders and filters before anything is waited
|
|
18803
|
+
* for so that no skill is served under the rules replaced, then its rules, every session closed when the
|
|
18804
|
+
* server is disabled.
|
|
18339
18805
|
*/
|
|
18340
18806
|
async configure() {
|
|
18341
18807
|
const { adt, projects } = this._host.config;
|
|
18342
|
-
|
|
18343
|
-
await this._skills.configure([...adt.mcp.skills ? [{
|
|
18808
|
+
const skills = this._skills.configure([...adt.mcp.skills ? [{
|
|
18344
18809
|
prefix: "devtool",
|
|
18345
18810
|
folder: this._host.skillsFolder,
|
|
18346
18811
|
include: ["*"]
|
|
18347
18812
|
}] : [], ...Object.values(projects).flatMap((project) => Object.values(project.directories).flatMap((directory) => Object.values(directory.files).flatMap((files) => files.mcpSkills ? [{
|
|
18348
18813
|
prefix: `files/${project.slug}/${directory.slug}/${files.slug}`,
|
|
18349
18814
|
folder: files.path,
|
|
18350
|
-
include: files.mcpSkills
|
|
18815
|
+
include: files.mcpSkills,
|
|
18816
|
+
filter: new FileFilter(files)
|
|
18351
18817
|
}] : [])))]);
|
|
18818
|
+
await Promise.all([skills, this.approvals.configure(adt.mcp, adt.cacheDir)]);
|
|
18352
18819
|
if (!adt.mcp.enabled) await Promise.all([...this._sessions.values()].map((session) => session.transport.close()));
|
|
18353
18820
|
}
|
|
18354
18821
|
/**
|
|
@@ -19389,9 +19856,10 @@ var DevtoolServer = class DevtoolServer {
|
|
|
19389
19856
|
} : tree, ws);
|
|
19390
19857
|
}
|
|
19391
19858
|
/**
|
|
19392
|
-
* Writes a file
|
|
19393
|
-
*
|
|
19394
|
-
*
|
|
19859
|
+
* Writes a file through its space as it stands once the write runs in turn, and reads the configuration again
|
|
19860
|
+
* when the files it is read from changed, applies it, a failure being reported, then sends the new state of the
|
|
19861
|
+
* file to the interface that asked and, once written, the files of its space to every interface before running
|
|
19862
|
+
* what the space does after a write.
|
|
19395
19863
|
* @param spaceId The identifier of the space.
|
|
19396
19864
|
* @param filePath The path of the file.
|
|
19397
19865
|
* @param content Its new content.
|
|
@@ -19399,8 +19867,8 @@ var DevtoolServer = class DevtoolServer {
|
|
|
19399
19867
|
* @param ws The connection of the interface.
|
|
19400
19868
|
*/
|
|
19401
19869
|
async writeFile(spaceId, filePath, content, baseUpdatedAt, ws) {
|
|
19402
|
-
const space = this.fileSpaces.get(spaceId);
|
|
19403
19870
|
const { file, reloaded } = await this.serializeFileChange(async () => {
|
|
19871
|
+
const space = this.fileSpaces.get(spaceId);
|
|
19404
19872
|
const before = await this.fileSpaces.configSnapshot();
|
|
19405
19873
|
const written = space ? await space.write(filePath, content, baseUpdatedAt) : unknownSpaceFile(spaceId, filePath);
|
|
19406
19874
|
return {
|
|
@@ -19470,16 +19938,20 @@ var DevtoolServer = class DevtoolServer {
|
|
|
19470
19938
|
});
|
|
19471
19939
|
}
|
|
19472
19940
|
/**
|
|
19473
|
-
* Changes the files and folders of a space for a person,
|
|
19474
|
-
* is read from changed and applies it, then sends
|
|
19941
|
+
* Changes the files and folders of a space for a person, through the space as it stands once the change runs
|
|
19942
|
+
* in turn, reads the configuration again when the files it is read from changed and applies it, then sends
|
|
19943
|
+
* the files of the space to every interface.
|
|
19475
19944
|
* @param spaceId The identifier of the space.
|
|
19476
19945
|
* @param change Changes the files of the space.
|
|
19477
19946
|
* @returns Why the change was refused, null once done.
|
|
19478
19947
|
*/
|
|
19479
19948
|
async changeFiles(spaceId, change) {
|
|
19480
|
-
const space = this.fileSpaces.get(spaceId);
|
|
19481
|
-
if (!space) return `${spaceId} is not a file space`;
|
|
19482
19949
|
const { error, reloaded } = await this.serializeFileChange(async () => {
|
|
19950
|
+
const space = this.fileSpaces.get(spaceId);
|
|
19951
|
+
if (!space) return {
|
|
19952
|
+
error: `${spaceId} is not a file space`,
|
|
19953
|
+
reloaded: false
|
|
19954
|
+
};
|
|
19483
19955
|
const before = await this.fileSpaces.configSnapshot();
|
|
19484
19956
|
try {
|
|
19485
19957
|
await change(space);
|
|
@@ -19499,20 +19971,24 @@ var DevtoolServer = class DevtoolServer {
|
|
|
19499
19971
|
return error;
|
|
19500
19972
|
}
|
|
19501
19973
|
/**
|
|
19502
|
-
* Makes a change of files of an agent in a space as agents see it,
|
|
19503
|
-
*
|
|
19504
|
-
*
|
|
19505
|
-
* that cannot be fully undone is shown as a warning
|
|
19974
|
+
* Makes a change of files of an agent in a space as agents see it, once the change runs in turn and only while the
|
|
19975
|
+
* space is still the one the change was allowed for, undone and refused when it changes the files the configuration
|
|
19976
|
+
* of the devtool is read from, the configuration then read again when the files restored differ from those read
|
|
19977
|
+
* last, and applied without the answer waiting for it; a change that cannot be fully undone is shown as a warning
|
|
19978
|
+
* of the configuration, naming the paths left.
|
|
19506
19979
|
* @param spaceId The identifier of the space.
|
|
19507
19980
|
* @param change The change.
|
|
19981
|
+
* @param allowed The space as it stood when the change was allowed.
|
|
19508
19982
|
* @returns The file written for a write, or the refusal once the change is undone.
|
|
19509
|
-
* @throws {Error} When the space is unknown, the change fails, or it cannot be
|
|
19983
|
+
* @throws {Error} When the space is unknown or was replaced by a reload since, the change fails, or it cannot be
|
|
19984
|
+
* undone.
|
|
19510
19985
|
*/
|
|
19511
|
-
async changeAsAgent(spaceId, change) {
|
|
19512
|
-
const space = this.fileSpaces.getForAgents(spaceId);
|
|
19513
|
-
if (!space) throw new Error(`${spaceId} is not a file space`);
|
|
19986
|
+
async changeAsAgent(spaceId, change, allowed) {
|
|
19514
19987
|
try {
|
|
19515
19988
|
const { outcome, reloaded } = await this.serializeFileChange(async () => {
|
|
19989
|
+
const space = this.fileSpaces.getForAgents(spaceId);
|
|
19990
|
+
if (!space) throw new Error(`${spaceId} is not a file space`);
|
|
19991
|
+
if (space !== allowed) throw new Error(`${spaceId} changed with the configuration since this change was allowed, ask for it again`);
|
|
19516
19992
|
const changed = await changeUnlessConfigChanges(async () => this.fileSpaces.configSnapshot(), async () => applyAgentChange(space, change));
|
|
19517
19993
|
return {
|
|
19518
19994
|
outcome: changed,
|
|
@@ -20128,7 +20604,7 @@ async function renewCertificates(names, configPaths = []) {
|
|
|
20128
20604
|
}
|
|
20129
20605
|
}
|
|
20130
20606
|
// package.json
|
|
20131
|
-
var version = "1.1.
|
|
20607
|
+
var version = "1.1.2";
|
|
20132
20608
|
// src/skills.ts
|
|
20133
20609
|
const MANIFEST = ".devtool-skills.json";
|
|
20134
20610
|
/**
|