@frontman-ai/astro 0.1.5 → 0.1.7
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/index.js +451 -367
- package/dist/integration.js +447 -366
- package/index.d.ts +7 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,6 +4,8 @@ import { existsSync, readFileSync } from 'fs';
|
|
|
4
4
|
import * as Nodepath from 'path';
|
|
5
5
|
import { dirname, join } from 'path';
|
|
6
6
|
import { createRequire } from 'module';
|
|
7
|
+
import * as Nodebuffer from 'buffer';
|
|
8
|
+
import * as Nodechild_process from 'child_process';
|
|
7
9
|
|
|
8
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
11
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
@@ -16,19 +18,14 @@ var __commonJS = (cb, mod) => function __require2() {
|
|
|
16
18
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
|
-
// ../../node_modules/
|
|
21
|
+
// ../../node_modules/@vscode/ripgrep/lib/index.js
|
|
20
22
|
var require_lib = __commonJS({
|
|
21
|
-
"../../node_modules/
|
|
23
|
+
"../../node_modules/@vscode/ripgrep/lib/index.js"(exports$1, module) {
|
|
22
24
|
var path = __require("path");
|
|
23
25
|
module.exports.rgPath = path.join(__dirname, `../bin/rg${process.platform === "win32" ? ".exe" : ""}`);
|
|
24
26
|
}
|
|
25
27
|
});
|
|
26
28
|
|
|
27
|
-
// ../../node_modules/@rescript/runtime/lib/es6/Stdlib_JsError.js
|
|
28
|
-
function throwWithMessage(str) {
|
|
29
|
-
throw new Error(str);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
29
|
// ../../node_modules/@rescript/runtime/lib/es6/Primitive_option.js
|
|
33
30
|
function some(x) {
|
|
34
31
|
if (x === void 0) {
|
|
@@ -94,30 +91,43 @@ function orElse(opt, other) {
|
|
|
94
91
|
return other;
|
|
95
92
|
}
|
|
96
93
|
}
|
|
94
|
+
function isSome(x) {
|
|
95
|
+
return x !== void 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ../frontman-core/src/FrontmanCore__Hosts.res.mjs
|
|
99
|
+
var apiHost = "api.frontman.sh";
|
|
100
|
+
var clientJs = "https://app.frontman.sh/frontman.es.js";
|
|
101
|
+
var clientCss = "https://app.frontman.sh/frontman.css";
|
|
102
|
+
var devClientJs = "http://localhost:5173/src/Main.res.mjs";
|
|
97
103
|
|
|
98
104
|
// src/FrontmanAstro__Config.res.mjs
|
|
99
105
|
var host = process.env["FRONTMAN_HOST"];
|
|
100
|
-
var defaultHost = host !== void 0 ? host :
|
|
106
|
+
var defaultHost = host !== void 0 ? host : apiHost;
|
|
101
107
|
var ensureConfig = (function(c2) {
|
|
102
108
|
return c2 || {};
|
|
103
109
|
});
|
|
104
110
|
function makeFromObject(rawConfig) {
|
|
105
111
|
let config = ensureConfig(rawConfig);
|
|
112
|
+
let host2 = getOr(config.host, defaultHost);
|
|
113
|
+
let isDev = host2 !== apiHost;
|
|
106
114
|
let projectRoot = getOr(orElse(config.projectRoot, orElse(process.env["PROJECT_ROOT"], process.env["PWD"])), ".");
|
|
107
115
|
let sourceRoot = getOr(config.sourceRoot, projectRoot);
|
|
108
116
|
let basePath = getOr(config.basePath, "frontman");
|
|
109
117
|
let serverName = getOr(config.serverName, "frontman-astro");
|
|
110
118
|
let serverVersion = getOr(config.serverVersion, "1.0.0");
|
|
111
119
|
let isLightTheme = getOr(config.isLightTheme, false);
|
|
112
|
-
let
|
|
113
|
-
let baseUrl = getOr(process.env["FRONTMAN_CLIENT_URL"], "http://localhost:5173/src/Main.res.mjs");
|
|
120
|
+
let baseUrl = getOr(config.clientUrl, getOr(process.env["FRONTMAN_CLIENT_URL"], isDev ? devClientJs : clientJs));
|
|
114
121
|
let url2 = new URL(baseUrl);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (!parsedUrl.searchParams.has("host")) {
|
|
118
|
-
throwWithMessage(`[frontman-astro] clientUrl must include a "host" query parameter. Got: ` + clientUrl);
|
|
122
|
+
if (url2.searchParams.has("clientName")) ; else {
|
|
123
|
+
url2.searchParams.set("clientName", "astro");
|
|
119
124
|
}
|
|
125
|
+
if (url2.searchParams.has("host")) ; else {
|
|
126
|
+
url2.searchParams.set("host", host2);
|
|
127
|
+
}
|
|
128
|
+
let clientUrl = url2.href;
|
|
120
129
|
return {
|
|
130
|
+
isDev,
|
|
121
131
|
projectRoot,
|
|
122
132
|
sourceRoot,
|
|
123
133
|
basePath,
|
|
@@ -125,6 +135,7 @@ function makeFromObject(rawConfig) {
|
|
|
125
135
|
serverVersion,
|
|
126
136
|
host: host2,
|
|
127
137
|
clientUrl,
|
|
138
|
+
clientCssUrl: orElse(config.clientCssUrl, isDev ? void 0 : clientCss),
|
|
128
139
|
isLightTheme
|
|
129
140
|
};
|
|
130
141
|
}
|
|
@@ -1997,6 +2008,7 @@ var ctx = {
|
|
|
1997
2008
|
function factory$4(definer) {
|
|
1998
2009
|
return definitionToSchema(definer(ctx));
|
|
1999
2010
|
}
|
|
2011
|
+
var js_schema = definitionToSchema;
|
|
2000
2012
|
function option(item) {
|
|
2001
2013
|
return factory$1(item, unit);
|
|
2002
2014
|
}
|
|
@@ -2236,8 +2248,10 @@ function toJSONSchema(schema3) {
|
|
|
2236
2248
|
}
|
|
2237
2249
|
return jsonSchema;
|
|
2238
2250
|
}
|
|
2251
|
+
var literal = js_schema;
|
|
2239
2252
|
var array = factory$2;
|
|
2240
2253
|
var dict = factory$3;
|
|
2254
|
+
var union = factory;
|
|
2241
2255
|
var schema = factory$4;
|
|
2242
2256
|
|
|
2243
2257
|
// ../../node_modules/sury/src/S.res.mjs
|
|
@@ -2247,9 +2261,11 @@ var bool2 = bool;
|
|
|
2247
2261
|
var int2 = int;
|
|
2248
2262
|
var json2 = json;
|
|
2249
2263
|
var enableJson2 = enableJson;
|
|
2264
|
+
var literal2 = literal;
|
|
2250
2265
|
var array2 = array;
|
|
2251
2266
|
var dict2 = dict;
|
|
2252
2267
|
var option2 = option;
|
|
2268
|
+
var union2 = union;
|
|
2253
2269
|
var parseOrThrow2 = parseOrThrow;
|
|
2254
2270
|
var reverseConvertToJsonOrThrow2 = reverseConvertToJsonOrThrow;
|
|
2255
2271
|
var schema2 = schema;
|
|
@@ -4004,69 +4020,160 @@ function fromString2(x, radix) {
|
|
|
4004
4020
|
return maybeInt | 0;
|
|
4005
4021
|
}
|
|
4006
4022
|
}
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4023
|
+
function execPromise(command, options) {
|
|
4024
|
+
return new Promise((resolve3, _reject) => {
|
|
4025
|
+
let cwd = options.cwd;
|
|
4026
|
+
let env = options.env;
|
|
4027
|
+
let maxBuffer = getOr(options.maxBuffer, 52428800);
|
|
4028
|
+
Nodechild_process.exec(command, {
|
|
4029
|
+
cwd,
|
|
4030
|
+
env,
|
|
4031
|
+
maxBuffer,
|
|
4032
|
+
encoding: "utf8"
|
|
4033
|
+
}, (err, stdout, stderr) => {
|
|
4034
|
+
if (err == null) {
|
|
4035
|
+
return resolve3({
|
|
4036
|
+
TAG: "Ok",
|
|
4037
|
+
_0: {
|
|
4038
|
+
stdout,
|
|
4039
|
+
stderr
|
|
4040
|
+
}
|
|
4041
|
+
});
|
|
4042
|
+
} else {
|
|
4043
|
+
return resolve3({
|
|
4044
|
+
TAG: "Error",
|
|
4045
|
+
_0: {
|
|
4046
|
+
code: fromNullable(err.code),
|
|
4047
|
+
stdout,
|
|
4048
|
+
stderr,
|
|
4049
|
+
message: err.message
|
|
4050
|
+
}
|
|
4051
|
+
});
|
|
4031
4052
|
}
|
|
4053
|
+
});
|
|
4054
|
+
});
|
|
4055
|
+
}
|
|
4056
|
+
function spawnPromise(command, args, options) {
|
|
4057
|
+
let maxBuffer = getOr(options.maxBuffer, 52428800);
|
|
4058
|
+
return new Promise((resolve3, _reject) => {
|
|
4059
|
+
let cwd = options.cwd;
|
|
4060
|
+
let env = options.env;
|
|
4061
|
+
let proc = Nodechild_process.spawn(command, args, {
|
|
4062
|
+
cwd,
|
|
4063
|
+
env
|
|
4064
|
+
});
|
|
4065
|
+
let stdoutChunks = {
|
|
4066
|
+
contents: []
|
|
4032
4067
|
};
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
let actualError = getOr(fromNullable(exn._1), exn);
|
|
4036
|
-
return {
|
|
4037
|
-
TAG: "Error",
|
|
4038
|
-
_0: {
|
|
4039
|
-
code: fromNullable(actualError.code),
|
|
4040
|
-
stdout: getOr(map(fromNullable(actualError.stdout), bufferToString), ""),
|
|
4041
|
-
stderr: getOr(map(fromNullable(actualError.stderr), bufferToString), "")
|
|
4042
|
-
}
|
|
4068
|
+
let stderrChunks = {
|
|
4069
|
+
contents: []
|
|
4043
4070
|
};
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
let
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4071
|
+
let stdoutLen = {
|
|
4072
|
+
contents: 0
|
|
4073
|
+
};
|
|
4074
|
+
let stderrLen = {
|
|
4075
|
+
contents: 0
|
|
4076
|
+
};
|
|
4077
|
+
let resolved = {
|
|
4078
|
+
contents: false
|
|
4079
|
+
};
|
|
4080
|
+
let guardedResolve = (value) => {
|
|
4081
|
+
if (resolved.contents) {
|
|
4082
|
+
return;
|
|
4083
|
+
} else {
|
|
4084
|
+
resolved.contents = true;
|
|
4085
|
+
return resolve3(value);
|
|
4056
4086
|
}
|
|
4057
4087
|
};
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4088
|
+
proc.stdout.on("data", (chunk) => {
|
|
4089
|
+
if (resolved.contents) {
|
|
4090
|
+
return;
|
|
4091
|
+
} else {
|
|
4092
|
+
stdoutChunks.contents.push(chunk);
|
|
4093
|
+
stdoutLen.contents = stdoutLen.contents + chunk.byteLength | 0;
|
|
4094
|
+
if (stdoutLen.contents > maxBuffer) {
|
|
4095
|
+
proc.kill("SIGTERM");
|
|
4096
|
+
return guardedResolve({
|
|
4097
|
+
TAG: "Error",
|
|
4098
|
+
_0: {
|
|
4099
|
+
code: void 0,
|
|
4100
|
+
stdout: Nodebuffer.Buffer.concat(stdoutChunks.contents).toString("utf8"),
|
|
4101
|
+
stderr: Nodebuffer.Buffer.concat(stderrChunks.contents).toString("utf8"),
|
|
4102
|
+
message: "stdout maxBuffer exceeded"
|
|
4103
|
+
}
|
|
4104
|
+
});
|
|
4105
|
+
} else {
|
|
4106
|
+
return;
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
});
|
|
4110
|
+
proc.stderr.on("data", (chunk) => {
|
|
4111
|
+
if (resolved.contents) {
|
|
4112
|
+
return;
|
|
4113
|
+
} else {
|
|
4114
|
+
stderrChunks.contents.push(chunk);
|
|
4115
|
+
stderrLen.contents = stderrLen.contents + chunk.byteLength | 0;
|
|
4116
|
+
if (stderrLen.contents > maxBuffer) {
|
|
4117
|
+
proc.kill("SIGTERM");
|
|
4118
|
+
return guardedResolve({
|
|
4119
|
+
TAG: "Error",
|
|
4120
|
+
_0: {
|
|
4121
|
+
code: void 0,
|
|
4122
|
+
stdout: Nodebuffer.Buffer.concat(stdoutChunks.contents).toString("utf8"),
|
|
4123
|
+
stderr: Nodebuffer.Buffer.concat(stderrChunks.contents).toString("utf8"),
|
|
4124
|
+
message: "stderr maxBuffer exceeded"
|
|
4125
|
+
}
|
|
4126
|
+
});
|
|
4127
|
+
} else {
|
|
4128
|
+
return;
|
|
4129
|
+
}
|
|
4130
|
+
}
|
|
4131
|
+
});
|
|
4132
|
+
proc.on("error", (err) => guardedResolve({
|
|
4062
4133
|
TAG: "Error",
|
|
4063
4134
|
_0: {
|
|
4064
|
-
code:
|
|
4065
|
-
stdout:
|
|
4066
|
-
stderr:
|
|
4135
|
+
code: void 0,
|
|
4136
|
+
stdout: Nodebuffer.Buffer.concat(stdoutChunks.contents).toString("utf8"),
|
|
4137
|
+
stderr: Nodebuffer.Buffer.concat(stderrChunks.contents).toString("utf8"),
|
|
4138
|
+
message: err.message
|
|
4067
4139
|
}
|
|
4068
|
-
};
|
|
4069
|
-
|
|
4140
|
+
}));
|
|
4141
|
+
proc.on("close", (nullableCode) => {
|
|
4142
|
+
let code = nullableCode == null ? void 0 : some(nullableCode);
|
|
4143
|
+
if (!(nullableCode == null) && nullableCode === 0) {
|
|
4144
|
+
return guardedResolve({
|
|
4145
|
+
TAG: "Ok",
|
|
4146
|
+
_0: {
|
|
4147
|
+
stdout: Nodebuffer.Buffer.concat(stdoutChunks.contents).toString("utf8"),
|
|
4148
|
+
stderr: Nodebuffer.Buffer.concat(stderrChunks.contents).toString("utf8")
|
|
4149
|
+
}
|
|
4150
|
+
});
|
|
4151
|
+
}
|
|
4152
|
+
let codeStr = nullableCode == null ? "null" : nullableCode.toString();
|
|
4153
|
+
guardedResolve({
|
|
4154
|
+
TAG: "Error",
|
|
4155
|
+
_0: {
|
|
4156
|
+
code,
|
|
4157
|
+
stdout: Nodebuffer.Buffer.concat(stdoutChunks.contents).toString("utf8"),
|
|
4158
|
+
stderr: Nodebuffer.Buffer.concat(stderrChunks.contents).toString("utf8"),
|
|
4159
|
+
message: `Process exited with code ` + codeStr
|
|
4160
|
+
}
|
|
4161
|
+
});
|
|
4162
|
+
});
|
|
4163
|
+
});
|
|
4164
|
+
}
|
|
4165
|
+
async function execWithOptions(command, options) {
|
|
4166
|
+
let newrecord = { ...options };
|
|
4167
|
+
newrecord.maxBuffer = getOr(options.maxBuffer, 52428800);
|
|
4168
|
+
return await execPromise(command, newrecord);
|
|
4169
|
+
}
|
|
4170
|
+
async function spawnResult(command, args, cwd) {
|
|
4171
|
+
let options_maxBuffer = 52428800;
|
|
4172
|
+
let options = {
|
|
4173
|
+
cwd,
|
|
4174
|
+
maxBuffer: options_maxBuffer
|
|
4175
|
+
};
|
|
4176
|
+
return await spawnPromise(command, args, options);
|
|
4070
4177
|
}
|
|
4071
4178
|
function resolve(sourceRoot, inputPath) {
|
|
4072
4179
|
let normalizedRoot = Nodepath.normalize(sourceRoot);
|
|
@@ -4214,14 +4321,14 @@ function getRipgrepPath() {
|
|
|
4214
4321
|
return;
|
|
4215
4322
|
}
|
|
4216
4323
|
}
|
|
4217
|
-
function buildRipgrepArgs(pattern2, searchPath, type_, glob, caseInsensitive,
|
|
4324
|
+
function buildRipgrepArgs(pattern2, searchPath, type_, glob, caseInsensitive, literal3, maxResults) {
|
|
4218
4325
|
let args = [];
|
|
4219
4326
|
args.push("-n");
|
|
4220
4327
|
args.push("-H");
|
|
4221
4328
|
if (caseInsensitive) {
|
|
4222
4329
|
args.push("-i");
|
|
4223
4330
|
}
|
|
4224
|
-
if (
|
|
4331
|
+
if (literal3) {
|
|
4225
4332
|
args.push("-F");
|
|
4226
4333
|
}
|
|
4227
4334
|
args.push("-m");
|
|
@@ -4238,7 +4345,7 @@ function buildRipgrepArgs(pattern2, searchPath, type_, glob, caseInsensitive, li
|
|
|
4238
4345
|
args.push(searchPath);
|
|
4239
4346
|
return args;
|
|
4240
4347
|
}
|
|
4241
|
-
function buildGitGrepArgs(pattern2, caseInsensitive,
|
|
4348
|
+
function buildGitGrepArgs(pattern2, caseInsensitive, literal3, maxResults, glob, type_) {
|
|
4242
4349
|
let args = [
|
|
4243
4350
|
"grep",
|
|
4244
4351
|
"-n",
|
|
@@ -4247,12 +4354,22 @@ function buildGitGrepArgs(pattern2, caseInsensitive, literal2, maxResults) {
|
|
|
4247
4354
|
if (caseInsensitive) {
|
|
4248
4355
|
args.push("-i");
|
|
4249
4356
|
}
|
|
4250
|
-
if (
|
|
4357
|
+
if (literal3) {
|
|
4251
4358
|
args.push("-F");
|
|
4252
4359
|
}
|
|
4253
4360
|
args.push("--max-count");
|
|
4254
4361
|
args.push(maxResults.toString());
|
|
4255
4362
|
args.push(pattern2);
|
|
4363
|
+
let hasPathspec = isSome(glob) || isSome(type_);
|
|
4364
|
+
if (hasPathspec) {
|
|
4365
|
+
args.push("--");
|
|
4366
|
+
if (glob !== void 0) {
|
|
4367
|
+
args.push(glob);
|
|
4368
|
+
}
|
|
4369
|
+
if (type_ !== void 0 && glob === void 0) {
|
|
4370
|
+
args.push(`*.` + type_);
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4256
4373
|
return args;
|
|
4257
4374
|
}
|
|
4258
4375
|
function parseGrepOutput(output, maxResults) {
|
|
@@ -4287,119 +4404,152 @@ function parseGrepOutput(output, maxResults) {
|
|
|
4287
4404
|
});
|
|
4288
4405
|
fileMap[filePath] = matches2;
|
|
4289
4406
|
});
|
|
4290
|
-
let
|
|
4407
|
+
let allFiles = Object.entries(fileMap).map((param) => ({
|
|
4291
4408
|
path: param[0],
|
|
4292
4409
|
matches: param[1]
|
|
4293
|
-
}))
|
|
4410
|
+
}));
|
|
4411
|
+
let totalFiles = allFiles.length;
|
|
4412
|
+
let files = allFiles.slice(0, maxResults);
|
|
4294
4413
|
return {
|
|
4295
4414
|
files,
|
|
4296
4415
|
totalMatches: totalMatches.contents,
|
|
4297
|
-
truncated:
|
|
4416
|
+
truncated: totalFiles > maxResults
|
|
4298
4417
|
};
|
|
4299
4418
|
}
|
|
4300
|
-
async function executeRipgrep(rgPath, pattern2, searchPath, type_, glob, caseInsensitive,
|
|
4301
|
-
let args = buildRipgrepArgs(pattern2, searchPath, type_, glob, caseInsensitive,
|
|
4302
|
-
let
|
|
4303
|
-
|
|
4304
|
-
let result = await exec(command);
|
|
4305
|
-
if (result.TAG === "Ok") {
|
|
4306
|
-
return {
|
|
4307
|
-
TAG: "Ok",
|
|
4308
|
-
_0: parseGrepOutput(result._0.stdout, maxResults)
|
|
4309
|
-
};
|
|
4310
|
-
}
|
|
4311
|
-
let match = result._0;
|
|
4312
|
-
let match$1 = match.code;
|
|
4313
|
-
let exit = 0;
|
|
4314
|
-
if (match$1 !== void 0) {
|
|
4315
|
-
if (match$1 === 1) {
|
|
4316
|
-
return {
|
|
4317
|
-
TAG: "Ok",
|
|
4318
|
-
_0: {
|
|
4319
|
-
files: [],
|
|
4320
|
-
totalMatches: 0,
|
|
4321
|
-
truncated: false
|
|
4322
|
-
}
|
|
4323
|
-
};
|
|
4324
|
-
}
|
|
4325
|
-
exit = 1;
|
|
4326
|
-
} else {
|
|
4327
|
-
exit = 1;
|
|
4328
|
-
}
|
|
4329
|
-
if (exit === 1) {
|
|
4330
|
-
return {
|
|
4331
|
-
TAG: "Error",
|
|
4332
|
-
_0: `Ripgrep failed: ` + match.stderr
|
|
4333
|
-
};
|
|
4334
|
-
}
|
|
4335
|
-
} catch (raw_exn) {
|
|
4336
|
-
let exn = internalToException(raw_exn);
|
|
4337
|
-
let msg = getOr(flatMap(fromException(exn), message2), "Unknown error");
|
|
4419
|
+
async function executeRipgrep(rgPath, pattern2, searchPath, type_, glob, caseInsensitive, literal3, maxResults) {
|
|
4420
|
+
let args = buildRipgrepArgs(pattern2, searchPath, type_, glob, caseInsensitive, literal3, maxResults);
|
|
4421
|
+
let result = await spawnResult(rgPath, args, void 0);
|
|
4422
|
+
if (result.TAG === "Ok") {
|
|
4338
4423
|
return {
|
|
4339
|
-
TAG: "
|
|
4340
|
-
_0:
|
|
4424
|
+
TAG: "Ok",
|
|
4425
|
+
_0: parseGrepOutput(result._0.stdout, maxResults)
|
|
4341
4426
|
};
|
|
4342
4427
|
}
|
|
4428
|
+
let match = result._0;
|
|
4429
|
+
let match$1 = match.code;
|
|
4430
|
+
if (match$1 === 1) {
|
|
4431
|
+
return {
|
|
4432
|
+
TAG: "Ok",
|
|
4433
|
+
_0: {
|
|
4434
|
+
files: [],
|
|
4435
|
+
totalMatches: 0,
|
|
4436
|
+
truncated: false
|
|
4437
|
+
}
|
|
4438
|
+
};
|
|
4439
|
+
}
|
|
4440
|
+
let stderr = match.stderr;
|
|
4441
|
+
let detail = stderr === "" ? match.message : stderr;
|
|
4442
|
+
return {
|
|
4443
|
+
TAG: "Error",
|
|
4444
|
+
_0: `Ripgrep failed: ` + detail
|
|
4445
|
+
};
|
|
4343
4446
|
}
|
|
4344
|
-
async function executeGitGrep(pattern2, searchPath, caseInsensitive,
|
|
4345
|
-
let args = buildGitGrepArgs(pattern2, caseInsensitive,
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
TAG: "Ok",
|
|
4363
|
-
_0: {
|
|
4364
|
-
files: [],
|
|
4365
|
-
totalMatches: 0,
|
|
4366
|
-
truncated: false
|
|
4367
|
-
}
|
|
4368
|
-
};
|
|
4447
|
+
async function executeGitGrep(pattern2, searchPath, caseInsensitive, literal3, maxResults, glob, type_) {
|
|
4448
|
+
let args = buildGitGrepArgs(pattern2, caseInsensitive, literal3, maxResults, glob, type_);
|
|
4449
|
+
let result = await spawnResult("git", args, searchPath);
|
|
4450
|
+
if (result.TAG === "Ok") {
|
|
4451
|
+
return {
|
|
4452
|
+
TAG: "Ok",
|
|
4453
|
+
_0: parseGrepOutput(result._0.stdout, maxResults)
|
|
4454
|
+
};
|
|
4455
|
+
}
|
|
4456
|
+
let match = result._0;
|
|
4457
|
+
let code = match.code;
|
|
4458
|
+
if (code === 1) {
|
|
4459
|
+
return {
|
|
4460
|
+
TAG: "Ok",
|
|
4461
|
+
_0: {
|
|
4462
|
+
files: [],
|
|
4463
|
+
totalMatches: 0,
|
|
4464
|
+
truncated: false
|
|
4369
4465
|
}
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4466
|
+
};
|
|
4467
|
+
}
|
|
4468
|
+
let stderr = match.stderr;
|
|
4469
|
+
let codeStr = getOr(map(code, (c2) => c2.toString()), "unknown");
|
|
4470
|
+
let detail = stderr === "" ? match.message : stderr;
|
|
4471
|
+
return {
|
|
4472
|
+
TAG: "Error",
|
|
4473
|
+
_0: `Git grep failed (exit ` + codeStr + `): ` + detail
|
|
4474
|
+
};
|
|
4475
|
+
}
|
|
4476
|
+
function buildPlainGrepArgs(pattern2, searchPath, caseInsensitive, literal3, maxResults, glob, type_) {
|
|
4477
|
+
let args = ["-rn"];
|
|
4478
|
+
if (caseInsensitive) {
|
|
4479
|
+
args.push("-i");
|
|
4480
|
+
}
|
|
4481
|
+
if (literal3) {
|
|
4482
|
+
args.push("-F");
|
|
4483
|
+
}
|
|
4484
|
+
args.push("-m");
|
|
4485
|
+
args.push(maxResults.toString());
|
|
4486
|
+
if (glob !== void 0) {
|
|
4487
|
+
args.push("--include");
|
|
4488
|
+
args.push(glob);
|
|
4489
|
+
} else if (type_ !== void 0) {
|
|
4490
|
+
args.push("--include");
|
|
4491
|
+
args.push(`*.` + type_);
|
|
4492
|
+
}
|
|
4493
|
+
args.push("--exclude-dir=node_modules");
|
|
4494
|
+
args.push("--exclude-dir=.git");
|
|
4495
|
+
args.push("--exclude-dir=dist");
|
|
4496
|
+
args.push("--exclude-dir=build");
|
|
4497
|
+
args.push("--exclude-dir=_build");
|
|
4498
|
+
args.push(pattern2);
|
|
4499
|
+
args.push(searchPath);
|
|
4500
|
+
return args;
|
|
4501
|
+
}
|
|
4502
|
+
async function executePlainGrep(pattern2, searchPath, caseInsensitive, literal3, maxResults, glob, type_) {
|
|
4503
|
+
let args = buildPlainGrepArgs(pattern2, searchPath, caseInsensitive, literal3, maxResults, glob, type_);
|
|
4504
|
+
let result = await spawnResult("grep", args, void 0);
|
|
4505
|
+
if (result.TAG === "Ok") {
|
|
4383
4506
|
return {
|
|
4384
|
-
TAG: "
|
|
4385
|
-
_0:
|
|
4507
|
+
TAG: "Ok",
|
|
4508
|
+
_0: parseGrepOutput(result._0.stdout, maxResults)
|
|
4386
4509
|
};
|
|
4387
4510
|
}
|
|
4511
|
+
let match = result._0;
|
|
4512
|
+
let code = match.code;
|
|
4513
|
+
if (code === 1) {
|
|
4514
|
+
return {
|
|
4515
|
+
TAG: "Ok",
|
|
4516
|
+
_0: {
|
|
4517
|
+
files: [],
|
|
4518
|
+
totalMatches: 0,
|
|
4519
|
+
truncated: false
|
|
4520
|
+
}
|
|
4521
|
+
};
|
|
4522
|
+
}
|
|
4523
|
+
let stderr = match.stderr;
|
|
4524
|
+
let codeStr = getOr(map(code, (c2) => c2.toString()), "unknown");
|
|
4525
|
+
let detail = stderr === "" ? match.message : stderr;
|
|
4526
|
+
return {
|
|
4527
|
+
TAG: "Error",
|
|
4528
|
+
_0: `Grep failed (exit ` + codeStr + `): ` + detail
|
|
4529
|
+
};
|
|
4388
4530
|
}
|
|
4389
4531
|
async function execute(ctx2, input) {
|
|
4390
4532
|
let searchPath = resolveSearchPath(ctx2.sourceRoot, input.path);
|
|
4391
4533
|
let caseInsensitive = getOr(input.case_insensitive, false);
|
|
4392
|
-
let
|
|
4393
|
-
let maxResults = getOr(input.max_results,
|
|
4534
|
+
let literal3 = getOr(input.literal, false);
|
|
4535
|
+
let maxResults = getOr(input.max_results, 20);
|
|
4536
|
+
let gitGrepWithFallback = async () => {
|
|
4537
|
+
let gitResult = await executeGitGrep(input.pattern, searchPath, caseInsensitive, literal3, maxResults, input.glob, input.type);
|
|
4538
|
+
if (gitResult.TAG === "Ok") {
|
|
4539
|
+
return gitResult;
|
|
4540
|
+
} else {
|
|
4541
|
+
return await executePlainGrep(input.pattern, searchPath, caseInsensitive, literal3, maxResults, input.glob, input.type);
|
|
4542
|
+
}
|
|
4543
|
+
};
|
|
4394
4544
|
let rgPath = getRipgrepPath();
|
|
4395
4545
|
if (rgPath === void 0) {
|
|
4396
|
-
return await
|
|
4546
|
+
return await gitGrepWithFallback();
|
|
4397
4547
|
}
|
|
4398
|
-
let result = await executeRipgrep(rgPath, input.pattern, searchPath, input.type, input.glob, caseInsensitive,
|
|
4548
|
+
let result = await executeRipgrep(rgPath, input.pattern, searchPath, input.type, input.glob, caseInsensitive, literal3, maxResults);
|
|
4399
4549
|
if (result.TAG === "Ok") {
|
|
4400
4550
|
return result;
|
|
4401
4551
|
} else {
|
|
4402
|
-
return await
|
|
4552
|
+
return await gitGrepWithFallback();
|
|
4403
4553
|
}
|
|
4404
4554
|
}
|
|
4405
4555
|
var name2 = "grep";
|
|
@@ -4716,7 +4866,6 @@ var outputSchema5 = bool2;
|
|
|
4716
4866
|
var inputSchema6 = schema2((s2) => ({
|
|
4717
4867
|
pattern: s2.m(string2),
|
|
4718
4868
|
path: s2.m(option2(string2)),
|
|
4719
|
-
type: s2.m(option2(string2)),
|
|
4720
4869
|
max_results: s2.m(option2(int2))
|
|
4721
4870
|
}));
|
|
4722
4871
|
var outputSchema6 = schema2((s2) => ({
|
|
@@ -4740,56 +4889,38 @@ function buildRipgrepArgs2(searchPath) {
|
|
|
4740
4889
|
args.push(searchPath);
|
|
4741
4890
|
return args;
|
|
4742
4891
|
}
|
|
4743
|
-
function
|
|
4744
|
-
let
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
return fileName2.includes(part);
|
|
4764
|
-
}
|
|
4765
|
-
} else {
|
|
4766
|
-
return false;
|
|
4767
|
-
}
|
|
4768
|
-
});
|
|
4769
|
-
} else {
|
|
4770
|
-
patternMatches = fileName2.includes(patternLower);
|
|
4771
|
-
}
|
|
4772
|
-
let typeMatches;
|
|
4773
|
-
if (type_ !== void 0) {
|
|
4774
|
-
switch (type_) {
|
|
4775
|
-
case "directory":
|
|
4776
|
-
typeMatches = filePath.endsWith("/");
|
|
4777
|
-
break;
|
|
4778
|
-
case "file":
|
|
4779
|
-
typeMatches = !filePath.endsWith("/");
|
|
4780
|
-
break;
|
|
4781
|
-
default:
|
|
4782
|
-
typeMatches = true;
|
|
4892
|
+
function matchesPattern(fileName2, patternLower) {
|
|
4893
|
+
let fileNameLower = fileName2.toLowerCase();
|
|
4894
|
+
if (patternLower === "") {
|
|
4895
|
+
return true;
|
|
4896
|
+
}
|
|
4897
|
+
if (!patternLower.includes("*")) {
|
|
4898
|
+
return fileNameLower.includes(patternLower);
|
|
4899
|
+
}
|
|
4900
|
+
let parts = patternLower.split("*");
|
|
4901
|
+
let partsLength = parts.length;
|
|
4902
|
+
return reduceWithIndex(parts, true, (matches2, part, idx) => {
|
|
4903
|
+
if (matches2) {
|
|
4904
|
+
if (part === "") {
|
|
4905
|
+
return true;
|
|
4906
|
+
} else if (idx === 0) {
|
|
4907
|
+
return fileNameLower.startsWith(part);
|
|
4908
|
+
} else if (idx === (partsLength - 1 | 0)) {
|
|
4909
|
+
return fileNameLower.endsWith(part);
|
|
4910
|
+
} else {
|
|
4911
|
+
return fileNameLower.includes(part);
|
|
4783
4912
|
}
|
|
4784
|
-
} else {
|
|
4785
|
-
typeMatches = true;
|
|
4786
|
-
}
|
|
4787
|
-
if (patternMatches) {
|
|
4788
|
-
return typeMatches;
|
|
4789
4913
|
} else {
|
|
4790
4914
|
return false;
|
|
4791
4915
|
}
|
|
4792
4916
|
});
|
|
4917
|
+
}
|
|
4918
|
+
function filterAndPaginate(lines, pattern2, maxResults) {
|
|
4919
|
+
let patternLower = pattern2.toLowerCase();
|
|
4920
|
+
let matchedFiles = lines.filter((filePath) => {
|
|
4921
|
+
let fileName2 = Nodepath.basename(filePath);
|
|
4922
|
+
return matchesPattern(fileName2, patternLower);
|
|
4923
|
+
});
|
|
4793
4924
|
let truncated = matchedFiles.length > maxResults;
|
|
4794
4925
|
let files = matchedFiles.slice(0, maxResults);
|
|
4795
4926
|
return {
|
|
@@ -4798,113 +4929,67 @@ function parseRipgrepOutput(output, pattern2, type_, maxResults) {
|
|
|
4798
4929
|
truncated
|
|
4799
4930
|
};
|
|
4800
4931
|
}
|
|
4801
|
-
function
|
|
4802
|
-
let lines = output.trim().split("\n").filter((line) => line !== "");
|
|
4803
|
-
let truncated = lines.length > maxResults;
|
|
4804
|
-
let files = lines.slice(0, maxResults);
|
|
4805
|
-
return {
|
|
4806
|
-
files,
|
|
4807
|
-
totalResults: lines.length,
|
|
4808
|
-
truncated
|
|
4809
|
-
};
|
|
4810
|
-
}
|
|
4811
|
-
async function executeRipgrep2(rgPath, pattern2, searchPath, type_, maxResults) {
|
|
4932
|
+
async function executeRipgrep2(rgPath, pattern2, searchPath, maxResults) {
|
|
4812
4933
|
let args = buildRipgrepArgs2(searchPath);
|
|
4813
|
-
let
|
|
4814
|
-
|
|
4815
|
-
let
|
|
4816
|
-
if (result.TAG === "Ok") {
|
|
4817
|
-
return {
|
|
4818
|
-
TAG: "Ok",
|
|
4819
|
-
_0: parseRipgrepOutput(result._0.stdout, pattern2, type_, maxResults)
|
|
4820
|
-
};
|
|
4821
|
-
}
|
|
4822
|
-
let match = result._0;
|
|
4823
|
-
let match$1 = match.code;
|
|
4824
|
-
let exit = 0;
|
|
4825
|
-
if (match$1 !== void 0) {
|
|
4826
|
-
if (match$1 === 1) {
|
|
4827
|
-
return {
|
|
4828
|
-
TAG: "Ok",
|
|
4829
|
-
_0: {
|
|
4830
|
-
files: [],
|
|
4831
|
-
totalResults: 0,
|
|
4832
|
-
truncated: false
|
|
4833
|
-
}
|
|
4834
|
-
};
|
|
4835
|
-
}
|
|
4836
|
-
exit = 1;
|
|
4837
|
-
} else {
|
|
4838
|
-
exit = 1;
|
|
4839
|
-
}
|
|
4840
|
-
if (exit === 1) {
|
|
4841
|
-
return {
|
|
4842
|
-
TAG: "Error",
|
|
4843
|
-
_0: `Ripgrep failed: ` + match.stderr
|
|
4844
|
-
};
|
|
4845
|
-
}
|
|
4846
|
-
} catch (raw_exn) {
|
|
4847
|
-
let exn = internalToException(raw_exn);
|
|
4848
|
-
let msg = getOr(flatMap(fromException(exn), message2), "Unknown error");
|
|
4934
|
+
let result = await spawnResult(rgPath, args, void 0);
|
|
4935
|
+
if (result.TAG === "Ok") {
|
|
4936
|
+
let lines = result._0.stdout.trim().split("\n").filter((line) => line !== "");
|
|
4849
4937
|
return {
|
|
4850
|
-
TAG: "
|
|
4851
|
-
_0:
|
|
4938
|
+
TAG: "Ok",
|
|
4939
|
+
_0: filterAndPaginate(lines, pattern2, maxResults)
|
|
4852
4940
|
};
|
|
4853
4941
|
}
|
|
4942
|
+
let match = result._0;
|
|
4943
|
+
let match$1 = match.code;
|
|
4944
|
+
if (match$1 === 1) {
|
|
4945
|
+
return {
|
|
4946
|
+
TAG: "Ok",
|
|
4947
|
+
_0: {
|
|
4948
|
+
files: [],
|
|
4949
|
+
totalResults: 0,
|
|
4950
|
+
truncated: false
|
|
4951
|
+
}
|
|
4952
|
+
};
|
|
4953
|
+
}
|
|
4954
|
+
return {
|
|
4955
|
+
TAG: "Error",
|
|
4956
|
+
_0: `Ripgrep failed: ` + match.stderr
|
|
4957
|
+
};
|
|
4854
4958
|
}
|
|
4855
4959
|
async function executeGitLsFiles(pattern2, searchPath, maxResults) {
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
let
|
|
4859
|
-
cwd: searchPath
|
|
4860
|
-
});
|
|
4861
|
-
if (result.TAG === "Ok") {
|
|
4862
|
-
return {
|
|
4863
|
-
TAG: "Ok",
|
|
4864
|
-
_0: parseGitLsFilesOutput(result._0.stdout, maxResults)
|
|
4865
|
-
};
|
|
4866
|
-
}
|
|
4867
|
-
let match = result._0;
|
|
4868
|
-
let match$1 = match.code;
|
|
4869
|
-
let exit = 0;
|
|
4870
|
-
if (match$1 !== void 0) {
|
|
4871
|
-
if (match$1 === 1) {
|
|
4872
|
-
return {
|
|
4873
|
-
TAG: "Ok",
|
|
4874
|
-
_0: {
|
|
4875
|
-
files: [],
|
|
4876
|
-
totalResults: 0,
|
|
4877
|
-
truncated: false
|
|
4878
|
-
}
|
|
4879
|
-
};
|
|
4880
|
-
}
|
|
4881
|
-
exit = 1;
|
|
4882
|
-
} else {
|
|
4883
|
-
exit = 1;
|
|
4884
|
-
}
|
|
4885
|
-
if (exit === 1) {
|
|
4886
|
-
return {
|
|
4887
|
-
TAG: "Error",
|
|
4888
|
-
_0: `Git ls-files failed: ` + match.stderr
|
|
4889
|
-
};
|
|
4890
|
-
}
|
|
4891
|
-
} catch (raw_exn) {
|
|
4892
|
-
let exn = internalToException(raw_exn);
|
|
4893
|
-
let msg = getOr(flatMap(fromException(exn), message2), "Unknown error");
|
|
4960
|
+
let result = await spawnResult("git", ["ls-files"], searchPath);
|
|
4961
|
+
if (result.TAG === "Ok") {
|
|
4962
|
+
let lines = result._0.stdout.trim().split("\n").filter((line) => line !== "");
|
|
4894
4963
|
return {
|
|
4895
|
-
TAG: "
|
|
4896
|
-
_0:
|
|
4964
|
+
TAG: "Ok",
|
|
4965
|
+
_0: filterAndPaginate(lines, pattern2, maxResults)
|
|
4897
4966
|
};
|
|
4898
4967
|
}
|
|
4968
|
+
let match = result._0;
|
|
4969
|
+
let match$1 = match.code;
|
|
4970
|
+
if (match$1 === 1) {
|
|
4971
|
+
return {
|
|
4972
|
+
TAG: "Ok",
|
|
4973
|
+
_0: {
|
|
4974
|
+
files: [],
|
|
4975
|
+
totalResults: 0,
|
|
4976
|
+
truncated: false
|
|
4977
|
+
}
|
|
4978
|
+
};
|
|
4979
|
+
}
|
|
4980
|
+
return {
|
|
4981
|
+
TAG: "Error",
|
|
4982
|
+
_0: `Git ls-files failed: ` + match.stderr
|
|
4983
|
+
};
|
|
4899
4984
|
}
|
|
4900
4985
|
async function execute6(ctx2, input) {
|
|
4901
4986
|
let searchPath = resolveSearchPath(ctx2.sourceRoot, input.path);
|
|
4902
|
-
let maxResults = getOr(input.max_results,
|
|
4987
|
+
let maxResults = getOr(input.max_results, 20);
|
|
4903
4988
|
let rgPath = getRipgrepPath2();
|
|
4904
4989
|
if (rgPath === void 0) {
|
|
4905
4990
|
return await executeGitLsFiles(input.pattern, searchPath, maxResults);
|
|
4906
4991
|
}
|
|
4907
|
-
let result = await executeRipgrep2(rgPath, input.pattern, searchPath,
|
|
4992
|
+
let result = await executeRipgrep2(rgPath, input.pattern, searchPath, maxResults);
|
|
4908
4993
|
if (result.TAG === "Ok") {
|
|
4909
4994
|
return result;
|
|
4910
4995
|
} else {
|
|
@@ -4912,34 +4997,34 @@ async function execute6(ctx2, input) {
|
|
|
4912
4997
|
}
|
|
4913
4998
|
}
|
|
4914
4999
|
var name7 = "search_files";
|
|
4915
|
-
var description6 = `Fast file
|
|
5000
|
+
var description6 = `Fast file name search tool that finds files matching a pattern.
|
|
4916
5001
|
|
|
4917
5002
|
WHEN TO USE THIS TOOL:
|
|
4918
|
-
- Use when you need to find files
|
|
5003
|
+
- Use when you need to find files by name pattern
|
|
4919
5004
|
- Great for locating specific files like "config.json" or "*.test.ts"
|
|
4920
5005
|
- Useful for finding all files with a specific extension or naming convention
|
|
4921
5006
|
- When you need to discover the file structure of a project
|
|
5007
|
+
- Note: this tool only searches file names, not directory names. Use list_files to browse directories.
|
|
4922
5008
|
|
|
4923
5009
|
PARAMETERS:
|
|
4924
5010
|
- pattern (required): The filename pattern to search for (supports glob-like patterns)
|
|
4925
5011
|
- path (optional): Directory to search in (defaults to source root)
|
|
4926
|
-
- type (optional): Filter by type - "file" for files only, "directory" for directories only
|
|
4927
5012
|
- max_results (optional): Maximum number of results to return (default: 20)
|
|
4928
5013
|
|
|
4929
5014
|
EXAMPLES:
|
|
4930
5015
|
- Find all config files: pattern="config"
|
|
4931
5016
|
- Find TypeScript test files: pattern="*.test.ts"
|
|
4932
|
-
- Find directories named "components": pattern="components", type="directory"
|
|
4933
5017
|
- Find files in specific directory: pattern="*.json", path="src/config"
|
|
4934
5018
|
|
|
4935
5019
|
OUTPUT:
|
|
4936
|
-
Returns list of matching file
|
|
5020
|
+
Returns list of matching file paths.
|
|
4937
5021
|
Results are sorted by modification time (newest first).
|
|
4938
5022
|
|
|
4939
5023
|
LIMITATIONS:
|
|
4940
5024
|
- Results limited to max_results (default 20)
|
|
4941
5025
|
- Hidden files (starting with '.') are included
|
|
4942
|
-
- Respects .gitignore when using git ls-files fallback
|
|
5026
|
+
- Respects .gitignore when using git ls-files fallback
|
|
5027
|
+
- Only finds files, not directories`;
|
|
4943
5028
|
var inputSchema7 = schema2((s2) => ({
|
|
4944
5029
|
startPath: s2.m(option2(string2))
|
|
4945
5030
|
}));
|
|
@@ -5325,16 +5410,6 @@ async function handleToolCall(registry, config, req) {
|
|
|
5325
5410
|
status: 400
|
|
5326
5411
|
});
|
|
5327
5412
|
}
|
|
5328
|
-
function toRelativePath2(absolutePath, sourceRoot) {
|
|
5329
|
-
let normalizedRoot = sourceRoot.endsWith("/") ? sourceRoot : sourceRoot + "/";
|
|
5330
|
-
if (absolutePath.startsWith(normalizedRoot)) {
|
|
5331
|
-
return absolutePath.slice(normalizedRoot.length, absolutePath.length);
|
|
5332
|
-
} else if (absolutePath.startsWith(sourceRoot)) {
|
|
5333
|
-
return absolutePath.slice(sourceRoot.length, absolutePath.length);
|
|
5334
|
-
} else {
|
|
5335
|
-
return absolutePath;
|
|
5336
|
-
}
|
|
5337
|
-
}
|
|
5338
5413
|
function corsHeaders() {
|
|
5339
5414
|
return Object.fromEntries([
|
|
5340
5415
|
[
|
|
@@ -5385,7 +5460,7 @@ async function handleResolveSourceLocation(config, req) {
|
|
|
5385
5460
|
parent: void 0
|
|
5386
5461
|
};
|
|
5387
5462
|
let resolved = await Te(sourceLocation);
|
|
5388
|
-
let relativeFile =
|
|
5463
|
+
let relativeFile = toRelativePath(config.sourceRoot, resolved.file);
|
|
5389
5464
|
let responseJson = Object.fromEntries([
|
|
5390
5465
|
[
|
|
5391
5466
|
"componentName",
|
|
@@ -5435,6 +5510,12 @@ async function handleResolveSourceLocation(config, req) {
|
|
|
5435
5510
|
status: 400
|
|
5436
5511
|
});
|
|
5437
5512
|
}
|
|
5513
|
+
var dynamicTypeSchema = union2([
|
|
5514
|
+
literal2("static"),
|
|
5515
|
+
literal2("single"),
|
|
5516
|
+
literal2("rest"),
|
|
5517
|
+
literal2("optional")
|
|
5518
|
+
]);
|
|
5438
5519
|
var inputSchema8 = schema2((s2) => ({
|
|
5439
5520
|
placeholder: s2.m(option2(bool2))
|
|
5440
5521
|
}));
|
|
@@ -5442,34 +5523,22 @@ var pageSchema = schema2((s2) => ({
|
|
|
5442
5523
|
path: s2.m(string2),
|
|
5443
5524
|
file: s2.m(string2),
|
|
5444
5525
|
isDynamic: s2.m(bool2),
|
|
5445
|
-
dynamicType: s2.m(
|
|
5526
|
+
dynamicType: s2.m(dynamicTypeSchema)
|
|
5446
5527
|
}));
|
|
5447
5528
|
var outputSchema8 = array2(pageSchema);
|
|
5448
5529
|
function analyzeDynamicSegment(segment) {
|
|
5449
5530
|
if (segment.startsWith("[[") && segment.endsWith("]]")) {
|
|
5450
|
-
return "
|
|
5531
|
+
return "optional";
|
|
5451
5532
|
} else if (segment.startsWith("[...") && segment.endsWith("]")) {
|
|
5452
|
-
return "
|
|
5533
|
+
return "rest";
|
|
5453
5534
|
} else if (segment.startsWith("[") && segment.endsWith("]")) {
|
|
5454
|
-
return "
|
|
5535
|
+
return "single";
|
|
5455
5536
|
} else {
|
|
5456
|
-
return "
|
|
5457
|
-
}
|
|
5458
|
-
}
|
|
5459
|
-
function dynamicTypeToString(dt) {
|
|
5460
|
-
switch (dt) {
|
|
5461
|
-
case "Static":
|
|
5462
|
-
return "static";
|
|
5463
|
-
case "SingleParam":
|
|
5464
|
-
return "single";
|
|
5465
|
-
case "RestParam":
|
|
5466
|
-
return "rest";
|
|
5467
|
-
case "OptionalParam":
|
|
5468
|
-
return "optional";
|
|
5537
|
+
return "static";
|
|
5469
5538
|
}
|
|
5470
5539
|
}
|
|
5471
5540
|
function isDynamicSegment(segment) {
|
|
5472
|
-
return analyzeDynamicSegment(segment) !== "
|
|
5541
|
+
return analyzeDynamicSegment(segment) !== "static";
|
|
5473
5542
|
}
|
|
5474
5543
|
function fileToRoute(filePath) {
|
|
5475
5544
|
let p2 = filePath.replace(/\.(astro|md|mdx|html)$/, "").replace(/\/index$/, "");
|
|
@@ -5480,71 +5549,81 @@ function fileToRoute(filePath) {
|
|
|
5480
5549
|
}
|
|
5481
5550
|
}
|
|
5482
5551
|
function getMostSignificantDynamicType(segments) {
|
|
5483
|
-
return reduce(segments, "
|
|
5552
|
+
return reduce(segments, "static", (acc, segment) => {
|
|
5484
5553
|
let segType = analyzeDynamicSegment(segment);
|
|
5485
|
-
if (segType === "
|
|
5486
|
-
return "
|
|
5554
|
+
if (segType === "rest") {
|
|
5555
|
+
return "rest";
|
|
5487
5556
|
}
|
|
5488
5557
|
switch (acc) {
|
|
5489
|
-
case "
|
|
5490
|
-
case "
|
|
5558
|
+
case "static":
|
|
5559
|
+
case "single":
|
|
5491
5560
|
break;
|
|
5492
|
-
case "
|
|
5493
|
-
return "
|
|
5494
|
-
case "
|
|
5495
|
-
return "
|
|
5561
|
+
case "rest":
|
|
5562
|
+
return "rest";
|
|
5563
|
+
case "optional":
|
|
5564
|
+
return "optional";
|
|
5496
5565
|
}
|
|
5497
5566
|
switch (segType) {
|
|
5498
|
-
case "
|
|
5499
|
-
if (acc === "
|
|
5500
|
-
return "
|
|
5567
|
+
case "static":
|
|
5568
|
+
if (acc === "static") {
|
|
5569
|
+
return "static";
|
|
5501
5570
|
} else {
|
|
5502
|
-
return "
|
|
5571
|
+
return "single";
|
|
5503
5572
|
}
|
|
5504
|
-
case "
|
|
5505
|
-
return "
|
|
5506
|
-
case "
|
|
5507
|
-
return "
|
|
5573
|
+
case "single":
|
|
5574
|
+
return "single";
|
|
5575
|
+
case "optional":
|
|
5576
|
+
return "optional";
|
|
5508
5577
|
}
|
|
5509
5578
|
});
|
|
5510
5579
|
}
|
|
5511
|
-
async function findPages(baseDir, currentPath, projectRoot) {
|
|
5580
|
+
async function findPages(baseDir, currentPath, projectRoot, sourceRoot) {
|
|
5512
5581
|
let fullPath = Nodepath.join(projectRoot, baseDir, currentPath);
|
|
5513
5582
|
try {
|
|
5514
5583
|
let entries = await Fs2.promises.readdir(fullPath);
|
|
5515
5584
|
return (await Promise.all(entries.map(async (entry) => {
|
|
5516
5585
|
let entryPath = Nodepath.join(fullPath, entry);
|
|
5517
|
-
let stats = await Fs2.promises.
|
|
5586
|
+
let stats = await Fs2.promises.lstat(entryPath);
|
|
5587
|
+
if (stats.isSymbolicLink()) {
|
|
5588
|
+
return [];
|
|
5589
|
+
}
|
|
5518
5590
|
if (stats.isDirectory()) {
|
|
5519
5591
|
if (entry.startsWith("_") || entry === "api" || entry === "components") {
|
|
5520
5592
|
return [];
|
|
5521
5593
|
} else {
|
|
5522
|
-
return await findPages(baseDir, Nodepath.join(currentPath, entry), projectRoot);
|
|
5594
|
+
return await findPages(baseDir, Nodepath.join(currentPath, entry), projectRoot, sourceRoot);
|
|
5523
5595
|
}
|
|
5524
5596
|
}
|
|
5525
5597
|
if (!(entry.endsWith(".astro") || entry.endsWith(".md") || entry.endsWith(".mdx") || entry.endsWith(".html"))) {
|
|
5526
5598
|
return [];
|
|
5527
5599
|
}
|
|
5528
|
-
let
|
|
5529
|
-
let routePath = fileToRoute(
|
|
5530
|
-
let
|
|
5600
|
+
let filePath = Nodepath.join(currentPath, entry);
|
|
5601
|
+
let routePath = fileToRoute(filePath);
|
|
5602
|
+
let filePathNoExt = filePath.replace(/\.(astro|md|mdx|html)$/, "");
|
|
5603
|
+
let segments = filePathNoExt.split("/");
|
|
5531
5604
|
let hasDynamic = segments.some(isDynamicSegment);
|
|
5532
5605
|
let dynType = getMostSignificantDynamicType(segments);
|
|
5606
|
+
let relativeToSourceRoot = toRelativePath(sourceRoot, entryPath);
|
|
5533
5607
|
return [{
|
|
5534
5608
|
path: routePath,
|
|
5535
|
-
file:
|
|
5609
|
+
file: relativeToSourceRoot,
|
|
5536
5610
|
isDynamic: hasDynamic,
|
|
5537
|
-
dynamicType:
|
|
5611
|
+
dynamicType: dynType
|
|
5538
5612
|
}];
|
|
5539
5613
|
}))).flat();
|
|
5540
|
-
} catch (
|
|
5541
|
-
|
|
5614
|
+
} catch (raw_exn) {
|
|
5615
|
+
let exn = internalToException(raw_exn);
|
|
5616
|
+
let msg = getOr(flatMap(fromException(exn), message2), "");
|
|
5617
|
+
if (msg.includes("ENOENT")) {
|
|
5618
|
+
return [];
|
|
5619
|
+
}
|
|
5620
|
+
throw exn;
|
|
5542
5621
|
}
|
|
5543
5622
|
}
|
|
5544
5623
|
async function execute8(ctx2, _input) {
|
|
5545
5624
|
try {
|
|
5546
|
-
let srcPages = await findPages("src/pages", "", ctx2.projectRoot);
|
|
5547
|
-
let rootPages = await findPages("pages", "", ctx2.projectRoot);
|
|
5625
|
+
let srcPages = await findPages("src/pages", "", ctx2.projectRoot, ctx2.sourceRoot);
|
|
5626
|
+
let rootPages = await findPages("pages", "", ctx2.projectRoot, ctx2.sourceRoot);
|
|
5548
5627
|
let allPages = srcPages.concat(rootPages);
|
|
5549
5628
|
return {
|
|
5550
5629
|
TAG: "Ok",
|
|
@@ -5581,7 +5660,7 @@ function make2() {
|
|
|
5581
5660
|
}
|
|
5582
5661
|
|
|
5583
5662
|
// src/FrontmanAstro__Middleware.res.mjs
|
|
5584
|
-
function uiHtml(clientUrl, isLightTheme) {
|
|
5663
|
+
function uiHtml(clientUrl, clientCssUrl, isLightTheme) {
|
|
5585
5664
|
let openrouterKey = flatMap(process.env["OPENROUTER_API_KEY"], (key) => {
|
|
5586
5665
|
if (key !== "") {
|
|
5587
5666
|
return key;
|
|
@@ -5596,12 +5675,14 @@ function uiHtml(clientUrl, isLightTheme) {
|
|
|
5596
5675
|
});
|
|
5597
5676
|
let runtimeConfig = JSON.stringify(configObj);
|
|
5598
5677
|
let themeClass = isLightTheme ? "" : "dark";
|
|
5678
|
+
let cssLink = clientCssUrl !== void 0 ? `<link rel="stylesheet" href="` + clientCssUrl + `">` : "";
|
|
5599
5679
|
return `<!DOCTYPE html>
|
|
5600
5680
|
<html lang="en" class="` + themeClass + `">
|
|
5601
5681
|
<head>
|
|
5602
5682
|
<meta charset="UTF-8">
|
|
5603
5683
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
5604
5684
|
<title>Frontman</title>
|
|
5685
|
+
` + cssLink + `
|
|
5605
5686
|
<style>
|
|
5606
5687
|
html, body, #root {
|
|
5607
5688
|
margin: 0;
|
|
@@ -5619,7 +5700,7 @@ function uiHtml(clientUrl, isLightTheme) {
|
|
|
5619
5700
|
</html>`;
|
|
5620
5701
|
}
|
|
5621
5702
|
function serveUI(config) {
|
|
5622
|
-
let html = uiHtml(config.clientUrl, config.isLightTheme);
|
|
5703
|
+
let html = uiHtml(config.clientUrl, config.clientCssUrl, config.isLightTheme);
|
|
5623
5704
|
let headers2 = Object.fromEntries([[
|
|
5624
5705
|
"Content-Type",
|
|
5625
5706
|
"text/html"
|
|
@@ -5669,8 +5750,8 @@ var collectRequestBody = (async function(req) {
|
|
|
5669
5750
|
for await (const chunk of req) {
|
|
5670
5751
|
chunks.push(chunk);
|
|
5671
5752
|
}
|
|
5672
|
-
const { Buffer:
|
|
5673
|
-
return
|
|
5753
|
+
const { Buffer: Buffer3 } = await import('buffer');
|
|
5754
|
+
return Buffer3.concat(chunks);
|
|
5674
5755
|
});
|
|
5675
5756
|
|
|
5676
5757
|
// src/FrontmanAstro__ViteAdapter.res.mjs
|
|
@@ -5823,4 +5904,7 @@ function make3(configInput) {
|
|
|
5823
5904
|
// src/FrontmanAstro.res.mjs
|
|
5824
5905
|
var frontmanIntegration = make3;
|
|
5825
5906
|
|
|
5826
|
-
|
|
5907
|
+
// index.mjs
|
|
5908
|
+
var index_default = frontmanIntegration;
|
|
5909
|
+
|
|
5910
|
+
export { index_default as default, frontmanIntegration };
|